Work with code and errors
Explain code, find problems, write a commit message for a diff, and explain or search an error.
Select code, a diff or an error message, then open the Rite command. Rite reads the text as code, a diff or an error, and the actions for it come first.
Before you start
Section titled “Before you start”- Set up an AI provider. Most of these actions ask the model. See Set up an AI provider.
- Give the Rite command a hotkey. See Bind a hotkey.
Run a code action
Section titled “Run a code action”Select the code
Section titled “Select the code”Select the code, the diff or the error message.
Open the Rite command
Section titled “Open the Rite command”Press your hotkey for the Rite command. The title of the first section says “code”, “a diff” or “an error”.
Run an action
Section titled “Run an action”Select a row in the first section after the text, and press ↵Linux Enter.
Rite reads the text as code when it has two or more lines and at least half of them look like code. Braces, semicolons and words such as function, const, def, class and import look like code. One line can be a guess: the title then says “code?”.
| Action | Runs | Result | What it does |
|---|---|---|---|
| Explain This Code | Asks the model | Shows the result | Explains what the code does, step by step, in plain words. |
| Find Problems | Asks the model | Shows the result | Lists the bugs and risks, most serious first. It says nothing about style. |
| Add a Doc Comment | Asks the model | Replaces the text | Adds a documentation comment above the code, in the convention of its language. |
| Add Comments | Asks the model | Replaces the text | Adds short comments that explain why, where the code is not obvious. It changes no code. |
| Suggest Better Names | Asks the model | Shows the result | Lists clearer names for the variables and functions, with the old name, the new name and a reason. |
| Convert to Another Language | Asks the model | A list | Opens a list of languages. The model converts the code to the language you choose. |
Convert to Another Language offers these languages: TypeScript, JavaScript, Python, Go, Rust, Java, C#, Swift, Kotlin, Ruby, PHP, SQL and Bash.
Rite reads code as a diff when it has a diff --git line or a hunk header such as @@ -1,4 +1,5 @@. A diff gets the Diff section in place of the code actions.
| Action | Runs | Result | What it does |
|---|---|---|---|
| Write a Commit Message | Asks the model | Shows the result | Writes a subject line under 60 characters, a blank line, then a short body on what changed and why. |
| Explain This Change | Asks the model | Shows the result | Explains what the diff changes and why it was most likely made. |
| Review for Problems | Asks the model | Shows the result | Lists the bugs and risks, most serious first, with the line of each. |
| Write a PR Description | Asks the model | Shows the result | Writes one summary sentence, then bullet points of the changes. |
Rite reads the text as an error when it has the shape of one. Examples are a stack trace, a Python traceback, TypeError: …, error: …, fatal: … and npm ERR!. A short line such as command not found or Permission denied is a guess: the title then says “an error?”.
| Action | Runs | Result | What it does |
|---|---|---|---|
| Explain This Error | Asks the model | Shows the result | Explains what the error means and what most likely caused it. |
| Suggest a Fix | Asks the model | Shows the result | Gives the exact command or code change first, then one sentence on why. |
| Open the File at That Line | No model | Opens an app | Opens the file that the error names. |
| Search the Web for This Error | No model | Opens an app | Searches DuckDuckGo for the first line of the error, in the default browser. |
| Format as a Code Block | No model | Replaces the text | Replaces the selection with the error inside a Markdown code block. |
Rite shows Open the File at That Line only when the error names a file, as in src/app.ts:12:5 or File "app.py", line 3. Rite writes out ~ as your home folder. It leaves a relative path as it is.
What you see
Section titled “What you see”- An action that shows its result opens an answer screen. The answer is beside the list. Press ↵Linux Enter to copy it, or ⇧↵Linux Shift+Enter to paste it at the cursor.
- To ask a follow-up question, type it in the search bar of the answer screen.
- Add a Doc Comment, Add Comments and Convert to Another Language open the result screen first. Press ↵Linux Enter there to replace the selection. See Rewrite text.
- In a code editor, Rite tells the model to keep code, identifiers and indentation exactly as written. See Kinds of app.
- In a terminal, Rite never pastes. See Use Rite in a terminal.
If it does not work
Section titled “If it does not work”- Rite reads the code as text. Select more lines. Rite needs two or more lines, and half of them must look like code.
- Open the File at That Line is missing. The error names no file, or the file is not in a form that Rite reads.
- The code actions are missing. They can be turned off. See Turn actions on or off.
- See Troubleshooting.