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.


Example tasks Claude does seamlessly
- Optimize code inside repositories. Run benchmarks and find ways to improve performance.
- Data analysis task: find insights using data about a video streaming platform.
- Generate UI components: improve styling of an app and use the Playwright MCP server to open + control a browser for verification.
- 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.
curl -fsSL https://claude.ai/install.sh | bash
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.
multi‑step implementations
changes affect multiple files or components
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:
- Mention action: mention
@claudein a GitHub comment with a task → Claude Code can make a PR to address it. - Pull request action: create a PR → Claude runs + reviews changes → writes a code review in GitHub.
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.
- PreToolUse (read tool): check if the file is
.env. - Block access if so.
- PostToolUse (write/edit): run
tsc --noEmit. - Pass errors back into Claude.
- 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.