title: "Claude Code Cheatsheet"
last_updated: 2026-03-21
tested_with:
claude-code: "1.0.x"
status: proven
difficulty: beginner
npm install -g @anthropic-ai/claude-code
| Command | Description |
claude | Start interactive session in current directory |
claude "prompt" | Start session with an initial prompt |
claude --continue | Resume the most recent conversation |
claude --resume | Pick a previous conversation to resume |
claude -p "prompt" | Headless mode -- run a single prompt, print result, exit |
claude -p "prompt" --output-file out.txt | Headless mode with output saved to file |
claude config | Open configuration settings |
| Command | Description |
/help | Show all available commands |
/clear | Clear conversation history and start fresh |
/compact | Summarize conversation to reclaim context window |
/model | Switch to a different model mid-session |
/status | Show current session info (model, project, etc.) |
/cost | Display token usage and cost for the current session |
| Shortcut | Description |
Shift+Tab | Toggle between plan mode and code mode |
Plan mode lets the agent reason and propose a plan without making changes. Code mode (default) allows the agent to read and write files.
| File | Purpose |
CLAUDE.md | Project memory -- conventions, build commands, architecture notes. Loaded automatically at session start. |
~/.claude/CLAUDE.md | User-level memory applied to all projects. |
.claude/settings.json | Project-level settings (allowed/denied tools, permissions). |
~/.claude/settings.json | User-level settings. |
.claude/commands/*.md | Custom slash commands scoped to the project. |
~/.claude/commands/*.md | Custom slash commands available globally. |
Claude Code asks for approval before performing potentially risky actions.
| Category | Examples | Default |
| Read | Reading files, listing directories | Allowed |
| Write | Creating/editing files | Requires approval |
| Shell | Running shell commands | Requires approval |
Grant standing permissions via .claude/settings.json:
{
"permissions": {
"allow": [
"Edit",
"Bash(npm test)",
"Bash(npm run build)"
],
"deny": [
"Bash(rm -rf *)"
]
}
}
| Shortcut | Action |
Enter | Send message |
Shift+Tab | Toggle plan/code mode |
Escape | Cancel current generation |
Ctrl+C | Cancel or exit |
Up arrow | Cycle through previous prompts |
| Flag | Description |
-p, --print | Headless mode (non-interactive) |
--continue | Resume last conversation |
--resume | Pick a conversation to resume |
--output-file | Write headless output to a file |
--model | Specify model to use |
--verbose | Enable verbose logging |
--allowedTools | Specify which tools the agent can use |
--max-turns | Limit number of agentic turns in headless mode |
| Variable | Purpose |
ANTHROPIC_API_KEY | API key for direct Anthropic access |
CLAUDE_CODE_USE_BEDROCK | Set to 1 to use AWS Bedrock as provider |
CLAUDE_CODE_USE_VERTEX | Set to 1 to use Google Vertex AI as provider |
AWS_REGION | AWS region for Bedrock |
AWS_PROFILE | AWS profile for Bedrock authentication |
CLOUD_ML_REGION | Google Cloud region for Vertex AI |
ANTHROPIC_MODEL | Override the default model |
DISABLE_PROMPT_CACHING | Set to 1 to disable prompt caching |
- Run
/compact after finishing each sub-task to keep context clean.
- Put build/test commands in
CLAUDE.md so the agent runs them correctly every time.
- Use
claude -p in scripts and CI pipelines for non-interactive use.
- Start with strict permissions and relax them as you build trust.