Reference guide for Claude Code startup parameters, essential commands, memory system, context management, permission modes, model selection, MCP servers, and keyboard shortcuts.
Claude Code accepts command-line flags when launched from the terminal. These control session behavior, model selection, permissions, and output format.
| Flag | What It Does | Example |
|---|---|---|
--print / -p | Print response and exit without interactive mode | claude -p "explain this project" |
--continue / -c | Resume the most recent conversation in the current directory | claude -c |
--resume / -r | Resume a session by ID or name | claude -r "auth-refactor" |
--name / -n | Set a display name for the session | claude -n "feature-work" |
--fork-session | Create new session ID while preserving conversation history | claude --resume abc --fork-session |
--output-format | Output format: text, json, stream-json (print mode) | claude -p --output-format json "query" |
--max-turns | Limit number of agentic turns (print mode) | claude -p --max-turns 5 "query" |
--max-budget-usd | Maximum dollar amount to spend on API calls (print mode) | claude -p --max-budget-usd 5.00 "query" |
| Flag | What It Does | Example |
|---|---|---|
--model | Set model for the session (alias or full name) | claude --model opus |
--effort | Set effort level: low, medium, high, max | claude --effort high |
--fallback-model | Enable automatic fallback when default model is overloaded (print mode) | claude -p --fallback-model sonnet "query" |
| Flag | What It Does | Example |
|---|---|---|
--permission-mode | Start in a specific mode: default, acceptEdits, plan, auto, bypassPermissions, dontAsk | claude --permission-mode plan |
--allowedTools | Tools that execute without prompting | claude --allowedTools "Bash(git *)" "Read" |
--disallowedTools | Tools removed from Claude's context entirely | claude --disallowedTools "Bash(rm *)" |
--dangerously-skip-permissions | Skip all permission prompts (isolated environments only) | claude -p --dangerously-skip-permissions "refactor" |
| Flag | What It Does | Example |
|---|---|---|
--system-prompt | Replace the entire default system prompt | claude --system-prompt "You are a Python expert" |
--system-prompt-file | Load replacement system prompt from a file | claude --system-prompt-file ./prompt.txt |
--append-system-prompt | Append custom text to the default prompt | claude --append-system-prompt "Always use TypeScript" |
--append-system-prompt-file | Append file contents to the default prompt | claude --append-system-prompt-file ./rules.txt |
| Flag | What It Does | Example |
|---|---|---|
--settings | Load additional settings from a JSON file | claude --settings ./settings.json |
--add-dir | Add additional working directories | claude --add-dir ../lib ../shared |
--mcp-config | Load MCP servers from JSON file | claude --mcp-config ./mcp.json |
--agent | Use a specific agent for the session | claude --agent security-reviewer |
--worktree / -w | Start in an isolated git worktree | claude -w feature-auth |
--bare | Minimal mode: skip hooks, skills, plugins, MCP, memory, CLAUDE.md | claude --bare -p "query" |
--verbose | Enable verbose logging with full turn-by-turn output | claude --verbose |
--version / -v | Print version number and exit | claude -v |
Type / in Claude Code to see all available commands. These are the built-in slash commands organized by category.
| Command | What It Does |
|---|---|
/resume | Resume a past session from an interactive picker |
/clear | Start a new session without saving the current conversation |
/rename | Change the display name of the current session |
/btw | Ask a quick side question without adding to conversation history |
| Command | What It Does |
|---|---|
/init | Generate a starting CLAUDE.md file based on codebase analysis |
/memory | Browse, open, and edit CLAUDE.md and auto memory files; toggle auto memory on/off |
| Command | What It Does |
|---|---|
/compact | Summarize conversation to free context space; optionally add focus: /compact focus on the API changes |
/context | View what is using space in the context window |
/cost | View token and API usage costs for the current session |
| Command | What It Does |
|---|---|
/config | Open configuration interface to adjust settings |
/settings | View or modify settings files |
/model | Switch models and adjust effort level |
/effort | Change effort level: low, medium, high, max, or auto |
/theme | Choose color theme or toggle syntax highlighting |
/vim | Enable vim-style editing mode |
/terminal-setup | Set up terminal shortcuts (e.g., Shift+Enter for multiline) |
| Command | What It Does |
|---|---|
/plan | Enter plan mode to propose changes without making them; prefix to any prompt |
/diff | View uncommitted changes in the current repository |
| Command | What It Does |
|---|---|
/agents | List all configured subagents and manage configuration |
/mcp | Configure and manage MCP servers and their costs |
/plugin | Discover, install, and manage plugins |
/hooks | View and manage configured hooks |
| Command | What It Does |
|---|---|
/export | Export conversation as plain text |
/status | View current authentication status and account information |
/doctor | Diagnose common issues and see keybinding warnings |
/feedback | Report bugs, feature requests, or other feedback |
/help | Show help menu |
! at the start of your input to run a bash command directly (e.g., ! git status). The output is added to the conversation context. Type @ to trigger file path autocomplete.
Claude Code has an auto-memory system that accumulates knowledge across sessions. Claude saves notes for itself based on patterns, corrections, and discoveries.
~/.claude/projects/<project>/memory/
MEMORY.md # Index file (loaded at session start)
debugging.md # Topic-specific notes
api-conventions.md # (Claude creates these as needed)
...
Memory is stored per project (derived from the git repository). All worktrees within the same repo share one memory directory. Memory is machine-local and is not synced to the cloud.
| Resource | Limit |
|---|---|
| MEMORY.md loaded at startup | First 200 lines or 25KB, whichever comes first |
| Topic files | No per-file limit; loaded on demand when relevant |
| Total memory directory | No hard limit; keep reasonable for performance |
/memory
Opens an interactive browser showing all CLAUDE.md and rule files loaded in the session, a toggle for auto memory, and a link to open the memory folder. You can also edit files directly at ~/.claude/projects/<project>/memory/.
Three methods:
# In a session
/memory (then toggle off)
# In settings file (.claude/settings.json or ~/.claude/settings.json)
{ "autoMemoryEnabled": false }
# Via environment variable
export CLAUDE_CODE_DISABLE_AUTO_MEMORY=1
Set in user or local settings (not project settings):
{ "autoMemoryDirectory": "~/my-custom-memory-dir" }
Delete files directly from ~/.claude/projects/<project>/memory/. There is no slash command to bulk-clear memory. You can also ask Claude to forget specific things and it will remove the relevant entries.
The context window holds your conversation history, file contents, command outputs, CLAUDE.md instructions, auto memory, loaded skills, and system instructions. When it fills up, older content is compressed.
| Model | Standard | Extended |
|---|---|---|
| Opus 4.6 | 200K tokens | 1M tokens |
| Sonnet 4.6 | 200K tokens | 1M tokens |
| Haiku 4.5 | 200K tokens | Not available |
1M context is included with Max and Team plans. Pro and API users can access it via extra usage.
/compact
Claude summarizes earlier parts of the conversation, preserving your requests and key code snippets. Detailed instructions from early in the conversation may be lost, but CLAUDE.md is always re-injected fresh from disk.
/compact focus on the API changes
Tells Claude what to prioritize when summarizing. Use this to preserve specific context that matters for your current task.
Claude Code manages context automatically in this order:
/context to see what is consuming space.
Permission modes control what Claude can do without asking. Cycle through them with Shift+Tab during a session.
| Mode | Claude Can Do Without Asking | Best For |
|---|---|---|
default | Read files only | Getting started, sensitive work |
acceptEdits | Read and edit files | Iterating on code you are reviewing |
plan | Read files, explore only (no edits) | Exploring codebase, planning refactors |
auto | All actions with background safety checks | Long-running tasks, reducing prompts |
dontAsk | Only pre-approved tools (allow rules) | Locked-down environments |
bypassPermissions | Everything, no checks | Isolated containers and VMs only |
Press Shift+Tab to cycle through: default, acceptEdits, plan, auto.
claude --permission-mode plan
claude --permission-mode acceptEdits
# In .claude/settings.json or ~/.claude/settings.json
{
"permissions": {
"defaultMode": "acceptEdits"
}
}
Add allow and deny rules in settings for specific tool patterns:
{
"permissions": {
"allow": [
"Bash(npm test)",
"Bash(git *)",
"Read"
],
"deny": [
"Bash(rm -rf *)",
"Bash(git push --force *)"
]
}
}
Auto mode uses a background classifier to evaluate actions. It blocks by default:
curl | bash)It allows by default: local file operations, installing declared dependencies, read-only HTTP requests, and pushing to your branch.
Claude Code supports multiple models with aliases for convenience. Aliases always point to the latest version.
| Alias | Model | Best For |
|---|---|---|
opus | Claude Opus 4.6 | Complex reasoning, architecture decisions |
sonnet | Claude Sonnet 4.6 | Daily coding tasks, fast iteration |
haiku | Claude Haiku 4.5 | Simple tasks, quick answers |
opus[1m] | Opus with 1M context | Long sessions, large codebases |
sonnet[1m] | Sonnet with 1M context | Long sessions with fast execution |
opusplan | Opus for planning, Sonnet for execution | Strong planning with efficient coding |
| Method | Command | Priority |
|---|---|---|
| In session | /model opus | Highest |
| At startup | claude --model opus | High |
| Environment variable | export ANTHROPIC_MODEL=opus | Medium |
| Settings file | { "model": "opus" } | Lowest |
Controls how deeply Claude reasons about each response. Persists across sessions except max.
| Level | When to Use |
|---|---|
low | Fast, straightforward tasks |
medium | Default; recommended for most coding |
high | Complex debugging, architectural decisions |
max | Deepest reasoning (Opus 4.6 only) |
auto | Reset to model default |
Set with /effort high, claude --effort high, or include "ultrathink" in your prompt for a one-off high-effort turn.
MCP (Model Context Protocol) servers are external integrations that extend Claude's capabilities by connecting to third-party services, databases, and tools.
/mcp
Shows installed MCP servers, per-server token costs, and options to add or remove servers.
# In .claude/settings.json or ~/.claude/settings.json
{
"mcpServers": {
"github": {
"type": "stdio",
"command": "npx",
"args": ["@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_TOKEN"
}
}
}
}
claude --mcp-config ./mcp.json
| Type | Description | Use Case |
|---|---|---|
stdio | Local process communicating via stdin/stdout | Local tools, CLIs, scripts |
http | Cloud-hosted server over HTTP | Hosted services, SaaS integrations |
sse | Server-sent events connection | Streaming data sources |
| Scope | File | Shared |
|---|---|---|
| Local (personal) | .claude/settings.local.json | No |
| Project (team) | .claude/settings.json | Yes, via git |
| User (all projects) | ~/.claude/settings.json | No |
/mcp to check per-server token costs.
All shortcuts except Ctrl+C and Ctrl+D are customizable via /keybindings.
| Shortcut | Action |
|---|---|
Ctrl+C | Cancel current input or generation |
Ctrl+D | Exit Claude Code session |
Ctrl+L | Clear terminal screen (keeps conversation) |
Ctrl+O | Toggle verbose output / transcript view |
Ctrl+R | Reverse search command history |
Ctrl+T | Toggle task list visibility |
Esc Esc | Rewind or summarize |
| Shortcut | Action |
|---|---|
Shift+Tab | Cycle permission modes: default, acceptEdits, plan, auto |
Option+P / Alt+P | Switch model without clearing prompt |
Option+T / Alt+T | Toggle extended thinking mode |
Option+O / Alt+O | Toggle fast mode |
| Shortcut | Action |
|---|---|
Ctrl+K | Delete to end of line |
Ctrl+U | Delete from cursor to line start |
Ctrl+Y | Paste deleted text |
Alt+B | Move cursor back one word |
Alt+F | Move cursor forward one word |
Ctrl+G | Open input in external text editor |
Ctrl+S | Stash current prompt |
| Method | How |
|---|---|
| Quick escape | \ then Enter (works in all terminals) |
| macOS default | Option+Enter |
| Shift+Enter | Works in iTerm2, WezTerm, Ghostty, Kitty; run /terminal-setup for others |
| Control sequence | Ctrl+J (line feed) |
| Paste mode | Paste directly for multi-line code blocks |
| Prefix | Action |
|---|---|
/ | Show available commands and skills |
! | Run bash command directly (output added to session) |
@ | File path autocomplete mention |
/terminal-setup to configure Shift+Enter for multiline input.
Claude Code sessions are independent by default -- each new session starts fresh. Keeping context across sessions requires deliberate use of persistence mechanisms. Here is every tool available and when to use each one.
The most direct way to maintain context is to resume the previous session. Claude reloads the full conversation history, including all file reads, edits, and decisions made.
# Resume the most recent session in the current directory
claude -c
# Pick from a list of past sessions
claude --resume
# Resume a specific named session
claude -r "auth-refactor"
# Resume and continue with a new prompt
claude -c "now add the unit tests"
# Inside a session
/resume
When to use: You are continuing the same task from yesterday. You want Claude to remember everything -- the files it read, the approach it chose, and the rationale for decisions.
Limitations: Old sessions eventually exceed the context window. If the session is very long, earlier messages may be auto-compacted. Named sessions make it easier to find the right one later.
Unnamed sessions pile up and become hard to distinguish. Name every session that you might return to.
# Start a named session
claude -n "payment-refactor"
# Rename the current session
/rename checkout-migration
# Resume by name later
claude -r "payment-refactor"
When to use: Any multi-session task. Name by feature, ticket, or branch -- whatever helps you find it in a list of 20 sessions.
CLAUDE.md is re-loaded from disk at the start of every session and re-injected after compaction. It is the most durable form of project context.
# .claude/CLAUDE.md -- always loaded, never lost
## Current Sprint
- Auth migration to Supabase (deadline: April 15)
- Do not modify legacy auth until migration is complete
## In-Progress Work
- Payment refactor: branch payment-v2, PR #142
- Checkout flow: waiting on design review before proceeding
## Decisions Made
- Using Riverpod over Bloc (decided March 15, see ADR-003)
- Storing monetary values as integers in cents
When to use: Project-level context that every session should know. Sprint priorities, in-progress branches, architectural decisions, and constraints that apply to all work.
How to maintain: Update the "Current Sprint" and "In-Progress Work" sections weekly. Remove completed items. Claude reads this every time -- stale entries waste context and cause confusion.
Auto memory persists things Claude discovers during sessions -- build commands, debugging patterns, your preferences, and project conventions. It is stored in ~/.claude/projects/<project>/memory/ and the index (MEMORY.md) is loaded at every session start.
# View and manage memory
/memory
# Ask Claude to remember something specific
"Remember that the payments service requires VPN access to test locally"
# Ask Claude to forget something
"Forget what you saved about the old auth system"
When to use: Let it run in the background. Claude will save things that help future sessions -- corrections you give it, patterns it discovers, and solutions to problems it encounters. Review periodically with /memory and prune stale entries.
What it does not do: Auto memory does not save task progress, TODO lists, or debugging logs. It saves patterns and learnings, not ephemeral state.
The most reliable way to carry work between sessions is through git. Commits, branch names, and PR descriptions persist indefinitely and Claude can read them.
# Start a new session and catch up via git
claude
> "Check git log and the open PRs to understand what I was working on yesterday"
# Or be specific
claude -c "I was working on the checkout migration on branch checkout-v2.
Check the recent commits and continue where I left off."
When to use: Always. Commit frequently with descriptive messages. Create PRs with detailed descriptions. When you return to a session, Claude can reconstruct context from the git history even without resuming the old session.
Best practices:
feature/checkout-migration, fix/payment-roundingGit worktrees let you work on multiple features simultaneously, each with its own directory and Claude session.
# Start Claude in an isolated worktree
claude -w checkout-migration
# Each worktree gets its own session history
# Resume a worktree session later
claude -w checkout-migration -c
When to use: You are juggling multiple features or reviewing a PR while working on something else. Each worktree has its own working directory, branch, and Claude session, so context does not bleed between tasks.
For fine-grained task tracking within a feature, leave TODO comments in the code itself. Claude can find and act on them in the next session.
// TODO(floyd): Add retry logic for failed payments -- see Stripe docs
// TODO: Validate coupon codes against the promotions table
// TODO: Write integration tests for the checkout flow
When to use: When you stop mid-feature and need to remember specific next steps. In the next session, ask Claude to find and work through the TODOs:
"Find all TODO comments in the checkout feature and work through them"
Before ending a session, ask Claude to write a handoff summary that you can paste into the next session.
# At the end of a session
"Write a handoff summary of what we did, what is left to do, and any
decisions we made. I will paste this into our next session."
Claude will produce a structured summary of the work done, open questions, and next steps. Save it in a file, a note, or just copy it. Paste it as the first message of the next session:
# Start of next session
"Here is context from our last session: [paste handoff summary].
Continue with the next item."
When to use: When resuming the old session is not practical (too long, too old, or different machine). The handoff summary is more focused than a full session resume because it captures only what matters for the next step.
Combine these mechanisms based on the duration and complexity of your work:
| Scenario | Approach |
|---|---|
| Quick task (1 session) | No special tracking needed. Commit when done. |
| Multi-day feature | Name the session. Commit at stopping points. Resume with claude -c or claude -r "name". |
| Long-running project | Track priorities and in-progress work in CLAUDE.md. Use git branches and PRs. Let auto memory accumulate patterns. |
| Team project | CLAUDE.md in version control for shared context. PR descriptions for handoffs. Named branches per feature. |
| Switching between tasks | Use worktrees (claude -w). Each task gets its own isolated branch and session. |
| Different machine | Git carries everything. Start a new session and point Claude at the branch, PR, or recent commits. |