Claude Code in Action Cheatsheet

Some files, features, and shortcuts to keep in mind when using Claude Code (from Anthropic's Course 'Claude Code in Action').

What is Claude Code?

Claude Code is a highly agentic coding environment that runs directly in your terminal. You give it natural‑language tasks, and it can read your repo, edit files, run commands, and orchestrate multi‑step workflows.

Coding assistant
Tools

Example tasks Claude does seamlessly

  1. Optimize code inside repositories. Run benchmarks and find ways to improve performance.
  2. Data analysis task: find insights using data about a video streaming platform.
  3. Generate UI components: improve styling of an app and use the Playwright MCP server to open + control a browser for verification.
  4. GitHub integration: view and run code, and create comments, commits, and PRs.
    Example: Claude Review catching security issues.

Set‑up instructions

Set‑up command lines. Run Claude in terminal after install.

MacOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | bash
Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Files to be aware of

  • claude.md — auto‑generated project summary + shared instructions.
  • claude.local.md — your personal, repo‑specific custom instructions.
  • ~/.claude/CLAUDE.md — global defaults for all projects on your machine.
  • settings.local.json — required permissions + hook definitions.

Adding context

  • /init: scans codebase, creates a summary, and writes that to claude.md (included on every request).
  • Shift + Tab: auto‑accept file changes.
  • #: add following text to memory.
    Example: "#Use comments sparingly."
  • @: add file to context.
  • Ctrl + V: paste a screenshot into context.
  • Shift + Tab + Tab: planning mode.
  • think / think more / think a lot / think longer / ultrathink: cause Claude to think more.
Planning
Thinking
broad understanding of codebase needed
multi‑step implementations
changes affect multiple files or components
complex logic problems
debugging difficult issues
algorithmic challenges

Controlling context

  • Esc: interrupt Claude.
  • Esc + Esc: rewind a conversation or skip over intermediate parts (return to checkpoint).
  • /compact: summarize all information in context.
  • /clear: clear all of the context.

If Claude Code keeps making the same mistake (like asking about a missing file), add the instruction into memory with #.

Custom commands

Custom commands automate tasks you do frequently.

  • How: add a command inside .claude/commands/ex1.md (can take string arguments).
  • Example: Audit and update outdated packages — run npm audit,npm audit fix, then run tests to verify nothing broke.

MCP servers

Example instruction:

claude mcp add playwright npx @playwright/mcp@latest
  • Playwright lets Claude navigate a real browser.
    Example: Claude creates UI/UX → uses Playwright to open browser + screenshot UI → re‑evaluate and modify styling.

GitHub integration

For set‑up: /install-github-app

What you can do in GitHub:

  1. Mention action: mention @claude in a GitHub comment with a task → Claude Code can make a PR to address it.
  2. Pull request action: create a PR → Claude runs + reviews changes → writes a code review in GitHub.
You can customize review steps (e.g., use Playwright MCP for testing a PR).

Hooks

Hooks allow automatic interjections within the agent’s workflow. Configure in settings.json.

  • PreToolUse: triggered before Claude uses a tool.
  • PostToolUse: triggered after Claude uses a tool.
Hook example #1: Prevent tool from reading .env
  • PreToolUse (read tool): check if the file is .env.
  • Block access if so.
Hook example #2: Catch Type Errors
  • PostToolUse (write/edit): run tsc --noEmit.
  • Pass errors back into Claude.
Hook example #3: Query deduplication prevention
  • PreToolUse (write/edit): scan ./queries.
  • If the query already exists, report results back to Claude instead of rewriting.

SDK

The SDK helps you run Claude Code programmatically from within your own applications and scripts. Handy for integrating Claude into larger pipelines or tools.

Two‑column cheatsheet layout with deeper orange headers.