Appearance
Code Generation SOP
FreshThree methods for generating code with Gemini Code Assist.
Method 1: Quick Pick Menu (Code Transformation)
The most powerful method — shows a diff view so you can review changes before accepting.
VS Code
- Press
Ctrl+I(Win/Linux) orCmd+I(Mac) - Type your command and press Enter
- Review the diff view
- Click Accept or Reject
IntelliJ
- Press
Alt+\(Win/Linux) orCmd+\(Mac) - Type command > Enter
- Review diff > Accept Changes
Transformation Commands
| Command | What it does | Example |
|---|---|---|
/generate | Create new code | /generate function to parse CSV |
/fix | Fix bugs/errors | /fix NullPointerException in this method |
/doc | Add documentation | /doc this class with JSDoc |
/simplify | Simplify code | /simplify this nested if-else chain |
Method 2: Comment-Driven Generation
Write a natural language comment, then trigger generation.
mermaid
flowchart LR
A[Write comment describing what you want] --> B[Trigger generation]
B --> C[Ghost text appears]
C --> D{Accept?}
D -->|Yes| E[Press Tab]
D -->|No| F[Press Esc]VS Code:
- Write comment:
// Function to upload file to S3 with retry logic - Press
Ctrl+Enter - Preview appears as ghost text
- Press
Tabto accept
IntelliJ:
- Write comment
- Press
Alt+Gor right-click > Generate Code - Press
Tabto accept
Method 3: Chat Interface
- Click spark Gemini icon in activity bar
- Optionally select code for context
- Type your prompt:
"Write unit tests for the selected function""Implement the IUserRepository interface"
- Copy generated code into your file
Tips for Better Results
Specificity wins
- Be specific: "Generate a Python function that reads a CSV file and returns a pandas DataFrame, with error handling for missing values and invalid formats"
- Not vague: "Make a CSV function"
- Reference specific APIs:
"Use boto3 S3 client (not the resource interface)" - Include constraints:
"Must handle errors without raising exceptions, return Result type" - Specify language/framework explicitly when working in a new file
- Enterprise users: use
@REPO_NAMEto anchor suggestions to your codebase