CLI Launch Commands
claudeStart interactive session
claude "prompt"One-shot query, non-interactive
claude -cResume last conversation
claude -r <id>Resume a specific session by ID
claude -p "prompt"Print mode: pipe output to stdout
claude --bg "task"Start a background session (detached)
claude agentsDashboard: manage all running sessions
claude agents --jsonList live sessions as JSON (for scripting)
claude project purgeDelete all CC state for a project (--dry-run safe)
claude --model <m>Specify model at launch
claude --add-dir <path>Add extra working directory
claude --dangerously-skip-permissionsAuto-approve all (trusted CI only)
Core Slash Commands
/helpShow all available commands
/initScan project, create CLAUDE.md
/clearReset conversation history
/compactSummarize history, free context window
/modelSwitch model (session only; press d to set default)
/effort <level>Set effort mid-session: low · medium · high · max
/fastEnable Fast Mode (Opus at 2.5x speed)
/planSwitch to planning / read-only mode
/code-review [high]Review for correctness bugs; --comment posts inline to PR
/usagePer-category limits breakdown: skills, subagents, plugins, MCP
More Slash Commands
/todosList tracked TODO items
/add-dir <path>Add working directory to session
/doctorHealth check installation
/rewindRevert to previous code state (revert code only option)
/bg "task"Fork session to background and continue working
/install-github-appEnable auto PR review via GitHub
/keybindingsEdit custom keyboard bindings
/rcRemote control (mobile access)
/usage-creditsCheck extra usage credit balance
Keyboard Shortcuts
Esc
Stop Claude (do not use Ctrl+C!)
EscEsc
Browse and jump to previous messages
↑
Navigate past prompts and sessions
ShiftTab
Cycle: normal → auto-accept → plan
CtrlV
Paste image from clipboard
Shift+drag
Reference a file in chat (not open it)
!
Run shell command directly in session
@
Reference file or directory inline
CLAUDE.md — Project Memory
Run /init to auto-generate. Claude reads this on every session — add anything it must always know.
# CLAUDE.md
## Stack
Next.js 15, TypeScript, Postgres
## Commands
Build: npm run build
Test: npm test
Lint: npm run lint
## Conventions
- Use pnpm, not npm
- No default exports
- Tests alongside source files
Model Selection Guide
Sonnet 4.5Default. Best balance for everyday coding tasks
Haiku 4.5Fastest and cheapest — use for simple or token-heavy tasks
Opus 4.6Strong for complex planning, architecture, large files
Opus 4.7 ✨Latest — stronger coding & long-running tasks, better vision
Pro tip: Pro/Max5 defaults to Sonnet. Use /fast for Opus at 2.5x speed. /model now changes current session only — press d to set a new default.
In-Session Syntax and References
@src/app.tsReference a specific file
@src/Reference an entire directory
!npm testRun shell command (saves tokens)
!git diff HEADRun git commands inside session
"fix @auth/login.ts"Natural language + file reference
/model opusSwitch models on the fly mid-task
Custom Commands and Skills
Store prompts as Markdown files, invoke with /name
~/.claude/commands/Global — all projects
.claude/commands/Project-scoped only
.claude/skills/New format — supports auto-invoke
# .claude/commands/review.md
Review this code for bugs,
security issues, and edge cases.
Be concise. Skip style nits.
settings.json — Key Config
// .claude/settings.json
"model": "claude-sonnet-4-20250514",
"permissions": {
"allowedTools": ["Read","Write","Bash(git *)"],
"deny": ["Read(./.env)"]
},
"hooks": {
"PostToolUse": [{
"matcher": "Write(*.py)",
"command": "black $file"
}],
"PostCompact": [{
"command": "echo compacted"
}]
}
GitHub and PR Integration
/install-github-appEnable auto-review of all PRs
Customize the review prompt to keep it focused:
# claude-code-review.yml
direct_prompt: |
Review for bugs and security
issues only. Be concise.
Skip style and nit comments.
MCP Servers and Extensions
claude mcp add <name>Add MCP server to config
claude mcp listShow all configured servers
claude mcp remove <n>Remove a server
GitHub MCP — PRs, issues, repos
Filesystem MCP — Extended access
Postgres MCP — Query DB directly
Browser MCP — Web automation
System Prompt Flags
--append-system-promptAdd to default prompt (recommended)
--system-promptReplace default prompt entirely
--append-system-prompt-fileAppend instructions from a file
--system-prompt-fileReplace prompt with file contents
Use --append to preserve built-in CC capabilities. Use --system-prompt only when you need full control.
More Useful CLI Flags
-n / --name <name>Set a display name for the session
--worktree / -wIsolated git worktree; auto-cleaned if no changes
--from-pr <#>Resume or start a PR-linked session
--effort <level>Set effort: low · medium · high · max
--bareSkip hooks, LSP & plugins — lean scripting mode
--output-formatjson · text · stream-json (use with -p)
💡 --worktree is great for risky refactors — work in isolation, then merge. --bare pairs with --dangerously-skip-permissions for fast, headless CI pipelines.
🔌 Plugins & Background Sessions — NEW (2026)
Plugin Commands
claude plugin install <name>Install from marketplace
claude plugin listShow installed plugins
claude plugin details <name>Inventory + per-session token cost
claude plugin validateValidate plugin manifest
/pluginBrowse & manage in-session
Background Sessions
claude --bg "task"Start detached background session
claude agentsDashboard: all running sessions
claude agents --jsonList sessions as JSON for scripting
Ctrl+TPin session (keeps alive when idle)
/resumeResume background sessions (marked bg)
New Hooks (2026)
PostToolUse — after file write
PreToolUse — before any action
PostCompact — after /compact
SessionStart — on session open
SubagentStop — when agent ends
Notification — custom alerts
✨ Auto Mode — NEW (Research Preview · Mar 2026)
What it is
A middle path between manual approval and --dangerously-skip-permissions. A classifier reviews every tool call before it runs, blocking destructive actions while letting safe ones proceed automatically.
What it blocks
Mass file deletion · sensitive data exfiltration · malicious code execution. If Claude keeps hitting blocks, it eventually prompts the user instead of looping.
How to enable
--enable-auto-modeLaunch flag to turn it on
Shift+TabCycle to auto mode in-session
VS Code / Desktop: Settings → Claude Code → toggle on, then select from the permission mode drop-down. Works with Sonnet 4.6 & Opus 4.6. Available on Team plan now; Enterprise & API coming soon.
⚠️ Auto mode reduces risk vs. --dangerously-skip-permissions but doesn't eliminate it — still recommended to use in isolated/sandboxed environments. The classifier may occasionally allow borderline actions or block benign ones.
Pro Tips — Maximize Productivity
01Use /clear oftenStart each new task fresh. Old context wastes tokens and can confuse Claude with unrelated conversation history.
02Prefer ! for shell commandsType !npm test directly — it bypasses conversational overhead and saves tokens compared to asking Claude to run it.
03Auto-accept mode for safe opsPress Shift+Tab twice to enable auto-accept. Only use for low-risk, well-understood operations.
04Build your CLAUDE.md on day oneRun /init, then edit it. Add build commands, stack details, lint rules, and coding conventions — Claude reads it every session.
05Add hooks to enforce code qualityUse PostToolUse hooks to auto-run formatters (Prettier, Black) and type-checkers after every file write.
06Esc stops Claude, not Ctrl+CPress Esc to pause mid-task without exiting. Double-Esc lets you browse and jump to any previous message in the session.
07Use /compact for long sessionsWhen context grows large, /compact summarizes history and keeps Claude sharp — especially important for complex multi-file tasks.
08Ctrl+V for image pasteCommand+V does not work for images. Use Ctrl+V to paste screenshots directly into the session for visual debugging context.