Quick Reference

A dense, scannable cheat sheet of commands, shortcuts, patterns, and troubleshooting tips. Bookmark this page for fast lookups.

Essential Slash Commands

Type these directly into the Claude Code prompt. All commands start with /.

CommandDescription
/helpShow all available commands and usage tips
/clearClear conversation history and start fresh (keeps CLAUDE.md context)
/compactCondense the conversation to save context window space
/costShow current session token usage and cost breakdown
/doctorRun diagnostic checks on your Claude Code installation
/initCreate a CLAUDE.md file for the current project with sensible defaults
/loginSwitch accounts or re-authenticate
/logoutLog out of your current session
/memoryOpen and edit the project CLAUDE.md directly
/modelSwitch between available Claude models mid-session
/permissionsView and manage tool permissions (allow/deny rules)
/reviewReview pending file changes before accepting them
/statusShow current session info: model, project, context usage
/terminal-setupConfigure terminal integration (shell, theme, key bindings)
/vimToggle vim keybindings for the input prompt

Keyboard Shortcuts

These shortcuts work in the Claude Code input prompt.

ShortcutAction
EscapeInterrupt Claude while it is generating a response
Ctrl + CCancel the current input or running command
Ctrl + DExit Claude Code (end session)
Ctrl + LClear the terminal screen (keeps conversation history)
Up / DownNavigate through your previous prompts
Shift + EnterInsert a newline in the input (multi-line prompt)
TabAutocomplete file paths and slash commands
EnterSend the current prompt to Claude
Permission Shortcuts
When Claude asks for permission to run a tool, you can respond with y (yes once), n (deny), or a (always allow this tool for the session).

Common Patterns

Copy-and-adapt these prompt patterns for everyday tasks.

Explain Code

Explain what src/services/auth.ts does. Focus on the token
refresh logic and how it handles expired sessions.

Find and Fix Bugs

Users are reporting 500 errors on POST /api/orders. Check
the route handler in src/routes/orders.ts, the validation
logic, and the database query. Find the bug and fix it.

Write Tests

Write unit tests for src/utils/formatCurrency.ts. Cover
edge cases: negative numbers, zero, very large numbers,
different locales. Use the testing patterns from
tests/utils/formatDate.test.ts as a reference.

Refactor

Refactor src/components/Dashboard.tsx. It's 400 lines and
does too much. Extract the chart section into a DashboardChart
component and the stats section into DashboardStats. Keep all
existing functionality and tests passing.

Code Review

Review the staged changes (git diff --cached). Look for:
bugs, security issues, performance problems, missing error
handling, and deviations from our coding standards. Be specific
about line numbers and suggest fixes.

Generate Documentation

Generate JSDoc comments for all exported functions in
src/services/. Don't change any logic -- only add
documentation. Include parameter descriptions, return types,
and a brief example for complex functions.

Git Operations

# Commit with a good message
Commit my staged changes with a descriptive message.

# Create a PR
Create a PR for this branch. Summarize all changes since
we branched from main.

# Resolve merge conflicts
There are merge conflicts after rebasing on main. Resolve
them, keeping our branch's logic but accepting main's
structural changes.

Project Scaffolding

Create a new API endpoint POST /api/invitations. It should:
- Accept { email, role } in the body
- Validate the email and role (admin, member, viewer)
- Check the user doesn't already exist
- Create an invitation record in the database
- Send an invitation email via the existing email service
- Return 201 with the invitation object
Follow the patterns in src/routes/users.ts.

CLAUDE.md Template

Copy this template as a starting point for your project's CLAUDE.md file. Customize it to match your project's conventions.

# Project: [Your Project Name]

## Overview
[One-sentence description of what this project does]

## Tech Stack
- Language: TypeScript
- Framework: Next.js 14 (App Router)
- Database: PostgreSQL via Drizzle ORM
- Styling: Tailwind CSS
- Testing: Vitest + Testing Library
- Package Manager: pnpm

## Project Structure
- src/app/         → Next.js pages and routes
- src/components/  → Reusable React components
- src/lib/         → Shared utilities and helpers
- src/services/    → Business logic and API clients
- src/db/          → Database schema and migrations

## Coding Standards
- Use functional components with hooks (no class components)
- Prefer named exports over default exports
- Use TypeScript strict mode -- no `any` types
- Error handling: always use try/catch with typed errors
- Imports: use @/ path aliases, group by external/internal

