Anthropic's Agentic CLI for Software Development
The complete reference guide to commands, shortcuts, configuration, permissions, MCP integration, memory, subagents, hooks, skills, and best practices.
00 // Quick Reference
Essential commands, shortcuts, and key files at a glance. Everything you need for day-to-day Claude Code usage in four compact tables.
Keyboard Shortcuts
| Tab | Toggle extended thinking mode |
| Shift+Tab | Cycle permission modes (Normal / Auto-Accept / Plan) |
| Cmd/Ctrl+P | Model picker |
| Ctrl+G | Open external editor |
| Escape / Ctrl+C | Cancel generation / interrupt |
| Ctrl+L | Clear screen |
| Shift+Enter | Submit message (after /terminal-setup) |
| @ + filename | Reference files and MCP resources |
Essential Slash Commands
| /help | Show all available commands |
| /init | Initialize project, create CLAUDE.md |
| /model | Switch Claude model |
| /context | Show context window usage |
| /compact | Compress conversation history |
| /clear | Clear conversation entirely |
| /cost | Show API token usage |
| /review | Code review recent changes |
| /doctor | Diagnose installation issues |
| /add-dir | Add directory to context |
| /allowed-tools | Manage tool permissions |
| /fast | Toggle fast output mode |
Permission Modes
| Normal | Prompts for every dangerous operation (default) |
| Auto-Accept | Approves all actions without prompting |
| Plan Mode | Read-only, no modifications allowed |
| Bypass | Skips all checks (containers only!) |
Cycle with Shift+Tab · Rules: deny → ask → allow
Key Files & Paths
| CLAUDE.md | Project instructions (repo root) |
| ~/.claude/settings.json | Global user configuration |
| .claude/settings.json | Project config (git-tracked) |
| .claude/settings.local.json | Personal overrides (gitignored) |
| .claude/skills/ | Custom skills directory |
| .claude/rules/ | Split CLAUDE.md into focused files |
| ~/.claude/projects/<id>/memory/ | Auto-memory per project |
| ~/.claude/keybindings.json | Custom keyboard shortcuts |
# Start with specific model
claude --model claude-opus-4-6
# Resume a previous session
claude --resume "session-id" "continue working on this"
# Agent mode with budget limit
claude --agent --max-budget-usd 100
# Restrict tools for safety
claude --allowedTools "Read,Write(src/**),Bash(git *)"
# Verbose logging with additional directories
claude --model opus --verbose --add-dir src/
01 // Interface
Claude Code's keybindings provide rapid access to model switching, thinking mode, permission cycling, and editor integration. Press ? in Claude Code to see shortcuts for your environment.
| Shortcut | Action | Notes |
|---|---|---|
| Tab | Toggle extended thinking mode | Sticky across sessions -- stays enabled until you toggle off |
| Shift+Tab | Cycle permission modes | Normal → Auto-Accept → Plan → Normal |
| Cmd/Ctrl+P | Open model picker | Switch between Opus, Sonnet, Haiku |
| Alt+P | Model picker (alternate) | Alias for Cmd/Ctrl+P |
| Ctrl+G | Open external editor | Compose longer prompts in your preferred editor |
| Escape / Ctrl+C | Cancel / interrupt | Stops current generation or exits |
| Ctrl+L | Clear screen | Visual clear only, does not clear context |
| Shift+Enter | Submit message | Requires /terminal-setup for iTerm2/VS Code |
| Alt+M | Toggle permission modes | Alternate for Shift+Tab |
| Alt+B / Alt+F | Move backward / forward one word | Requires Option as Meta in terminal |
Customization
All keyboard shortcuts can be reconfigured in ~/.claude/keybindings.json. See the official keybindings documentation for the full configuration schema.
Claude Code operates in three primary modes, cycled via Shift+Tab:
Prompts for every potentially dangerous operation. Full read and write capabilities, but every file edit, command, and tool use requires explicit approval. Best for production work and unfamiliar codebases.
Eliminates confirmation prompts entirely. Claude executes actions immediately without interrupting for approval. UI shows "auto-accept edit on" when active. Best for rapid prototyping and trusted environments.
Read-only operations only. Prevents any modifications while allowing comprehensive analysis, code review, and architectural exploration. Perfect for exploring unfamiliar code and reviewing changes.
02 // Commands
Claude Code includes 30+ slash commands for session management, project setup, context control, code review, and tool configuration. Type /help to see all available commands.
| Command | Category | Description |
|---|---|---|
| /help | Core | Shows all available slash commands with descriptions |
| /init | Setup | Initializes project by analyzing codebase and creating CLAUDE.md with conventions, structure, and context |
| /model | Core | Switch between Claude models -- Sonnet 4.5, Opus 4.6, Haiku 4.5 |
| /context | Context | Displays colored grid showing what consumes your context window -- files, conversation, system prompts |
| /compact | Context | Compresses conversation history into a summary, starts new session with summary as context; supports custom instructions for what to preserve |
| /clear | Context | Clears conversation history entirely to start fresh and save tokens |
| /cost | Usage | Shows API token usage and spending (for API users; not relevant for Max/Pro subscribers) |
| /review | Dev | Requests code review of recent changes |
| /bug | Dev | Helps troubleshoot and fix bugs in current context |
| /doctor | Setup | Runs diagnostic checks to troubleshoot installation and configuration |
| /terminal-setup | Setup | Installs Shift+Enter key binding for iTerm2 and VS Code terminals |
| /add-dir | Context | Adds additional directories to Claude's context for monorepo or multi-repo work |
| /allowed-tools | Permissions | Manages tool permission rules; e.g., /allowed-tools add Bash(git *) |
| /fast | Core | Toggles fast mode -- same Opus 4.6 model with faster output |
| /resume | Session | Resume a previous conversation session by ID |
Custom Commands
Create your own slash commands by adding markdown files to .claude/commands/ or .claude/skills/. Skills are recommended over commands as they support additional features like supporting files, subagent execution, and invocation control.
03 // Configuration
CLAUDE.md is the single highest-impact configuration for Claude Code. Ten minutes of setup saves hours of repeated explanations every session. Combined with settings.json, it provides complete control over Claude's behavior.
| Location | Scope | Use Case |
|---|---|---|
~/CLAUDE.md |
All projects | Universal preferences, personal coding style |
/repo/CLAUDE.md |
Single repository | Project-specific instructions -- check into source control for team sharing |
/parent/CLAUDE.md |
Monorepo parent | Shared context for all packages within a monorepo |
.claude/rules/*.md |
Repository | Split CLAUDE.md into focused rule files -- all auto-loaded with same priority |
Important
The filename is case-sensitive -- it must be exactly CLAUDE.md (uppercase CLAUDE, lowercase .md). Claude Code looks for this specific filename when loading memory files.
# Project Name
## Tech Stack
- Framework: Next.js 14, React 18
- Language: TypeScript
- Styling: Tailwind CSS
## Code Conventions
- Use functional components with hooks
- Prefer named exports over default exports
- All files use 2-space indentation
## Project Structure
- /src/components -- React components
- /src/lib -- Utility functions
- /src/app -- Next.js app router pages
## Testing
- Run `npm test` before committing
- Maintain >80% coverage
## Git Workflow
- Branch naming: feature/, fix/, chore/
- Commit format: Conventional Commits
{
"model": "claude-opus-4-6",
"maxBudgetUsd": 50,
"permissions": {
"allowedTools": [
"Read",
"Write(src/**)",
"Bash(git *)",
"Bash(npm *)"
],
"disallowedTools": [
"Read(.env*)",
"Write(production.config.*)",
"Bash(rm *)",
"Bash(sudo *)"
]
}
}
{
"addFiles": ["src/**/*.ts", "README.md"],
"hooks": {
"PostToolUse": {
"type": "command",
"command": "prettier --write {filePath}",
"match": { "tool": "Write" }
}
}
}
04 // Security
Claude Code's permission system provides fine-grained control over what actions the agent can perform. Rules follow a deny-first evaluation order, ensuring safety while allowing flexible workflows.
| Mode | Behavior | Best For | Activation |
|---|---|---|---|
| Normal | Prompts for every potentially dangerous operation | Production work, unfamiliar codebases | Default mode |
| Auto-Accept | All actions approved without prompting | Rapid prototyping, trusted projects | Shift+Tab (1x) |
| Plan Mode | Read-only -- no file modifications allowed | Code review, exploration, analysis | Shift+Tab (2x) |
| Bypass | Skips ALL permission checks | CI/CD, containers, VMs only | --dangerously-skip-permissions |
| Custom Rules | Fine-grained allow/ask/deny per tool | Team workflows, enterprise | settings.json |
Warning
Only use Bypass mode in fully isolated environments -- containers, VMs, or ephemeral CI runners where Claude cannot cause lasting damage. Never use --dangerously-skip-permissions on your development machine.
Rules are evaluated in order: deny → ask → allow. The first matching rule wins, so deny rules always take precedence.
{
"permissions": {
"deny": [
"Read(.env*)", // Block reading .env files
"Bash(rm *)", // Block rm commands
"Bash(sudo *)" // Block sudo commands
],
"ask": [
"Write(database/**)", // Prompt before database changes
"Bash(npm install *)" // Prompt before installing packages
],
"allowedTools": [
"Read", // Allow all reads (except denied)
"Write(src/**)", // Allow writes in src/ only
"Bash(git *)", // Allow all git commands
"Edit" // Allow all edits
]
}
}
| Pattern | Meaning | Example |
|---|---|---|
| ToolName | Permits every action for this tool | Read -- allow all reads |
| ToolName(*) | Permits any argument | Bash(*) -- any bash command |
| ToolName(filter) | Permits matching calls only | Write(src/**) -- only src/ writes |
05 // Protocol
The Model Context Protocol is an open-source standard enabling Claude Code to connect to external tools, databases, and APIs. 2026 updates include MCP Tool Search (85% context reduction), OAuth 2.0 authentication, and MCP Apps.
MCP servers are configured in ~/.claude/settings.json under the mcpServers key:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
},
"postgres": {
"command": "docker",
"args": ["run", "--rm", "-i", "mcp-server-postgres"],
"env": { "DATABASE_URL": "${DATABASE_URL}" }
}
}
}
Type @ in your prompt to see available resources from all connected MCP servers. Resources appear alongside files in the autocomplete menu:
# Reference MCP resources in prompts using @
@database/users # Query users table
@github/PR-123 # Reference GitHub PR
@notion/ProjectDocs # Access Notion docs
Automatically activates when MCP tool descriptions exceed 10% of the context window. Dynamically loads tools on-demand instead of preloading all of them, reducing context consumption by up to 85%.
Output warning threshold at 10,000 tokens, configurable default limit of 25,000 tokens. Claude Code helps manage token usage to prevent overwhelming your conversation context.
06 // Persistence
Claude Code uses multiple memory layers to maintain context across sessions. Auto-memory saves patterns and preferences automatically, while CLAUDE.md provides user-defined persistent instructions.
| Memory Type | Location | Scope | Purpose |
|---|---|---|---|
| Auto Memory | ~/.claude/projects/<id>/memory/ |
Per-project | Automatically saves patterns, commands, and preferences |
| CLAUDE.md | Project root or ~/ |
Project or global | User-defined instructions and conventions |
| Conversation | Session only | Current session | Active conversation history |
MEMORY.md as entrypoint, plus optional topic files (e.g., git-workflow.md, testing-patterns.md)| Command | Action | When to Use |
|---|---|---|
| /context | Colored grid showing context consumption | Monitor what is consuming your context window |
| /compact | Summarize and compress conversation history | Before hitting context limits (proactive is better than reactive) |
| /clear | Clear conversation history entirely | Starting a completely fresh task |
| /add-dir | Add directory to context | Working across multiple repos or packages |
Pro Tip
Run /compact proactively before your context fills up -- compaction works better with headroom. You can add custom instructions to specify what to preserve during summarization.
07 // Power Features
Subagents, the Task tool, hooks, background tasks, and custom skills represent Claude Code's most powerful capabilities for complex multi-step workflows and automation.
Subagents enable parallel execution of up to 7 agents simultaneously, dramatically speeding up complex workflows. The Task tool coordinates work across sessions using directed acyclic graphs (DAGs).
Codebase research and understanding. Delegated to automatically when Claude needs to understand project structure.
Strategic planning and architectural decisions. Active in Plan Mode for analysis without modifications.
Standard coding tasks. Spawned for independent work units with scoped directory access.
~/.claude/tasksrun_in_background: true for long-running workStore custom subagent definitions in .claude/skills/<agent-name>/SKILL.md:
---
name: code-reviewer
description: Specialized code review agent for security and performance
agent: true
---
# Code Review Instructions
When reviewing code:
1. Check for security vulnerabilities
2. Analyze performance implications
3. Verify test coverage
4. Ensure style guide compliance
Hooks are user-defined shell commands that execute at specific points in Claude Code's lifecycle. They provide deterministic control -- ensuring actions always happen rather than relying on the LLM to choose them.
| Type | Description | Use Case |
|---|---|---|
| command | Runs a shell command | Auto-format, lint, notifications, git operations |
| prompt | Single-turn LLM evaluation | Validation, quality checks, code review gates |
| agent | Multi-turn agent with tool access | Complex verification workflows |
{
"hooks": {
"PostToolUse": {
"type": "command",
"command": "prettier --write {filePath}",
"match": { "tool": "Write" }
}
}
}
{
"hooks": {
"PostToolUse": {
"type": "command",
"command": "npm test -- {filePath}",
"match": {
"tool": "Write",
"path": "src/**/*.ts"
}
}
}
}
Run long-running commands without blocking your workflow. Claude Code maintains process continuity across sessions.
# Start a background task
Bash(command: "npm run dev", run_in_background: true)
# Start a background subagent
Task(prompt: "Run full test suite", run_in_background: true)
# Check results later
TaskOutput(task_id)
TaskOutput(task_id) to retrieve results when readySkills are the recommended approach for reusable workflows, commands, and knowledge. They're stored in .claude/skills/ and support features that commands do not.
| Feature | Skills (.claude/skills/) | Commands (.claude/commands/) |
|---|---|---|
| YAML frontmatter | Yes | Yes |
| Supporting files | Yes | No |
| Subagent execution | Yes | No |
| Invocation control | Yes | No |
| Recommended | Yes | Deprecated |
---
name: api-endpoint
description: Scaffolds a new REST API endpoint with tests
invocation: manual # or auto-load
agent: false
---
# Create API Endpoint
When invoked, follow these steps:
1. Create endpoint in src/api/endpoints/{name}.ts
2. Use template from template.ts in this skill folder
3. Add route to src/api/router.ts
4. Create tests in tests/api/{name}.test.ts
5. Update OpenAPI schema
6. Run tests to verify
~/.claude/skills/ -- available across all projects.claude/skills/ -- specific to one repository.claude/skills/ in subdirectories automatically discovered when editing files there08 // Command Line
Start Claude Code with advanced options using command-line flags. Flags can be combined for precise control over model selection, tool access, cost limits, and session management.
| Flag | Category | Description | Example |
|---|---|---|---|
| --model | Model | Select Claude model | claude --model claude-opus-4-6 |
| --resume / -r | Session | Resume specific session by ID | claude -r "abc123" "continue" |
| --allowedTools | Permissions | Allow tools without prompting | claude --allowedTools "Read,Write(src/**)" |
| --disallowedTools | Permissions | Deny specific tools | claude --disallowedTools "Bash(rm *)" |
| --tools | Permissions | Limit base tool set | claude --tools "Read,Write,Edit" |
| --add-dir | Context | Add directory to context | claude --add-dir /path/to/dir |
| --max-budget-usd | Cost | Set spending limit | claude --max-budget-usd 50 |
| --verbose | Debug | Enable verbose logging | claude --verbose |
| --remote | Session | Start web-based session | claude --remote |
| --agent | Advanced | Run as agent (enables Task tool) | claude --agent |
| --dangerously-skip-permissions | Permissions | Bypass ALL permission checks | Isolated environments only |
# Start with Opus, verbose logging, and load src/ directory
claude --model opus --verbose --add-dir src/
# Resume session with specific tools allowed
claude --resume abc123 --allowedTools "Read,Write(src/**),Bash(git *)"
# Agent mode with budget limit in a container
claude --agent --max-budget-usd 100 --dangerously-skip-permissions
09 // Mastery
Effective prompting, workflow optimization, multi-session strategies, and security practices that separate power users from beginners. Compiled from Anthropic's official documentation and the Claude Code community.
Make a UI for the app
Too vague -- Claude will make assumptions about everything.
Create a Linear-style dashboard with:
- Dark mode using our existing theme tokens
- Table view with sortable columns
- Sidebar nav matching our design system
Specific context, reference designs, and clear requirements.
Claude excels with XML structure -- it provides more context than unstructured prompts:
<task>
<goal>Add user authentication to API</goal>
<requirements>
- Use JWT tokens
- Hash passwords with bcrypt
- Rate limit login attempts
- Add refresh token rotation
</requirements>
<constraints>
- Follow existing auth patterns
- Maintain backwards compatibility
</constraints>
</task>
Claude Code's creator (Boris Cherny) runs 5 local + 5-10 web sessions simultaneously, each with its own context and task. Use separate git worktrees to avoid conflicts:
# Terminal 1: Frontend work
cd ~/project && claude --add-dir src/components
# Terminal 2: Backend (separate worktree)
cd ~/project && git worktree add ../project-api main
cd ../project-api && claude --add-dir src/api
# Terminal 3: Testing
cd ~/project && claude --add-dir tests
Custom commands are the #2 time saver after CLAUDE.md. Experienced developers maintain around 15 custom commands across projects.
| Scenario | Recommended Mode |
|---|---|
| Exploring a new codebase | Plan Mode (read-only) |
| Rapid prototyping | Auto-Accept |
| Production changes | Normal (prompt for everything) |
| Code review | Plan Mode |
| CI/CD pipeline | Bypass (containers only) |
--max-budget-usd or configure in settings.jsondisallowedTools: ["Read(.env*)"] to block access to environment filesrm, sudo, and destructive git operations in your permission rules--dangerously-skip-permissions on a development machine/compact before hitting limits (works better with headroom)@filename is more efficient than pasting contentQuick Start Workflow
1. Run /init in any new project (creates CLAUDE.md)
2. Switch to Auto-Accept mode (Shift+Tab) for rapid iteration
3. Create custom commands for repetitive tasks
4. Monitor context with /context, compact with /compact
5. Run multiple parallel sessions for complex projects