Code actions
Access Bob's AI-powered code actions that provide quick fixes, refactorings, and code explanations directly in the Bob IDE through lightbulb icons and context menus.
Why use code actions?
- Quick access to Bob: Add code to your conversation without copying and pasting
- Contextual assistance: Get help with the exact code you are working on
- Streamlined workflow: Access Bob's capabilities without leaving your editor
- Automatic context: Bob receives file paths and line numbers automatically
How it works
Code actions appear when you:
- Select a range of code
- Place your cursor on a line with a diagnostic (error, warning, or hint)
- Invoke them through a keyboard shortcut or command
A lightbulb icon () appears in the editor gutter (the area to the left of line numbers) when code actions are available. You can also access them through the right-click context menu or keyboard shortcut (Ctrl + . or Cmd + . on macOS).
Available code actions
Bob provides these code actions:
| Action | Description |
|---|---|
| Fix with Bob | Asks Bob to fix the diagnostics (errors or warnings) on the selected code. Shown instead of Explain and Improve when the selection has diagnostics. |
| Explain with Bob | Asks Bob to explain the selected code |
| Improve with Bob | Asks Bob to suggest improvements to the selected code |
| Add to Bob Context | Adds selected code to your Bob conversation with file path and line numbers |
Add to Context
The Add to Context action is always available, as the last Bob action in the menu. When you use it, Bob includes the filename and line numbers with your code, helping Bob understand the exact location within your project.
Example of what Bob receives:
Can you explain this function?
@myFile.js:15:25The @myFile.js:15:25 notation represents the code you added, including its location.
Keyboard shortcuts in the editor
These are editor commands, not lightbulb code actions:
- Press Cmd + K (macOS) or Ctrl + K (Windows/Linux) in the editor to run IBM Bob: Inline edit, which opens an inline prompt to edit the code at the cursor or selection.
- Press Cmd + L (macOS) or Ctrl + L (Windows/Linux) to run IBM Bob: Add to chat context, which adds the current selection to the Bob chat.
When you select code, a small tooltip with Edit and Chat buttons also appears.
Cmd/Ctrl + K works only while the editor has focus. Both shortcuts and the tooltip are unavailable in files excluded by .bobignore.
Using code actions
You can access Bob's code actions in three ways:
From the lightbulb icon
- Select the code you want to work with.
- Click the lightbulb icon () that appears in the gutter.
- Select the Bob action you want from the menu.
- Review Bob's response in the chat panel.
From the context menu
- Select the code you want to work with.
- Right-click the selected code.
- Select Bob from the context menu.
- Select the action you want from the submenu.
- Review Bob's response in the chat panel.
From the Command Palette
- Select the code you want to work with.
- Open the Command Palette with Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS).
- Type "Bob" to filter commands.
- Select the code action you want (for example, "Bob: Explain Code").
- Review Bob's response in the chat panel.
Bob's tip: The Command Palette applies actions to your current active chat task if one exists.
Rollback
Automatically version workspace files during AI tasks. Safely explore AI suggestions and experiment with changes, and easily recover from unwanted changes.
Code reviews
Use the built-in Review workflow to get AI-powered code reviews directly in your IDE. Bob analyzes changes and flags potential issues before you commit your work.