Mastering Claude Code · ~9 min
Eleven lessons collapse into one reflex: read the symptom in front of you, reach for the surface that fits — and when the job leaves the interactive session, pick SDK, bare mode, or a dynamic workflow on purpose.
claude -p already does. This table makes the cheap
answer the automatic one.The through-line of the whole course: match the surface to the structure of the work, and add machinery only where the task earns it. Below is every lesson as a lookup, then a sharper decision among the three ways to run Claude outside the chat — and a mixed review to prove it stuck.
| Symptom you're staring at | Move | Lesson |
|---|---|---|
| About to let an agent write before you trust its plan | Plan Mode — explore read-only, agree the plan, then let it edit; cheap correction beats expensive rework | L1 |
| One context filling with unrelated subtasks | Delegate to sub-agents and teams — bounded work, clean main context, parallel fan-out | L2 |
| A long run drifting and you're flying blind | Watch it — agent-view plus the monitor tool to steer mid-run instead of after | L3 |
| A rule keeps getting ignored when you "ask nicely" | Hooks — enforce and auto-fix deterministically at PreToolUse / PostToolUse | L4 |
| Babysitting every approval, or want raw speed | Permission modes — auto mode for speed, hard-deny and disallowed-tools for the floor | L5 |
| The team drifts from shared guardrails | Managed settings — ship one drop-in so everyone inherits the same config | L6 |
| A skill underperforms and you keep restarting to fix it | The eval loop — measure against evals, reload mid-session, tighten without a restart | L7 |
| You want always-on custom behavior, packaged | Build a plugin — wire extension points and background monitors | L8 |
| Parallel agents colliding in one repo or monorepo | Worktrees and sparse paths — isolate batch work so agents never collide | L9 |
| Recurring work pinning your machine | Scheduling and cloud routines — move it off your laptop | L10 |
| The job has left the interactive session entirely | Pick the surface — SDK, bare mode, or dynamic workflow (below) | L11 |
The last row is the one this lesson grounds. Once work runs without you driving a session, three surfaces split cleanly by a single question — who holds the loop, and how reproducible does the run need to be?
| You need… | Surface | What carries it |
|---|---|---|
| Claude's agent loop embedded in an app, CI, or product | Agent SDK | query() — an async generator of typed messages; the same runtime as Claude Code, as a library |
| A scripted one-shot call that behaves identically on every machine | --bare flag | claude --bare -p — skips all local config discovery; you pass back only what the task needs |
| To orchestrate dozens-to-hundreds of agents at scale | Dynamic workflow | A script Claude writes and a background runtime executes; intermediate results stay in script variables |
The SDK gives you that loop programmatically: settingSources controls which filesystem
config it reads (CLAUDE.md, skills, hooks), and the omit-default has flipped between releases — so pin a version and
set it explicitly ([] for isolation, ["user","project","local"] for CLI parity). The
--bare flag is the deterministic opposite: it skips hooks, MCP servers, skills, plugins, auto-memory,
and CLAUDE.md discovery, keeps only Bash / read / edit, and is ~14% faster to the first API request — Anthropic has
said it will become the default for -p.
Each surface has a backfire, and they rhyme: reach for the SDK for a single task and you've added
a dependency claude -p already covers; reach for a workflow for linear work one
conversation can hold and you pay token cost with no return — that's a sub-agent job; reach for
--bare when your -p runs are already deterministic and you've mostly added flag noise
for a 14% saving. Workflows are also a research preview (v2.1.154+) with no mid-run sign-off. Match the tool to the
structure, not the ambition.
query() in an app or CI; set settingSources and maxTurns explicitly.ANTHROPIC_API_KEY, add back only what the task needs.Mixed review — the surfaces, plus a spaced recall
Question 1To embed Claude's full agent loop inside a CI pipeline or product, the surface is…
Question 2Because --bare skips OAuth and keychain reads, a bare run must get its auth from…
Question 3A dynamic workflow keeps the orchestrator's context clean by holding intermediate results in…
Question 4A linear task one conversation can comfortably hold should run as…
Question 5 · spaced recall from an earlier lessonIn Plan Mode, before you approve, the agent works…
query() gate into CI, convert a turn-by-turn task into a saved /<name> workflow, or
decide whether --bare is worth it for your existing -p runs. Or revisit any lesson; the
surfaces compound when you use them together.