Overview
Quick Edit is Polaris IDE’s powerful Cmd+K feature that lets you transform selected code using natural language instructions. Instead of manually editing code, describe what you want to change and let AI do the heavy lifting.How to use quick edit
Quick Edit maintains the same indentation level as your original code, ensuring consistent formatting.
Natural language instructions
You can use conversational instructions to modify your code:Code transformation examples
Quick Edit can handle a wide variety of transformations:Refactoring
- “Extract this into a separate function”
- “Convert class component to functional component”
- “Split this function into smaller helper functions”
Type safety
- “Add TypeScript types and interfaces”
- “Make this type-safe with proper generics”
- “Add JSDoc comments with type annotations”
Error handling
- “Add error handling with try-catch”
- “Add input validation”
- “Handle edge cases for null and undefined”
Optimization
- “Optimize this loop for performance”
- “Memoize this function using useMemo”
- “Convert to early return pattern”
Documentation
- “Add JSDoc comments”
- “Add inline comments explaining the logic”
- “Document parameters and return values”
Selection tooltip integration
When you select code in the editor, Polaris shows a floating toolbar with quick actions:- Cmd+K icon - Opens quick edit dialog
- Copy - Copies selection to clipboard
- Cut - Cuts selection
- Paste - Pastes from clipboard
The selection tooltip appears automatically when you highlight code, making quick edit always one click away.
Documentation scraping with Firecrawl
Quick Edit integrates Firecrawl to enhance transformations with documentation context. When your instruction includes a URL, Polaris:Example with documentation URL
API implementation
The quick edit endpoint is located at/api/quick-edit:
Configuration
Quick edit uses these AI generation parameters:- Temperature:
0.7(balanced creativity) - Max tokens:
2000(allows larger transformations) - Context: Selected code + full file + scraped documentation
Prompt structure
The quick edit prompt is carefully designed to ensure accurate transformations:Error handling
The quick edit system handles errors gracefully:- Invalid instruction - Returns original code
- Authentication failure - Returns 403 Unauthorized
- Missing parameters - Returns 400 Bad Request with clear error message
- AI generation failure - Returns 500 with error details
- Documentation scraping failure - Continues without documentation context
Source code reference
Implementation details:- API route:
src/app/api/quick-edit/route.ts:42 - Firecrawl integration:
src/app/api/quick-edit/route.ts:71 - URL detection regex:
src/app/api/quick-edit/route.ts:16 - AI provider:
src/lib/ai-providers.ts:6