Skip to content
| Marketplace
Sign in
Visual Studio Code>AI>Grok AI / xAI for VS CodeNew to Visual Studio Code? Get it now.
Grok AI / xAI for VS Code

Grok AI / xAI for VS Code

GM DevCore

|
1,233 installs
| (1) | Free
Integrate xAI's Grok into VS Code — chat, explain, generate, fix, and get inline completions.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

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

v6.1.7 — Apply-diff fix, agent context capping

  • Fixed The apply button's diff view (when no text was selected) showed a bogus comparison — it diffed an empty virtual document against your live file instead of showing the proposed change. The diff now correctly shows current ↔ proposed content
  • Fixed Long agent runs ballooned the API payload — tool outputs (up to 20 KB each) accumulated across turns and were re-sent on every call. The agent now trims its oldest exchanges mid-run (keeping the system prompt and recent context within a ~12k token budget), so 20-turn sessions stay fast and don't overflow the context window

v6.1.6 — Agent context parity, live model list, polish

  • Fixed Agent Mode ignored .grok/memory.md and @ file mentions — the agent now receives the same project context as regular chat, so it follows your conventions when acting on the workspace
  • Fixed @ mention autocomplete never saw files created after the first fetch — the file list now refreshes automatically (5-second throttle) while you type
  • Changed The in-chat model picker now loads the live model list from your xAI account (cached 5 minutes), so newly released models appear without an extension update; the static list remains as instant fallback
  • Fixed Multiple duplicate "Grok Errors" channels appeared in the Output panel dropdown — all components now share a single channel

v6.1.5 — Usage tracking fix, agent write diffs, smarter sessions

  • Fixed Token usage statistics always showed zero — the tracker was wired up but never actually recorded anything; both regular chat and agent mode now record usage after every exchange
  • Added Agent write_file to an existing file now opens a diff preview (current ↔ proposed) before you decide, with a non-modal Allow / Always allow / Block prompt so you can scroll the diff while deciding
  • Added Sessions are auto-named from your first message (e.g. "fix the login timeout bug…") instead of "Chat 12/05/2026 3:44 PM" — only applies if you haven't renamed the session yourself
  • Fixed Markdown task checkboxes (- [ ] / - [x]) rendered as literal text — now shown as ☐ / ☑

v6.1.4 — Reliability: history cap, retry, real stop

  • Fixed Long conversations could overflow the context window and fail or run up cost — the API now receives a capped window (most recent ~12k tokens / 40 messages); your full chat history is still shown and saved
  • Added Automatic retry with exponential backoff on transient errors (429 rate limits, 500/502/503/504 server errors, and network resets) — up to 2 retries at 800ms then 1600ms
  • Fixed The Stop button now actually aborts the in-flight HTTP request instead of just stopping the display, so no more tokens are consumed after you stop

v6.1.3 — Agent persistence + tool output formatting

  • Fixed Agent stopped after a single tool call instead of continuing — it now persists through multiple tool calls until the task is genuinely complete
  • Fixed Tool output (directory listings, command results) was rendered as a code block with copy/insert/apply buttons — now shown as a clean blockquote
  • Changed System prompt rewritten to emphasise persistence: explore subfolders, chain tool calls, don't stop early or ask the user mid-task
  • Added Loop nudges the model (up to 4 times) if it describes an action without emitting a tool call, and detects genuine completion via summary/question patterns

v6.1.2 — Agent / autonomous mode loop fix

  • Fixed Autonomous mode stopped after the first response — the tool-call parser was too strict and failed on reasoning models that wrap the JSON in markdown fences or format it slightly differently
  • Fixed Agent now retries once if the model describes what it will do instead of acting, nudging it to emit a real tool call
  • Fixed Streaming text no longer drops characters around <tool_call> tag boundaries
  • Changed Parser now handles fenced JSON, bare JSON objects, trailing commas, and validates tool names before executing

✨ v6.1.1 — Slash commands, @ mentions, Apply button, project memory

Four new productivity features:

/ slash commands — type / at the start of the input for an autocomplete menu: /explain, /fix, /test, /docs, /optimize, /review, /commit, /agent, /clear. Arrow keys to navigate, Enter or Tab to select.

@ file mentions — type @ followed by a filename to attach that file as context (e.g. @auth.ts what does this do?). Autocomplete shows matching workspace files; the file's contents are sent with your message.

