Your complete quick-reference companion for Claude Code. Power commands, prompt formulas, CLAUDE.md templates, MCP patterns, and daily workflow recipes — everything you need in one bookmark.
# [Project Name] ## What This Is [One paragraph: what the project does, who uses it, tech stack] ## Architecture - [Framework/language] for [backend/frontend/both] - [Database] for storage - Key directories: [/src, /tests, /config - describe each] ## Coding Rules - [Rule 1 - e.g., always use async/await not .then()] - [Rule 2 - e.g., all functions need JSDoc comments] - [Rule 3 - naming convention, e.g., use snake_case for Python] ## DO NOT Touch - [File/dir 1] — [why: e.g., auto-generated, don't edit directly] - [File/dir 2] — [why: e.g., requires security review first] ## How to Run - Tests: [command] - Dev server: [command] - Build: [command]
# Project: [Name] | Last Updated: [Date] ## Project Context - **Purpose:** [What problem this solves, for whom] - **Stack:** [Full tech stack with versions] - **Environment:** [dev/staging/prod setup] - **Team size:** [N engineers], [N month old codebase] ## Directory Structure /src - Application source code /api - REST API routes (Express/FastAPI) /services - Business logic layer (never in routes!) /models - Data models and DB schema /utils - Pure utility functions (no side effects) /tests - Test files (mirror src structure) /migrations - DB migrations (NEVER edit manually) /scripts - Utility scripts for deployment/data tasks ## Critical Conventions ### Code Style - Async: always use async/await (never .then() callbacks) - Error handling: never swallow errors, always propagate or log - Types: strict TypeScript — never use `any` or `!` non-null assertions - Imports: use path aliases (@/services/user, not ../../services/user) ### Business Logic - ALL business logic in /services, NEVER in route handlers - Services must be stateless and independently testable - Database calls only from services (not from routes or models) - Never expose internal IDs directly in API responses ### Database - Use Prisma ORM for all DB operations - Never write raw SQL unless performance-critical (justify in comment) - All schema changes via migrations (npx prisma migrate dev) - Index all foreign keys and frequently-queried columns ## DO NOT EVER - Modify /migrations — these are immutable - Commit secrets, API keys, or credentials to ANY file - Use synchronous file I/O (fs.readFileSync) in request handlers - Skip input validation on any user-supplied data - Make architectural changes without running security tests ## Testing Requirements - Framework: Vitest + supertest for integration - Coverage target: 80% branches on all new code - Required: unit tests for all service functions - Required: integration tests for all API endpoints - Mocks: mock ALL external services (no real API calls in tests) ## How to Run - Dev: npm run dev - Tests: npm test - Test coverage: npm run test:coverage - Lint: npm run lint - Type check: npm run typecheck - DB migrate: npx prisma migrate dev ## MCP Servers Available - database: PostgreSQL read access for debugging - github: Repository management and PR creation ## Team Notes - [Add any context that would help a new engineer understand the most non-obvious things]
pip install mcp (Python)
npm install @modelcontextprotocol/sdk (TypeScript)
Server entry: asyncio.run(stdio_server(server))
Add to ~/.claude/config.json under "mcpServers".
Specify: command, args, env vars.
Test with: claude mcp list
Retryable Error
{"error": true,
"retryable": true,
"message": "Query timed out",
"suggestion": "Add date filter"}
Human-Required Error
{"error": true,
"retryable": false,
"message": "Auth failed",
"suggestion": "Admin: update credentials"}
- name: Claude Security Gate
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
git diff origin/${{ github.base_ref }}..HEAD > diff.txt
RESULT=$(claude --no-interactive "
Security audit this diff for OWASP Top-10 vulnerabilities,
hardcoded secrets, and auth bypass risks.
If ANY critical vulnerability found, output: SECURITY_GATE: FAIL
Otherwise output: SECURITY_GATE: PASS
$(cat diff.txt)
")
echo "$RESULT"
if echo "$RESULT" | grep -q "SECURITY_GATE: FAIL"; then
echo "❌ Security gate failed"
exit 1
fi
| Task | Recommended Model | Reason |
|---|---|---|
| Complex architecture, multi-file refactor | Claude Sonnet 4 / Sonnet 4.5 | Best reasoning for complex tradeoffs |
| Routine bug fixes, simple features | Claude Sonnet 4.5 | Fast + high quality for well-defined tasks |
| CI/CD subagents, repetitive analysis | Claude Haiku 4.5 | 10× cheaper, sufficient for scoped tasks |
| Coordinator agent (multi-agent) | Claude Sonnet 4.5 | Better orchestration decisions |
| Security audit of critical code | Claude Sonnet 4.5+ | Thoroughness worth the cost on high-risk |
| Concept | What It Is | Why It Matters |
|---|---|---|
| CLAUDE.md | Project config file Claude reads at startup — architecture, conventions, forbidden actions | 10× better output with a good CLAUDE.md vs. none |
| Agentic Loop | The observe → plan → act → evaluate cycle Claude runs autonomously | Understanding this helps you write better tasks |
| Plan Mode | Claude proposes implementation plan before starting — you approve or redirect | Critical for complex/high-risk tasks |
| MCP | Model Context Protocol — universal standard for connecting Claude to external tools/data | Makes Claude infinitely extensible to your toolchain |
| Agent SDK | Python/TS library for building Claude agents programmatically in your apps | Enables production multi-agent systems and pipelines |
| Slash Commands | Custom task templates stored as .md files in .claude/commands/ | Turn common tasks into one-keystroke operations |
| Hooks | Functions that intercept tool calls before/after execution | Safety gates, audit logs, PII redaction in agents |
| Context Window | 200K tokens ≈ entire mid-size codebase in a single session | Claude can understand your whole project simultaneously |
| Coordinator/Subagent | Architecture pattern: coordinator orchestrates specialist subagents | Most versatile pattern for complex enterprise workflows |