Tech Bytes Tech Bytes
Updated March 2026

Claude Code
Cheat Sheet

Every keyboard shortcut, slash command, hook, MCP server setup, and CLAUDE.md tip — in one page. Bookmark it.

40+ commands 15+ shortcuts 8 hook events 20+ MCP servers

Keyboard Shortcuts

15 shortcuts
Esc Essential

Interrupt current response or cancel a running tool. Hit twice to clear input.

Enter or Ctrl+J

Submit your message. Use Shift+Enter for a newline without submitting.

/
Navigation

Navigate message history. Up recalls your previous prompt.

Ctrl+L

Clear terminal display. Context is preserved — different from /clear.

Ctrl+E Useful

Open current input in your $EDITOR (vim, nano, VS Code). Great for long prompts.

Ctrl+C

Cancel the current operation mid-stream. Claude stops generating immediately.

Type /fast
New

Toggle Fast Mode — same Opus model, faster output. Useful for quick iterations.

y / Enter

Approve a tool use request. n to deny. a to approve all remaining.

Slash Commands

25+ commands
/clear Daily use

Wipe conversation context. Use between unrelated tasks to avoid context bleed.

/compact Daily use

Summarize conversation history to free context window. Keeps key facts, drops noise.

/help

Show all available commands and current configuration.

/model

Switch Claude model mid-session. /model opus, /model sonnet.

/review-pr Skill

Review a GitHub PR. Pass the PR number: /review-pr 123

/commit Skill

Auto-generate a commit message from staged changes and commit.

/doctor

Check Claude Code setup health: API key, permissions, MCP status, config.

/status

Show current git status, model, context usage, and active MCP connections.

/settings

Open the interactive settings panel — permissions, model, theme, hooks.

/mcp

List connected MCP servers and their available tools.

/quit

Exit Claude Code cleanly. Also works: /exit

/fast New

Toggle Fast Mode. Faster responses, same Opus model — no quality loss.

CLI Flags & Launch Options

--print / -p Scripting

Non-interactive mode. Pipe output to files or other tools.

bash claude -p "summarize this file" < README.md > summary.txt
--dangerously-skip-permissions Caution

Auto-approve all tool calls. Use only in trusted automation scripts — never on prod.

--model

Start with a specific model.

bash claude --model claude-opus-4-6 claude --model claude-sonnet-4-6
--continue / -c

Resume the most recent conversation. Picks up exactly where you left off.

--resume <session-id>

Resume a specific past session by ID. IDs visible in /status.

--add-dir <path>

Add extra directories to Claude's context beyond the current working directory.

Hooks — Automate Anything

Powerful

Hooks run shell commands on specific Claude Code events. Configured in settings.json under hooks.

~/.claude/settings.json { "hooks": { "PreToolUse": [{ "command": "echo 'Tool: $CLAUDE_TOOL_NAME' >> ~/.claude/tool.log" }], "PostToolUse": [{ "command": "say 'done'" }], "Notification": [{ "command": "terminal-notifier -message '$CLAUDE_NOTIFICATION'" }], "Stop": [{ "command": "afplay /System/Library/Sounds/Glass.aiff" }] } }
PreToolUse Hook

Fires before Claude calls any tool. Env: $CLAUDE_TOOL_NAME, $CLAUDE_TOOL_INPUT. Exit code 2 to block the tool.

PostToolUse Hook

Fires after tool completes. Env: $CLAUDE_TOOL_RESULT. Great for logging, notifications.

Notification

Fires when Claude needs your attention. Env: $CLAUDE_NOTIFICATION. Use to push alerts to Slack, phone, etc.

Stop

Fires when Claude finishes a response. Play a sound, send a webhook, run tests.

UserPromptSubmit New

Fires when you submit a message. Env: $CLAUDE_USER_PROMPT. Use to log every prompt or enforce rules.

SubagentStop

Fires when a spawned sub-agent finishes. Useful in multi-agent orchestration flows.

Practical Hook Recipes

Auto-run tests after every file edit

"PostToolUse": [{ "command": "if [ $CLAUDE_TOOL_NAME = 'Edit' ]; then npm test --silent; fi" }]

Slack alert when Claude finishes

