01
Slash commands
14 ESSENTIAL /init Generate a fresh CLAUDE.md from your codebase
/clear Reset conversation context · start fresh, keep CLAUDE.md
/compact Compress the conversation to free context tokens
/agents List + manage sub-agents for the project
/mcp List connected MCP servers · reconnect on hang
/hooks Open settings to configure event hooks
/model Switch between Opus / Sonnet / Haiku
/permissions Manage tool allow/deny lists for the project
/cost Show token + API cost for current session
/login Re-authenticate with Anthropic credentials
/config Open Claude Code settings (theme, model, etc.)
/help List all slash commands available now
/review Review a pull request (built-in skill)
/security-review Security audit of pending changes (built-in skill)
PRO TIP
User-installed skills (in ~/.claude/skills/) appear as slash commands too. Anything with a name: in its frontmatter becomes /skill-name.
02
Keyboard shortcuts
IN-SESSION ⇧+⏎ Newline in input (without sending)
⏎ Send message
⌃+C Cancel running tool · interrupt response
⌃+D Exit session cleanly
⌃+R Reverse-search prompt history
⌃+O Show full compression summary
!cmd Run a shell command directly (without asking)
↑ ↓ Navigate prompt history
03
CLI flags
LAUNCH OPTIONS claude -p "..." Print mode — single-shot non-interactive call · ideal for scripts
--allowedTools Whitelist tools (e.g. "Bash,Read,Edit") for the run
--output-format Set output format · json, stream-json, text
--model Force a specific model · claude-opus-4-7, claude-sonnet-4-6
--mcp-config Point to a custom MCP server config JSON
--resume Resume a prior session from a saved JSONL
--dangerously-skip-permissions Bypass tool-permission prompts · use carefully in CI only
cat file | claude -p Pipe stdin into the prompt · great for transforming files
PATTERN claude -p "audit this branch" --allowedTools "Bash,Read,Grep" --output-format json — gives you a structured audit you can pipe into the next step.
04
Hooks · event-triggered shell
5 EVENTS PreToolUse Fires before any tool runs · gate writes, block git push, validate input
PostToolUse Fires after a tool · auto-lint, audit log, format on save
Notification Fires when Claude sends a notification · pipe to your DND or terminal-notifier
Stop Fires when Claude finishes a turn · summarize, git-commit, log timing
SubagentStop Fires when a sub-agent completes · roll up results, notify parent
// .claude/settings.json — auto-lint HTML after every Write
{
"hooks": {
"PostToolUse": [{
"matcher": "Write|Edit",
"hooks": [{
"type": "command",
"command": "~/scripts/lint-html.sh"
}]
}]
}
}
05
MCP servers · plugins for Claude
CORE PATTERN /mcp List connected servers · reconnect if a transport wedges
claude mcp add Add a server · claude mcp add my-server -- npx my-mcp-server
claude mcp list Show all configured MCP servers + their commands
claude mcp remove Remove a server config (doesn't uninstall the package)
GOTCHA
Some MCP transports wedge silently after the first tool call. If subsequent calls hang >60s, run /mcp to reconnect.
06
Sub-agents · parallel work
SPECIALIZED CONTEXT general-purpose Full tool access · complex multi-step tasks
Explore Fast read-only search · find files / grep / answer "where is X"
Plan Designs an implementation plan · no code-writing tools
claude-code-guide Q&A about Claude Code features, hooks, MCP, SDK
WHEN TO USE
Spawn sub-agents for: broad codebase exploration (>3 search queries), parallel content generation, audit + fix pipelines. Don't spawn one for trivial lookups — that's overhead.
07
Headless mode
AUTOMATION # One-shot task
claude -p "generate this week's content schedule" # Pipe input
cat article.md | claude -p "convert this to an X thread" # Tool-restricted
claude -p "audit the SEO" --allowedTools "Read,Glob,Grep" # JSON output for downstream pipes
claude -p "list todos" --output-format json | jq '.todos[]' # Cron-ready
0 6 * * 1-5 cd /path/to/proj && claude -p "daily brief" --allowedTools "Bash,Read" > brief-$(date +%F).md
08
CLAUDE.md hierarchy
PROJECT INTELLIGENCE
~/.claude/CLAUDE.md // global · all projects
~/Developer/.../proj/CLAUDE.md // repo root (committed)
~/Developer/.../proj/.claude/CLAUDE.md // local (gitignored ok)
~/Developer/.../proj/subdir/CLAUDE.md // directory-specific scope
CASCADE
All applicable CLAUDE.md files load in scope order — most specific wins on conflicts. Add a subdir/CLAUDE.md for rules that only apply within that subdir.
09
Skills · reusable prompts
~/.claude/skills/ --- name: my-skill description: One-line summary · used for auto-triggering --- # Instructions for Claude
Steps to perform when invoked...
PATTERNS
Single-file (name.md) or directory (name/SKILL.md) both work. Invoke as /name. user-invocable: true in frontmatter forces manual invocation only.
10
Permissions
TOOL ALLOWLIST // .claude/settings.json — least-prompt setup
{
"permissions": {
"allow": [
"Bash(git status:*)",
"Bash(git diff:*)",
"Bash(npm test:*)",
"Read(./**)",
"WebFetch(domain:vercel.com)"
],
"deny": [
"Bash(rm -rf:*)",
"Bash(git push --force:*)"
]
}
}
11
Escape hatches
WHEN STUCK /clear Conversation gone weird? Reset context, keep CLAUDE.md
/compact Running long? Compact to summary + recent turns
/mcp MCP server wedged? Reconnect
⌃ + C Tool stuck? Cancel · resume on next message
⌃ + O Confused about state? Show compression summary
claude --resume Session crashed? Resume from saved JSONL
12
Gotchas
LEARNED THE HARD WAY ~/Desktop iCloud-synced · file ops throttle. Keep code in ~/Developer/
git worktrees Background sessions REQUIRE a worktree before edits. Use EnterWorktree
--no-verify Never skip git hooks unless explicitly asked · fix root cause instead
cd everywhere Prefer absolute paths over cd · stay in cwd, use git -C
commit msgs Use HEREDOC for multi-line · git commit -m "$(cat <<'EOF' ... EOF)"