Claude Academy
Sign in

Vault / wiki/301/cheatsheet.md

updated 2026-05-28

CCA-F Cheatsheet

The single-page condensed brain dump. Read every day in the final week.

Domains + weights

  1. Agentic Architecture & Orchestration — 27%
  2. Tool Design & MCP Integration — 18%
  3. Claude Code Configuration & Workflows — 20%
  4. Prompt Engineering & Structured Output — 20%
  5. Context Management & Reliability — 15%

Five agentic patterns

PatternUse when
Prompt chainingSteps known in advance
RoutingMultiple specialized handlers
Parallelization (sectioning / voting)Independent subtasks OR consensus
Orchestrator-workersDynamic decomposition needed
Evaluator-optimizerQuality > speed; iterative refinement

Default: simplest pattern that works. Workflow > agent unless dynamism required.

Tool design rules

  • One tool, one verb.
  • Description = teacher's note: "Use when X, not when Y."
  • Enums > strings; optional > required; default values reduce hallucination.
  • Return short structured output; large blobs → resource URI.
  • Annotate destructive / idempotent / read-only.
  • Errors are structured (is_error: true, type, message).

Error types

  • transient (retry) | permanent (adapt) | validation (model retries) | uncertain (defensive read) | user_declined | unavailable (graceful).

MCP — who decides

  • Tools → model.
  • Resources → application (host attaches).
  • Prompts → user (slash command).

MCP transports

  • stdio = local subprocess.
  • SSE = legacy remote.
  • Streamable HTTP = current remote standard; OAuth 2.1.

Claude Code config precedence

CLI flags > .claude/settings.local.json > .claude/settings.json (shared) > ~/.claude/settings.json (user) > enterprise.

Deny always beats allow. Allow skips confirmation prompt.

CLAUDE.md hierarchy

~/.claude/CLAUDE.md (personal) ← project shared ← project local (gitignored) ← subdir.

Slash command vs Skill vs Subagent

SlashSkillSubagent
Invoked byUser typing /xModel (auto)Model (delegate)
Loaded when idleNoneDescription onlyNone
ContentsPrompt templatePrompt + files + scriptsNew agent w/ own context

Prompt-engineering ladder (in order)

  1. Clear and direct → 2. Few-shot → 3. Let it think → 4. XML tags → 5. Role → 6. Prefill → 7. Chain.

Structured output — three techniques

  1. Force tool use (tool_choice: {type: "tool", name}) — most reliable.
  2. Prefill { or <output>.
  3. Prompt-only — least reliable.

CALM (context mgmt)

  • Cache stable prefixes.
  • Align prefix structure.
  • Limit history.
  • Monitor cache hits + tokens.

Compaction strategies

  • Progressive summarization | State object | Sliding window | Retrieval-on-demand | Subagent delegation.

Prompt-caching mechanics

  • cache_control: {type: "ephemeral"}.
  • 5-min TTL default; 1h tier where available.
  • Up to 4 breakpoints.
  • Cache write ≈ 125% input; cache read ≈ 10%.
  • Pays off after ~2 reuses.
  • Any prefix change invalidates.

Batch API

  • 50% input + output discount.
  • Async, ≤24h SLA.
  • Use custom_id for mapping.
  • Caches inside the batch.
  • For interactive flows: do NOT use batch.

Model choice

WantModel
Best reasoningOpus 4.7 (claude-opus-4-7)
Balanced productionSonnet 4.6 (claude-sonnet-4-6)
Cheap + fastHaiku 4.5 (claude-haiku-4-5-20251001)

Idempotency rules

  • Idempotent → retry safe.
  • Non-idempotent → defensive read first; require user confirm.

Six scenarios — anchors

  1. Support → routing + tools + escalation.
  2. Code-gen Claude Code → CLAUDE.md + plan mode + slash commands.
  3. Research → orchestrator-workers + subagents + provenance.
  4. Dev productivity → MCP heavy + read-only defaults.
  5. CI/CD → --print + narrow allow + hooks.
  6. Extraction → forced tool use + Batch API + validation loop.

Test-day discipline

  • Read each question twice.
  • "Obvious" is usually wrong by one trade-off.
  • When two answers look right, pick the one that respects principles over conditionals, and least privilege over convenience.
  • Flag uncertainties; review at end.

See also