"Stop": [{ "command": "curl -X POST $SLACK_WEBHOOK -d '{\"text\":\"Claude done!\"}'" }]

Block writes to production files

"PreToolUse": [{ "command": "echo $CLAUDE_TOOL_INPUT | grep -q 'prod' && exit 2 || exit 0" }]

Log every prompt to a file

"UserPromptSubmit": [{ "command": "echo \"$(date): $CLAUDE_USER_PROMPT\" >> ~/claude-prompts.log" }]

CLAUDE.md — Your AI Instruction File

Most impactful

Claude reads CLAUDE.md at the start of every session. It's how you give Claude project-specific rules, context, and constraints — permanently, without repeating yourself.

Project-level

/your-repo/CLAUDE.md

Checked in. Shared with team. Git-tracked.

User-level

~/.claude/CLAUDE.md

Personal preferences. Applies to all projects.

Sub-dir level

src/api/CLAUDE.md

Scoped to a subdirectory. Overrides parent.

CLAUDE.md — starter template # Project: MyApp ## Stack - Backend: FastAPI + Python 3.12 - Frontend: React 19 + TypeScript + Tailwind - DB: PostgreSQL 16 via SQLAlchemy - Deploy: AWS Lambda + CloudFront ## Code Style - Use `async/await` everywhere (no sync DB calls) - Snake_case for Python, camelCase for TypeScript - Never use `any` in TypeScript - Max function length: 40 lines ## Rules - Never commit secrets or API keys - Run `pytest` before suggesting a PR - All new endpoints need a docstring + OpenAPI tag - Prefer editing existing files over creating new ones ## Commands - Start dev server: `uvicorn main:app --reload` - Run tests: `pytest tests/ -v` - Lint: `ruff check . && mypy .`

Power Tips

Import other files

Use @path/to/file.md inside CLAUDE.md to pull in other docs dynamically.

Override mid-session

Tell Claude to "ignore the rule about X for this task" — it respects inline overrides.

Memory files

Claude can write to ~/.claude/memory/ to persist facts across sessions automatically.

Git worktrees

Run Claude with isolation: "worktree" in agent calls to work on a clean copy safely.

MCP Servers — Supercharge Claude's Tools

Game changer

MCP (Model Context Protocol) lets Claude talk to external services as native tools. Add servers in ~/.claude/settings.json.

settings.json — MCP config { "mcpServers": { "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_TOKEN": "ghp_..." } }, "postgres": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"] }, "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects"] } } }

GitHub

@modelcontextprotocol/server-github

PRs, issues, repos, commits — Claude can read and write directly.

PostgreSQL

@modelcontextprotocol/server-postgres

Query your DB in natural language. Great for debugging.

Filesystem

@modelcontextprotocol/server-filesystem

Read/write files outside your project directory safely.

Slack

@modelcontextprotocol/server-slack

Read Slack channels, post messages, search history.

Puppeteer

@modelcontextprotocol/server-puppeteer

Control a headless browser. Scrape, test, automate.

Memory

@modelcontextprotocol/server-memory

Persistent knowledge graph across sessions.

Vibe Coding Workflows

Ship faster

🏗️ New Feature in 30 min

  1. 1Describe feature + constraints to Claude
  2. 2/compact after planning, before coding
  3. 3Let Claude implement, review diffs not full files
  4. 4Hook: auto-run tests on every edit
  5. 5/commit → done

🐛 Debug Unknown Bug

  1. 1Paste error + stack trace, say "don't fix yet"
  2. 2Ask Claude to hypothesize 3 root causes first
  3. 3Pick most likely, ask for minimal repro
  4. 4Fix + add regression test
  5. 5/commit with "fix:" prefix

🔍 Explore Unfamiliar Codebase

  1. 1"Give me a high-level map of this repo"
  2. 2"Trace the request from API entry to DB"
  3. 3"What would break if I change X?"
  4. 4Add what you learned to CLAUDE.md

🤖 Automate with Agents

  1. 1Use claude -p "task" in cron/CI pipelines
  2. 2Add --dangerously-skip-permissions for headless
  3. 3Hook on Stop to post results to Slack
  4. 4Use tmux sessions for persistent agents

More dev tools, cheat sheets & how-tos

Weekly. No noise. Unsubscribe any time.