Apply button on code blocks — every code block now has an apply button alongside copy/insert. With text selected it replaces the selection; with no selection it opens a diff view so you can review before accepting.

Project memory file — run Grok: Create Project Memory File to scaffold .grok/memory.md. Grok reads it automatically and includes it as context in every chat — perfect for teaching it your stack, conventions, and things to avoid. Persists per-project.

v6.0.5 — HTML tag rendering fix

  • Fixed Grok occasionally emitted literal HTML tags like <strong>, <em>, <code> instead of markdown — now converted to markdown equivalents before rendering

v6.0.4 — Dynamic model list

  • Added Grok: Refresh Model List from xAI fetches the real list of models your API key can access

v6.0.3 — Verbose error logging

  • Added Grok Errors output channel logs every error with full HTTP status, response body, and timestamp
  • Added Grok: Show Errors Log command in the Command Palette opens it instantly
  • Changed Generic "An error occurred" replaced with the first 200 chars of the actual error message — fall-through case now shows what really went wrong
  • Added Pattern matching for HTTP 400 / 403 / 404 / 500-class errors with specific guidance for each
  • Added API key validation requests are logged with status code and response body

v6.0.2 — Silent migration + API key validation

  • Added API key is validated against xAI before every chat send (cached per-session). Invalid or expired keys show a clear actionable message instead of a generic error
  • Fixed "Unknown inline model" warning kept appearing for users upgrading from older versions — stale model settings are now silently migrated to grok-4.3 on activation with no warning

v6.0.1 — Model migration fix

  • Fixed Chat threw an error after the v6.0.0 model update — six other files (tokenTracker, chatViewProvider, inlineProvider, streamToEditor, statusBar, configValidator) still hardcoded the old grok-3 defaults and were sending invalid model names to the API
  • Fixed Settings panel showed deprecated models — configValidator allowlist now matches the new model list (grok-4.3, grok-4.20-reasoning, grok-4.20-non-reasoning)
  • Changed Token tracker pricing updated for new models

🚀 v6.0.0 — Major release

  • Changed Models updated to latest xAI lineup — grok-4.3 (default), grok-4.20-reasoning, grok-4.20-non-reasoning; all deprecated models removed
  • Added Token counter now shows percentage of context used (e.g. 4.2k tokens (3%)) with larger, bolder text and a thicker progress bar
  • Added Agent intro banner on first launch — walks new and upgrading users through Agent Mode with a two-column layout and one-click mode activation
  • Fixed Autonomous mode was still showing approval dialogs — check was missing from the callback
  • Fixed Agent button was cut off at minimum sidebar width — moved from header to input toolbar
  • Fixed All overlay panels (Sessions, Templates, Theme) clip-proof via position:absolute inside position:relative wrapper
  • Fixed Sessions dropdown showed only a shadow — root cause was overflow:hidden on all ancestor elements; replaced with full-area overlay
  • Fixed Delete session did nothing — two-click confirm state machine was reset by its own auto-cancel timer; simplified to single-click
  • Fixed Context and Files buttons silently failed — executeCommand indirection blocked when sidebar had focus; now handled directly in provider
  • Fixed No-key banner referenced a non-existent 🔑 icon; replaced with a prominent amber button

🤖 v5.9 — Agent Mode

Let Grok act directly in your workspace. Click Agent in the input toolbar to cycle through three modes:

  • 🤖 Agent (purple) — every action shows an Allow / Always allow / Block dialog
  • ⚡ Autonomous (red war-room) — no approvals, Grok acts immediately; chat turns red
  • Off — standard chat

Tools: read file, write file, run shell command, list directory, search files. All workspace-sandboxed.

v5.7 — Theme system

  • Added 🎨 theme picker with six themes: VS Code Auto (default), Dark, Light, Midnight, Ocean, Warm
  • Fixed "You" bubble invisible on grey/light VS Code themes
  • Fixed Tooltip contrast — fixed dark charcoal background regardless of host theme

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

  1. Install the extension from the VSIX file
  2. Get your API key from console.x.ai
  3. Press Ctrl+Shift+P → Grok: Set API Key
  4. 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-4.3 Chat model
grok.inlineModel grok-4.3 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

  • VS Code 1.85+
  • xAI API key — console.x.ai

Build from Source

npm install
npm install -g typescript @vscode/vsce
npx tsc -p tsconfig.json
vsce package --no-dependencies
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft