# Codecov: Generate AI prompts from coverage

> For the complete documentation index, see [llms.txt](https://edgafner.github.io/llms.txt).

> **TL;DR**
> Generate: click a coverage bar, then Generate AI Prompt
>
>
>
> Templates: `Settings | Tools | Codecov`, group AI Prompt Templates

From the coverage gutter, the plugin builds a prompt that contains the code of a line and copies it to the clipboard. Paste the prompt into the AI chat or coding agent you use. The plugin does not send the code to an AI service itself.

## Generate a prompt

Procedure: Copy a prompt for a line

1. In the editor, click the coverage bar next to a line.

2. In the popup, click Generate AI Prompt. A notification confirms that the prompt is on the clipboard, for example "AI prompt for uncovered code copied to clipboard!".

3. Paste the prompt into your AI assistant and review the tests it suggests.

## What the prompt contains

The plugin picks the template and the code by the coverage status of the line you clicked:

Covered line
: The Prompt for covered code template, with the text of that line.

Partially covered or not covered line
: The Prompt for uncovered code template. If the block of missed lines around the line is inside a method or function, the prompt contains that whole method or function. Otherwise, it contains only the block of missed lines.

## Customize the prompt templates

Procedure: Edit a template

1. Open `Settings | Tools | Codecov` (`Ctrl+Alt+S`, macOS: `⌘ ,`).

2. In the AI Prompt Templates group, expand Prompt Templates.

![AI Prompt Templates settings with Prompt Templates expanded, showing the covered and uncovered code templates with the CODE_TOKEN placeholder](images/codecov_settings_ai_prompts.png)

3. Edit Prompt for covered code or Prompt for uncovered code. Keep the `<CODE_TOKEN>` placeholder where the code goes.

4. Click OK.

The default template for uncovered code is:

```PLAINTEXT
Write comprehensive unit tests for the following code that tests do not cover:

<CODE_TOKEN>

Include edge cases and error scenarios. Use the project's existing test framework and follow the established testing patterns.
```

The default template for covered code is:

```PLAINTEXT
Analyze the following code already covered by tests:

<CODE_TOKEN>

Suggest potential improvements or edge cases that could be tested.
```

The templates are saved per project.

## Turn off AI prompts

Procedure: Turn off prompt generation

1. Go to `Settings | Tools | Codecov`.

2. Clear Enable AI prompt generation from coverage gutters and click OK.

The Generate AI Prompt link stays in the coverage popup. When you click it, a notification reads "AI prompts are disabled. Enable them in Codecov settings."

## See also

### Related topics

[Codecov: View coverage in the editor](codecov-editor-coverage.html) [Codecov: Settings reference](codecov-settings-reference.html)

### Useful resources

[Codecov on JetBrains Marketplace](https://plugins.jetbrains.com/plugin/23390-codecov)

