DEV Community

Cover image for Claude Code Cheatsheet: Commands, Hooks & Subagents
Dev Encyclopedia
Dev Encyclopedia

Posted on • Originally published at devencyclopedia.com

Claude Code Cheatsheet: Commands, Hooks & Subagents

Most developers use Claude Code like a fancy autocomplete. That's maybe 20% of what it can do.

Claude Code is a terminal agent with full project access. It reads files, runs shell commands, commits to git, runs parallel subagents, and enforces rules through lifecycle hooks. Once you know the full feature set, the way you work changes.

I put together a complete reference covering:

  • Every slash command and when to reach for each
  • Keyboard shortcuts worth memorizing (Esc Esc, Ctrl+B, !command)
  • CLAUDE.md — the file that shapes every session
  • Hooks — the rules Claude literally cannot ignore
  • Custom slash commands vs. Skills (and the threshold for choosing)
  • Subagents — how parallel workers cut a 20-min task to 7 min
  • PR review setup with inline GitHub comments

The thing most people miss: CLAUDE.md vs. Hooks

CLAUDE.md is advisory. Claude reads it at session start and follows its instructions roughly 80% of the time. It's the right place for style preferences, stack context, and reminders.

Hooks are deterministic shell scripts. A PreToolUse hook that exits with code 1 stops Claude cold. No exceptions, no model judgment. That's how you block rm -rf, enforce Prettier on every write, and prevent .env files from ever touching a commit.

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{
        "type": "command",
        "command": "echo $CLAUDE_TOOL_INPUT_COMMAND | grep -q 'rm -rf' && exit 1 || exit 0"
      }]
    }]
  }
}
Enter fullscreen mode Exit fullscreen mode

Rule of thumb: CLAUDE.md for guidance, hooks for anything where "most of the time" is not good enough.

Subagents change the math on long tasks

Context windows fill up. In a long session, the earlier parts of your conversation fade from Claude's working memory and output quality drops.

Subagents solve this by offloading work to separate Claude instances with clean, empty context. Claude can run three subagents simultaneously. Code review, test run, and DB migration check in parallel instead of sequentially. Tasks that take 20 minutes in a single session regularly finish in 7.

Full cheatsheet with every command, shortcut, hook type, and subagent config with working examples throughout:

Claude Code Cheatsheet: Commands, Hooks & Subagents — Dev Encyclopedia

The complete Claude Code reference: every slash command, keyboard shortcut, hook, subagent, and CLAUDE.md tip — with real examples for developers.

devencyclopedia.com

Originally published on Dev Encyclopedia

Top comments (0)