Claude Code is an agentic CLI. You speak in natural language; it reads files, runs commands, edits code, and ships work. Everything else is configuration around that loop.
The agentic loop runs in three blended phases โ gather context, take action, verify results โ and uses built-in tools (Read, Edit, Write, Bash, Grep, Glob, WebFetch, Task) to touch your project. Each tool call feeds the next decision. You extend this loop by adding knowledge, connections, or constraints โ without ever changing the loop itself.
| CLAUDE.md | Project memory. Auto-loaded at session start. |
| Skills | Model-invoked capabilities. Claude picks them. |
| Slash commands | User-invoked prompts. You type /name. |
| Subagents | Isolated contexts for specialized tasks. |
| MCP servers | External tools (GitHub, Sentry, DBs, APIs). |
Every extension costs some context window. Skills load descriptions upfront and bodies on demand. Subagents cost zero main-context tokens because they run in isolation. Hooks cost nothing unless they return output. Choose accordingly โ see context costs per feature.
| Interactive | TUI conversation. claude. |
| Headless | One-shot or piped. claude -p "โฆ". |
| Remote | Claude Code on Web / mobile Remote Control. |
/etc/claude-code/managed-settings.json โ enterprise policy.claude/settings.local.json โ personal, git-ignored.claude/settings.json โ project, checked in~/.claude/settings.json โ user defaultsLater layers never override earlier ones. A deny rule in project settings can't be loosened by a personal override.
Four supported installers. The native script is the only one that auto-updates in the background; Homebrew and winget need manual upgrades. The npm path still works but is deprecated โ if you're new, don't start there.
# Official install script
curl -fsSL https://claude.ai/install.sh | bash
# Homebrew
brew install --cask claude-code
brew upgrade claude-code # manual upgrade
# PowerShell
irm https://claude.ai/install.ps1 | iex
# winget
winget install Anthropic.ClaudeCode
winget upgrade Anthropic.ClaudeCode # manual
VS Code and JetBrains plugins exist โ launch Claude from an IDE gutter, get inline diff proposals, and keep your terminal free. See VS Code and JetBrains docs.
# Start in the current project
cd your-project && claude
# Version / update / health
claude --version
claude update
claude doctor
# Force reinstall if update misbehaves
claude install --force
# Auth
claude # prompts /login on first run
ANTHROPIC_AUTH_TOKEN or the provider's credentials before launch.
claude doctor after any config change โ it flags unreachable permission rules, duplicate MCP servers, missing LSP binaries, and broken hooks.
Every flag is also available via config file or an env var. The CLI is the canonical source โ the full CLI reference lists everything including less-used diagnostic flags.
| -c, --continue | Resume most recent session in this dir |
| -r, --resume <id> | Resume a specific session id or /rename name |
| --fork-session | Branch from a resumed session, preserving the original |
| --from-pr <#> | Resume session linked to a PR |
| -w, --worktree <name> | Run in a named git worktree |
| --teleport | Move current session to another cwd |
| --rename / --name | Set human-readable session name |
| --add-dir <path> | Grant access to another directory |
| --model <id> | Override session model (alias or full name) |
| --effort <level> | low ยท medium ยท high |
| --append-system-prompt | Add to default system prompt (safe) |
| --system-prompt[-file] | Replace default system prompt (strict) |
| --agents '<json>' | Define subagents inline via JSON |
| --mcp-config <file> | Load MCP servers from a specific JSON file |
| --plugin-dir <path> | Load a local plugin for this session (dev mode) |
| -p, --print "q" | Non-interactive. Print result, exit. |
| --output-format | text ยท json ยท stream-json |
| --max-turns <n> | Cap agentic turns |
| --allowedTools "โฆ" | Whitelist tools (comma-sep) |
| --disallowedTools "โฆ" | Deny specific tools |
| --disable-slash-commands | Kill all /cmd |
| --permission-mode <m> | Launch in plan / acceptEdits / bypassPermissions |
| --setting-sources | Limit which settings files load |
| --verbose / --debug | Debug logging + MCP handshake logs |
| --exclude-dynamic- system-prompt-sections | Better cross-user prompt caching in print mode |
| --setting-sources | Restrict loaded settings to specific sources |
--append-system-prompt. --system-prompt strips Claude Code's defaults (tool-use framing, safety rails) โ only use it when you need full control.
--continue + --fork-session lets you explore a risky path without destroying the original transcript. Great for "try rewriting this with X, but let me go back if it breaks."
Memorize Esc, Esc Esc, Shift+Tab, Ctrl+B, and Alt/Option+P before anything else. Full list in the interactive mode reference.
| ! | Bash mode prefix (single command) |
| @ | File / folder mention autocomplete |
| \+Enter | Newline in prompt (backslash + Enter) |
| Alt+Enter | Newline (most terminals) |
| Shift+Enter | Newline (run /terminal-setup first) |
| Tab | Accept suggestion / add supplementary context |
| Ctrl+V | Paste image |
| Ctrl+G | Edit prompt in external editor ($EDITOR) |
| Ctrl+U | Clear entire input buffer |
| Esc | Interrupt Claude |
| Esc Esc | Open rewind menu |
| โ after interrupt | Restore + rewind in one step |
| Shift+Tab | Cycle: normal โ auto-accept โ plan |
| Ctrl+B | Send task to background |
| Ctrl+X Ctrl+K | Stop all background agents |
| Alt/Option+P | Switch models mid-prompt |
| Ctrl+R | Full output / context pane |
| Ctrl+O | Verbose transcript toggle |
| Ctrl+T | Toggle task list (when active) |
"terminal.integrated.macOptionIsMeta": true.
Type / to open the menu; continue typing to filter. Unknown commands suggest the closest match. Full catalog in the commands reference.
| /init | Generate CLAUDE.md by scanning the repo. Run first in any new project. |
| /clear | Wipe conversation history (files on disk remain). Use when switching tasks. |
| /compact [focus] | Compress context while keeping a focus area. Use above ~80% context. |
| /rewind ยท /undo | Restore to a prior checkpoint โ conversation, code, or both. |
| /context | Grouped view of skills, agents, rules, and context usage by category. |
| /stats ยท /cost | Token usage ยท spend breakdown for the current session. |
| /usage | Plan usage and rate-limit status. |
| /model [alias] | Switch model. Warns before switching mid-conversation (re-reads history uncached). |
| /effort [level] | Adaptive reasoning tuner: low / medium / high. |
| /btw | Ask a side question without polluting main conversation context. |
| /help | List everything, filtered as you type. |
| /review | Code review of recent changes. |
| /security-review | Automated security audit of the diff. |
| /pr_comments | Read / respond to PR review comments. |
| /team-onboarding | Generate an onboarding guide for new contributors based on the project structure and CLAUDE.md. 2.1.101 |
| /add-dir [--remember] | Grant Claude access to an extra directory. --remember persists to settings. |
| /memory | Edit CLAUDE.md memory files inline. |
| /rename | Give the session a descriptive name (e.g. oauth-migration). |
| /sandbox | Enable sandboxed Bash tool with filesystem + network isolation. |
| /agents | Manage subagents (project + user scope). Tabbed UI for Running / Library. |
| /skills | List installed skills. Sort by token cost with t in newer versions. |
| /plugin | Plugin manager UI. install ยท enable ยท disable ยท uninstall. |
| /reload-plugins | Pick up plugin changes without restarting. |
| /mcp | MCP server list + OAuth actions. |
| /hooks | Configure event hooks. |
| /permissions | Inspect / edit permission rules. |
| /chrome | Drive Chrome via the Claude in Chrome extension. BETA |
| /config | Settings editor (replaces /output-style). |
| /theme | Colors + syntax highlighting. Toggle highlight with Ctrl+T. |
| /statusline | Customize terminal status line. |
| /terminal-setup | Install Shift+Enter binding (iTerm2, VS Code, Kitty, Alacritty, Zed, Warp). |
| /keybindings | Edit ~/.claude/keybindings.json. |
| /vim | Vim-style modal editing in the prompt. |
| /tasks | Background task manager. |
| /login ยท /logout | Anthropic account auth. |
| /bug ยท /feedback | Report issues to Anthropic. |
| /doctor | Diagnostics: unreachable permission rules, duplicate MCP configs, missing deps. |
/revieww โ "did you mean /review?"). MCP-exposed prompts appear as /mcp__<server>__<prompt>.
Toggle with Shift+Tab. The current mode shows under the prompt. Permission rules layer on top โ see the IAM & permissions docs.
| normal | Default. Asks before write/edit/bash and sensitive reads. |
| acceptEdits | "YOLO-lite". Accepts file edits automatically. Still asks for risky Bash. |
| plan | Read-only brainstorming. Produces a plan file, no writes. End plan to execute. |
| bypassPermissions | Accepts everything. Only use in sandboxed / throwaway envs. Can be disabled via disableBypassPermissionsMode. |
Permission rules evaluate deny โ ask โ allow. First match wins. Use Tool alone or Tool(specifier) โ for example, Bash(git push:*) or Read(./.env*). MCP server rules use the server name: mcp__github (whole server) or an exact tool like mcp__github__get_issue. Wildcards on tool names don't exist.
PreToolUse hooks returning updatedInput are re-checked against permissions.deny rules. Deny always wins over hook-granted permissions โ a hook cannot downgrade a deny into an ask.
Claude Code resolves aliases per-provider. On the Anthropic API, opus โ Opus 4.7 and sonnet โ Sonnet 4.6. On Bedrock / Vertex / Foundry, opus โ Opus 4.6 and sonnet โ Sonnet 4.5 (newer models available by explicit name or pinning env var). Always pin versions in production.
| Alias | Anthropic API | Bedrock / Vertex / Foundry | Use for |
|---|---|---|---|
| opus | claude-opus-4-7 | claude-opus-4-6 | Architecture, complex reasoning, gnarly debugging |
| sonnet | claude-sonnet-4-6 | claude-sonnet-4-5 | Daily driver. 90 %+ of coding work. |
| haiku | claude-haiku-4-5 | claude-haiku-4-5 | Mechanical edits, routing, high-volume tasks |
| opusplan | hybrid | Opus for planning, Sonnet for execution | |
ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU}_MODEL.
# Launch with a specific model
claude --model claude-sonnet-4-6
claude --model claude-opus-4-7
# Mid-session
/model sonnet
/model opus
/model opusplan
# While typing a prompt
Alt+P # or Option+P on macOS
| low | Fast, cheap. Good for mechanical edits, routing, high-volume tasks. |
| medium | Default for most tasks. Balanced reasoning and speed. |
| high | Deep chain-of-thought. Use for thorny problems and architecture decisions. |
/clear or /compact).
Loaded automatically at session start. One per project root, plus a user-global file at ~/.claude/CLAUDE.md. Edit inline via /memory. The first 200 lines or 25 KB โ whichever comes first โ are loaded into every session's context.
@path/to/doc.md to import).env + deny rules instead# BrandName โ project management SaaS
Stack: Next.js 15 ยท TypeScript ยท Drizzle + Postgres ยท Tailwind.
Package manager: pnpm. Node 20.
## Commands
- Dev: pnpm dev
- Test: pnpm test (Vitest, watch by default)
- Lint: pnpm lint --fix
## Conventions
- Commit style: Conventional Commits.
- Server components by default; mark client with "use client".
- Never edit db/migrations/** โ generate via pnpm db:generate.
## Refs
@docs/architecture.md
@docs/api-contract.md
CLAUDE.md under 200 lines. If it's growing, move reference content to skills or split into .claude/rules/ files with paths frontmatter that only load when Claude touches matching files.
Skills and commands have converged. .claude/commands/ still works; .claude/skills/ is the recommended home โ it supports auto-invocation, supporting files, subagent execution, and the Agent Skills open standard.
| Dimension | Slash command | Skill |
|---|---|---|
| Invocation | User types /name | Model picks it OR user types /name |
| Location | .claude/commands/*.md | .claude/skills/<name>/SKILL.md |
| Structure | Single file | Directory + templates, scripts, refs |
| Best for | Quick repeat prompts | Reusable capabilities shared with team |
// .claude/commands/commit.md
---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
argument-hint: [message]
description: Create a conventional commit
model: claude-haiku-4-5
---
## Context
- Status: !`git status`
- Diff: !`git diff HEAD`
- Branch: !`git branch --show-current`
- Recent: !`git log --oneline -10`
## Task
Create a single Conventional Commits commit.
Message hint from user: $ARGUMENTS
// .claude/skills/api-conventions/SKILL.md
---
name: api-conventions
description: API design rules for this codebase. Use when writing
or reviewing any route under app/api or services/*.
allowed-tools: Read, Grep, Glob
---
# API conventions
- REST nouns; no verbs in paths.
- Validate inputs with Zod at the route boundary.
- Errors: return { error: { code, message } }, HTTP code matches.
- Server components fetch via typed client in lib/api/.
$ARGUMENTS โ all args as one string$1, $2, $3 โ positional!`cmd` โ run shell command, inject output@path/to/file โ inline file contents| allowed-tools | Restrict to a tool subset |
| model | Override model for this invocation |
| disable-model-invocation | true = user-only |
| context: fork | Run in a forked context |
| agent | Run under a named subagent |
| argument-hint | Shows in command picker |
SLASH_COMMAND_TOOL_CHAR_BUDGET.
Subagents run in an isolated context window with a custom system prompt and a whitelisted toolset. Use them when a task would pollute the main conversation, or when you want a proactive expert that jumps in automatically. They return a summary, not a full transcript โ zero main-context cost.
// .claude/agents/code-reviewer.md
---
name: code-reviewer
description: Proactively reviews code for quality, security,
maintainability. MUST BE USED immediately after writing or modifying code.
tools: Read, Grep, Glob, Bash
model: inherit
---
You are a senior reviewer. When invoked:
1. Run git diff to see recent changes.
2. Check for: readability, naming, duplication, error handling,
exposed secrets, input validation, test coverage, performance.
3. Output feedback by priority: Critical ยท Warnings ยท Suggestions.
4. For each, provide a concrete fix.
description. Claude invokes automatically.claude --agents '{...}' for one-off definitions.| .claude/agents/ | Project subagents (highest priority) |
| ~/.claude/agents/ | Personal subagents |
| tools / disallowedTools | Tool allowlist / denylist |
| model / effort | Override per-agent |
| background | Run concurrently vs. blocking |
| isolation: worktree | Run inside a fresh git worktree |
| memory | Persistent agent-scoped dir |
Edit or Write is safer and stays in its lane.
Hooks fall into three cadences: once per session (SessionStart, SessionEnd), once per turn (UserPromptSubmit, Stop, StopFailure), every tool call (PreToolUse, PostToolUse). They can be shell commands, HTTP endpoints, or prompts. See the full event schema reference.
| Event | Fires when |
|---|---|
| SessionStart | Claude Code starts or resumes |
| UserPromptSubmit | You submit a prompt, before Claude sees it. Stdout adds to context. |
| PreToolUse | Before a tool call. Can block (exit 2) or mutate input. |
| PostToolUse | After a tool call completes |
| PreCompact | Before /compact. Can block with exit 2. |
| SubagentStop | Subagent finished. Gets $AGENT_ID + transcript path. |
| Stop | Claude finishes responding |
| SessionEnd | Session closes |
| Notification | Claude fires a notification |
| Setup | Repo setup / maintenance ops |
// .claude/settings.json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{ "type": "command",
"command": "npx prettier --write \"$FILE_PATH\"" }
]
}
],
"Stop": [
{
"hooks": [
{ "type": "command",
"command": "echo \"$(date): $CONVERSATION_SUMMARY\" >> ~/.claude/activity.log" }
]
}
]
}
}
| 0 | Success, continue |
| 2 | Block tool call, send stderr back to Claude |
| other | Error, surfaces in --debug |
$FILE_PATH โ affected file$CLAUDE_PROJECT_DIR โ project root$CLAUDE_SESSION_ID โ current session$CONVERSATION_SUMMARY โ Stop only$AGENT_ID โ SubagentStop onlyModel Context Protocol servers expose tools, resources, and prompts. HTTP transport is preferred over stdio โ it's cross-client compatible and easier to manage. See the MCP setup guide.
| claude mcp add <name> <cmd> | Add stdio server with command |
| claude mcp add --transport http <name> <url> | Add HTTP-transport server |
| claude mcp add --transport sse <name> <url> | Add SSE-transport server |
| claude mcp list | Show installed servers |
| claude mcp get <name> | Details on one server |
| claude mcp remove <name> | Uninstall |
| /mcp enable|disable <name> | Toggle in-session |
When MCP tool descriptions would consume more than 10 % of context, Claude Code loads them dynamically instead of preloading. Set ENABLE_TOOL_SEARCH=true to force it on. Expect ~85 % token reduction on heavy setups and better tool-selection accuracy on Opus.
https://mcp.context7.com/mcp, with the API key in env.CONTEXT7_API_KEY using the ctx7sk_ prefix. Full quit-and-relaunch of Claude Desktop is required after config changes.
| GitHub | claude mcp add --transport http github https://api.githubcopilot.com/mcp/ |
| Linear | claude mcp add --transport http linear https://mcp.linear.app/mcp |
| Notion | claude mcp add --transport http notion https://mcp.notion.com/mcp |
| Sentry | claude mcp add --transport http sentry https://mcp.sentry.dev/mcp |
| Vercel | claude mcp add --transport http vercel https://mcp.vercel.com/ |
| Supabase | npx -y @supabase/mcp-server-supabase@latest (stdio, needs SUPABASE_ACCESS_TOKEN) |
| Stripe | claude mcp add --transport http stripe https://mcp.stripe.com |
| Playwright | npx @playwright/mcp@latest (stdio) |
| Figma | claude mcp add --transport http figma https://mcp.figma.com/mcp |
| Cloudflare | claude mcp add --transport http cloudflare https://mcp.cloudflare.com/mcp |
MCP-exposed prompts appear as /mcp__<server>__<prompt>. Example: /mcp__github__list_prs.
// /etc/claude-code/managed-mcp.json (excerpt)
{
"allowedMcpServers": [
{ "serverName": "github" },
{ "serverName": "sentry" }
],
"deniedMcpServers": [
{ "serverName": "filesystem" }
]
}
Denylist takes absolute precedence over allowlist.
A plugin is a self-contained directory โ the unit of sharing for Claude Code extensions. Install scopes: user (personal), project (checked into git, shared with team), local (project-local, gitignored).
| /plugin | Open plugin manager UI |
| /plugin marketplace add <url|path> | Register a marketplace (GitHub org, local dir) |
| /plugin install <name>@<marketplace> | Install |
| /plugin enable|disable|uninstall <name>@<mkt> | Lifecycle |
| /reload-plugins | Pick up plugin changes without restart |
| claude plugin update | Pull latest marketplace versions |
| claude plugin install <n>@<m> --scope project | Install to project (shared with team) |
| claude --plugin-dir <path> | Dev-mode: load a local plugin for the session only |
my-plugin/
โโโ .claude-plugin/
โ โโโ plugin.json # manifest (required)
โโโ skills/ # auto-invokable capabilities
โโโ commands/ # flat .md slash commands
โโโ agents/ # subagents
โโโ hooks/ # hook configs
โโโ monitors/ # background monitors
โโโ .mcp.json # MCP servers
โโโ .lsp.json # LSP servers
โโโ scripts/
plugin.json and any hook scripts before enabling. Policy-managed plugins auto-update correctly regardless of where you first installed them from.
| Ctrl+B | Send current task to background |
Prefix prompt with & | Start backgrounded immediately |
| /tasks | List + manage running tasks |
| Ctrl+X Ctrl+K | Stop all background agents |
| CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 | Disable entirely |
Run parallel sessions on the same repo without git stash dances. Each worktree keeps its own Claude session with full context. Great for "feature branch + urgent hotfix + model comparison" scenarios.
# Parallel feature + hotfix
git worktree add ../app-auth -b feature/auth main
git worktree add ../app-hotfix -b hotfix/crit main
cd ../app-auth && claude # terminal 1
cd ../app-hotfix && claude # terminal 2
# Claude-native shortcut
claude -w feature/auth
claude --worktree hotfix/crit
The status line JSON input includes workspace.git_worktree, set whenever cwd is inside a linked worktree โ handy for custom statuslines. Subagents with isolation: worktree run in a fresh worktree automatically.
Headless mode (-p/--print) is the backbone of every Claude-in-CI story: PR reviews, security audits, nightly dependency reports, log triage. The Agent SDK gives you the same capabilities from TypeScript or Python, with fine-grained control over permissions, hooks, and approvals.
# One-shot
claude -p "summarize the last 10 commits"
# Structured output with metadata (cost, session_id)
claude -p --output-format json "audit this file" > result.json
# Streaming messages for real-time UIs
claude -p --output-format stream-json "long task"
# Pipe in
gh pr diff 123 | claude -p \
--append-system-prompt "You are a security reviewer" \
--output-format json \
--allowedTools "Read,Grep" > audit.json
# Multi-turn via session id
sid=$(claude -p "start analysis" --output-format json | jq -r .session_id)
claude --resume "$sid" -p "now check test coverage"
claude --resume "$sid" -p "summarize findings"
--exclude-dynamic-system-prompt-sections trims out per-user sections from print mode so cross-user prompt caching actually hits. Worth using on any shared CI job where many runs share a static system prompt.
// TypeScript โ @anthropic-ai/claude-agent-sdk
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const msg of query({
prompt: "/code-review",
options: { maxTurns: 3 }
})) {
// msg has type + payload
console.log(msg);
}
TRACEPARENT / TRACESTATE from the environment, so Claude Code runs slot into your existing distributed trace tree. Use with OTEL_LOG_TOOL_DETAILS / OTEL_LOG_TOOL_CONTENT for full observability.
Settings layer from enterprise โ project โ project-local โ user. Full schema in the settings reference. Permission rule syntax is in the IAM reference.
| claude config list | All settings (merged view) |
| claude config get <key> | Read one setting |
| claude config set <key> <value> | Write |
| claude config add / remove <key> <value> | List-valued settings |
// .claude/settings.json
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(pnpm *)",
"Bash(git status)",
"Bash(git diff)",
"Bash(git add *)",
"Bash(git commit *)"
],
"ask": [
"Bash(git push:*)",
"Bash(npm install *)",
"Bash(pnpm add *)"
],
"deny": [
"Read(./.env*)",
"Read(./secrets/**)",
"Read(./**/credentials*)",
"Read(./**/*.key)",
"Read(./**/*.pem)",
"Bash(rm -rf:*)",
"Bash(curl:*)",
"Bash(wget:*)"
]
}
}
# Keep personal settings out of git
.claude/settings.local.json
# Keep policy-managed hooks + plugin locks IN git
# so the team gets the same behavior
mcp__github__* does nothing. Use "mcp__github" (whole server) or an exact tool name like "mcp__github__get_issue".
claude doctor warns about unreachable permission rules (e.g. a deny shadowed by an earlier allow). Run it after editing settings.
Any env var can also be set under env in settings.json to apply it to every session. Full list in the environment variables reference.
| Variable | Effect |
|---|---|
| ANTHROPIC_MODEL | Default model for new sessions |
| ANTHROPIC_DEFAULT_OPUS_MODEL | Pin Opus alias to a specific version (prod) |
| ANTHROPIC_DEFAULT_SONNET_MODEL | Pin Sonnet alias |
| ANTHROPIC_DEFAULT_HAIKU_MODEL | Pin Haiku alias |
| ANTHROPIC_AUTH_TOKEN | Custom auth header (proxies) |
| ANTHROPIC_CUSTOM_HEADERS | Extra HTTP headers |
| API_TIMEOUT_MS | Per-request API timeout |
| ENABLE_LSP_TOOL=1 | Turn on Language Server Protocol integration |
| ENABLE_TOOL_SEARCH=true | Force dynamic MCP tool loading |
| SLASH_COMMAND_TOOL_CHAR_BUDGET | Raise the skill-description budget |
| CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 | Disable background agents |
| CLAUDE_CODE_PERFORCE_MODE 2.1.98 | Fail on read-only edits with a p4 edit hint instead of overwriting |
| CLAUDE_CODE_SUBPROCESS_ENV_SCRUB 2.1.98 | Scrub subprocess env + enable PID namespace isolation (Linux) |
| CLAUDE_CODE_SCRIPT_CAPS 2.1.98 | Cap per-session script invocations |
| CLAUDE_CODE_CERT_STORE | bundled to use bundled CA store instead of OS trust store |
| CLAUDE_ENV_FILE | Extra env file to source (e.g. ~/.zprofile) |
| CLAUDE_CODE_TMPDIR | Override temp dir |
| CLAUDE_CODE_GIT_BASH_PATH | Windows: path to git-bash |
| CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1 | Disable cd carry-over across Bash calls |
| ENABLE_PROMPT_CACHING_1H | Opt into 1-hour prompt cache TTL |
| FORCE_PROMPT_CACHING_5M | Force 5-minute TTL |
| DISABLE_TELEMETRY | Disable usage telemetry |
| DISABLE_PROMPT_CACHING | Kill prompt caching (warns at startup) |
| OTEL_LOG_USER_PROMPTS | Opt-in: include user prompts in OTEL spans |
| OTEL_LOG_TOOL_DETAILS / _CONTENT | Opt-in: tool-call detail in traces |
| TRACEPARENT / TRACESTATE 2.1.98 | W3C distributed tracing for Bash subprocesses + SDK |
Starting points, not scripture. Mix and match for your stack. For richer patterns, see common workflows and best practices.
cd your-project
claude
> /init
> # review the generated CLAUDE.md, trim aggressively
> /memory # add commands, conventions, "do not touch" zones
> /permissions # lock down .env and secrets
claude --model opusplan
> Shift+Tab Shift+Tab # enter plan mode
> Plan a migration from REST to GraphQL for the user service.
> # exit plan โ Claude switches to Sonnet for execution
git worktree add ../app-hotfix -b hotfix/login-500 main
cd ../app-hotfix && claude "fix the 500 on /api/login"
# main project keeps running in the other terminal, full context
# .github/workflows/review.yml (excerpt)
- run: |
gh pr diff ${{ github.event.number }} | \
claude -p \
--append-system-prompt "Senior reviewer. Focus on security, regressions." \
--output-format json \
--allowedTools "Read,Grep" \
--exclude-dynamic-system-prompt-sections \
> review.json
// .claude/settings.json
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{
"type": "command",
"command": "npx prettier --write \"$FILE_PATH\" 2>/dev/null || true"
}]
}]
}
}
/model opus only when it's stuck./compact at ~80 % context โ cheaper than letting it auto-compact under pressure./clear between unrelated tasks. Don't pay to carry old context.model: claude-haiku-4-5 in frontmatter./effort low for mechanical work; save high for hard reasoning./btw for side questions โ answers in a dismissible overlay, never enter history./rewind restores tracked edits only. Changes made by rm, mv, cp, or external editors are not recoverable. Commit often.mcp__github__* matches nothing. Use the server name alone or list tools explicitly..local suffix is convention, not magic. .claude/settings.local.json is not auto-ignored. You still need a .gitignore entry.brew upgrade claude-code or winget upgrade Anthropic.ClaudeCode manually.ENABLE_TOOL_SEARCH=true on heavy setups โ 85 % token reduction in Anthropic's benchmarks.PreToolUse hooks cannot override permissions.deny โ deny wins.disable-model-invocation: true. Otherwise Claude may invoke them at surprising moments.ANTHROPIC_DEFAULT_*_MODEL to versioned IDs so your agents are reproducible.allowedMcpServers and deniedMcpServers, denied wins โ regardless of order.export in one command won't be available in the next. Use CLAUDE_ENV_FILE or a SessionStart hook to populate env dynamically.cd carries over between Bash calls by default (but not across subagent sessions). Disable with CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1 if it causes confusion.CLAUDE_CODE_CERT_STORE=bundled only if you need to skip OS certificate trust (some enterprise TLS setups).