Base usage and IDE integration
Claude Code can be used in four shapes. Pick the one that matches the work in front of you.
Mode 1 — Terminal-only
cd ~/projects/myapp
claude
> Refactor src/auth/middleware.ts to use the new TokenService.
Best for: server work, quick edits, anything where your hands are already on the terminal.
Mode 2 — IDE companion
Install the official extension:
- VS Code / Cursor / Windsurf — search "Claude Code" in the marketplace
- JetBrains (IntelliJ, PHPStorm, WebStorm, RubyMine, etc.) — search "Claude Code" in plugins
- Neovim — the community plugin
claude.nvimworks well
The integration adds:
- A keybind (default
Cmd/Ctrl + Esc) to open Claude Code with your current selection as context - Live diff preview on file edits
- Click-to-jump on file paths Claude prints
Best for: most everyday coding work.
Mode 3 — Sidecar
Run Claude Code in a separate terminal window beside your editor. Claude has full filesystem access; the editor stays out of the loop.
Best for: long refactors where Claude is making sweeping changes and you want to review without distraction.
Mode 4 — Headless
claude -p "Add a CHANGELOG entry for the latest commit" --output-format json
Headless mode runs Claude one-shot, prints structured output, and exits. This is the foundation of Ralph loops, scheduled tasks, and CI integrations (covered in chapters 5 and 6).
Setting up the VS Code integration end-to-end
- Open VS Code in your project:
code . - Install the Claude Code extension.
- Press
Cmd+Esc(macOS) /Ctrl+Esc(Windows/Linux). Claude Code opens in a panel. - Select code in your editor → press
Cmd+Escagain → that selection is added to Claude's context. - Claude's file edits appear as a diff in the editor; accept or reject inline.
JetBrains specific
JetBrains exposes the same chord but routes through the IDE's built-in terminal. If Cmd+Esc conflicts with another binding, change it under Preferences → Keymap → "Open Claude Code".
Neovim specific
-- After installing claude.nvim via lazy.nvim or packer
vim.keymap.set('n', '<leader>cc', '<cmd>ClaudeCode<cr>')
vim.keymap.set('v', '<leader>cc', '<cmd>ClaudeCodeWithSelection<cr>')
Try it
Install the IDE extension that matches your editor, set the keybind to Cmd/Ctrl + Esc, and run a small task end-to-end (rename a variable across three files). Notice how the diff preview changes the trust loop.