> claude code
Anthropic's terminal coding agent — start and resume sessions, drive it headless from scripts and CI, wire up MCP servers, and keep it on a leash with permissions and CLAUDE.md
// getting started
5 commands// sessions
5 commandsContinue the most recent conversation
$ claude -cResume a specific past session
$ claude -rName a session so it is easy to find later
$ claude -n "payment-refactor"Run a session in an isolated git worktree
$ claude -w feature-authLaunch a session in the background and monitor it
$ claude --bg "investigate the flaky test"// cli flags & headless
7 commandsGet a one-shot answer and exit
$ claude -p "what does the auth module do?"Pipe command output into Claude
$ cat build-error.txt | claude -p "explain the root cause of this error"Get structured JSON output for scripts
$ claude -p "summarize this project" --output-format json | jq -r '.result'Stream responses as real-time JSON events
$ claude -p "explain recursion" --output-format stream-json --verbose --include-partial-messagesCap turns and spend in automation
$ claude -p "fix the failing tests" --max-turns 5 --max-budget-usd 1.00Choose or pin the model for a session
$ claude --model sonnetGive Claude extra directories and prompt instructions
$ claude --add-dir ../shared-lib ../api// slash commands
7 commandsReclaim context by compacting the conversation
$ /compactStart a fresh conversation without restarting
$ /clearSee what is filling the context window
$ /contextCheck token usage and cost for the session
$ /usageUndo Claude's edits with a checkpoint
$ /rewindGenerate a CLAUDE.md for the project
$ /initReview a pull request or scan the diff for vulnerabilities
$ /review// keyboard shortcuts
8 commandsInterrupt Claude in the middle of a task
Esc
Rewind the conversation with a double Esc
Esc Esc
Switch permission modes on the fly
Shift+Tab
Search your command history
Ctrl+R
See the full transcript with tool details
Ctrl+O
Run a shell command without leaving the prompt
$ ! npm testReference a file by path in your prompt
@
Edit the prompt with vim keybindings
Esc
// memory & settings
5 commandsGive Claude persistent project instructions
$ ~/.claude/CLAUDE.mdSave a fact to memory during a session
$ /memoryImport other files into CLAUDE.md
$ See @README.md for the project overview.Configure Claude Code with settings.json
$ ~/.claude/settings.jsonSet environment variables and a default mode via settings
$ { "env": { "AWS_PROFILE": "dev", "DISABLE_AUTOUPDATER": "1" } }// permissions & tools
4 commandsUnderstand and start in a permission mode
$ claude --permission-mode planSkip all permission prompts
$ claude --dangerously-skip-permissionsPre-approve or deny specific tools for a run
$ claude -p "run the tests and fix failures" --allowedTools "Bash,Read,Edit"Layer persistent allow and deny rules in settings
$ { "permissions": { "allow": ["Bash(npm run test:*)"], "deny": ["Read(./.env)"] } }// mcp, agents & hooks
6 commandsAdd a local MCP server that runs a command
$ claude mcp add my-server -- npx -y my-mcp-serverConnect a remote HTTP MCP server
$ claude mcp add --transport http sentry https://mcp.sentry.dev/mcpList, inspect, and remove MCP servers across scopes
$ claude mcp listCreate a custom slash command
$ .claude/commands/summarize.mdCreate a specialized subagent
$ .claude/agents/code-reviewer.mdRun a shell command on lifecycle events with hooks
$ { "hooks": { "PostToolUse": [ { "matcher": "Write|Edit", "hooks": [ { "type": "command", "command": "npm run lint --silent" } ] } ] } }