Grok AI / xAI for VS Code
GMDevCore · GMDevCore.gm-grok-vscode
Integrate xAI's Grok directly into VS Code — sidebar chat, inline completions, code actions, git integration, and more.
Changelog
🤖 v5.9.1 — Agent Mode
Agent Mode lets Grok act autonomously in your workspace — reading files, running commands, searching the codebase, and writing code, all without you having to copy-paste anything.
How to use:
- Click the Agent button in the input toolbar (bottom-right of the chat)
- Type your task in plain English — "add dark mode to the settings page", "write and run tests for auth.ts", "find all console.log calls and remove them"
- For each action Grok wants to take, a dialog appears with Allow, Always allow [tool], and Block
- Click Allow to let it proceed, Always allow to skip future dialogs for that tool type, or Block to make Grok try a different approach
Three modes — click the Agent button to cycle:
- Off — standard chat, no tool access
- 🤖 Agent (purple) — full tool access, every action needs your approval
- ⚡ Autonomous (red) — no approvals, Grok acts immediately. The chat turns red so you always know it's running unsupervised.
Tools available: read file, write file, run shell command, list directory, search files. All paths are workspace-sandboxed — Grok cannot touch anything outside your project folder.
First launch: New users see an intro banner explaining Agent Mode. It disappears after you dismiss it.
- Fixed Agent ignored tools and responded as chat — switched to prompt-based tool parsing using XML tags in the streamed response
- Changed Approval is now a native VS Code modal with Allow / Block buttons
- Added Grok Agent output channel for debugging
v5.8.2 — Agent mode activation fix
- Fixed Agent mode button did nothing — was in the TypeScript type definition but missing from the runtime allowlist Set, so every click was silently dropped
- Added Blue agent mode banner appears in the chat panel when agent mode is active, with a "Turn off" link
- Fixed Clear chat, Settings, and Theme tooltips were cut off on the right edge of the sidebar — now anchor to the right side of the button instead of centering
v5.8.0 — Persistent file context
- Added Attached files now persist across the entire conversation — previously context was only sent with the first message
- Added File list bar shows each attached file as a chip with its name, language, and size
- Added Remove individual files with the ✕ on each chip without clearing everything
- Fixed Context button now correctly shows all attached files and keeps them active through follow-up questions
v5.7.4 — API key banner fix
- Fixed No-key banner said "press 🔑" but there was no key icon anywhere — banner now has a prominent inline button that opens the key prompt directly
- Fixed Error messages referenced a non-existent 🔑 icon — now correctly direct users to the banner or Command Palette
- Fixed Tooltips showed black text on black background on light VS Code themes — tooltip background and text are now fixed dark charcoal / near-white regardless of theme
v5.7.1 — VS Code Auto theme default
- Changed Default theme is now VS Code Auto — the chat panel adapts to your current VS Code theme automatically (Dark+, One Dark, GitHub Light, Solarized, etc.)
- Changed Dark teal theme moved to explicit opt-in via the 🎨 theme picker
- Changed All colours mapped to
--vscode-* CSS tokens with hardcoded fallbacks
v5.7.0 — Theme system
- Added 🎨 Theme picker button in the chat header
- Added Five themes: VS Code Auto, Dark, Light, Midnight, Ocean, Warm
- Added Theme choice persisted across VS Code restarts
- Fixed "You" message bubble was too dark on grey/light VS Code themes — now uses the host theme's hover colour
Features
💬 Chat Panel
Full sidebar chat with streaming responses, session management, message editing, and export.
- Named, persistent chat sessions — switch, rename, delete from the All Chats panel
- Edit any sent message with ✏ — conversation rewinds and regenerates from that point
- Export chat as Markdown to clipboard or file (
Ctrl+Shift+X)
- In-webview model switcher — click the model chip to change without leaving the sidebar
- Per-session custom system prompt — override Grok's persona for the current chat
- Token counter bar shows context usage toward the 128k limit
🤖 Auto File Context
The current open file is automatically included with every message — Grok always knows what you're looking at. A blue 📄 filename chip in the header shows when it's active.
✍️ Code Actions (right-click)
Select any code → right-click → Grok submenu:
| Command |
What it does |
| Explain Selected Code |
Plain-English explanation |
| Refactor Code (Chat) |
Suggests a cleaner version |
| Refactor Code (Diff View) |
Side-by-side diff to review before applying |
| Fix Bug (Chat / Diff View) |
Identifies and fixes bugs |
| Write Unit Tests |
Comprehensive tests with mocks and edge cases |
| Add Comments / Docstrings |
Language-specific documentation |
| Optimize Code |
Performance improvements with explanation |
| Translate to Another Language |
Convert code to a target language |
| Explain Error |
Explains diagnostics at cursor |
⚡ Direct Editor Integration
Stream code directly into your file — no copy-paste:
| Shortcut |
Action |
Ctrl+Shift+I |
Generate Code at Cursor — describe what you need |
Ctrl+Shift+C |
Continue Writing — streams a natural continuation |
Ctrl+Shift+D |
Fill TODO — replaces the nearest TODO/FIXME comment |
👁 Code Lens
Clickable Explain / Tests / Docs buttons appear above every function and class. Supports TypeScript, JavaScript, Python, Rust, Go, C/C++, C#, Java, Swift, Kotlin, Ruby, PHP, Vue, Svelte.
🔴 Diagnostic Hover
Hover over any red squiggle to get Explain this error and Fix it links inline.
📝 Inline Completions
Copilot-style ghost-text suggestions as you type. Press Tab to accept, Escape to dismiss.
📋 Templates
13 built-in prompt templates (Security Audit, PR Review, Unit Tests, JSDoc, README, etc.) plus custom templates you can save and reuse.
🌿 Git Integration
- Generate Commit Message — reads your staged diff, writes a Conventional Commits message directly to the SCM input box
- Explain Diff — explain staged, working tree, or last commit changes
- Generate PR Description — structured PR template from diff + commits
🖥 Terminal Integration
Right-click in the terminal or use the Command Palette:
- Explain Terminal Output — what did that command do?
- Explain Terminal Error — why did it fail?
- Fix Terminal Error — get a corrected command
📊 Usage Statistics
Local token and cost estimates (no data sent anywhere). Hover the status bar chip or run Grok: Show Usage Statistics.
Setup
- Install the extension from the VSIX file
- Get your API key from console.x.ai
- Press
Ctrl+Shift+P → Grok: Set API Key
- Click the Grok icon in the Activity Bar, or press
Ctrl+Shift+G
Your API key is stored in VS Code's encrypted SecretStorage (OS keychain) — never in settings.json.
Keyboard Shortcuts
| Action |
Windows / Linux |
macOS |
| Open Chat |
Ctrl+Shift+G |
Cmd+Shift+G |
| Explain Code |
Ctrl+Shift+E |
Cmd+Shift+E |
| Fix Bug (Diff) |
Ctrl+Shift+F |
Cmd+Shift+F |
| Quick Ask |
Ctrl+Shift+A |
Cmd+Shift+A |
| Use Template |
Ctrl+Shift+T |
Cmd+Shift+T |
| New Chat |
Ctrl+Shift+N |
Cmd+Shift+N |
| Generate at Cursor |
Ctrl+Shift+I |
Cmd+Shift+I |
| Continue Writing |
Ctrl+Shift+C |
Cmd+Shift+C |
| Fill TODO |
Ctrl+Shift+D |
Cmd+Shift+D |
| Export Chat |
Ctrl+Shift+X |
Cmd+Shift+X |
Settings
| Setting |
Default |
Description |
grok.model |
grok-3 |
Chat model |
grok.inlineModel |
grok-3-mini-fast |
Model for inline completions and stream-to-editor |
grok.inlineSuggestions |
true |
Enable ghost-text completions |
grok.codeLens |
true |
Show Explain / Tests / Docs above functions |
grok.diagnosticHover |
true |
Grok actions on error squiggles |
grok.autoFileContext |
true |
Auto-include current file in every message |
grok.maxTokens |
4096 |
Max tokens per response |
grok.temperature |
0.7 |
0 = deterministic, 2 = creative |
Requirements
Build from Source
npm install
npm install -g typescript @vscode/vsce
npx tsc -p tsconfig.json
vsce package --no-dependencies