## Testing Requirements
- All new functions need unit tests
- Test files go next to source: foo.ts → foo.test.ts
- Use `describe/it` blocks with clear test names
- Mock external services, never hit real APIs in tests
- Run: `pnpm test` (unit), `pnpm test:e2e` (integration)

## Common Commands
- `pnpm dev`        → Start dev server on port 3000
- `pnpm build`      → Production build
- `pnpm test`       → Run unit tests
- `pnpm lint`       → ESLint + Prettier check
- `pnpm db:migrate` → Run pending database migrations
- `pnpm db:seed`    → Seed database with test data

## Important Notes
- Never commit .env files or secrets
- The /api/admin/* routes require admin auth middleware
- Database migrations must be backward-compatible
- Use the logger from src/lib/logger.ts (not console.log)
Keep It Updated
Your CLAUDE.md is only useful if it reflects reality. Update it when you add new dependencies, change conventions, or restructure the project. Run /memory to edit it quickly from within a Claude session.

CLI Flags Reference

Flags you can pass when launching claude from your terminal.

FlagDescription
-p, --printNon-interactive mode: run a prompt and print the result (no TUI)
--model <name>Choose a specific model (e.g., claude-sonnet-4-20250514)
--allowedTools <list>Restrict which tools Claude can use (comma-separated)
--resume <id>Resume a previous conversation by session ID
--continueContinue the most recent conversation
--output-format <fmt>Set output format: text, json, or stream-json
--verboseShow detailed logging (useful for debugging)
--versionPrint the installed Claude Code version

Troubleshooting

Common issues and how to resolve them.

Authentication Errors

Symptom: "Authentication failed" or "Invalid API key" messages.

  • Run /login to re-authenticate
  • Check that your API key is still valid in your Anthropic dashboard
  • If using an organization key, verify your access has not been revoked
  • Run /doctor to diagnose configuration issues

Context Window Full

Symptom: Claude stops understanding earlier parts of the conversation or gives inconsistent answers.

  • Run /compact to compress the conversation history
  • Run /cost to check your current token usage
  • Start a new session with /clear if the context is too polluted
  • For large codebases, point Claude to specific files instead of asking it to scan everything

Slow Responses

Symptom: Claude takes a long time to respond or seems to hang.

  • Check your internet connection -- Claude Code requires a stable connection
  • Large file operations take longer; be patient or scope the request to fewer files
  • Press Escape to interrupt and rephrase with a narrower scope
  • Run /status to check if a background process is still running

Permission Denied Errors

Symptom: Claude cannot read or write files, or tool calls are blocked.

  • Run /permissions to review your current tool permission rules
  • Check that Claude Code has access to the project directory (file system permissions)
  • If you previously denied a tool, you may need to reset permissions or start a new session
  • On macOS, check System Settings > Privacy & Security for terminal access

Wrong Files Edited

Symptom: Claude edited a file you did not intend it to modify.

  • Use git diff to see exactly what changed
  • Undo with git checkout -- path/to/file for specific files
  • Be more explicit about which files to modify in your next prompt
  • Use --allowedTools to restrict write access to specific paths

Installation Issues

Symptom: claude command not found or crashes on startup.

  • Ensure Node.js 18+ is installed: node --version
  • Reinstall: npm install -g @anthropic-ai/claude-code
  • Check your PATH includes the npm global bin directory
  • On macOS with Homebrew Node: try npx @anthropic-ai/claude-code as a quick test
  • Run claude /doctor for a full diagnostic report
When in Doubt
If you encounter an issue not listed here, run /doctor first. It checks your installation, authentication, permissions, and network connectivity. Share the output when asking for help.

Further Resources

Deepen your Claude Code knowledge with these resources:

  • Official Documentation -- docs.anthropic.com/en/docs/claude-code -- comprehensive reference for all features and APIs
  • Claude Code GitHub -- github.com/anthropics/claude-code -- source code, issue tracker, and release notes
  • Anthropic Cookbook -- github.com/anthropics/anthropic-cookbook -- practical examples and integration patterns
  • Prompt Engineering Guide -- docs.anthropic.com/en/docs/build-with-claude/prompt-engineering -- techniques for writing more effective prompts
  • Anthropic Discord -- community discussions, tips from other users, and direct support from the team
  • Keyset -- keyset.dev -- host, schedule, and add human-in-the-loop routing to your Claude Code agents
Keep Learning
Claude Code is actively developed with frequent updates. Check the release notes regularly for new features, and run npm update -g @anthropic-ai/claude-code to stay on the latest version.