GeezerVison is showing computingforgeeks.com — Claude Code Cheat Sheet (PDF): Commands, Shortcuts | ComputingForGeeks
Claude Code is Anthropic’s AI-powered CLI tool that reads your codebase, edits files, runs commands, and manages git workflows directly from the terminal. It operates as an agentic coding assistant: you describe what you want in plain English, and it figures out which files to read, what commands to run, and what changes to make. This cheat sheet covers every command, shortcut, configuration option, and workflow pattern you need to be productive with Claude Code.
Original content from computingforgeeks.com - post 162997
The releases since 2.1.282 moved the aliases again: sonnet now resolves to Sonnet 5.5 and haiku to Haiku 5.5, while opus stays on Opus 5.5, and 2.1.321 moved fable from Fable 5.1 to Fable 5.2, which is cheaper at $8/$40 per million tokens and supports /fast. Every plan and provider now starts interactive sessions in auto mode when no permission mode is configured, Ultracode became its own /effortultracode switch, /doctorprompt-audit flags CLAUDE.md rules written for older models, and claudeprojectpurge is now plain claudepurge. Every alias, command, and flag below was checked against Claude Code 2.1.303 on macOS in October 2026, the cost and error output comes from that install, and the 2.1.304 compact-window change was checked on an Ubuntu 26.04 VM later that month. The fable alias, the /model picker and the Fable fast-mode dialog were rechecked on Claude Code 2.1.322 on an Ubuntu 24.04 VM in November 2026.
The /model picker on 2.1.322: Default is still Opus 5.5 at medium effort, Fable now means Fable 5.2, and /status confirms the alias resolves to claude-fable-5-2
This cheat sheet is also available as a GitHub repository you can star, fork, and reference offline. Contributions and suggestions are welcome there. For the official changelog and new features, check the Claude Code releases on GitHub.
Claude Code Commands Cheat Sheet: the Daily 20
If you only learn twenty things, learn these. They cover starting and resuming sessions, steering the model, keeping the context window clean, and getting out of trouble, which is most of what a working day in Claude Code involves:
Action
How
Start new session
claude
Continue last session
claude-c
Initialize project
/init
Switch to plan mode
Shift+Tab
Switch model
/modelopus or Option+P / Alt+P
Undo changes
Esc+Esc
Free context space
/compact
Start fresh
/clear
Check plan usage and cost
/usage (/cost is an alias)
Review changes
/diff
Security scan
/security-review
Name session
/renamemy-feature
Resume session
/resume or claude-r
Mention a file
@path/to/file
Run bash directly
!ls-la
Multiline input
\+Enter
Stop Claude mid-turn
Esc (Ctrl+C also works, but twice exits)
Exit
Ctrl+D
Non-interactive
claude-p"query"
Show all commands
/help
Fix-It Recipes: What to Press When Something Goes Wrong
Most cheat sheets list commands alphabetically, which is no help when Claude has just rewritten the wrong file. This table starts from the situation instead. Every key and command in it was checked against 2.1.303:
Situation
Do this
Claude is editing the wrong thing right now
Esc stops the turn and keeps what was done so far
Undo the last edits, code and chat together
EscEsc on an empty prompt, or /rewind, then pick a checkpoint
You cleared a long prompt with Ctrl+C by accident
Press Up while the prompt is still empty to bring the draft back
Park a half-written prompt to ask something else
Ctrl+S stashes it; press it again on an empty prompt to restore
Quick question without polluting the context
/btwwhatdoesthisregexmatch?
Context is filling up mid-task
/compactkeeptheauthrefactornotes, or /context first to see what is eating it
Try a different approach without losing this one
/branch copies the conversation so you can go back
Switching to unrelated work
/clear, which is cheaper than compacting
Send queued messages without waiting for the turn
Ctrl+Enter, or Ctrl+XCtrl+S in terminals without extended keys
Background subagents are running away
Ctrl+XCtrl+K twice within 3 seconds stops them all
Hit a usage limit
/rate-limit-options lists waiting, credits, and other ways to keep going
Something is broken in your setup
/doctor, then f to let Claude fix what it finds; claude--safe-mode starts with every customization off
CLAUDE.md rules feel ignored on newer models
/doctorprompt-audit flags instructions written for older models
Find the session you named yesterday
claude-rauth-fix resumes an exact name match directly; a partial name opens the picker pre-filtered
The two people get wrong most often are Esc and Ctrl+C. Esc interrupts Claude and leaves you in the session, while a second Ctrl+C on an empty prompt exits Claude Code entirely. If you came from a shell where Ctrl+C is the reflex for “stop”, retrain that finger, because exiting throws away the in-memory state of any background work the session was supervising.
What Changed From 2.1.282 to 2.1.304
These are the changes since the last revision of this cheat sheet that alter how you type or what you get by default. The full list lives in the official changelog, but most of it is bug fixes:
Change
Version
What it means for you
Auto mode is the starting mode on every plan and provider when no mode is configured
2.1.283, 2.1.284
Pro, Max, and Team already had it; Enterprise, API, and third-party provider users now get it too. Set permissions.defaultMode for the old prompting behavior
/auto-mode-setup works on every provider
2.1.304
The guided setup that drafts autoMode.environment from your project now also runs on Bedrock, Vertex, Foundry, the Claude apps gateway, and sessions with telemetry turned off
claude-p and Agent SDK runs with no mode set start in manual (default) mode
2.1.302
Tool calls that need approval are denied in scripts unless you pass --allowedTools or --permission-mode
/doctorprompt-audit (also /checkupprompt-audit)
2.1.283
Audits CLAUDE.md, skills, agents, and commands for prompting patterns aimed at older models
Ultracode is its own toggle: /effortultracodeon|off
2.1.284
The slash command no longer forces xhigh and stays on at any effort level; the --effortultracode launch flag still starts at xhigh
/mcpreconnectall
2.1.284
Retries every MCP server that failed to connect or needs authentication
claude--desktop, claudepluginconfigure
2.1.285
Hand a session to the desktop app; inspect a plugin’s options
Background commands get a time limit in unattended runs only
2.1.285, 2.1.288
In -p, SDK, CI, and cloud runs, background commands stop after 30 minutes by default (raise it with BASH_DEFAULT_TIMEOUT_MS and BASH_MAX_TIMEOUT_MS). Terminal, desktop, and VS Code sessions have no limit since 2.1.288
/code-review--max-findings<n>|all|default
2.1.288
Ask for more or fewer findings; the choice sticks until default
/autocompact saved per model
2.1.288
Opus and Sonnet can keep different compaction windows
CLAUDE_CODE_AUTO_COMPACT_WINDOW accepts k and M suffixes
2.1.304
Before this, 200k silently gave you a 100K window. Values outside 100k to 1M are now clamped with a warning, and unreadable ones are ignored with a warning
claudeattach and claudelogs accept part of a session name
2.1.290
No need to copy the short id
Idle compaction for conversations over 200K tokens
2.1.299
Terminal sessions idle about 54 minutes get compacted before the prompt cache expires. Change the threshold with CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS; turn it off with the /config row or "idleCompaction":false
claudeprojectpurge renamed to claudepurge
2.1.288
The old name still works and prints a notice. --dry-run lists what would go, --all covers every project
MCP tool search on by default behind a custom ANTHROPIC_BASE_URL
2.1.304
Gateway users now get deferred MCP tools without setting ENABLE_TOOL_SEARCH. If your gateway cannot forward tool_reference blocks, set ENABLE_TOOL_SEARCH=false. On 2.1.304 itself a gateway that rejects tool search fails every request; 2.1.305 and later retry without it
The auto-mode default is the one that changes behavior without you noticing. On a fresh install you will see far fewer permission prompts than older tutorials describe, and that is the classifier at work rather than a broken prompt. If your team policy requires a human to approve each command, pin "defaultMode":"default" in the project’s .claude/settings.json so a new laptop does not quietly start in auto. That only sets the starting mode, though, because anyone can still press Shift+Tab into auto; real enforcement is permissions.disableAutoMode set to "disable" in managed settings.
The compact window fix is worth checking if you set the variable in a shell profile months ago. Before 2.1.304, CLAUDE_CODE_AUTO_COMPACT_WINDOW=200k silently set a 100K window, so sessions compacted at half the size you asked for and nothing said why. From 2.1.304 a bad value tells you what it did instead of failing silently. This is the 2.1.304 binary on an Ubuntu 26.04 VM with a value below the floor:
CLAUDE_CODE_AUTO_COMPACT_WINDOW=50k claude -p"say hi"
The warning names the value it read and the size it used, before the session continues (that VM was not signed in, hence the last line):
CLAUDE_CODE_AUTO_COMPACT_WINDOW="50k" reads as 50,000 tokens, so Claude Code treats it as the 100k minimum. Set it to a size from 100k to 1M, such as 200k or 200000, or unset it.
Not logged in · Please run /login
2M gets the matching “is too large, so Claude Code treats it as the 1M maximum” line, and a typo such as abc is ignored with a warning rather than guessed at. 200k, 500K, 1M, and the plain 200000 all pass without a word. The same k and M forms work in the /autocompact command and the --autocompact flag.
Installation
Install Claude Code on macOS, Linux, or Windows (WSL):
curl -fsSLhttps://claude.ai/install.sh| bash
On macOS via Homebrew:
brew install--caskclaude-code
On Windows (PowerShell):
irm https://claude.ai/install.ps1 | iex
Verify and authenticate:
claude --version
claude authlogin
A working install prints the version followed by (ClaudeCode), for example 2.1.304(ClaudeCode) on the Ubuntu lab VM. Sign-in is a one-time step per machine; later sessions reuse it.
Keyboard Shortcuts
These work in the interactive Claude Code terminal. This is the most-referenced section, so bookmark it.
Essential Shortcuts
Shortcut
Action
Ctrl+C
Interrupt a running operation. If nothing is running, first press clears input, second exits. Up on the empty prompt brings a cleared draft back
Ctrl+S
Stash the current prompt; press again on an empty prompt to restore it with its mode and pasted content
Ctrl+Enter
Send queued messages now instead of after the current turn (Ctrl+XCtrl+S in any terminal)
Ctrl+_
Undo the last edit in the prompt input
Esc
Interrupt Claude mid-turn, keeping the work done so far
Esc+Esc
Clear the input draft, or (when input is empty) open the rewind menu to restore a checkpoint
Ctrl+D
Exit Claude Code
Ctrl+L
Redraw the screen to recover a garbled display
Ctrl+R
Reverse search command history
Shift+Tab
Cycle permission modes (manual, acceptEdits, plan, plus auto and bypassPermissions when available). New sessions with no configured mode start in auto
Toggle the task list (on Opus 4.8, Sonnet 5, and newer the task tools need CLAUDE_CODE_ENABLE_TODO_TOOLS=1)
Ctrl+B
Move a running bash command or agent to the background (tmux: press twice)
Ctrl+XCtrl+K
Kill all running background subagents (press twice within 3 seconds)
Input and Editing
Shortcut
Action
\+Enter
New line, works in every terminal
Ctrl+J
New line, works in any terminal with no configuration
Option+Enter (Mac) / Alt+Enter (Linux/Win)
New line (platform default)
Shift+Enter
New line in iTerm2, WezTerm, Ghostty, Kitty, Warp, Apple Terminal, Windows Terminal. Run /terminal-setup for VS Code, Cursor, Zed
Ctrl+A / Ctrl+E
Move cursor to start / end of line
Ctrl+K
Delete to end of line
Ctrl+U
Delete from cursor to line start
Ctrl+W
Delete back to the previous whitespace, Bash style: one press removes a whole path or --flag=value. Option+Delete (macOS) or Ctrl+Backspace (Windows) deletes a single word
Ctrl+Y
Paste text deleted with Ctrl+K/U/W
Alt+B / Alt+F
Move cursor back/forward one word (macOS needs Option set as Meta)
Cmd+V (Mac) / Ctrl+V or Alt+V (Linux/Win/WSL)
Paste image from clipboard
Up/Down
Move cursor, then navigate command history at the edges
Model and Mode Switching
Shortcut
Action
Option+P (Mac) / Alt+P (Linux/Win)
Open the model picker (Opus, Sonnet, Fable, Haiku)
Option+T (Mac) / Alt+T (Linux/Win)
Toggle extended thinking (no effect on Opus 5.5, Sonnet 5.5, Haiku 5.5, or the Fable models, which always think)
Option+O (Mac) / Alt+O (Linux/Win)
Toggle fast mode
Shift+Tab / Alt+M
Cycle permission mode (all platforms)
?
Show all shortcuts (in the transcript viewer)
Quick Prefixes
Prefix
Action
/
Open slash command menu
!
Run bash command directly
@
Autocomplete file path mention
Slash Commands Reference
Session and Context Management
Command
What It Does
/clear
Wipe conversation history and free context window
/compact[focus]
Summarize conversation to free context, optionally focused on one topic
/cost
Alias for /usage: plan limits, session cost, and prompt-cache hits
/context
Visualize what is consuming your context window
/resume
Pick and resume a previous session
/rename[name]
Name current session for easy resuming later
/rewind
Rewind to a previous checkpoint
/diff
Review uncommitted changes in the working tree. In fullscreen mode it opens a panel beside the conversation that updates as Claude edits
/copy
Copy last response to clipboard
/export[file]
Export conversation as text file
/cd[path]
Move this session to a new working directory, keeping the prompt cache
/background / /bg
Detach the whole session to keep running as a background agent
/tasks
View and manage everything running in the background, including finished subagents and the model each ran on (alias /bashes)
/autocompact[size|auto]
Set how full the context gets before auto-compaction, for example /autocompact500k
Configuration and Model
Command
What It Does
/model[name]
Switch model (opus, sonnet, haiku, fable) and save it as the default for new sessions. Press s in the picker to use it for this session only
/effort[level]
Set reasoning effort (low, medium, high, xhigh, max, ultracode, auto; status prints it). Saved per model, so each model keeps its own level. Opus 5.5, Sonnet 5.5, and Haiku 5.5 default to medium, Opus 4.7 to xhigh, the rest to high
/config[key=value]
Open settings, or set a key inline (/configtheme=dark, /configmodel=sonnet). Vim editor mode now lives here. Run /config--help for keys
/permissions
View and manage tool permissions and review recent auto-mode denials
/mcp
Manage MCP server connections and OAuth
/terminal-setup
Configure terminal keybindings for your shell
/keybindings
Open your keyboard shortcuts file to rebind keys
/theme
Change color theme (light, dark, auto, colorblind-safe, custom)
/tui[fullscreen]
Switch the terminal renderer; fullscreen enables the flicker-free view
/output-style[name]
List output styles or switch to one, for example /output-styleconcise
/skills
List skills with their token cost (t sorts by tokens) and toggle each one’s visibility
/plugin / /reload-plugins
Open the plugin menu, or reload active plugins without restarting
Project and Code Tools
Command
What It Does
/init
Initialize project, generating a CLAUDE.md with project context
/memory
View and edit CLAUDE.md files and auto-memory
/code-review[level][--fix][--comment]
Review the diff for bugs and cleanups. --fix applies findings, --comment posts inline PR comments, ultra runs a cloud multi-agent review
/simplify[target]
Cleanup-only review (reuse, simplification, efficiency) that auto-applies fixes. Use /code-review to hunt bugs
/review[PR]
Review a pull request locally in the current session
/security-review
Scan pending changes for security vulnerabilities
/run
Launch and drive your app to confirm a change actually works, not just that tests pass
/verify
Build, run, and observe the app to confirm a change does what it should. Claude no longer runs this (or /code-review) on its own; invoke it explicitly
/advisor[model|off]
Consult a second model (fable, opus, sonnet, or a model ID) at key moments during a task
/skill-doctor
Show which loaded skills go unused and what each costs in context, so you can prune them. Needs feature-flag fetching enabled
/import[codex|gemini|cursor]
Bring instruction files, MCP servers, commands, subagents, and skills over from another coding agent (--dry-run previews). Not available on Bedrock, Vertex, or Foundry
/add-dir[path]
Add another directory to the working context
/plan
Enter plan mode, a read-only exploration before making changes
/branch[name]
Branch the current conversation to try a different direction without losing this one
/fork[directive]
Copy the conversation into a new background session (its own row in claudeagents) while you keep working in the original
/subtask[directive]
Spawn an in-session subagent that inherits the full conversation and reports back when done (the previous /fork behavior)
/goal[condition]
Keep working across turns until a stated condition is met
/batch[task]
Decompose a large change into 5 to 30 units and run each in its own parallel worktree
/debug[description]
Troubleshoot problems in the current session
System and Account
Command
What It Does
/help
Show all available commands
/doctor / /checkup
Full setup checkup: diagnoses install, settings, auth, and MCP, then press f to have Claude fix what it finds
/insights
Generate a session analysis report: patterns, efficiency, suggestions
/status
Show version, model, and account info
/login / /logout
Sign in or out
/bug
Submit a bug report with session logs
/stats
Open /usage on its Stats tab: usage patterns, daily streaks, and session history
/usage
Show plan usage and rate limits
/release-notes
View changelog for current version
/loop[interval][prompt]
Run a prompt repeatedly while the session is open. Omit the interval and Claude paces itself
/voice
Toggle push-to-talk voice dictation (hold Space)
/schedule
Create, update, list, or run scheduled remote agents (cron tasks)
/fast
Toggle fast mode (same model, faster output, higher price) on Opus 5.5 or Fable 5.2. On Fable, run it while Fable 5.2 is the active model
/hooks
View and manage configured hooks
/desktop
Hand off current session to the Desktop app
/teleport
Pull a web/iOS session into your terminal
/web-setup
Connect GitHub for cloud sessions using your local gh credentials
/list-agents
List the subagents, teammates, and other sessions Claude can message (alias /peers). Only where cross-session messaging is on
/remote-control
Continue this local session from claude.ai or the Claude app on another device
/reload-skills
Re-scan skill and command directories so on-disk changes apply without a restart
/sandbox
Toggle sandbox mode (supported platforms only)
/recap
Summarize what has happened in the session so far
/statusline
Configure the status line from a description or your shell prompt
/privacy-settings
View and update privacy settings (Pro and Max)
/focus
Toggle the focus view: only your last prompt, a one-line tool summary, and the final response
/powerup
Learn Claude Code features through quick interactive lessons with animated demos
/dataviz
Design charts and dashboards with colorblind-safe, contrast-checked palettes
/deep-research[question]
Fan out web searches, cross-check sources, and synthesize a cited report
/autofix-pr[prompt]
Spawn a cloud session that watches your PR and pushes fixes when CI fails or reviewers comment
/fewer-permission-prompts
Scan your transcripts and pre-approve common read-only commands to cut prompt fatigue
/team-onboarding
Generate a team onboarding guide from your last 30 days of Claude Code usage
/rate-limit-options
Ways to keep working when a usage limit blocks a request: wait and auto-continue, add usage credits, or upgrade your plan
/usage-credits
Configure usage credits, or request them from your admin on Team and Enterprise
/auto-mode-setup
Draft autoMode.environment entries from your project and recent sessions, review, then save
/ultrareview[PRorbranch]
Deep multi-agent code review in a cloud sandbox
/stop
Stop the background session you are attached to; transcript and worktree are kept
/exit / /quit
Exit the CLI. In an attached background session it detaches and the session keeps running
/color[color]
Color the prompt bar for this session (red, blue, green, yellow, purple, orange, pink, cyan)
/ide / /chrome
Manage IDE integrations, or Claude in Chrome settings
/install-github-app
Install the Claude GitHub App on a repo, optionally with GitHub Actions workflows
/remote-env
Choose the default cloud environment for cloud sessions started from the CLI
/setup-bedrock / /setup-vertex
Provider wizards, hidden until CLAUDE_CODE_USE_BEDROCK=1 or the Vertex equivalent is set
/update-config[request]
Bundled skill: describe a settings change and Claude edits the right settings.json
/vim, /pr-comments
Removed (2.1.92 and 2.1.91). Vim mode lives in /config under Editor mode; ask Claude directly for PR comments
CLI Flags – Non-Interactive and Automation
Starting Sessions
Claude Code reads your current directory as the project root. Launch it from the repo where you want work to happen:
# Start interactive session
claude
# Start with initial prompt
claude "refactor the auth module"# Continue most recent session
claude -c# Resume specific session by name
claude -r"auth-refactor"# Name a session for later
claude -n"feature-payments"# Run in isolated git worktree
claude -wfeature-branch# Run in worktree with tmux panes
claude -wfeature-branch--tmux# Resume session linked to a GitHub PR
claude --from-pr42# Fork a session (new ID, keeps context)
claude -c--fork-session# Enable auto mode (AI decides permissions)
claude --permission-modeauto# Skip all permission prompts (sandboxes and containers only)
claude --dangerously-skip-permissions# Add bypassPermissions to the Shift+Tab cycle without starting in it
claude --permission-modeplan--allow-dangerously-skip-permissions# Bare mode (skip hooks, plugins, auto-memory) for fast scripted calls
claude --bare# Safe mode: start with ALL customizations disabled to troubleshoot a broken config
claude --safe-mode# Restricted mode: no Bash, code-running tools, or WebFetch; file tools confined to the working dirs;# only managed settings and --settings load, so your own hooks and permission rules are skipped
claude --restricted# Continue this local session from claude.ai or the Claude app on another device
claude --remote-control# Preview, then import config from another coding agent (codex, gemini, or cursor)
claude importcodex--dry-run
Run the --dry-run form of claudeimport first on any repo you care about, since it only lists what would be brought over.
Print Mode (Non-Interactive / Piping)
The -p flag runs Claude Code non-interactively: it processes the prompt and exits. This is the key to integrating Claude Code into scripts, CI/CD pipelines, and Unix pipes:
# Simple query
claude -p"explain this error in server.log"# Pipe input
cat error.log| claude -p"what caused this crash?"# Git diff review
git diffmain| claude -p"review for security issues"# JSON output for scripting
claude -p"list all TODO comments"--output-formatjson# Structured output with schema validation
claude -p"extract function names from auth.py"\--output-formatjson\--json-schema'{"type":"object","properties":{"functions":{"type":"array","items":{"type":"string"}}}}'# Auto-approve tools (careful with this)
claude -p"run tests and fix failures"--allowedTools"Bash,Read,Edit"# Set spending limit
claude -p"refactor the API layer"--max-budget-usd5.00# Limit turns
claude -p"fix the bug"--max-turns3# Fallback model when primary is overloaded
claude -p"review this code"--fallback-modelhaiku# Restrict available tools
claude -p"analyze this"--tools"Read,Grep,Glob"# Block specific tools (deny list)
claude -p"refactor auth module"--disallowedTools"Bash(rm:*),Bash(sudo:*)"# Override system prompt entirely
claude -p"review this code"--system-prompt"You are a security auditor. Focus only on vulnerabilities."# Append to default system prompt
claude -p"explain this function"--append-system-prompt"Always include time complexity analysis."# Load MCP servers from external config file
claude -p"check open issues"--mcp-config./ci-mcp.json# Disable session persistence (ephemeral, for CI/CD)
claude -p"run lint check"--no-session-persistence# Debug mode (logs API calls, tool usage, timings)
claude -p"fix the build"--debug# Debug with category filter
claude -p"fix the build"--debug"api,hooks"# Write debug output to a file
claude -p"fix the build"--debug-file/tmp/claude-debug.log# Select a specific agent
claude -p"review auth.py"--agentcode-reviewer# Streaming JSON output (realtime events for SDK and automation)
claude -p"fix the build"--output-formatstream-json--verbose# Streaming JSON input
claude -p--input-formatstream-json--output-formatstream-json# Pin a specific session ID (must be a valid UUID)
claude -p"run lint"--session-id550e8400-e29b-41d4-a716-446655440000# Load extra settings inline or from a file (overrides matching keys for this run)
claude -p"audit deps"--settings./ci-settings.json# Only load specific setting sources
claude -p"check types"--setting-sourcesuser,project# Replace the default system prompt from a file
claude -p"review"--system-prompt-file./reviewer.txt# Improve prompt-cache reuse across users and machines in scripted runs
claude -p"lint"--exclude-dynamic-system-prompt-sections# Enable Chrome browser integration
claude --chrome
Every one of those runs bills the system prompt, tool definitions, and your CLAUDE.md files before it reads your prompt, so the model alias matters more than the prompt length for short scripted calls.
What One claude -p Call Costs per Model
To put numbers on that, the same one-word prompt went to each alias from a scratch directory, with JSON output so the cost and the resolved model ID come back with the answer:
claude -p--modelhaiku--output-formatjson"Reply with the single word ok"| jq '{result, total_cost_usd, duration_ms, num_turns, modelUsage: (.modelUsage | keys)}'
The modelUsage key shows which model the alias resolved to, which is the quickest way to confirm what haiku means on your account today:
Repeating it for every alias on the same setup gave this spread. The first call in a directory also pays to write the prompt cache, which is why a repeat Haiku call came in slightly cheaper than the first:
Alias
Resolved model ID
Cost of a one-word reply
haiku
claude-haiku-5-5
$0.0034 to $0.0039
sonnet
claude-sonnet-5-5
$0.074
opus
claude-opus-5-5
$0.143
fable (on 2.1.303)
claude-fable-5-1
$0.404
Those figures come from 2.1.303, when fable still meant Fable 5.1 at $10/$50 per million tokens. From 2.1.321 the same alias calls claude-fable-5-2, which the /model picker lists at $8/$40, so expect the Fable row to come in lower on a current install. Run the jq command above with --modelfable to get your own figure. On 2.1.303, Fable cost about 100 times what Haiku did for the same trivial answer. A cron job that runs claude-p every five minutes is 288 calls a day, which works out to about $41 a day on the default Opus 5.5 and about $1 on Haiku before it does any real work, so scripted checks should name --modelhaiku explicitly and set --max-budget-usd as a ceiling. Save Opus and Fable for runs where the reasoning is the point.
Error: “Not logged in · Please run /login” with –bare
--bare skips hooks, plugins, and CLAUDE.md discovery, which makes CI runs reproducible, but it also stops reading OAuth tokens and the keychain. On a machine signed in with a Claude subscription, the same command that works normally fails immediately:
claude -p--bare--modelhaiku"Reply ok"
The session never starts:
Not logged in · Please run /login
Running /login will not help. For the Anthropic API, bare mode accepts only ANTHROPIC_API_KEY or an apiKeyHelper passed through --settings (Bedrock, Vertex, and Foundry still read their own provider credentials), so export an API key in the CI environment, or drop --bare and use --setting-sources to control which settings load.
A mistyped subcommand becomes a prompt
Claude Code treats any unknown first word as the prompt. Interactively you notice at once, but when stdout is a pipe or a file the session runs in print mode, so claudestauts|head sends the word “stauts” to the model, bills a full turn, and prints a chatty answer instead of an error. Scripts that wrap Claude Code subcommands should check claude--help output for the subcommand first, or quote the intent explicitly with -p so a typo is at least obvious in the logs.
Model and Effort Flags
Pick a model and reasoning budget up front instead of toggling mid-session. Flags stick for the session they start:
# Use specific model
claude --modelopus
claude --modelsonnet
claude --modelhaiku
claude --modelfable# Pin an exact version instead of an alias
claude --modelclaude-opus-5-5# Set reasoning effort for this session only
claude --efforthigh# More thorough (costs more)
claude --effortlow# Faster, cheaper
claude --effortultracode# xhigh plus dynamic workflows# Custom system prompt
claude --append-system-prompt"Always use TypeScript. Never use any."# Load system prompt from file
claude --append-system-prompt-file./coding-rules.txt
Both append flags add to the default system prompt instead of replacing it, so Claude Code keeps its built-in tool instructions. --system-prompt (or --system-prompt-file) is the one that replaces everything.
CLAUDE.md – Project Instructions
CLAUDE.md is the single most important file for customizing Claude Code behavior on a per-project basis. It is loaded automatically at the start of every session. For the full directory structure, including rules, agents, skills, and settings, see the .claude directory guide.
File Locations and Scope
Location
Scope
Shared with Team?
./CLAUDE.md
This project only
Yes (commit to git)
./.claude/CLAUDE.md
This project only
Yes (commit to git)
~/.claude/CLAUDE.md
All your projects
No (personal)
.claude/rules/*.md
Path-specific rules
Yes (commit to git)
./AGENTS.md
Read instead of CLAUDE.md when the repo has no CLAUDE.md
Yes (commit to git)
Repos set up for Codex or other agents often carry an AGENTS.md already. Claude Code reads it on its own when no CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md exists in the working directory or above it. If both files exist, only CLAUDE.md loads, so either import @AGENTS.md from CLAUDE.md or change the Project instructions row in /config to read both.
Example CLAUDE.md
Create the file at the project root. Claude Code reads it on every session start in that directory:
vi CLAUDE.md
Add your project instructions:
# My Project
## Build and Test
- Run tests: `npm test`
- Build: `npm run build`
- Lint: `npm run lint`
## Code Style
- Use TypeScript strict mode
- Prefer functional components in React
- All API responses must include error handling
- Never commit .env files
## Architecture
- Backend: Express.js + PostgreSQL
- Frontend: React + TailwindCSS
- Auth: JWT tokens stored in httpOnly cookies
See @README.md for project overview.
See @package.json for available scripts.
The @filename syntax imports content from other files, and Claude reads them automatically.
Path-Specific Rules
Rules that only apply to certain files. Create .claude/rules/api.md:
vi .claude/rules/api.md
Add frontmatter with path patterns:
---
paths:-"src/api/**/*.ts"
---
# API Rules-All endpoints must validate input with Zod-Return proper HTTP status codes-Include rate limiting on public endpoints
Generate a CLAUDE.md automatically for any project with /init.
Permission Modes
Claude Code decides which tool calls need your approval based on the permission mode. With nothing configured, interactive sessions start in auto, where a classifier approves routine calls and blocks risky ones. Toggle between modes with Shift+Tab. For production lockdown configurations, see the DevOps setup guide which covers permission rules, safety hooks, and CLAUDE.md hardening for infrastructure work.
Mode
Behavior
Use Case
manual (config value default)
Prompts on first use of each tool. A grey pause badge in the footer shows when it is active
Normal interactive work
plan
Read-only: no edits, no commands
Safe exploration and planning
acceptEdits
Auto-approves file edits, prompts for commands
Trusted editing sessions
dontAsk
Auto-denies unless pre-approved
Strict control
auto
AI classifier decides allow/deny per tool call
Trusted projects with clear CLAUDE.md rules
bypassPermissions
Skips all prompts (dangerous)
Containers/sandboxes only
A cloned repo can no longer switch these risky modes on for you: "defaultMode":"auto" and "bypassPermissions" are ignored in .claude/settings.json and .claude/settings.local.json. Set them in ~/.claude/settings.json or pass --permission-mode at launch.
Pre-Approve Specific Tools
In .claude/settings.json or via the CLI:
# Allow git commands and file reads without prompting
claude --allowedTools"Read,Bash(git *)"# Block dangerous tools explicitly
claude --disallowedTools"Bash(rm:*),Bash(sudo:*),Bash(chmod:*)"# Combine both: allow some, block others
claude --allowedTools"Bash(git:*),Read,Edit"--disallowedTools"Bash(rm -rf:*)"
Or in settings:
vi .claude/settings.json
Add permission rules:
{"permissions":{"allow":["Read","Bash(git *)","Bash(npm run *)","Bash(docker compose *)"],"deny":["Bash(rm -rf *)"]}}
Deny rules are checked before allow rules, so a command that matches both lists is blocked.
The most capable model, for the hardest, longest-running tasks. $8/$40 per million tokens, $16/$80 in fast mode. Never a default; pick it with /modelfable. Fable 5.1 and Fable 5 stay reachable as claude-fable-5-1 and claude-fable-5. In Claude apps gateway sessions the alias still means Fable 5 unless ANTHROPIC_DEFAULT_FABLE_MODEL is set. On some plans Fable bills usage credits
opusplan
Opus, then Sonnet
Opus reasoning during plan mode, then auto-switches to Sonnet for execution
opus[1m] / sonnet[1m]
1M-token context
Only matters on Opus 4.6 and Sonnet 4.6. Every Fable model, Sonnet 5.5, Sonnet 5, and Opus 4.7 and later run 1M on every plan with no suffix
default / best
Tier default / same as opus
default reverts to your account’s recommended model; best now uses the same model as opus, so it no longer reaches Fable
Switch models mid-session with /modelopus or Option+P (Mac) / Alt+P (Linux/Windows). The /model picker saves your choice as the default for new sessions (press s to switch for the current session only). Aliases like opus always point to the latest release, so pin a full name (claude-opus-5-5) when you need a fixed version. Opus 5.5 needs Claude Code 2.1.280 or later, Sonnet 5.5 needs 2.1.284, the haiku alias reaches Haiku 5.5 from 2.1.293, Fable 5.2 needs 2.1.321, Fable 5.1 needs 2.1.257, and Opus 5 needs 2.1.219, so run claudeupdate if /model does not list one. ANTHROPIC_DEFAULT_MODEL sets the model new sessions start on, but only when nothing else picks one: no --model, no ANTHROPIC_MODEL, and no model in any settings file, including one saved earlier by /model.
Effort levels control how much adaptive reasoning Claude applies. The available levels depend on the model: every Fable model, Opus 5.5, Sonnet 5.5, Haiku 5.5, Opus 5, Sonnet 5, Opus 4.8, and Opus 4.7 support all five, while Sonnet 4.6 and Opus 4.6 support all of them except xhigh (an xhigh request on those falls back to high). The default is high everywhere except Fable 5.2 and the 5.5 generation (Opus 5.5, Sonnet 5.5, and Haiku 5.5), which start at medium, and Opus 4.7, which starts at xhigh. If Fable 5.2, Opus 5.5 or Sonnet 5.5 feels shallower than the model you used before, that default is usually why.
Level
Use Case
/effortlow
Short, scoped, latency-sensitive tasks that are not intelligence-sensitive
/effortmedium
Routine refactors, single-file changes, test generation. Default on Fable 5.2, Opus 5.5, Sonnet 5.5, and Haiku 5.5.
/efforthigh
Multi-file edits, debugging, non-trivial work. Default on Fable 5.1, Fable 5, Opus 5, Sonnet 5, Opus 4.8, Opus 4.6, and Sonnet 4.6.
/effortxhigh
Design decisions, tricky cross-module refactors, gnarly bugs. Default on Opus 4.7. Available on every effort-capable model except Opus 4.6 and Sonnet 4.6 (Haiku 4.5 has no effort levels; Haiku 5.5 supports all five)
/effortmax
The hardest problem of the week. Deepest reasoning, no token cap, session-only, and prone to overthinking
/effortultracodeon|off
A Claude Code switch rather than a model level: Claude orchestrates a dynamic workflow of background agents for substantive tasks. Since 2.1.284 it no longer forces xhigh and stays on at whatever effort you pick (Tab toggles it in the /effort slider)
A level typed after /effort (or confirmed with Enter in the slider) is saved as that model’s default; press s in the slider to apply it to this session only. Set effort for a single session at launch with claude--efforthigh, or globally with the CLAUDE_CODE_EFFORT_LEVEL environment variable, which overrides every other source. Run /effortauto to reset to the model default.
For one-off deep reasoning without changing your session effort, put the word ultrathink anywhere in your prompt. Claude Code recognizes it and adds an in-context instruction for that turn only. Note that the older “think”, “think hard”, and “think harder” phrases are no longer special keywords; they are passed through as ordinary prompt text, so ultrathink is the one to remember.
Turn On Fast Mode for Fable 5.2
Fast mode serves the same model up to 2.5 times faster at a higher token price. Claude Code 2.1.321 added it for Fable 5.2, at $16/$80 per million tokens, twice Fable’s standard rate according to Anthropic’s Fable 5.2 announcement. There is no CLI flag for it: claude--help on 2.1.322 lists nothing with “fast” in it. Start on Fable, then open the dialog:
claude --modelfable
Inside the session, type /fast, press Space to toggle and Enter to confirm, or press Option+O / Alt+O to toggle it directly. A ↯ marker beside the prompt means it is on. The order matters on Fable. "fastMode":true in settings does nothing for Fable 5.2 until you run /fast while Fable 5.2 is the active model, and switching to Fable from a fast Opus session turns fast mode off unless you already turned it on while on Fable 5.2. Our lab session ran on a placeholder API key, so the availability check failed and the dialog showed this instead of the toggle:
On a real account, “Fast mode unavailable due to network connectivity issues” means Claude Code could not reach api.anthropic.com for that check. It skips ANTHROPIC_BASE_URL, so a gateway-only network trips it. Allowlist api.anthropic.com or set CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS=1. On Pro, Max and Team plans fast mode bills usage credits only, never your plan limits, so turn usage credits on first or /fast answers “Fast mode requires usage credits”. Team and Enterprise also need an Owner to enable fast mode. The first toggle in a conversation pays the uncached fast price on the whole context, so turn it on at the start of a session. The fast mode docs list the other refusal messages.
MCP Servers – Extend Claude Code
MCP (Model Context Protocol) lets Claude Code connect to external tools and data sources. Project servers live in .mcp.json at the repo root. Personal servers you want in every project are stored in ~/.claude.json, which claudemcpadd--scopeuser writes for you. The MCP servers setup guide walks through GitHub, Postgres, and browser servers end to end.
vi .mcp.json
Example configuration with GitHub and PostgreSQL servers:
You can also add servers from the command line instead of hand-editing JSON. Claude Code writes the config for you:
# Add an HTTP server
claude mcpadd--transporthttpsentryhttps://mcp.sentry.dev/mcp# Add a server to every project (user scope, stored in ~/.claude.json)
claude mcpadd--transporthttp--scopeusersentryhttps://mcp.sentry.dev/mcp# Add a stdio server with environment variables
claude mcpaddgithub-eGITHUB_PERSONAL_ACCESS_TOKEN=$GITHUB_TOKEN --npx@modelcontextprotocol/server-github# List, inspect, or remove a server
claude mcplist
claude mcpgetgithub
claude mcpremovegithub# Log in or out of a server that uses OAuth
claude mcplogingithub
claude mcplogoutgithub
Manage MCP connections with /mcp in the interactive session or pass a config file on the CLI:
# Load MCP servers from an external config
claude --mcp-config./team-mcp.json# Load multiple configs
claude --mcp-config./github-mcp.json./db-mcp.json# Ignore all other MCP sources, only use this config
claude --mcp-config./ci-mcp.json--strict-mcp-config
The --mcp-config flag is useful in CI/CD where you need consistent MCP server configuration across runs. --strict-mcp-config ensures only the specified servers are loaded, ignoring any from .mcp.json or user settings.
Custom Skills – Your Own Slash Commands
Skills are reusable prompts that show up as slash commands. Create them at .claude/skills/ (project) or ~/.claude/skills/ (personal).
Example, create a deploy skill:
mkdir -p.claude/skills/deploy
vi .claude/skills/deploy/SKILL.md
Add the skill definition:
---
name:deploydescription:Deploy the application to productionargument-hint:"[environment]"user-invocable:true
---
Deploy the application to the $0 environment (default:staging).Steps:1. Run the test suite2. Build the production bundle3. Deploy using the deploy script4. Verify the deployment health check
Now use it: /deployproduction
Custom Subagents
Subagents are specialized AI agents that Claude can delegate tasks to. Each one is a single Markdown file in .claude/agents/ (project) or ~/.claude/agents/ (personal). The old /agents wizard is gone: typing it now only reminds you to ask Claude to write the file or edit it yourself. The subagents guide covers tool scoping and model choice in more depth.
mkdir -p.claude/agents
vi .claude/agents/code-reviewer.md
Define the agent:
---
name:code-reviewerdescription:Expert code reviewer. Use proactively after code changes.tools:Read, Grep, Glob, Bashmodel:sonnet
---
You are a senior code reviewer. When reviewing code:-Check for security vulnerabilities (SQL injection, XSS, etc.)-Verify error handling is complete-Flag any hardcoded secrets or credentials-Suggest performance improvements-Check for proper input validation
Claude automatically delegates code review tasks to this agent, or you can invoke it directly with @code-reviewercheckmylatestchanges. Add omitClaudeMd:true to the frontmatter when a narrow agent should run without your user, project, and local CLAUDE.md files; it saves context on every spawn.
From the CLI, select an agent for the entire session:
# Use a named agent from .claude/agents/
claude --agentcode-reviewer# In print mode (CI/CD)
claude -p"review the latest commit"--agentcode-reviewer# Define agents inline (no files needed)
claude --agents'{"qa": {"description": "QA tester", "prompt": "You are a QA engineer. Write test cases for every change."}}'
Agents passed with --agents exist only for that session. The files in .claude/agents/ are the ones to commit so the whole team gets them.
Hooks – Automation Triggers
Hooks run shell commands automatically in response to Claude Code events. Configure in .claude/settings.json:
{"hooks":{"PostToolUse":[{"matcher":"Edit|Write","hooks":[{"type":"command","command":"npx prettier --write $(jq -r '.tool_input.file_path')"}]}],"Notification":[{"matcher":"","hooks":[{"type":"command","command":"osascript -e 'display notification \"Claude needs input\" with title \"Claude Code\"'"}]}]}}
The events you will reach for most are SessionStart, UserPromptSubmit, PreToolUse, PermissionRequest, PostToolUse, Stop, SubagentStop, PreCompact, Notification, and SessionEnd. Newer ones include PostToolUseFailure, FileChanged, CwdChanged, DirectoryAdded (fires after /add-dir), WorktreeCreate, and PreModelSwitch. The Claude Code hooks guide has working blockers and formatters for each, and the SSH server management guide shows hooks enforcing safety on production servers.
Context Window Management
Claude Code has a finite context window. Managing it well is the difference between a productive session and hitting walls.
Key Commands
Command
When to Use
/compact
Summarize conversation to free space mid-task
/compactFocusonauthmodule
Summarize but keep specific context intact
/clear
Complete reset between unrelated tasks
/context
See what is consuming your context
Tips for Long Sessions
Use /clear between unrelated tasks, so old context never leaks into new work
Run /compact proactively when you notice slowdowns
Use subagents for verbose operations (test runs, log analysis); their output stays in the subagent context
Move detailed instructions to skills instead of typing them every time
Keep CLAUDE.md under 200 lines. Move details to separate files and import with @filename
Git Worktrees – Parallel Work
Work on multiple tasks simultaneously without branch switching conflicts:
# Start Claude in a new worktree
claude -wfeature-auth# Batch changes across many files in parallel
/batch migrateallcomponentsfromclass-basedtofunctional
The -w flag creates an isolated git worktree. Changes happen in the worktree without affecting your main working directory. When the agent finishes, merge the worktree branch back.
Background Agents and Dynamic Workflows
Background agents are full Claude Code sessions that run detached from your terminal, so you can fire off a long task and keep working in the foreground. They keep running after you close the terminal and are managed from a small set of subcommands. This is the largest addition to Claude Code since the cheat sheet first shipped.
Start one from the shell with --bg. It prints a session ID and returns immediately:
# Launch a background agent and get its ID back
claude --bg"investigate the flaky test in tests/auth"# Run a shell command as a background job instead of a session
claude --bg--exec'pytest -x'# Run a specific subagent in the background
claude --bg--agentcode-reviewer"review the open PR"# Background agents can commit, push, and open a draft PR when they finish
claude --bg"fix the failing CI checks, then commit and open a PR"
From inside an interactive session, detach the whole thing with /background (alias /bg) and list what is running with /tasks. /fork works the other way around: it copies the current conversation into a new background session and leaves you working in the original, so a side investigation can run with full context without stealing your terminal (reach for /subtask when you want that fork to run inside the session instead). To watch and dispatch background sessions in a live view, open the agent manager:
claude agents
Manage individual background sessions from the shell by ID. The agent view shows the IDs, or you can list them as JSON for scripting:
# List live background sessions as JSON
claude agents--json# Attach a background session to this terminal
claude attach7c5dcf5d# Tail its recent output
claude logs7c5dcf5d# Stop, restart (keeps the conversation), or remove from the list
claude stop7c5dcf5d
claude respawn7c5dcf5d
claude rm7c5dcf5d
Background sessions run under a supervisor process. If the agent view reports that the background service did not respond, inspect or reset it:
# Show supervisor state, version, and worker count
claude daemonstatus# Stop the supervisor but keep workers so the next one reconnects
claude daemonstop--any--keep-workers
Dynamic workflows take this further. A single instruction is decomposed into many background subagents that run in parallel. Trigger one for a substantive task by setting the ultracode effort level, then run /workflows to watch progress live. By default Claude aims for a medium workflow (fewer than 10 agents), or small (fewer than 5) on Pro plans. The guideline is advice rather than a hard cap; change it or remove it under Dynamic workflow size in /config, or with the workflowSizeGuideline setting. For a codebase-wide change, /batch splits the work into independent units and runs each in its own git worktree with its own pull request.
The 200-per-session subagent spawn cap was removed in 2.1.224, and CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION is now a no-op; concurrency and depth limits still apply. Web searches are still capped at 200 per session (CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION). Any MCP tool call that runs past two minutes moves to the background automatically so the session stays usable (CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS).
Want a leaner session? Set CLAUDE_CODE_DISABLE_AGENT_VIEW=1 to turn off background agents and CLAUDE_CODE_DISABLE_WORKFLOWS=1 to turn off dynamic workflows.
If you run a long-lived agent gateway next to Claude Code, the OpenClaw cheat sheet (/openclaw-cheat-sheet/) covers its Gateway service, cron automations and the commands other sheets get wrong.
Effort is saved per model under modelSettings, which is what /efforthigh writes for you. A top-level "effortLevel" in ~/.claude/settings.json no longer counts for Opus 5.5, so the older form silently leaves it at medium. A few newer keys worth knowing: "attribution":false hides the commit and PR attribution lines (older CLI versions skip a settings file that holds it, so keep the object form in files shared across versions), modelPicker curates the /model list, and maxProseWidth caps prose width in wide terminals while tables and code keep the full width.
Gitignoring settings.local.json also makes it a quiet leak path: nothing flags what a “don’t ask again” approval stores in it, and an approval keeps the literal command, token included. Before you copy the file to another machine or hand it to a teammate, audit settings.local.json for leaked secrets, then pull out any allow entry you cannot explain.
Environment Variables
Variable
Purpose
ANTHROPIC_MODEL
Force the session model (e.g., opus); wins over a saved /model pick
ANTHROPIC_DEFAULT_MODEL
Model new sessions start on when no flag, ANTHROPIC_MODEL, or saved model setting picks one
ANTHROPIC_API_KEY
API key for direct API access
CLAUDE_CODE_EFFORT_LEVEL
Default effort (low/medium/high/xhigh/max)
CLAUDE_CODE_DISABLE_AUTO_MEMORY
Set to 1 to disable auto-memory
CLAUDE_CODE_DISABLE_1M_CONTEXT
Set to 1 to disable 1M token context
MAX_THINKING_TOKENS
Custom thinking budget (default varies)
HTTPS_PROXY
HTTP proxy for corporate networks
CLAUDE_CODE_NO_FLICKER
Set to 1 to use the fullscreen TUI renderer (same as tui:"fullscreen"): smooth, flicker-free output with mouse support
ENABLE_TOOL_SEARCH
Controls MCP tool search. Unset or true defers MCP tools, including behind an ANTHROPIC_BASE_URL gateway since 2.1.304; auto turns it on once tool definitions reach 10% of context (auto:N sets another threshold), and false loads every tool upfront
CLAUDE_CODE_SUBAGENT_MODEL
Default model for subagents, teammates, and workflow agents. A model named at spawn time or in the agent file wins; add CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 to force it everywhere
CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION
Cap on WebSearch tool calls per session (default 200)
CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS
How long an MCP call runs before moving to the background (default 2 minutes)
CLAUDE_CODE_DISABLE_AGENT_VIEW
Set to 1 to turn off background agents
CLAUDE_CODE_DISABLE_WORKFLOWS
Set to 1 to turn off dynamic workflows
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS
Set to 1 to disable background bash tasks
CLAUDE_CODE_TASK_LIST_ID
Share a task list across sessions via a named directory in ~/.claude/tasks/
DISABLE_AUTOUPDATER
Set to 1 to disable automatic updates entirely
ANTHROPIC_DEFAULT_FABLE_MODEL
Pin which model the fable alias resolves to
CLAUDE_CODE_AUTO_COMPACT_WINDOW
Token threshold to auto-compact before the window fills, from 100k to 1M: a plain integer or, since 2.1.304, a suffixed value such as 200k or 1M. Out-of-range values are clamped with a warning
CLAUDE_CODE_RETRY_WATCHDOG
Set to 1 for CI or unattended runs: retries 429 and 529 capacity errors indefinitely (backing off up to 5 minutes) instead of failing after CLAUDE_CODE_MAX_RETRIES. A 429 that reports a spend limit or exhausted credits still fails at once
CLAUDE_CODE_RESTRICTED
Set to 1 to start in restricted mode, same as --restricted
CLAUDE_CODE_SAFE_MODE
Set to 1 to start with every customization disabled, same as --safe-mode
CLAUDE_CODE_AUTO_MODE_SERVER
Set to 0 to keep auto mode’s classifier local instead of the server-side reviewer
CLAUDE_CODE_AUTO_MODE_MODEL
Model ID for auto mode’s classifier requests
CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS
Context size where idle compaction applies (default 200000)
CLAUDE_CODE_DISABLE_WEB_FETCH
Set to 1 to turn off WebFetch while keeping WebSearch
CLAUDE_CODE_DISABLE_FILE_MENTIONS
Set to 1 so @ mentions pass paths instead of expanding file contents
Two variables without their own row in the table decide where requests go and how they authenticate. ANTHROPIC_BASE_URL points Claude Code at an LLM gateway instead of the Anthropic API, and ANTHROPIC_AUTH_TOKEN carries the gateway credential as a Bearer header. Pair them with ANTHROPIC_MODEL and you can run Claude Code on free-tier models behind a self-hosted FreeLLMAPI proxy. Anthropic does not support routing Claude Code to non-Claude models through a gateway, so treat that setup as a cost-saving experiment rather than your daily driver.
The CLAUDE_CODE_NO_FLICKER variable is worth calling out. By default, the terminal renderer redraws the entire output with each token, causing visible flashing in code blocks and tables. With CLAUDE_CODE_NO_FLICKER=1, output streams line-by-line without screen jumps, syntax highlighting stays stable, and table columns stay aligned while populating. It also enables mouse event support (clicking and scrolling). Add it to your shell profile for a noticeably smoother experience:
Or use it in an alias that bundles your preferred defaults:
alias c="CLAUDE_CODE_NO_FLICKER=1 claude --effort max"
This is the same renderer you can turn on permanently with "tui":"fullscreen" in settings. The fullscreen view also unlocks transcript-viewer shortcuts: press ? for the full shortcut panel and { / } to jump between prompts.
File Structure Reference
Claude Code reads configuration from two scopes: your home directory for personal defaults and the project root for repo-specific rules. The tree below maps the files you’ll touch most:
# User-level (personal, all projects)
~/.claude.json # User-scoped MCP servers, app state
~/.claude/
settings.json # Global settings
keybindings.json # Custom keyboard shortcuts
CLAUDE.md # Personal instructions
rules/ # Personal rules
agents/ # Personal subagents
skills/ # Personal skills
# Project-level (shared with team)
.claude/
settings.json # Project settings (git tracked)
settings.local.json # Local overrides (gitignored)
CLAUDE.md # Project instructions
rules/ # Path-specific rules
agents/ # Project subagents
skills/ # Project skills
.mcp.json # Project MCP servers
CLAUDE.md # Project instructions (alternative location)
AGENTS.md # Read when no CLAUDE.md exists
Everything in the project half is meant for git except .claude/settings.local.json, which holds your personal overrides and should stay out of the repo.
Practical Workflow Tips
Start Every Project Right
The two-minute ritual that makes every subsequent session faster: seed a CLAUDE.md at the project root so Claude knows your conventions without being told each time:
# In your project root
claude
/init
This scans your project and generates a CLAUDE.md with build commands, test instructions, and code conventions. Review and edit it, because this file shapes every future interaction.
Plan Before You Build
Press Shift+Tab to enter plan mode before asking Claude to make changes. In plan mode, Claude reads and analyzes but cannot edit anything. Once you approve the plan, switch back to default mode and say “implement the plan”.
Undo Mistakes Instantly
Press Esc+Esc to open the rewind menu. Choose “Restore code and conversation” to undo both the code changes and the conversation that led to them. This is faster than git stash for quick experiments.
Pipe Everything
Claude Code is a normal Unix citizen on stdin/stdout. Anything you can pipe into grep, you can pipe into claude-p:
# Analyze logs
tail -500/var/log/app.log| claude -p"find the root cause of errors"# Review a PR
gh prdiff42| claude -p"security review this PR"# Generate commit message
git diff--staged| claude -p"write a conventional commit message"--modelhaiku# Translate
cat README.md| claude -p"translate to Japanese">README.ja.md# Docker container analysis
docker ps--formatjson| claude -p"which containers are using the most resources?"# Kubernetes pod debugging
kubectl logsdeployment/api--tail=200| claude -p"why are requests failing?"# Database structure review
pg_dump --schema-onlymydb| claude -p"suggest index improvements"# Summarize recent commits
git log--oneline-20| claude -p"write release notes from these commits"# Find config issues
cat /etc/nginx/nginx.conf| claude -p"check for misconfigurations"
For deeper walkthroughs of Docker and Kubernetes workflows with Claude Code, see the Docker guide and Kubernetes guide.
Automation Scripts
Chain multiple claude-p calls in a bash script for repeatable workflows:
#!/bin/bash# Automated PR review pipeline
git diffHEAD~1>/tmp/diff.txt
cat /tmp/diff.txt| claude -p"review for security issues"--modelsonnet>security_review.md
cat /tmp/diff.txt| claude -p"check for performance regressions"--modelsonnet>perf_review.md
cat /tmp/diff.txt| claude -p"write a one-paragraph summary"--modelhaiku>summary.md
Batch process multiple files:
#!/bin/bash# Generate docstrings for all Python files missing them
for f in$(grep -rL'"""'src/*.py);do
claude -p"add docstrings to functions missing them in $f"\--allowedTools"Read,Edit"--max-turns3done
Generate a changelog from git tags:
git logv1.0.0..v2.0.0--oneline|\
claude -p"create a changelog grouped by feature, fix, and chore"\--output-formattext>CHANGELOG.md
Text is already the default output format for -p, so the flag is there for whoever reads the script next: it makes plain that CHANGELOG.md gets prose, not JSON.
Side Questions with /btw
Need to ask something without derailing the current task? Use /btw:
/btw what was the name of that config file we edited earlier?
The response is ephemeral (not saved to context), low-cost (uses cache), and does not use any tools.
Cost Control
Use /cost to check spend at any time; it now shows the prompt-cache hit ratio and a likely cause for each cache miss
Use Sonnet for most work, Opus only for complex problems
Use /effortlow for simple tasks
Run /compact to reduce context size (fewer tokens per request)
Be specific in prompts, because vague requests cause more back-and-forth
Use --max-budget-usd5.00 in CI/CD to prevent runaway costs
Prompting Tips – Get Better Results
The quality of Claude Code’s output depends heavily on how you prompt it. These patterns consistently produce better results.
Be Specific, Not Vague
Bad Prompt
Good Prompt
“fix the bug”
“the login endpoint returns 500 when email contains a plus sign; fix the input validation in src/auth/login.ts”
“make it faster”
“the /api/users endpoint takes 3s on 10k rows; add database indexing and pagination”
“write tests”
“write unit tests for the calculateDiscount function in src/pricing.ts covering edge cases: zero price, negative quantity, expired coupon”
“clean up the code”
“extract the duplicate validation logic in src/api/orders.ts and src/api/returns.ts into a shared validator”
Use Plan Mode First
For complex tasks, switch to plan mode (Shift+Tab) and ask Claude to explore before coding:
# In plan mode:
"I need to add OAuth2 login with Google. Look at the existing auth flow
in src/auth/ and propose where to add the Google provider without
breaking the current email/password login."
Review the plan, then switch back to default mode and say “implement the plan”.
Give Verification Targets
Tell Claude how to verify its own work:
"Add rate limiting to the /api/auth endpoints. After implementing,
run npm test to make sure nothing breaks, and verify the rate limiter
works by checking the middleware is registered in the Express app."
Naming the check gives Claude a pass or fail signal to work toward, so it does not stop the moment the code compiles.
Use @file Mentions for Context
Point Claude at specific files instead of making it search:
"look at @src/db/schema.ts and @src/api/users.ts - the User model
has a new 'role' field in the schema but the API doesn't expose it.
Add the role field to the GET /users/:id response."
Each @ mention pulls that file straight into context, which saves the search turns and the tokens they would cost.
Course-Correct Early
If you see Claude going in the wrong direction, press Ctrl+C to stop and redirect. Do not wait for it to finish a large wrong change. Interrupt and clarify. If it already made bad changes, press Esc+Esc to rewind.
Break Large Tasks Into Steps
Instead of “build a user management system”, split it:
“Create the User database schema with id, email, name, role, created_at”
“Add CRUD API endpoints for users with input validation”
“Write tests for the user endpoints”
“Add role-based access control middleware”
Each step gets verified before moving to the next. This avoids wasting tokens on a bad foundation.
Token Saving Strategies
Every message sent to Claude includes the full conversation context. Larger context means higher cost and slower responses. These strategies keep your sessions efficient.
Context Hygiene
Strategy
How
Savings
Clear between tasks
/clear when switching to unrelated work
Biggest impact: resets to zero
Compact proactively
/compactFocusontheauthmodulechanges
Keeps relevant context, drops noise
Check context usage
/context to see what is consuming space
Identifies bloat sources
Use @file mentions
@src/auth.ts instead of “find the auth file”
Avoids exploratory file reads
Use subagents
Delegate verbose tasks (test runs, log analysis)
Output stays in subagent context
Model Selection
Task
Model
Effort
Simple edits, renames, formatting
Sonnet
/effortlow
Standard coding, tests, refactoring
Sonnet
/effortmedium
Complex debugging, architecture
Opus
/efforthigh
Quick questions
Haiku (via /btw)
N/A
CLAUDE.md Optimization
Keep the main CLAUDE.md under 200 lines, since it loads on every message
Move detailed instructions into skills, which only load when invoked
Use @file imports for large reference docs instead of pasting content
Put path-specific rules in .claude/rules/, which only load when Claude touches matching files
MCP and Tool Optimization
Disable unused MCP servers with /mcp, since each server adds tool definitions to context
Use CLI tools (gh, aws, gcloud) instead of MCP when a single command works
Leave MCP tool search on (the default): tool definitions load on demand instead of all at once. Run /skill-doctor and claudeplugindetails<name> to find skills and plugins that cost context without earning it
CI/CD Budget Controls
Any Claude Code invocation in CI should have a dollar cap and a fallback model, which matters more now that the top tier, Claude Fable 5.2, costs $8/$40 per million tokens and $16/$80 with fast mode on. Skip these and one bad prompt can drain your monthly budget in a single failing pipeline:
# Hard spending limit
claude -p"fix failing tests"--max-budget-usd2.00# Limit agentic turns
claude -p"review this file"--max-turns3# Use cheapest model for simple CI tasks
claude -p"check for linting errors"--modelhaiku
--max-turns exits with an error at the limit, so a CI job stuck in a loop fails fast. --max-budget-usd checks a client-side cost estimate and spend can pass it slightly, so leave headroom.
Diagnostics – /doctor and /insights
Three tools for seeing exactly what Claude Code is doing during a session:
–debug – Verbose Logging
When you need to see exactly what Claude Code is doing (API calls, tool invocations, timing), use --debug:
# Full debug output to stderr
claude --debug# Filter to specific categories
claude --debug"api,hooks"# Write debug logs to a file (keeps terminal clean)
claude --debug-file/tmp/claude-debug.log
This is especially useful when MCP servers are not connecting, hooks are not firing, or API calls are failing silently.
/doctor and /checkup – Full Setup Checkup
Run /doctor, or its alias /checkup, when something is not working right or when you want to tidy up your setup. It is no longer a read-only report. It runs a full checkup, and where it finds problems you press f to have Claude fix them. It confirms with you before changing anything. The checkup covers:
Claude Code version and auto-updater status, and updating to the latest release
Authentication state, token validity, and API connectivity
Settings file syntax and conflicts
MCP server health, plus removing unused skills, MCP servers, and plugins to save context
De-duplicating your personal CLAUDE.md against the project one, and splitting an overgrown root CLAUDE.md into nested files and skills
Turning off slow hooks, enabling auto mode, and pre-approving frequently denied read-only commands
/insights – Session Analysis
Run /insights after a long session to get an analysis report covering:
Token usage breakdown by category
Most expensive operations in the session
Patterns in how you use Claude Code
Suggestions for improving efficiency
Time spent waiting vs. actively working
Use this to identify habits that waste tokens and adjust your workflow.
IDE Integrations
Claude Code integrates with VS Code and JetBrains IDEs for inline diffs, context sharing, and side-by-side conversations. Wondering how it stacks up against other AI coding tools? See the OpenCode vs Claude Code vs Cursor comparison.
VS Code
Install the “Claude Code” extension from the VS Code marketplace
Open Command Palette (Cmd+Shift+P on Mac / Ctrl+Shift+P on Linux/Windows) and search “Claude Code”
Works with Cursor editor too
JetBrains (IntelliJ, PyCharm, WebStorm, etc.)
Install “Claude Code” from the JetBrains Marketplace
Works across all JetBrains IDEs
Supports interactive diffs and context sharing
Start Claude with IDE auto-detection:
claude --ide
With --ide, Claude Code connects on startup when exactly one supported IDE is running; with several open, pick one from /ide instead.
Auto Mode
Auto mode uses an AI classifier to decide whether each tool call needs your approval. Instead of prompting on every command, it allows safe operations (reads, git status, test runs) and blocks risky ones (force push, rm -rf, production deploys) automatically. Enable it with --permission-modeauto or press Shift+Tab to cycle to it.
Inspect the classifier rules with the claudeauto-mode subcommand:
# View current auto-mode config
claude auto-modeconfig# View default allow/deny rules
claude auto-modedefaults# Get AI feedback on your custom rules
claude auto-modecritique
Customize rules in .claude/settings.json or ~/.claude/settings.json under the autoMode key with allow, soft_deny, and environment arrays. The classifier reads these plus the defaults to make per-tool-call decisions. The same rules are editable in the Auto mode tab of /permissions, and /insights now estimates how many of your recent permission prompts auto mode would have handled.
/loop – Recurring Tasks
The /loop slash command runs a prompt or another slash command on a repeating interval within your session. Useful for polling deploy status, watching test results, or checking a service health endpoint.
# Check deploy status every 5 minutes
/loop 5m check if the deploy on staging is complete
# No interval: Claude picks the pace between iterations
/loop /test
# Custom interval with a slash command
/loop 2m /security-review
The loop runs in the background until you stop it or end the session. Each iteration gets its own context, so long-running loops do not bloat the conversation.
Subcommands Reference
Claude Code provides subcommands for management tasks outside of interactive sessions:
Subcommand
What It Does
claudeagents
Open the agent view to monitor and dispatch parallel background sessions (--json for scripting)
claudeattach<id>
Attach a background session to this terminal
claudelogs<id>
Print recent output from a background session
claudestop<id>
Stop a background session (also claudekill)
clauderespawn<id>
Restart a background session with its conversation intact
clauderm<id>
Remove a background session from the list (transcript stays on disk)
claudedaemonstatus
Show the background-session supervisor state and worker count
claudeauth
Manage authentication (login, logout, status)
claudeauto-modeconfig
Print effective auto-mode classifier rules
claudeauto-modedefaults
Show default allow/deny rules
claudeauto-modecritique
Get AI feedback on your custom auto-mode rules
claudeauto-modereset
Restore the default auto-mode configuration (add --yes to skip the confirmation)
claudedoctor
Health check for auto-updater, auth, MCP, settings
claudeimport[codex|gemini|cursor]
Import instruction files, MCP servers, commands, subagents, and skills from another agent (--dry-run first)
claudeinstall[target]
Install a specific version (stable, latest, or a version number)
If you would rather learn the workflow from a book than from release notes, Build with Claude Code (paid link) by Taeho Jo (Packt, August 2026, 408 pages) walks from a first session to deployed apps and is the most hands-on of the seven titles in our AI coding books round-up. Books lag the CLI by a few releases, so keep this page open next to it for the current flags and shortcuts.
Claude Code Alternatives for Other Models
Claude Code only talks to Anthropic models, directly or through Bedrock, Vertex, and Foundry. When a project needs a local model or a different provider, OpenCode covers more than 75 providers, Aider keeps every change as a git commit, and Claw Code is an open-source rewrite in Rust. For an open-source agent that runs on any OpenAI-compatible endpoint, including local Ollama, see the Hermes Agent cheat sheet. If your team already pays for GitHub Copilot, its terminal agent runs Claude or GPT models (pick one with --model at launch or /model mid-session) and still loads your CLAUDE.md, and the GitHub Copilot CLI cheat sheet covers its commands, permission flags, and MCP setup. Moving the other way is easier now: claudeimportcodex (or gemini, cursor) brings instruction files, MCP servers, and skills across, and --dry-run shows the plan before anything is written. The official Claude Code docs remain the reference for anything that changed after October 2026.
Founder of Computingforgeeks. Senior Systems Engineer with over a decade of hands-on experience building and managing production infrastructure. Core expertise in Linux/UNIX administration, cloud platforms (AWS, GCP, Azure), and Kubernetes ecosystems (EKS, GKE, OpenShift). Deep experience with virtualization (KVM, Proxmox, OpenStack), infrastructure as code (Terraform, Terragrunt, Ansible, Crossplane), GitOps workflows (ArgoCD, FluxCD), Nix/NixOS, and container orchestration at scale. Currently focused on integrating AI and LLMs into DevOps and platform engineering workflows. Every guide on this site is tested on real systems before publishing.
You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.