Show Menu
Cheatography

Claude Code Cheat Sheet (DRAFT) by

A reference for working with Claude Code.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

What is Claude Code?

An agentic CLI tool that reads your codebase, edits files, runs shell commands, and manages git workflows. It works across your terminal, VS Code, JetBrains, a desktop app, and the web.
It is not a chat interface that suggests code.
Claude plans work, writes across multiple files, runs tests, and creates PRs. It can take actions you can't undo — permis­sions matter.

Installing Claude

# Recommended (auto-updates)
curl -fsSL https://claude.ai/install.sh | bash

# macOS Homebrew
brew install --cask claude-code

First Run

cd your-project
claude              # interactive session
claude auth login   # if not authenticated
On first run Claude reads your repo and prompts for auth. Run /init inside a session to generate a CLAUDE.md project file.

Claude Code CLI Flags

Session Control
-c
Continue most recent session
-r <na­me>
Resume session by name
--resume <id>
Resume session by ID
--bg
Run session in background
Output and Automation
-p "­pro­mpt­"
Non-in­ter­active, print and exit
--outp­ut-­format json
Machin­e-r­eadable output
--outp­ut-­format stream­-json
Stream JSON as it arrives
--max-­turns N
Limit agentic turns
Tools and Permis­sions
--allo­wed­-tools
Comma-­sep­arated allow list, e.g. Read,Grep
--perm­iss­ion­-mode
default | accept­Edits | auto | bypass­Per­mis­sions
--model <na­me>
Override model for this session
--dang­ero­usl­y-s­kip­-pe­rmi­ssions
DANGER No prompts — CI only

Keyboard Shortcuts

Esc Esc
Interrupt current action and rewind the last message
Ctrl+C
Cancel current generation (keeps history)
Shift+Tab
Cycle permission mode: ask → auto → bypass
Ctrl+B
Push session to backgr­ound; reclaim terminal
@filename
Include a file's contents inline in your message
!`cmd`
Run a bash command and inject output into message
↑ / ↓
Navigate message history
/keybi­ndings
Edit shortcuts — stored in ~/.cla­ude­/ke­ybi­ndi­ngs.json
 

Slash Commands

Context management
/compact
Compress history to free context. Pass a focus hint: /compact keep auth module
/clear
Wipe conver­sation history entirely. Start fresh.
/status
Show context usage, session ID, model, cost
Session navigation
/rename
Name the current session (no arg = auto-name)
/fork
Branch conver­sation at this point (try altern­atives without losing current state)
/resume
Resume a previous session by name or ID
/export
Export conver­sation as plain text
Tools and Config
/model <na­me>
Switch model mid-se­ssion. Takes effect next message.
/doctor
Diagnose auth, config, and connection issues
/init
Generate CLAUDE.md for current project
/schedule
Create a recurring automated task
/help
List all current slash commands
Model Aliases
opus / sonnet / haiku
Short aliases:
/model opus
auto
Claude picks model per task

Planning and Flow Commands

/plan
Ask Claude to produce a plan before writing any code. Review and approve, then Claude executes. Use for any non-tr­ivial change.
/goal
Set a persistent session goal. Claude references it to stay on track across compacts and model switches. Useful for long sessions.
/effort
Set reasoning depth: low | normal | high. Default on Opus 4.8 is high. Lower for speed/­cost, higher for archit­ecture decisions.
/check­point
Save current conver­sation state as a named restore point. Useful before risky tool sequences.
/review
Request a code review of current working state. Add --fix to apply findings immedi­ately.
/workflow
Trigger a dynamic workflow — sequences of steps Claude will walk through. See ~/.cla­ude­/co­mmands/ for custom workflows.
Typical Flow Example:
/goal Refactor the auth module to PSR-12

/plan

# review the plan, press y to approve

# Claude writes code

/compact focus on auth module

/review --fix

Custom Slash Commands

File Locations
.claud­e/c­omm­ands/
Project commands (team-­shared)
~/.cla­ude­/co­mmands/
Personal commands (all projects)
Each .md file becomes a slash command named after the file. Invoked with /filename.
Example: .claud­e/c­omm­and­s/p­r-r­evi­ew.md
Review the current branch diff against main.
List bugs and security issues as a numbered list.
Then summarise in one sentence.
Arguments: $ARGUMENTS
Use
!`git diff main`
in the file body to pre-inject bash output. Use
@path/­to/file
to inline a file. Use
$ARGUMENTS
to accept runtime args:
/pr-review focus on SQL
.
 

CLAUDE.md: Project Instru­ctions

Read at the start of every session. The primary way to give Claude persistent context about your project without repeating yourself.
Locations (in priority order)
./CLAU­DE.md
Project root — committed to repo, shared with team
./.cla­ude­/CL­AUDE.md
Projec­t-l­ocal, can be gitignored
~/.cla­ude­/CL­AUDE.md
Personal global — applies to all projects
What To Put In It
Stack & conven­tions
PHP version, framework, coding standard (PSR-12)
Build & test commands
How to run tests, linter, deploy
Off-limits files
Files Claude should never touch
Project structure
Where things live and why
Behaviour rules
Always write tests, never edit migrations

Example CLAUDE.md snippet

Stack: PHP 8.3, Laravel 11, MySQL 8
Standard: PSR-12. Run: ./vendor/bin/pint
Tests: ./vendor/bin/pest — must pass before commit
Never edit files in /database/migrations/

Headless and Pipe Mode

# Pipe content as context
cat src/Auth.php | claude -p "Find security issues"
git diff main | claude -p "Review this diff"
git log --oneline -10 | claude -p "Write release notes"

# JSON output (includes cost, session ID, turn count)
claude -p "list TODOs" --output-format json | jq .

# Read-only: no file writes or bash
claude -p "explain architecture" \
  --allowed-tools Read,Grep

# Multi-step: reuse session across calls
SID=$(claude -p "analyse test failures" \
  --output-format json | jq -r '.session_id')
claude -p "fix the failures" --resume "$SID"

# Append system prompt for specialised context
claude -p "review errors" \
  --append-system-prompt "You are an SRE expert"
Use -p for scripts and CI. Claude runs the prompt and exits — no intera­ctive session.

Permis­sions and Safety

Permission Modes
default
accept­Edits
auto
bypass­Per­mis­sions
Tool allow/deny in settings
# .claude/settings.json
{
"­per­mis­sio­ns": {
"­all­ow": ["Ba­sh(git:)", "­Rea­d", "Write"],
"­den­y": ["Ba­sh(rm -rf
)"]
}
}
Restrict in CLI
claude --allo­wed­-tools Read,Grep "­review auth"