Grok AI for VS Code
Integrate xAI's Grok directly into VS Code — just like the built-in GitHub Copilot Chat or Claude extension.
Features
- 💬 Sidebar Chat — Full conversation history with streaming responses
- 💡 Explain Code — Select any code → right-click → "Grok: Explain Selected Code"
- 🔧 Refactor Code — Improve readability and best practices
- 🐛 Fix Bugs — Identify and fix issues in selection
- 📝 Add Comments — Generate docstrings and inline comments
- ✨ Generate Code — Describe what you need, get working code
- 📋 Copy / Insert — One-click copy or insert code blocks into your editor
- 🔄 Streaming — Token-by-token streaming with stop button
- 💾 History — Chat history persists across VS Code sessions (per workspace)
Setup
- Install the extension
- Get your API key from console.x.ai
- Press
Ctrl+Shift+P → Grok: Set API Key
- Open the chat panel via the Grok icon in the Activity Bar, or press
Ctrl+Shift+G
Keyboard Shortcuts
| Action |
Windows/Linux |
Mac |
| Open Chat |
Ctrl+Shift+G |
Cmd+Shift+G |
| Explain Selection |
Ctrl+Shift+E |
Cmd+Shift+E |
Settings
| Setting |
Default |
Description |
grok.apiKey |
— |
Your xAI API key |
grok.model |
grok-3 |
Model: grok-3, grok-3-fast, grok-3-mini, etc. |
grok.streamResponses |
true |
Enable token streaming |
grok.maxTokens |
4096 |
Max tokens per response |
grok.temperature |
0.7 |
Temperature (0–2) |
Select code in any editor, right-click, and you'll see:
- Grok: Explain Selected Code
- Grok: Refactor Selected Code
- Grok: Fix Bug in Selection
- Grok: Add Docstring / Comments
Requirements
Building from Source
npm install
npm run compile
# Install vsce globally to package:
npm install -g @vscode/vsce
vsce package
This produces a .vsix file you can install via Extensions: Install from VSIX.
| |