headroom.walls.sh · zed

Claude Code + Zed Editor

Zed has its own AI assistant built in, but Claude Code is a different thing: a terminal agent that writes and runs code across your whole project. The two work well together. This page covers how to run Claude Code from Zed's terminal, what each tool is actually for, and how to keep track of your session budget.

Zed AI vs Claude Code — what each is for

Zed AIClaude Code
Where it livesInside the editor — inline, panelTerminal agent — runs independently
What it doesInline completions, quick edits, explanationsMulti-file agent: reads, writes, runs code
Shell accessNoYes — runs tests, builds, git commands
Autonomous loopsNoYes — write → test → fix → repeat unattended
BillingZed subscription or your API keyClaude Pro/Max subscription or API
Project scopeOpen files and editor contextAny path in the working directory

Zed AI is the in-editor assistant for things you're actively writing. Claude Code is the agent for things you want done — refactors, test-fix loops, build debugging — that benefit from shell access and full project scope.

Opening Claude Code in Zed's terminal

Zed has a built-in terminal. Open it with Ctrl+` (or Cmd+` on macOS) or via the command palette: terminal: new. It opens at the project root.

From there, run Claude Code as normal:

claude

or start with a task immediately:

claude "add error handling to every function in src/handlers/ that currently returns unwrap()"

The terminal pane sits below the editor. While Claude Code runs, you stay in the editor — watch the file tree update as it writes, open changed files in the editor to see diffs, switch back to code when it pauses.

Zed's split pane layout works well with Claude Code: editor on the left, terminal on the right. Use Cmd+Shift+E to focus the terminal and Cmd+1 to return to the editor without closing the terminal.

Using Zed's file tree as context

Because Zed's terminal opens at the project root, you can reference any project path directly in Claude Code prompts:

claude "read src/parser.rs and write a test module for the tokenize function. Place it in tests/parser_tests.rs."

Or reference the currently open file by name (check the tab bar):

claude "explain the lifetime annotations in lexer.rs and suggest where they could be simplified"

For Rust projects specifically, Claude Code understands the Cargo workspace structure and can reference Cargo.toml for build targets, features, and workspace members.

CLAUDE.md for Zed projects

Add a CLAUDE.md at the project root to give Claude Code persistent context. Useful for Rust and performance-critical projects:

## Build
- Build: cargo build
- Test: cargo test
- Lint: cargo clippy -- -D warnings
- Format: cargo fmt

## Conventions
- No unwrap() in library code — use proper error propagation with ?
- All public APIs need doc comments
- Benchmarks live in benches/ using criterion
- Unsafe blocks require a // SAFETY: comment

Claude Code reads CLAUDE.md at session start and respects these rules throughout. No re-explaining the no-unwrap rule on every prompt.

Practical Zed + Claude Code workflow

  1. Open the project in Zed as normal
  2. Open the terminal pane (Ctrl+`) — already at project root
  3. Run claude to start a session, or pass a task directly
  4. While Claude Code works, use Zed's editor to review changes — the file tree updates in real time
  5. Use Zed's diff gutter to see line-level changes as they're written
  6. Ask follow-up questions or course-correct from the terminal pane

Zed keybindings for Claude Code workflows

Add these to ~/.config/zed/keymap.json to make terminal + Claude Code faster:

{
  "bindings": {
    "ctrl-grave": "terminal_panel::ToggleFocus",
    "cmd-shift-c": ["workspace::SendKeystrokes", "claude \n"]
  }
}

The toggle focus binding lets you switch between editor and terminal instantly. The second binding starts a Claude Code session from anywhere in the editor with a single shortcut.

Claude Code with Rust projects in Zed

Rust projects have specific patterns Claude Code handles well when given the right commands:

claude "find all .unwrap() calls in src/ that aren't in test modules, replace with proper error propagation using ?, run cargo build to verify"
claude "add criterion benchmarks for the parse_tokens function in src/lexer.rs — place them in benches/lexer_bench.rs, run cargo bench after"
claude "run cargo clippy and fix all warnings — don't just add #[allow] attributes, fix the actual issues"

Claude Code reads the compiler errors and fixes them iteratively — the Rust borrow checker's detailed error messages are exactly the kind of structured feedback it works well with.

When to use Zed AI vs Claude Code

If you're billing both to your Anthropic API key (BYOK for Zed AI), remember they share the same 5h/7d quota windows. A long Claude Code session can affect your remaining Zed AI budget and vice versa.

Headroom — see your session budget while Zed is open

If you're using Claude Code from Zed's terminal — especially for Rust build cycles and test loops — Headroom keeps your session and weekly utilization visible in the macOS menu bar without you leaving Zed. No token, no API key: it reads the file Claude Code writes to ~/.claude/.

Install in one line:

brew install patwalls/tap/headroom

Color-coded from calm to amber to red. The menu bar is always visible even when Zed is fullscreen.


Claude Code + VS Code
Claude Code + Neovim
Claude Code + JetBrains
Refactoring with Claude Code