File AI actions

Six one-click actions on the active file: Explain, Fix, Refactor, Tests, Docs, Implement.

Where they live

In the editor header, to the right of the file path. Buttons labeled with their action and a scope hint — Whole file when nothing's selected, Selection when there's a highlight.

What each one does

ButtonWhat it does
ExplainGenerates a plain-English description of what the file (or selection) does. Output goes to the agent panel.
FixLooks for bugs, errors, or anti-patterns and stages a diff.
RefactorSuggests a cleaner version of the code with the same behavior. Stages a diff.
TestsGenerates unit tests for the file or selection. Stages a new test file.
DocsGenerates docstrings/JSDoc for functions and classes in the file. Stages a diff.
ImplementFor stub/placeholder functions, fills in the body based on the function's name and signature.

Whole file vs selection

The button labels change based on selection state:

  • No selection → action targets the whole file.
  • Text selected → action targets just the selection (great for refactoring one function in a 1000-line file).

What happens after click

Each action sends a structured prompt to the agent. The agent processes it like any other run — you'll see streaming output in the Ask tab and, if it generated a diff, a banner pointing to the Changes panel for review.

For the smallest possible scope, use Inline diff (Cmd+K) instead. It edits in place without leaving the editor.

Cost

These use the same router as the planner. The "Explain" and "Docs" actions are cheap; "Refactor", "Tests", and "Implement" can spend more depending on file size.