Literate coding
Literate coding allows you to write code with AI assistance directly inside your editor. Instead of switching to a chat window or writing long prompts, you type instructions in plain language right where the code should go. Bob then generates the implementation for you in context and shows a diff of the changes.
Why use literate coding?
- Stay in your workflow: Write code without context switching to chat interfaces
- Maintain precise control: Specify exactly where and how AI should modify your code
- Express intent naturally: Describe what you want in plain language or pseudocode
- See changes before committing: Review diffs to ensure the generated code meets your needs
How it works
When you activate literate coding mode, you can write natural language instructions, pseudocode, annotations, or partial code snippets directly in your source file. These instructions appear highlighted in blue to distinguish them from regular code.
When you run the Generate command, Bob:
- Analyzes the entire file including your literate coding blocks
- Understands the surrounding context and your intent
- Replaces your instructions with real, executable code
- Shows you an inline diff so you can review the changes
This approach combines the expressiveness of natural language with the precision of direct code editing.
Getting started
Basic usage
-
Toggle literate coding mode:
- Press Cmd+M (Mac) or Ctrl+M (Windows/Linux)
- Or click the magic wand icon in the editor toolbar
-
Write your instructions:
- Type pseudocode, natural language instructions, or annotations
- Your text appears in blue, marking it as literate coding content
-
Generate code:
- Press Cmd+Enter (recommended) or click the Generate button
- Bob converts your instructions into real code and shows an inline diff
-
Review and apply:
- Accept changes: Cmd+Enter
- Reject changes: Cmd+Shift+Backspace
- Changes are written to your file before acceptance, allowing you to test before deciding
Tips and best practices
- Be specific about your requirements in your instructions
- Include relevant context like variable types or function parameters
- For complex logic, break down your instructions into smaller, focused blocks
- Use literate coding for both creating new code and modifying existing code
Current limitations
- Single-file scope: Currently works on one file at a time (multi-file support planned)
- Preview feature: Expect ongoing improvements to styling, diffing, and AI behavior
Enhance prompt
Improve your prompts before sending them to Bob. Click the sparkles icon in the chat input to automatically refine your request, making it clearer, more specific, and more likely to yield better results.
Skills
Reusable instruction sets that teach Bob new workflows and specialized tasks. Skills act as recipes that guide Bob through specific types of work in a consistent, repeatable manner.