By James Aspinwall, co-written by Alfred Pennyworth (my trusted AI) – March 2, 2026, 09:00
Claude Code is Anthropic’s agentic coding tool that lives in your terminal. It reads your codebase, edits files, runs commands, and manages git – all through natural language. But its real power is in the commands, flags, and configuration system that most developers never fully explore.
This guide covers everything: slash commands, CLI flags, custom skills, hooks, keyboard shortcuts, and real-world workflows. With examples.
Starting a Session
# Interactive session
claude
# Start with a prompt
claude "explain the auth flow in this project"
# Non-interactive (print mode) -- query and exit
claude -p "what does the User module do?"
# Continue last conversation
claude -c
# Resume a named session
claude -r "auth-refactor"
# Interactive session picker
claude --resume
# Pipe content in
cat lib/user.ex | claude -p "find bugs in this code"
# Start with a specific model
claude --model opus
# Start in a git worktree (isolated branch)
claude -w feature-branch
Essential Slash Commands
These are the commands you’ll use daily inside a Claude Code session.
Context Management
/clear Clear conversation history, free up context window
/compact Compress conversation to save context (add instructions to guide what to keep)
/context Visualize context usage as a colored grid -- see how full your window is
/cost Show token usage and cost for this session
/compact is critical for long sessions. When you’re running low on context, it summarizes the conversation while preserving key details. You can guide it:
/compact keep the database schema and auth flow details
Session Management
/resume Resume a previous session (interactive picker)
/rename auth-refactor Name your session for easy resumption
/fork feature-branch Fork conversation at this point
/export conversation.md Export full conversation as text
Named sessions are underrated. When you’re deep in a refactor, /rename it. Tomorrow, claude -r "auth-refactor" picks up right where you left off.
Code Review & Diffs
/diff View uncommitted changes with a diff viewer
/review Full code review of your PR or branch
/security-review Analyze pending changes for security vulnerabilities
/review is especially powerful – it reads the full diff against your base branch and gives structured feedback on correctness, style, edge cases, and potential bugs.
Configuration
/config Open settings interface
/model sonnet Switch models mid-session
/fast Toggle fast mode (same model, faster output)
/doctor Diagnose installation and configuration issues
/init Generate CLAUDE.md for your project
/vim Toggle vim mode for input
/keybindings Edit keyboard shortcuts
/hooks Manage lifecycle hooks
/mcp Manage MCP servers
Navigation
/help Show all available commands
/status Version, model, account info, connectivity
/skills List available custom skills
/stats Usage statistics, session history, streaks
CLI Flags – The Power User’s Toolkit
Permission Modes
# Manual mode -- confirm every action
claude --permission-mode manual
# Auto mode -- Claude runs without asking (careful)
claude --permission-mode auto
# Plan mode -- Claude plans but doesn't execute until you approve
claude --permission-mode plan
# Skip all permission prompts (scripts/CI only)
claude --dangerously-skip-permissions
Tool Restrictions
Control exactly which tools Claude can use:
# Only allow reading and searching -- no edits
claude --tools "Read,Grep,Glob"
# Allow specific bash commands without prompting
claude --allowedTools "Bash(mix test:*)" "Bash(git status)" "Read"
# Block destructive commands
claude --disallowedTools "Bash(rm -rf *)" "Bash(git push --force)"
System Prompt Customization
# Replace the entire system prompt
claude --system-prompt "You are a Go expert. Only suggest Go solutions."
# Append to the default prompt
claude --append-system-prompt "Always write tests for new functions."
# Load from file (print mode)
claude -p --system-prompt-file ./prompts/review.md "review this PR"
Output Formatting
# JSON output for scripting
claude -p --output-format json "list all TODO comments"
# Streaming JSON (for real-time processing)
claude -p --output-format stream-json "explain the architecture"
# Budget cap (print mode)
claude -p --max-budget-usd 0.50 "refactor the auth module"
# Turn limit
claude -p --max-turns 5 "fix the failing test"
Multi-Directory Projects
# Add additional directories Claude can access
claude -A ../shared-lib -A ../config "update the shared types"
Keyboard Shortcuts
The Essentials
| Shortcut | Action |
|---|---|
Esc |
Cancel current generation |
Esc Esc |
Rewind to previous checkpoint |
Ctrl+C |
Interrupt |
Ctrl+D |
Exit |
Ctrl+L |
Clear screen |
Ctrl+O |
Toggle verbose output |
Ctrl+R |
Reverse history search |
Ctrl+G |
Open prompt in external editor ($EDITOR) |
Multiline Input
| Shortcut | Action |
|---|---|
Shift+Enter |
New line (iTerm2, WezTerm, Ghostty, Kitty) |
\ + Enter |
New line (works in all terminals) |
Option+Enter |
New line (macOS default) |
Model & Mode Switching
| Shortcut | Action |
|---|---|
Alt+P / Option+P |
Switch model |
Alt+T / Option+T |
Toggle extended thinking |
Shift+Tab / Alt+M |
Cycle permission modes |
Task Management
| Shortcut | Action |
|---|---|
Ctrl+T |
Toggle task list |
Ctrl+B |
Background running task |
Ctrl+F Ctrl+F |
Kill all background agents |
Custom Keybindings
Edit ~/.claude/keybindings.json (or run /keybindings):
{
"bindings": [
{
"context": "Chat",
"bindings": {
"ctrl+e": "chat:externalEditor",
"ctrl+shift+k": "chat:submit"
}
},
{
"context": "Global",
"bindings": {
"ctrl+k ctrl+s": "app:exit"
}
}
]
}
Chord bindings (like ctrl+k ctrl+s) let you create two-key sequences for less common actions.
Custom Skills – Your Own Slash Commands
Skills are the most powerful customization point. They’re markdown files that define reusable commands.
Where Skills Live
~/.claude/skills/<name>/SKILL.md # Personal (all projects)
.claude/skills/<name>/SKILL.md # Project (shared via git)
Anatomy of a Skill
Create .claude/skills/test-module/SKILL.md:
---
name: test-module
description: Generate comprehensive tests for an Elixir module
user-invocable: true
argument-hint: [module-name]
allowed-tools: Read, Grep, Glob, Write
model: sonnet
---
Generate ExUnit tests for the module specified by $ARGUMENTS.
1. Read the module source file
2. Identify all public functions and their specs
3. Generate test cases covering:
- Happy path for each function
- Edge cases and error conditions
- Permission checks (if AccessControlled)
4. Write tests to test/<module>_test.exs
5. Follow existing test patterns in the project
Now /test-module User generates tests for the User module.
Skill with Subagent Isolation
---
name: security-scan
description: Scan codebase for security issues
context: fork
agent: Explore
---
Analyze all files in lib/ for:
- SQL injection (raw string interpolation in queries)
- XSS (unescaped user input in HTML)
- Command injection (user input in System.cmd)
- Hardcoded secrets (API keys, passwords)
- Insecure deserialization
Report findings with file, line, severity, and fix.
The context: fork runs the skill in an isolated subagent so it doesn’t pollute your main conversation.
Skill with Dynamic Context
---
name: deploy-check
description: Pre-deployment verification
---
Check deployment readiness:
1. Run tests: `!mix test`
2. Check for compiler warnings: `!mix compile --warnings-as-errors`
3. Review git status: `!git status`
4. Compare with main: `!git diff main...HEAD --stat`
Report any blockers.
The !command syntax injects live command output into the skill’s context.
Hooks – Automate Your Workflow
Hooks run shell commands, HTTP calls, or AI evaluations at specific lifecycle points.
Configure in settings.json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "echo 'Tool: $TOOL_NAME' >> ~/.claude/tool-log.txt"
}
]
}
],
"Notification": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "printf '\\a'"
}
]
}
],
"Stop": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "say 'Done'"
}
]
}
]
}
}
Hook Events
| Event | When | Can Block? |
|---|---|---|
SessionStart |
Session begins | No |
UserPromptSubmit |
You submit a prompt | Yes (exit 2) |
PreToolUse |
Before a tool runs | Yes (exit 2) |
PostToolUse |
After a tool succeeds | No |
PostToolUseFailure |
After a tool fails | No |
Notification |
Notification sent | No |
Stop |
Claude finishes responding | No |
PreCompact |
Before context compaction | No |
Blocking Hook Example
Prevent dangerous commands:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "if echo \"$TOOL_INPUT\" | grep -q 'rm -rf'; then echo 'Blocked: rm -rf' >&2; exit 2; fi"
}
]
}
]
}
}
Exit code 2 blocks the action. The stderr message is fed back to Claude as feedback.
AI-Powered Hooks
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "prompt",
"prompt": "Review this edit for security issues. If you find any, respond with BLOCK and explain why."
}
]
}
]
}
}
The prompt type runs a single-turn Claude evaluation. The agent type runs a multi-turn subagent for deeper verification.
MCP Server Configuration
MCP servers extend Claude Code with external tools.
# Add an HTTP MCP server
claude mcp add --transport http my-server https://my-server.com/mcp
# Add a stdio server (local process)
claude mcp add --transport stdio sqlite -- npx -y @anthropic/mcp-server-sqlite db.sqlite
# Add with auth
claude mcp add --transport http github https://api.githubcopilot.com/mcp/ \
--header "Authorization: Bearer ghp_xxxx"
# Scopes
claude mcp add --scope user ... # All your projects
claude mcp add --scope project ... # This project (shared via .mcp.json)
claude mcp add --scope local ... # This project, private (default)
# List and manage
claude mcp list
claude mcp get my-server
claude mcp remove my-server
CLAUDE.md – Project Instructions
The .claude/CLAUDE.md file is your project’s instruction manual for Claude. Run /init to generate one, or write it manually.
## Architecture
- Elixir OTP application with SQLite persistence
- See docs/architecture.md for the full diagram
## Conventions
- Use `{:ok, value}` or `{:error, reason}` at API boundaries
- GenServers accessed by registered name, not pid
- Each module owns its own Sqler instance
## Git
- Always ask before committing
- Write changelog before each commit
## Terms
- "singleton" = registered long-lived GenServer
- "router" = lib/my_mcp_server_router.ex
Claude reads this at the start of every session. Keep it concise – it counts against your context window.
Real-World Workflows
The Commit Flow
1. Write code with Claude
2. /diff -- review what changed
3. /review -- get AI code review
4. "commit these changes" -- Claude stages, writes message, commits
5. "create a PR" -- Claude pushes and creates PR via gh
Debug a Failing Test
claude "mix test test/user_test.exs is failing, fix it"
Claude reads the test, reads the source, identifies the mismatch, and fixes it. If the fix requires understanding more context, it explores the codebase automatically.
Refactor Across Files
claude "rename the `get_user` function to `find_user` everywhere in the codebase"
Claude greps for all usages, updates each file, and verifies the rename doesn’t break anything.
Batch Operations (Parallel Agents)
/batch "add @moduledoc to every module in lib/ that's missing one"
This spawns 5-30 parallel agents in isolated worktrees, each handling a subset of files. Each agent creates its own PR.
Security Audit
/security-review
Analyzes all pending changes for injection vulnerabilities, auth issues, data exposure, and insecure patterns.
Non-Interactive Scripting
# CI/CD: check for TODO comments
claude -p --output-format json "list all TODO and FIXME comments with file and line number" | jq '.result'
# Generate changelog from git log
git log --oneline v1.0..HEAD | claude -p "write a changelog from these commits"
# Validate JSON schema
claude -p --json-schema '{"type":"object","properties":{"valid":{"type":"boolean"},"issues":{"type":"array","items":{"type":"string"}}}}' \
"review config.json for issues"
Multi-Model Workflow
# Start with fast model for exploration
claude --model haiku
# In session, switch to powerful model for complex work
/model opus
# Or toggle fast mode for the same model
/fast
Settings Quick Reference
Permission Rules (settings.json)
{
"permissions": {
"allow": [
"Bash(mix test:*)",
"Bash(git status)",
"Bash(git diff:*)",
"Read",
"Glob",
"Grep"
],
"deny": [
"Bash(rm -rf *)",
"Bash(git push --force:*)",
"Bash(git reset --hard:*)"
]
}
}
Environment Variables
{
"env": {
"ENABLE_LSP_TOOL": "1",
"MIX_ENV": "test"
}
}
Command Cheat Sheet
| What You Want | Command |
|---|---|
| Start session |
claude |
| Quick answer |
claude -p "question" |
| Continue last |
claude -c |
| Clear context |
/clear |
| Save context |
/compact |
| Check usage |
/cost |
| Review code |
/review |
| Security check |
/security-review |
| View changes |
/diff |
| Switch model |
/model opus or Alt+P |
| Name session |
/rename my-feature |
| Resume session |
claude -r "my-feature" |
| Fork conversation |
/fork experiment |
| Export chat |
/export notes.md |
| Check health |
/doctor |
| Cancel generation |
Esc |
| Undo last |
Esc Esc |
| New line |
Shift+Enter or \ + Enter |
| External editor |
Ctrl+G |
| Verbose mode |
Ctrl+O |
Further Reading
- Claude Code CLI Reference
- Skills Documentation
- Hooks Guide
- awesome-claude-code – community skills, hooks, and configs
- claude-code-showcase – example configurations
Built with Claude Code, documented by Claude Code. It’s turtles all the way down.