Skip to content

Claude Code guide in three levels, Beginner to Advanced: hands-on lessons with checked exercises, every volatile fact cited to its source. Independent community guide.

Refine every lesson and capstone for Claude Code v2.1.308, dry-run at that version (#143)

Wesam Abousaid676831f9dbd3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 503f90c..5caaebf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,9 +4,9 @@ Editions of this guide, newest first. An edition is tagged `vYYYY.MM`, and a cor
## Unreleased
-Baseline: Claude Code v2.1.292 (stable), frozen on 2026-10-15.
+Baseline: Claude Code v2.1.308 (stable), frozen on 2026-10-24.
-Every change in the next edition is verified against this version, the `stable` dist-tag of [`@anthropic-ai/claude-code`](https://www.npmjs.com/package/@anthropic-ai/claude-code?activeTab=versions) on 2026-10-15. It stays frozen until the edition ships, unless a later `stable` release removes, renames or changes the default of something a lesson teaches.
+Every change in the next edition is verified against this version, the `stable` dist-tag of [`@anthropic-ai/claude-code`](https://www.npmjs.com/package/@anthropic-ai/claude-code?activeTab=versions) on 2026-10-24. It stays frozen until the edition ships, unless a later `stable` release removes, renames or changes the default of something a lesson teaches. It moved from v2.1.292 because v2.1.302 changed the permission mode a `claude -p` run starts in when nothing sets one ([CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#21302)).
## v2026.11 - 2026-10-23
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c7f2365..8e3bd46 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -256,7 +256,7 @@ The guide is organized as lessons in three levels: Beginner, Intermediate and Ad
### Lessons
-A lesson takes 10 to 20 minutes and moves the reader one step toward one can-do statement of its level. Every lesson has this shape, in this order:
+A lesson takes 15 to 25 minutes and moves the reader one step toward one can-do statement of its level. Every lesson has this shape, in this order:
1. An H1 with the lesson title, as the first line.
2. One `<sub>` header line under it: the level in bold, the position ("Lesson N of M"), "about N minutes", Needs (links to earlier lessons), and [the stamp](#the-stamp).
@@ -265,7 +265,7 @@ A lesson takes 10 to 20 minutes and moves the reader one step toward one can-do
- **You need:** earlier lessons, the environment, and where to practice. A variant callout (native Windows, a plan difference) goes here, at most one per variant.
- **The idea:** the working model in about 150 words at most, plus the lesson's one optional diagram.
- **Worked example:** numbered steps on a realistic task, with real commands and the observable state after each step.
- - **Your turn:** the exercise. Beginner repeats the example with exact steps; Intermediate finishes or fixes a partial file; Advanced gets a brief and acceptance criteria.
+ - **Your turn:** the exercise: a new decision on the same skill, never a repeat of the Worked example. Beginner gives exact steps; Intermediate finishes or fixes a partial file; Advanced gets a brief and acceptance criteria.
- **Check:** a task list of observable criteria, with any ready-made test it needs; then the `npm run check -- <id>` line where a check exists (core lessons and capstones, not Electives); then at most one "if not" diagnosis per tested item.
4. Optional slots: **Watch out** (at most 3 bullets: safety, then cost, then gotchas) and **Go further** (at most 3 links).
5. A footer: the `Sources:` line; previous, level index and next; one `Topic:` link; and "Stuck on this lesson?".
diff --git a/README.md b/README.md
index 4bcba05..80d604a 100644
--- a/README.md
+++ b/README.md
@@ -65,7 +65,7 @@ You'll shape Claude Code to your project with skills, hooks, subagents, MCP and
### Advanced
**Ready if** you can write a project skill, enforce a rule with a hook, delegate to a subagent and connect an MCP server.\
-You'll run Claude Code in parallel, unattended in CI, and for a team, within limits you set. About 3 hours 20 minutes, plus run time: 7 lessons, a capstone and 5 Electives.\
+You'll run Claude Code in parallel, unattended in CI, and for a team, within limits you set. About 4 hours, plus run time: 7 lessons, a capstone and 5 Electives.\
**[Start Advanced](docs/advanced/README.md)**
<a id="-whats-inside"></a><a id="-reading-tips"></a>
@@ -84,7 +84,7 @@ You'll run Claude Code in parallel, unattended in CI, and for a team, within lim
**Advanced:** [Level index](docs/advanced/README.md) · [Parallel sessions with worktrees](docs/advanced/01-parallel-sessions.md) · [Choose an orchestration pattern](docs/advanced/02-orchestration-patterns.md) · [Run and save a dynamic workflow](docs/advanced/03-dynamic-workflows.md) · [Script Claude Code with `claude -p`](docs/advanced/04-headless.md) · [GitHub Actions](docs/advanced/05-github-actions.md) · [Share your setup with a team](docs/advanced/06-share-your-setup.md) · [Put bounds on autonomous runs](docs/advanced/07-bounded-runs.md) · [Capstone](docs/advanced/capstone.md) · [Beyond this guide](docs/advanced/beyond-this-guide.md)
-**Advanced Electives:** [Agent teams](docs/advanced/electives/agent-teams.md) · [Agent view](docs/advanced/electives/agent-view.md) · [`/goal`, `/loop` and routines](docs/advanced/electives/goal-loop-routines.md) · [Testing and publishing a plugin](docs/advanced/electives/publish-a-plugin.md) · [Dev containers](docs/advanced/electives/dev-containers.md)
+**Advanced Electives:** [Agent teams](docs/advanced/electives/agent-teams.md) · [Agent view](docs/advanced/electives/agent-view.md) · [`/loop` and cloud scheduled tasks](docs/advanced/electives/goal-loop-routines.md) · [Testing and publishing a plugin](docs/advanced/electives/publish-a-plugin.md) · [Dev containers](docs/advanced/electives/dev-containers.md)
**Topics:** [All topics](docs/topics/README.md) · [Permissions and safety](docs/topics/permissions-and-safety.md) · [Memory and context](docs/topics/memory-and-context.md) · [Models, effort and cost](docs/topics/models-effort-and-cost.md) · [Skills](docs/topics/skills.md) · [Hooks](docs/topics/hooks.md) · [Subagents and parallel work](docs/topics/subagents-and-parallel-work.md) · [MCP](docs/topics/mcp.md) · [Plugins](docs/topics/plugins.md) · [Automation](docs/topics/automation.md)
diff --git a/docs/advanced/01-parallel-sessions.md b/docs/advanced/01-parallel-sessions.md
index 7520906..542fa76 100644
--- a/docs/advanced/01-parallel-sessions.md
+++ b/docs/advanced/01-parallel-sessions.md
@@ -1,6 +1,6 @@
# Parallel sessions with worktrees
-<sub>**Advanced** · Lesson 1 of 7 · about 20 minutes · Needs: [Advanced index](README.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-22</sub>
+<sub>**Advanced** · Lesson 1 of 7 · about 20 minutes · Needs: [Advanced index](README.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -8,7 +8,7 @@ By the end of this lesson you can run two Claude Code sessions at once, each in
## You need
-- One of your own repositories with a test command and no uncommitted changes, checked out on its default branch and up to date with a remote you can push to (Watch out says why), and your copy of the practice template with Node.js LTS and the Advanced checks ([Practice](README.md#practice)): the check runs from the copy. Set up the repository's `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
+- One of your own repositories with a test command and no uncommitted changes, checked out on its default branch and up to date with a remote you can push to (Watch out says why), and your copy of the practice template with Node.js LTS and the Advanced checks ([Practice](README.md#practice)): the check runs from the copy. Set up the repository's `.practice/` folder as the [Intermediate index](../intermediate/README.md#prepare-your-own-repository) describes, if you haven't yet.
- If you haven't run `claude` in that repository before, run it there once and accept the trust dialog: until then `claude --worktree` exits with an error ([Start Claude in a worktree](https://code.claude.com/docs/en/worktrees#start-claude-in-a-worktree)).
- macOS, Linux or WSL 2, and three terminals open at the repository's root: two for the sessions, one for git.
- Usage: moderate. Two sessions work at the same time.
@@ -17,9 +17,9 @@ By the end of this lesson you can run two Claude Code sessions at once, each in
A [git worktree](https://git-scm.com/docs/git-worktree) is a second working folder, on its own branch, that shares the repository's history. `claude --worktree <name>` (or `-w <name>`) creates one under `.claude/worktrees/<name>/` on a new branch, `worktree-<name>`, and starts the session in it ([Start Claude in a worktree](https://code.claude.com/docs/en/worktrees#start-claude-in-a-worktree)). Each session edits its own copy of the files. Claude Code also stops a worktree session's file-editing tools from changing your main checkout, and its commands from running there or pointing git at it ([How Claude Code enforces isolation](https://code.claude.com/docs/en/worktrees#how-claude-code-enforces-isolation)).
-Commits and branches are shared. Uncommitted edits, installed dependencies and gitignored files such as `.env` are not: each worktree is a fresh checkout. A `.worktreeinclude` file at the repository root copies the gitignored files it lists into each new worktree ([Copy gitignored files into worktrees](https://code.claude.com/docs/en/worktrees#copy-gitignored-files-into-worktrees)); list only what the project needs, since every worktree gets its own copy of each secret.
+Commits and branches are shared. Uncommitted edits, installed dependencies and gitignored files such as `.env` are not: each worktree is a fresh checkout ([Set up the worktree environment](https://code.claude.com/docs/en/worktrees#set-up-the-worktree-environment)).
-The work comes back through git: each session commits on its branch, you merge the branches from your main checkout, then remove the worktrees.
+The work comes back through git: each session commits on its branch, and you bring both branches into yours. Your review sets the pace. Claude Academy puts the ceiling at "how many streams one person can review properly" ([Parallel sessions and subagents](https://academy.claude.com/courses/ai-native-sdlc-playbook/parallel-sessions-and-subagents)), so run only as many sessions as you can read the diffs of.
## Worked example
@@ -31,7 +31,7 @@ The work comes back through git: each session commits on its branch, you merge t
git push
```
- The leading `\n` puts the rule on a line of its own, even if your `.gitignore` doesn't end with a newline. Afterwards `git status --short` prints nothing, and `git log -1 --oneline` shows the commit.
+ Afterwards `git status --short` prints nothing, and `git log -1 --oneline` shows the commit.
2. In terminal 1, start a session in a new worktree and give it a docs task:
```bash
@@ -42,7 +42,7 @@ The work comes back through git: each session commits on its branch, you merge t
Tidy the wording of the README's first section, then wait for me before you commit.
```
- Claude Code creates `.claude/worktrees/docs-pass/` on the branch `worktree-docs-pass`, and the session works there. In auto mode, the starting mode, Claude works without routine permission prompts ([Auto mode](https://code.claude.com/docs/en/permission-modes#eliminate-permission-prompts-with-auto-mode)), so a `git commit` wouldn't wait for you. Asking it to wait is what holds the commit until step 4: auto mode treats a boundary you state in the conversation as a reason to block the matching action ([Boundaries you state in conversation](https://code.claude.com/docs/en/permission-modes#boundaries-you-state-in-conversation)). If Claude Code asks before an edit, read it, then approve.
+ Claude Code creates `.claude/worktrees/docs-pass/` on the branch `worktree-docs-pass`, and the session works there. In auto mode, the mode a session starts in, a commit, or even a push to the repository you're working in, wouldn't wait for you ([Which mode a session starts in](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in), [What the classifier blocks by default](https://code.claude.com/docs/en/permission-modes#what-the-classifier-blocks-by-default)). Asking it to wait is what holds the commit until step 4: auto mode treats a boundary you state in the conversation as a reason to block the matching action. It's a soft stop, which a compacted conversation can lose; for a hard one, add a deny rule ([Boundaries you state in conversation](https://code.claude.com/docs/en/permission-modes#boundaries-you-state-in-conversation)).
3. In terminal 2, start a second session with the short flag and give it a test task:
```bash
@@ -53,7 +53,7 @@ The work comes back through git: each session commits on its branch, you merge t
This worktree is a fresh checkout: install the dependencies, then add one missing test for a small exported function and run the tests. Wait for me before you commit.
```
- Claude Code creates `.claude/worktrees/test-pass/` on the branch `worktree-test-pass`; the session installs the dependencies there before it adds the test. If Claude Code asks before a command, read the command before you approve it.
+ Claude Code creates `.claude/worktrees/test-pass/` on the branch `worktree-test-pass`; the session installs the dependencies there before it adds the test.
4. In terminal 3, in your main checkout, look at all three checkouts while both sessions wait for you:
```bash
@@ -71,7 +71,7 @@ The work comes back through git: each session commits on its branch, you merge t
git merge worktree-test-pass
```
- [`git merge`](https://git-scm.com/docs/git-merge) brings each branch's commits into yours. The first merge just moves your branch forward (a fast-forward): `worktree-docs-pass` started from the commit you pushed in step 1, so your branch has no commits it lacks. The second makes a merge commit, because your branch now has a commit `worktree-test-pass` lacks, and opens your editor for its message: save and close it. Run this step yourself: while a session is isolated in its worktree, Claude Code blocks its git commands that reach into the main checkout. If both tasks changed the same lines, git stops with a conflict: resolve it, or start `claude` in the main checkout and ask it to.
+ [`git merge`](https://git-scm.com/docs/git-merge) brings each branch's commits into yours. The first merge just moves your branch forward, and the second makes a merge commit and opens your editor for its message: save and close it. Run this step yourself: while a session is isolated in its worktree, Claude Code blocks its git commands that reach into the main checkout. If both tasks changed the same lines, git stops with a conflict: resolve it, or start `claude` in the main checkout and ask it to.
6. In each session, run `/exit`. The worktree's branch has a new commit, so Claude Code asks whether to keep or remove the worktree: choose remove ([Clean up worktrees](https://code.claude.com/docs/en/worktrees#clean-up-worktrees)). `git worktree list` no longer shows either worktree.
> [!CAUTION]
@@ -79,11 +79,16 @@ The work comes back through git: each session commits on its branch, you merge t
## Your turn
-Pick two real changes from your repository's backlog that touch different files, such as a small bug fix in one module and a missing test for another. Make each one in its own worktree session, with both sessions running at the same time, and bring both into your branch.
+Land two backlog changes made at once, with neither session touching the other's files. Pick two real changes from your repository's backlog that don't change the same lines and don't build on each other, such as a small bug fix in one module and a missing test for another. Git merges changes to different parts of one file cleanly, but two changes to the same lines collide when you bring them together ([How conflicts are presented](https://git-scm.com/docs/git-merge#_how_conflicts_are_presented)), and each session starts without the other's change. Keep it to two, because each session's diff still needs your review.
-Before you start the sessions, decide what a fresh worktree of your repository lacks before its tests can run. Dependencies are the usual gap: tell each session to install them, as the Worked example's test session did ([Set up the worktree environment](https://code.claude.com/docs/en/worktrees#set-up-the-worktree-environment)). A gitignored file the tests read, such as a local config, is the other: list it in a `.worktreeinclude` file at your repository root, which copies only the files that match a pattern and are gitignored, or have the session create a test-only copy ([Copy gitignored files into worktrees](https://code.claude.com/docs/en/worktrees#copy-gitignored-files-into-worktrees)). Every worktree gets its own copy of each file you list, so list only what the tests need.
+No backlog to pick from? Your copy of the practice template has two such changes:
-If the work they should build on isn't on the remote's default branch yet (see Watch out), get it there first, or add `"worktree": {"baseRef": "head"}` to `.claude/settings.local.json`, your personal settings file from [Intermediate lesson 4](../intermediate/04-permissions-and-sandbox.md), so new worktrees start from your local `HEAD` ([`worktree.baseRef`](https://code.claude.com/docs/en/settings-reference#worktree-baseref)).
+- `findLinks` in `src/links.js` lets a `~~~` line close a code block that opened with three backticks, so it reports links inside the block.
+- No test covers `src/cli.js`, the command that prints each broken link and sets the exit code.
+
+Before you start the sessions, decide what a fresh worktree of your repository lacks before its tests can run. Dependencies are the usual gap: tell each session to install them, as the Worked example's test session did. A gitignored file the tests read, such as a local config, is the other: list it in a `.worktreeinclude` file at your repository root, which copies only the files that match a pattern and are gitignored, or have the session create a test-only copy ([Copy gitignored files into worktrees](https://code.claude.com/docs/en/worktrees#copy-gitignored-files-into-worktrees)). Every worktree gets its own copy of each file you list, so list only what the tests need.
+
+If the work they should build on isn't on the remote's default branch yet, get it there first, or add `"worktree": {"baseRef": "head"}` to `.claude/settings.local.json`, your personal settings file from [Intermediate lesson 4](../intermediate/04-permissions-and-sandbox.md), so new worktrees start from your local `HEAD` ([`worktree.baseRef`](https://code.claude.com/docs/en/settings-reference#worktree-baseref)).
Acceptance criteria:
@@ -95,22 +100,22 @@ Acceptance criteria:
git worktree list --porcelain > .practice/a-1-worktrees.txt
```
-- Both branches are merged into your branch with `git merge`, not [`git merge --squash`](https://git-scm.com/docs/git-merge#Documentation/git-merge.txt---squash).
-- Your tests pass after both merges (not checked).
-- Both worktrees are removed, and any branch you kept is deleted only after it's merged.
+- Both changes are in your branch, by merge, rebase or squash, whichever your team uses.
+- Your tests pass with both changes in (not checked).
+- Both worktrees are removed, and any branch you kept is deleted only once its change is in your branch.
## Check
You are done when all of these are true:
- [ ] A committed `.gitignore` ignores `.claude/worktrees/`, and not the rest of `.claude/`.
-- [ ] `.practice/a-1-worktrees.txt` lists two worktrees under `.claude/worktrees/` whose commits split from each other, and both are merged into your branch.
+- [ ] `.practice/a-1-worktrees.txt` lists two worktrees under `.claude/worktrees/` whose commits split from each other, and both changes are in your branch.
- [ ] Neither of those worktrees still exists: `git worktree list` doesn't show them.
- [ ] Self-check (not tested): you can name what a fresh worktree of your repository lacked, such as its dependencies or a gitignored config file, and say whether you listed it in `.worktreeinclude` or had the session set it up, and why.
Run `npm run check -- a-1 --dir <your repo>` from your practice copy.
-If the first item fails, run `git -c core.excludesFile=/dev/null check-ignore -v .claude/worktrees/x` in your repository (the `-c` part swaps your global excludes file, [`core.excludesFile`](https://git-scm.com/docs/gitignore), for an empty one, as the check does): it should name your `.gitignore` and the line that matches ([git-check-ignore](https://git-scm.com/docs/git-check-ignore#Documentation/git-check-ignore.txt---verbose)). A rule only in `.git/info/exclude` or your global excludes file isn't committed, and a broad rule such as `.claude/` would also hide the settings and skills you commit for your team. If the second item fails, read the hint the check prints: save the file after both sessions commit and before you remove either worktree, and merge each branch with `git merge`. If the third item fails, run `git worktree remove <path>` from your main checkout on each path the check names, with `git worktree unlock <path>` first if git says it's locked. That leaves the worktree's branch: delete it once it's merged, with `git merge-base --is-ancestor worktree-<name> HEAD && git branch -D worktree-<name>`. The first command succeeds only when the branch is part of `HEAD` ([git-merge-base](https://git-scm.com/docs/git-merge-base#Documentation/git-merge-base.txt---is-ancestor)), and `-D` deletes it without git's own merged test, which checks the branch's upstream, when it has one, rather than `HEAD` ([git-branch](https://git-scm.com/docs/git-branch#Documentation/git-branch.txt--D)).
+If the first item fails, run `git check-ignore -v .claude/worktrees/x` in your repository: it should name your committed `.gitignore` ([git-check-ignore](https://git-scm.com/docs/git-check-ignore#Documentation/git-check-ignore.txt---verbose)). If the second item fails, read the hint the check prints: save the file after both sessions commit and before you remove either worktree. If the third item fails, exit any Claude Code session still open in a worktree it names: `/exit`, then remove it, or keep it and run `git worktree remove <path>` from your main checkout. Run `git worktree unlock <path>` first only when git says the worktree is locked and no session is open in it ([Clean up worktrees](https://code.claude.com/docs/en/worktrees#clean-up-worktrees)).
## Watch out
@@ -126,6 +131,6 @@ If the first item fails, run `git -c core.excludesFile=/dev/null check-ignore -v
---
-<sub>Sources: [Run parallel sessions with worktrees](https://code.claude.com/docs/en/worktrees) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Run agents in parallel](https://code.claude.com/docs/en/agents) · [git-worktree](https://git-scm.com/docs/git-worktree) · [git-merge](https://git-scm.com/docs/git-merge) · [git-check-ignore](https://git-scm.com/docs/git-check-ignore) · [gitignore](https://git-scm.com/docs/gitignore) · [git-merge-base](https://git-scm.com/docs/git-merge-base) · [git-branch](https://git-scm.com/docs/git-branch)</sub>
+<sub>Sources: [Run parallel sessions with worktrees](https://code.claude.com/docs/en/worktrees) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Run agents in parallel](https://code.claude.com/docs/en/agents) · [Parallel sessions and subagents](https://academy.claude.com/courses/ai-native-sdlc-playbook/parallel-sessions-and-subagents) · [git-worktree](https://git-scm.com/docs/git-worktree) · [git-merge](https://git-scm.com/docs/git-merge) · [git-check-ignore](https://git-scm.com/docs/git-check-ignore)</sub>
<sub>← [Advanced index](README.md) · [Choose an orchestration pattern](02-orchestration-patterns.md) → · Topic: [Subagents and parallel work](../topics/subagents-and-parallel-work.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-1)</sub>
diff --git a/docs/advanced/02-orchestration-patterns.md b/docs/advanced/02-orchestration-patterns.md
index 3b4c9f1..5453a5e 100644
--- a/docs/advanced/02-orchestration-patterns.md
+++ b/docs/advanced/02-orchestration-patterns.md
@@ -1,36 +1,38 @@
# Choose an orchestration pattern
-<sub>**Advanced** · Lesson 2 of 7 · about 20 minutes · Needs: [Parallel sessions with worktrees](01-parallel-sessions.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Advanced** · Lesson 2 of 7 · about 20 minutes · Needs: [Parallel sessions with worktrees](01-parallel-sessions.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
-By the end of this lesson you can choose between the main conversation, subagents, a dynamic workflow and an agent team by what a job needs and what it costs, and run a job as parallel subagents.
+By the end of this lesson you can choose between the main conversation, subagents, a dynamic workflow, `/batch` and an agent team by what a job needs and what it costs, and run a job as parallel subagents.
## You need
-- Your repository from [lesson 1](01-parallel-sessions.md), with at least three top-level folders that hold files, and your copy of the practice template with Node.js LTS: the check runs from the copy. Set up the repository's `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
-- macOS, Linux or WSL 2, and `jq`: the delegation log in Your turn is a shell command that uses it.
+- Your repository from [lesson 1](01-parallel-sessions.md), with at least three top-level folders that hold files, and your copy of the practice template with Node.js LTS: the check runs from the copy. Set up the repository's `.practice/` folder as the [Intermediate index](../intermediate/README.md#prepare-your-own-repository) describes, if you haven't yet.
+- macOS, Linux or WSL 2, and `jq`: the delegation log from [Intermediate lesson 6](../intermediate/06-subagents.md) uses it.
- Usage: moderate. Each subagent works in its own context window and sends its own requests, which count toward the same usage limits as your main conversation ([Create custom subagents](https://code.claude.com/docs/en/sub-agents)). For a lighter run, use two folders in the Worked example and two files in job 1.
## The idea
-Subagents, a dynamic workflow and an agent team all split a job across workers; what differs is who holds the plan ([When to use a workflow](https://code.claude.com/docs/en/workflows#when-to-use-a-workflow)). With subagents, Claude decides turn by turn, and each result comes back into your conversation. A dynamic workflow is a script Claude writes: it holds the loop and the intermediate results, so it can run many agents, cross-check their findings and rerun the same way. In an agent team, a lead supervises teammates who message each other directly ([Choose an approach](https://code.claude.com/docs/en/agents#choose-an-approach)).
+Subagents, a dynamic workflow and an agent team all split a job across workers; what differs is who holds the plan ([When to use a workflow](https://code.claude.com/docs/en/workflows#when-to-use-a-workflow)). With subagents, Claude decides turn by turn, and each result comes back into your conversation. A dynamic workflow is a script Claude writes: it holds the loop and the intermediate results, so it can run many agents, cross-check their findings and rerun the same way. In an agent team, a lead supervises teammates who message each other directly ([Choose an approach](https://code.claude.com/docs/en/agents#choose-an-approach)). The bundled `/batch` skill is subagents, packaged: it splits one large change into independent units and, once you approve its plan, runs each in its own worktree ([Commands](https://code.claude.com/docs/en/commands#all-commands)).
-Every pattern past one conversation adds usage: each subagent, and each agent a workflow spawns, sends requests of its own ([Why usage climbs](https://code.claude.com/docs/en/costs#why-usage-climbs-in-a-long-session)), and agent teams "use significantly more tokens than a single session" ([When to use agent teams](https://code.claude.com/docs/en/agent-teams#when-to-use-agent-teams)). So pick the cheapest pattern the job needs: ask these questions in order, and stop at the first answer that settles it.
+Every pattern past one conversation adds usage ([Why usage climbs](https://code.claude.com/docs/en/costs#why-usage-climbs-in-a-long-session)). So pick the cheapest pattern the job needs: ask these questions in order, and stop at the first answer that settles it.
A big job is not always a job to split. Keep it in the main conversation when its steps share a lot of context, such as planning, making the change and testing it ([Choose between subagents and main conversation](https://code.claude.com/docs/en/sub-agents#choose-between-subagents-and-main-conversation)). And workers that only report back to you are not a team; a team is for workers who must share findings and challenge each other as they go ([Compare with subagents](https://code.claude.com/docs/en/agent-teams#compare-with-subagents)).
```mermaid
flowchart TD
accTitle: Who holds the plan
- accDescr: A path for choosing how to split a job. If one conversation can do it without filling up, keep it in the main conversation. Otherwise, if the workers must talk to each other, a lead holds the plan in an agent team, which is experimental. If they need not talk and the job is a few tasks done once, Claude holds the plan and subagents return summaries. If it needs many agents, cross-checked findings or a rerun, a script holds the plan in a dynamic workflow.
+ accDescr: A path for choosing how to split a job. If one conversation can do it without filling up, keep it in the main conversation. Otherwise, if the workers must talk to each other, a lead holds the plan in an agent team, which is experimental. If they need not talk and the job needs cross-checked findings or a rerun, a script holds the plan in a dynamic workflow. If it is one large change that splits into independent units, /batch runs one subagent per unit in its own worktree. Otherwise Claude holds the plan and subagents return summaries.
A["A job"] --> B{"Can one conversation do it without filling up?"}
B -- yes --> M["Main conversation"]
B -- no --> C{"Must the workers talk to each other?"}
C -- yes --> T["Agent team: a lead holds the plan"]
- C -- no --> D{"Does it need many agents, cross-checked findings or a rerun?"}
- D -- no --> S["Subagents: Claude holds the plan"]
+ C -- no --> D{"Does it need cross-checked findings or a rerun?"}
D -- yes --> W["Dynamic workflow: a script holds the plan"]
+ D -- no --> E{"Is it one large change that splits into independent units?"}
+ E -- yes --> X["/batch: one worktree per unit"]
+ E -- no --> S["Subagents: Claude holds the plan"]
```
> [!NOTE]
@@ -39,43 +41,31 @@ flowchart TD
## Worked example
1. Pick three top-level folders in your repository, such as `src`, `test` and `docs`, and start `claude`. Keep [auto mode](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in), the mode it starts in, for this lesson.
-2. Ask the chart's questions about one job: a newcomer's summary of each folder. One conversation would fill with file reads it won't need again, so not the main conversation ([Choose between subagents and main conversation](https://code.claude.com/docs/en/sub-agents#choose-between-subagents-and-main-conversation)). The summaries needn't talk to each other, so no team. It's three tasks, done once, so subagents.
+2. Ask the chart's questions about one job: a newcomer's summary of each folder. One conversation would fill with file reads it won't need again, so not the main conversation ([Choose between subagents and main conversation](https://code.claude.com/docs/en/sub-agents#choose-between-subagents-and-main-conversation)). The summaries needn't talk to each other, so no team. Nothing needs cross-checking or a rerun, and nothing changes, so neither a workflow nor `/batch`: subagents.
3. Ask for them, with your own folder names, as the docs' parallel research example does ([Run parallel research](https://code.claude.com/docs/en/sub-agents#run-parallel-research)):
```text
Research the src, test and docs folders in parallel using separate subagents, and give me two sentences on each.
```
- By default, an interactive session runs subagents in the background, so your prompt stays free ([Run subagents in foreground or background](https://code.claude.com/docs/en/sub-agents#run-subagents-in-foreground-or-background)). The panel below the prompt shows a row for each one while it works.
-4. While they work, run `/tasks`. It lists each subagent with its state and the model it runs on; press Enter on a row to open its transcript ([Check on running work](https://code.claude.com/docs/en/agents#check-on-running-work), [Choose a model](https://code.claude.com/docs/en/sub-agents#choose-a-model)). Claude may start [built-in](https://code.claude.com/docs/en/sub-agents#built-in-subagents) `Explore` or `general-purpose` subagents, or forks of your conversation, so your rows will differ. When one finishes successfully, its row leaves the panel and the footer briefly shows `/tasks to see subagents`; the row of one that fails stays for a moment.
-5. When the summaries arrive, run `/usage`. On a Pro, Max, Team or Enterprise plan, its usage breakdown attributes your recent usage to skills, subagents, plugins and MCP servers, and flags behaviors, such as long context, that account for a notable share of it ([Plan usage breakdown](https://code.claude.com/docs/en/costs#plan-usage-breakdown)). Its Session block, intended for API users such as those signed in with a Console account, shows this session's estimated cost ([Using the `/usage` command](https://code.claude.com/docs/en/costs#using-the-%2Fusage-command)). Both are estimates.
+ By default, an interactive session runs subagents in the background, so your prompt stays free ([Run subagents in foreground or background](https://code.claude.com/docs/en/sub-agents#run-subagents-in-foreground-or-background)).
+4. While they work, run `/tasks`. It lists each item running in the background and lets you check on, attach to, or stop it ([Check on running work](https://code.claude.com/docs/en/agents#check-on-running-work)). Claude may start [built-in](https://code.claude.com/docs/en/sub-agents#built-in-subagents) `Explore` or `general-purpose` subagents, or forks of your conversation, so your rows will differ.
+5. When the summaries arrive, run `/usage` to see what that cost. On a Pro, Max, Team or Enterprise plan, it attributes your recent usage to skills, subagents, plugins and MCP servers, and recommends changes ([Plan usage breakdown](https://code.claude.com/docs/en/costs#plan-usage-breakdown)). The figures are estimates.
## Your turn
-**Brief:** five items from your team's backlog. Choose a pattern for each by what it needs and what it costs, write your choices down, then run job 1.
+**Brief:** pick the cheapest pattern for five backlog jobs, then run the one that needs parallel readers. Write your choices down, then run job 1.
1. Before Friday's release, audit the three largest source files for errors that are caught and then dropped. You want suspects by file and line; nothing gets fixed yet.
2. Add that audit to the release checklist for the whole codebase. The release manager has been burned by false alarms, so nothing goes on the list until it has been confirmed in the code.
-3. Rename a helper that about 40 files call, update every call site, and keep the build passing.
+3. Rename a helper that about 40 files call, update every call site in one commit, and keep the build passing.
4. A checkout test fails about one run in ten. There are three suspects: a race in a cache, an assertion that depends on the clock, and the order the tests run in. Have each suspect checked and bring back what each check found; you'll decide.
-5. Last month, three separate reports on that same test each blamed a different suspect, and nobody was convinced. This time the investigators should try to knock down each other's explanations while they work, until one survives that they all accept.
+5. Move every package under `packages/` from the old logging library to the new one. Each package builds and tests on its own, and each package's change can land on its own.
**Acceptance criteria:**
-- `.practice/a-2-choices.md` has one line per job, `<job number>: <pattern> because <reason>`, and each pattern is `main conversation`, `subagents`, `workflow` or `agent team`.
-- `.practice/a-2-hook.json` holds this [`SubagentStart` hook](https://code.claude.com/docs/en/hooks#subagentstart), which appends each subagent's id and type to `.practice/a-2-agents.txt` when it starts, like the delegation log in [Delegate to a custom subagent](../intermediate/06-subagents.md):
-
- ```json
- {
- "hooks": {
- "SubagentStart": [
- { "hooks": [ { "type": "command", "command": "jq -r '[.agent_id, .agent_type] | @tsv' >> \"$CLAUDE_PROJECT_DIR/.practice/a-2-agents.txt\"" } ] }
- ]
- }
- }
- ```
-
-- Job 1 ran as parallel subagents, one per file, in a session you started with `claude --settings .practice/a-2-hook.json` ([CLI reference](https://code.claude.com/docs/en/cli-reference#cli-flags)).
+- `.practice/a-2-choices.md` has one line per job, `<job number>: <pattern> because <reason>`, and each pattern is `main conversation`, `subagents`, `workflow`, `/batch` or `agent team`.
+- Job 1 ran as parallel subagents, one per file, in a session you started with the delegation log from Intermediate lesson 6, `claude --settings .practice/i-6-hook.json` ([CLI reference](https://code.claude.com/docs/en/cli-reference#cli-flags)). If this repository doesn't have that file yet, save it as that lesson's [Your turn](../intermediate/06-subagents.md#your-turn) shows.
- Job 1 changed no file: the reviewers only report, and `git status` shows no change from them.
- Only job 1 ran. The other four are choices.
@@ -84,27 +74,27 @@ flowchart TD
You are done when all of these are true:
- [ ] `.practice/a-2-choices.md` picks the cheapest pattern that fits each job.
-- [ ] `.practice/a-2-agents.txt` shows at least two subagents starting for job 1: `cut -f1 .practice/a-2-agents.txt | sort -u` lists two or more ids.
+- [ ] `.practice/i-6-agents.txt` shows at least two subagents other than Intermediate lesson 6's `test-gaps` starting: `grep -vxc test-gaps .practice/i-6-agents.txt` prints 2 or more.
- [ ] Self-check (not tested): for one real job from your own backlog, you can name its pattern, the question that decided it, and why a cheaper pattern wouldn't do.
Run `npm run check -- a-2 --dir <your repo>` from your practice copy.
-If a job's pattern is wrong, ask the chart's questions in order: the check's hint names the question that settles that job. If the log has fewer than two ids, start the session with the hook file and ask for one subagent per file, in parallel. A subagent that Claude resumes logs its id again, so it counts once.
+If a job's pattern is wrong, ask the chart's questions in order: the check's hint names the question that settles that job. If the log has fewer than two new lines, start the session with the hook file and ask for one subagent per file, in parallel.
## Watch out
- If Claude Code asks about a background subagent's tool call, the prompt appears in your main session, and an answer that lasts beyond that one tool call, such as a grant for the rest of the session, applies to the whole session, your main conversation included ([Tools, permissions, and results of background subagents](https://code.claude.com/docs/en/sub-agents#tools-permissions-and-results-of-background-subagents)). Answer such a prompt for that one call only, and ask reviewers only to read.
- Each subagent's result returns to your conversation, and each subagent spends tokens of its own while it runs, so many detailed results crowd your context and add to your usage. Ask for short results ([Run parallel research](https://code.claude.com/docs/en/sub-agents#run-parallel-research)).
-- With agent teams turned on, a subagent that Claude names launches as a teammate, so a team can form when you asked for subagents. The hook also logs a line each time a teammate that runs inside your main terminal handles a new message ([Claude spawns teammates instead of subagents](https://code.claude.com/docs/en/agent-teams#claude-spawns-teammates-instead-of-subagents), [SubagentStart](https://code.claude.com/docs/en/hooks#subagentstart)). If you turned teams on, add `"env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "0" }` to `.practice/a-2-hook.json`, as a top-level key beside `"hooks"`. A `--settings` file overrides your user, project and local settings and a shell export, and only managed settings override it ([Settings precedence](https://code.claude.com/docs/en/settings#settings-precedence)).
+- If you've turned agent teams on, a subagent that Claude names launches as a teammate instead ([Claude spawns teammates instead of subagents](https://code.claude.com/docs/en/agent-teams#claude-spawns-teammates-instead-of-subagents)): turn teams off for this lesson.
## Go further
- [Run agents in parallel](https://code.claude.com/docs/en/agents): the official comparison of the ways Claude Code works on several tasks at once, and how to check on each.
-- [Fork the current conversation](https://code.claude.com/docs/en/sub-agents#fork-the-current-conversation): a subagent that inherits your whole conversation and shares its prompt cache, for a side task that needs the same context.
+- [Fan out across files](https://code.claude.com/docs/en/best-practices#fan-out-across-files): `/batch` for a large migration, or your own loop of `claude -p` calls.
- [Agent team token costs](https://code.claude.com/docs/en/costs#agent-team-token-costs): what drives a team's usage, and how to keep it small.
---
-<sub>Sources: [Run agents in parallel](https://code.claude.com/docs/en/agents) · [Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows) · [Orchestrate teams of Claude Code sessions](https://code.claude.com/docs/en/agent-teams) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Manage costs effectively](https://code.claude.com/docs/en/costs) · [Hooks reference](https://code.claude.com/docs/en/hooks) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Settings files and precedence](https://code.claude.com/docs/en/settings)</sub>
+<sub>Sources: [Run agents in parallel](https://code.claude.com/docs/en/agents) · [Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows) · [Commands](https://code.claude.com/docs/en/commands) · [Orchestrate teams of Claude Code sessions](https://code.claude.com/docs/en/agent-teams) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Manage costs effectively](https://code.claude.com/docs/en/costs) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [CLI reference](https://code.claude.com/docs/en/cli-reference)</sub>
<sub>← [Parallel sessions with worktrees](01-parallel-sessions.md) · [Advanced index](README.md) · [Run and save a dynamic workflow](03-dynamic-workflows.md) → · Topic: [Subagents and parallel work](../topics/subagents-and-parallel-work.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-2)</sub>
diff --git a/docs/advanced/03-dynamic-workflows.md b/docs/advanced/03-dynamic-workflows.md
index 4afff9e..3d1855f 100644
--- a/docs/advanced/03-dynamic-workflows.md
+++ b/docs/advanced/03-dynamic-workflows.md
@@ -1,137 +1,97 @@
# Run and save a dynamic workflow
-<sub>**Advanced** · Lesson 3 of 7 · about 20 minutes, plus run time · Needs: [Choose an orchestration pattern](02-orchestration-patterns.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Advanced** · Lesson 3 of 7 · about 20 minutes, plus run time · Needs: [Choose an orchestration pattern](02-orchestration-patterns.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
-By the end of this lesson you can have Claude write a dynamic workflow for a job that fans out across many files, read it and keep it small before it runs, and save a migration that keeps fixing until your tests pass as a command that takes its folder from `args`.
+By the end of this lesson you can keep one session working until a check you can run passes, with `/goal`, and save an audit that fans out across many files, with each finding checked by a second agent, as a workflow command that takes its folder from `args`.
## You need
-- One of your own repositories with a test command that passes, such as `npm test`, and a migration it needs in at least two folders: an old form that `git grep -n -E '<pattern>'` finds, such as a deprecated call, an old import path or a helper you're replacing ([git grep](https://git-scm.com/docs/git-grep)). No migration in mind? Your copy of the practice template has one: files in `test/` and `practice/` build paths from `import.meta.url`, where Node.js offers [`import.meta.dirname`](https://nodejs.org/api/esm.html#importmetadirname). Run the check from your copy of the practice template, with Node.js LTS. Set up the repository's `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
-- Usage: heavy. Each run starts several subagents ([Cost](https://code.claude.com/docs/en/workflows#cost)). Cheap variant: keep each run to one small folder, and start Claude Code with `--model sonnet` as step 1 shows.
+- One of your own repositories with a test command that passes, such as `npm test`, and a migration it needs in one small folder: an old form that `git grep -n -E '<pattern>'` finds, such as a deprecated call, an old import path or a helper you're replacing ([git grep](https://git-scm.com/docs/git-grep)). No migration in mind? Your copy of the practice template has one: files in `test/` build paths from `import.meta.url`, where Node.js offers [`import.meta.dirname`](https://nodejs.org/api/esm.html#importmetadirname). Run the check from your copy of the practice template, with Node.js LTS. Set up the repository's `.practice/` folder as the [Intermediate index](../intermediate/README.md#prepare-your-own-repository) describes, if you haven't yet.
+- Usage: heavy. A goal runs turn after turn, and each workflow run starts several subagents ([Cost](https://code.claude.com/docs/en/workflows#cost)). Cheap variant: keep each run to one small folder, and start Claude Code with `--model sonnet` ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)).
> [!NOTE]
> On Pro, dynamic workflows are off until you turn them on from the **Dynamic workflows** row in `/config`, and the size guideline defaults to `small` ([Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows), [Set a size guideline](https://code.claude.com/docs/en/workflows#set-a-size-guideline)).
## The idea
-A dynamic workflow is a JavaScript script that Claude writes for your task. A runtime runs it in the background while your session stays responsive ([Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows)). The script starts the subagents and keeps their results in its own variables, so only the final answer reaches your conversation: the script, not Claude, [holds the plan](02-orchestration-patterns.md#the-idea) ([When to use a workflow](https://code.claude.com/docs/en/workflows#when-to-use-a-workflow)).
+`/goal <condition>` keeps one session working toward a condition: after each turn, a separate model checks whether it holds, and if not, Claude starts another turn ([Keep Claude working toward a goal](https://code.claude.com/docs/en/goal)). That evaluator doesn't run commands or read files: it judges only what Claude surfaced in the conversation, so name the check Claude must run and what must not change ([Write an effective condition](https://code.claude.com/docs/en/goal#write-an-effective-condition)). Use it when one session can do the job.
-Because the plan is code, you can read it before it runs, independent agents can check each other's findings before they're reported, and you can save a run that did what you wanted as a command, `/<name>`, that can take new input from `args` each time ([When to use a workflow](https://code.claude.com/docs/en/workflows#when-to-use-a-workflow), [Pass input to a saved workflow](https://code.claude.com/docs/en/workflows#pass-input-to-a-saved-workflow)).
-
-Because the script holds the loop, a workflow can also keep fixing until a check passes, and stop when rounds stop making progress, as the docs' example prompts show for a type check ([Example workflow prompts](https://code.claude.com/docs/en/workflows#example-workflow-prompts)).
-
-A size guideline tells Claude how many agents to aim for when it writes the script. It is advice, not a cap ([Set a size guideline](https://code.claude.com/docs/en/workflows#set-a-size-guideline)).
+A dynamic workflow is for what one session can't do: a JavaScript script Claude writes, which a runtime runs in the background, starting subagents and keeping their results in its own variables ([Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows)). Because the plan is code, you can read it before it runs, have independent agents check each other's findings, and save a run as a command, `/<name>`, that takes new input from `args` each time ([When to use a workflow](https://code.claude.com/docs/en/workflows#when-to-use-a-workflow), [Pass input to a saved workflow](https://code.claude.com/docs/en/workflows#pass-input-to-a-saved-workflow)).
## Worked example
-1. At the root of your repository, start Claude Code in Manual mode:
-
- ```bash
- claude --permission-mode manual
- ```
+Migrate one small folder in a single session, gated by a goal.
- For the cheap variant, start it on Sonnet instead:
+1. Save the `git grep -E` pattern that finds the old form on one line in `.practice/a-3-pattern.txt`, so the check can find the old form in your history. For the practice template's migration, that's:
```bash
- claude --permission-mode manual --model sonnet
+ printf '%s\n' 'import\.meta\.url' > .practice/a-3-pattern.txt
```
- The status bar shows `⏸ manual mode on` ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)). In Manual mode, Claude Code asks before every workflow run, unless you've told it not to ask again for that workflow in this project, so you see each plan before it starts ([Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs)).
-
- When nothing else assigns a model, a workflow's agents run on your session's model ([Cost](https://code.claude.com/docs/en/workflows#cost)). `--model` sets it for this session only, where `/model` would also save it as your default ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags), [Commands](https://code.claude.com/docs/en/commands#all-commands)).
-2. Set the size guideline:
+ Then start `claude` at the root of your repository. A goal doesn't change your permission mode, and in auto mode, the mode a session starts in, goal turns run without waiting for you ([Set a goal](https://code.claude.com/docs/en/goal#set-a-goal), [Which mode a session starts in](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in)).
+2. Set the goal, with your own pattern and folder:
```text
- /config workflowSizeGuideline=small
+ /goal git grep -n -E 'import\.meta\.url' -- test lists nothing, npm test exits 0, and no file outside test/ changes, or stop after 20 turns
```
- `small` asks Claude for the fewest agents; the docs suggest it "when you want to bound what a workflow spends". Claude Code keeps this choice in `~/.claude.json`, not in the repository, and it applies from your next prompt ([All settings](https://code.claude.com/docs/en/settings-reference#workflowsizeguideline), [Set a size guideline](https://code.claude.com/docs/en/workflows#set-a-size-guideline)).
-3. Ask for a workflow of your own. Replace `<folder>` with a small folder of your repository:
+ It has one measurable end state, the checks that prove it, a constraint, and a turn clause that bounds the run ([Write an effective condition](https://code.claude.com/docs/en/goal#write-an-effective-condition)). Setting a goal starts a turn at once, with the condition as the directive, and a `◎ /goal active` indicator shows while it runs.
+3. While it works, run `/goal` with no argument. It shows the condition, how long it has run, the turns evaluated, the token spend and the evaluator's most recent reason ([Check status](https://code.claude.com/docs/en/goal#check-status)). If the goal was already achieved, it shows the achieved condition with its duration, turn count and token spend. When the evaluator judges the condition met, Claude Code clears the goal and records an achieved entry in the transcript ([How evaluation works](https://code.claude.com/docs/en/goal#how-evaluation-works)).
+4. Be the last check. The evaluator judged what Claude showed it, so run the checks yourself: `git grep -n -E '<pattern>' -- <folder>` lists nothing, and your test command passes. Read `git diff`, then commit what you accept.
- ```text
- use a workflow to audit every file under <folder> for errors that are caught and then ignored, and adversarially verify each finding before reporting it
- ```
-
- Asking for "a workflow" in your own words tells Claude to write one for this task ([Ask for a workflow in your prompt](https://code.claude.com/docs/en/workflows#ask-for-a-workflow-in-your-prompt)). Claude Code then asks whether to run it, listing the planned phases, with **Yes, run it**, **View raw script** and **No**. A script Claude wrote for this task gets no don't-ask-again option. Choose **View raw script** to read it first, or press `Ctrl+G` to open it in your editor ([Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs)). It has the shape of the docs' example, though yours will differ:
+## Your turn
- ```javascript
- export const meta = {
- name: 'audit-routes',
- description: 'Audit every route handler for missing auth checks',
- }
+**Brief:** make the release audit a saved command that reports only the findings a second agent confirmed. The release manager runs it on a different folder each release, so it takes the folder as input. The audit looks for errors that are caught and then ignored, and changes no file.
- const found = await agent('List every .ts file under src/routes/.', {
- schema: { type: 'object', required: ['files'], properties: { files: { type: 'array', items: { type: 'string' } } } },
- })
+One way to get there:
- const audits = await pipeline(found.files, file =>
- agent(`Audit ${file} for missing authentication checks.`, { label: file }),
- )
+1. Set the size guideline, so Claude aims for few agents: `/config workflowSizeGuideline=small`. It is advice, not a cap, and applies from your next prompt ([Set a size guideline](https://code.claude.com/docs/en/workflows#set-a-size-guideline)).
+2. Start a session in Manual mode, `claude --permission-mode manual` ([Available modes](https://code.claude.com/docs/en/permission-modes#available-modes)). In Manual mode, Claude Code asks before each workflow run, unless you've chosen **Yes, and don't ask again** for that workflow, so you see each plan before it starts ([Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs)). The workflow's agents get the same permission checks as any other tool call in your session ([Ask for a workflow in your prompt](https://code.claude.com/docs/en/workflows#ask-for-a-workflow-in-your-prompt)). In Manual mode, read each prompt and choose **Yes**, not **Yes, and switch to auto mode** ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)). To avoid prompts on a long run, add the tools the agents need to your allow rules before starting ([Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs)). Ask for a workflow on a small folder:
- return audits.filter(Boolean)
+ ```text
+ use a workflow to audit every file under <folder> for errors that are caught and then ignored, and adversarially verify each finding before reporting it
```
- `agent()` starts one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agents at the same time ([What the saved script looks like](https://code.claude.com/docs/en/workflows#what-the-saved-script-looks-like)). Then choose **Yes, run it**.
-4. While it works, run `/workflows` and select your audit run; when the session has only one run, it opens that run directly. The progress view shows each phase with its agent counts. `↑` and `↓` select, `Enter` opens a phase and then an agent (its prompt, its recent tool calls and its result), `Esc` backs out, and `p` pauses the run or resumes it ([Watch the run](https://code.claude.com/docs/en/workflows#watch-the-run)). A one-line progress summary also shows in the task panel below the input box ([Run a bundled workflow](https://code.claude.com/docs/en/workflows#run-a-bundled-workflow)).
-5. When the run finishes and its findings appear in your session, run `/workflows`, select your audit run, and press `s`. In the save dialog, `Tab` switches between `.claude/workflows/` in your project, shared with everyone who clones the repository once you commit it, and `~/.claude/workflows/`, available in every project but only to you. Make sure `.claude/workflows/` in your project is selected, pressing `Tab` if it isn't, then press `Enter` ([Save the workflow for reuse](https://code.claude.com/docs/en/workflows#save-the-workflow-for-reuse)). Claude Code writes the script as a `.js` file to the closest `.claude/workflows/` folder that already exists between your working directory and the repository root, or to `.claude/workflows/` at the root if there's none yet. From your next session on, the workflow runs as a command, `/<name>`, listed in `/` autocomplete beside the bundled `/deep-research` ([Bundled workflows](https://code.claude.com/docs/en/workflows#bundled-workflows)).
-
-## Your turn
-
-**Brief:** migrate your repository one folder at a time, with a workflow you save. Build a workflow that takes a folder from `args`, finds every use of the old form in it, has agents migrate the files in a few batches that each own different files, not one agent per file, then runs your test command and keeps fixing until it passes. Run it on a small folder first and read what it spent in `/workflows` before you run it on a second folder.
+ Asking for "a workflow" in your own words tells Claude to write one for this task ([Ask for a workflow in your prompt](https://code.claude.com/docs/en/workflows#ask-for-a-workflow-in-your-prompt)). Claude Code then asks whether to run it, listing the planned phases, with **Yes, run it**, **View raw script** and **No**. Choose **View raw script** to read it first: `agent()` starts one subagent, `pipeline()` runs one per item in a list, and `parallel()` runs a set of agents at the same time ([What the saved script looks like](https://code.claude.com/docs/en/workflows#what-the-saved-script-looks-like)). Then choose **Yes, run it**.
+3. While it works, run `/workflows`: the progress view shows each phase with its agent counts, and each agent's prompt, tool calls and result ([Watch the run](https://code.claude.com/docs/en/workflows#watch-the-run)). Answer any permission prompt in your session: in the progress view, `Esc` backs out one level ([Watch the run](https://code.claude.com/docs/en/workflows#watch-the-run)). When the findings appear in your session, select the run in `/workflows` and press `s`. In the save dialog, make sure `.claude/workflows/` in your project is selected, the location shared with everyone who clones the repository (`Tab` switches between the two locations), then press `Enter` ([Save the workflow for reuse](https://code.claude.com/docs/en/workflows#save-the-workflow-for-reuse)).
+4. Run `/workflow-authoring`, which loads the reference Claude works from when it writes scripts, and ask Claude to change the saved script so it takes the folder from `args`. Run `/reload-skills` ([Edit a saved script](https://code.claude.com/docs/en/workflows#edit-a-saved-script)).
+5. Ask `Run /<name> on <folder>` for a second folder, and read which findings its checking agents confirmed. Run by name, the prompt also offers **Yes, and don't ask again for `<name>` in `<path>`**; choose **Yes, run it** for now, so you still see each plan ([Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs)). When `git status` shows no change from it, commit the script.
**Acceptance criteria:**
- It's saved in `.claude/workflows/`, committed, and runs by name. Its first statement stays `export const meta`, a plain object literal with a `name` and a `description`: a variable, a function call or a spread there drops `/<name>` from `/` autocomplete ([Edit a saved script](https://code.claude.com/docs/en/workflows#edit-a-saved-script)).
- It reads the folder from `args`, so `Run /<name> on <folder>` works on any folder without editing the script.
-- It stops on its own: when your test command passes, or after two rounds in a row that make no progress, so a change your tests can't accept doesn't loop until the runtime's agent cap ([Behavior and limits](https://code.claude.com/docs/en/workflows#behavior-and-limits)).
-- After each run, `git grep -n -E '<pattern>' -- <folder>` lists nothing, your test command passes, and you've reviewed and committed the run's changes.
-- The pattern that finds the old form is saved on one line in `.practice/a-3-pattern.txt`, so the check can find the old form in your history.
-
-One way to get there: save the pattern before you start. For the practice template's migration, that's:
-
-```bash
-printf '%s\n' 'import\.meta\.url' > .practice/a-3-pattern.txt
-```
-
-Write the first version with a "use a workflow" request on the small folder, read its script before you approve it, and save the run as in step 5. Then run `/workflow-authoring`, which loads the reference Claude works from when it writes scripts, and ask Claude to change the saved script so it takes the folder from `args` ([Edit a saved script](https://code.claude.com/docs/en/workflows#edit-a-saved-script)). Run `/reload-skills`, commit the script, then ask `Run /<name> on <folder>` for the second folder.
-
-After each run, review and commit its changes, then ask Claude to save the report:
-
-```text
-Save that report to .practice/a-3-run1.md: the folder you ran it on as the first line, then one line per file the migration changed, starting with the path:line of its first change, and nothing else.
-```
-
-Use `.practice/a-3-run2.md` for the second folder.
+- A second agent checks each finding before it's reported: the script calls `agent()` at least twice, once to find and once to check.
+- You've run it by name on a second folder, and it changed no file there: `git status` shows no change from it.
## Check
You are done when all of these are true:
-- [ ] A committed script in `.claude/workflows/` has a literal `export const meta`, with a `name` and a `description`, as its first statement, and reads its input from `args`: `git ls-tree -r --name-only HEAD .claude/workflows` lists it.
-- [ ] `.practice/a-3-run1.md` and `.practice/a-3-run2.md` name two different folders on their first lines, and each cites at least one `path:line` inside its folder.
-- [ ] The `git grep -E` pattern in `.practice/a-3-pattern.txt` matched inside both folders at an earlier commit, and matches inside neither at `HEAD`.
-- [ ] Self-check (not tested): your test command passes at `HEAD`, and before you approved the first run you read its script and can say how many agents it starts and what ends its fix rounds if the tests never pass.
+- [ ] A committed script in `.claude/workflows/` has a literal `export const meta`, with a `name` and a `description`, as its first statement, reads its input from `args`, and calls `agent()` at least twice: `git ls-tree -r --name-only HEAD .claude/workflows` lists it.
+- [ ] The `git grep -E` pattern in `.practice/a-3-pattern.txt` matched in a folder at an earlier commit and matches nothing in that folder at `HEAD`.
+- [ ] Self-check (not tested): you ran the saved workflow by name on a second folder and can name a finding its checking agents confirmed or dropped, and before you approved the first run you read its script and can say how many agents it starts.
Run `npm run check -- a-3 --dir <your repo>` from your practice copy.
-If the first item fails, check that the script is committed (`git check-ignore -v .claude/workflows/<file>.js` names any ignore rule that hides it; add it with `git add -f` and commit it) and that it reads `args`. If a report cites a `path:line` outside its folder, or none inside it, make sure the script reads the folder from `args`, start `claude` at the repository root so paths start there, and ask Claude to save the report again with only the files the migration changed in that folder. If the old form still matches at `HEAD`, commit the run's changes, or run the workflow on that folder again. If the pattern never matched, test it on a commit from before the run: `git grep -n -E '<pattern>' <commit> -- <folder>` should list the old form.
+If the first item fails, read its hint: it names the line or the part of the script to change, and you commit the fix. If the second item fails, commit the migration, or set the goal again for the folder the hint names.
## Watch out
- In auto mode, Claude Code asks only before your first workflow launch: any **Yes** records consent in your user settings, and later launches start without asking. A workflow's agents use your permission rules, and when your session is in accept-edits, auto or bypass mode, they run in that same mode ([Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs), [Permission modes](https://code.claude.com/docs/en/sub-agents#permission-modes)). Read each script before you approve it, and stay in Manual mode for a workflow you haven't read.
-- A run can use meaningfully more tokens than the same task in conversation, and it counts toward your plan's usage and rate limits. Try a workflow on one small folder first, and ask Claude to use a smaller model for stages that don't need the strongest one. `/workflows` shows each agent's token usage as the run goes, and `x` on a selected run stops it. When a run grows unusually large, its progress line shows a `Large workflow` warning. Once you choose a size guideline, its agent count replaces the warning's built-in agent threshold, and a large projected token total can still trigger it. The warning doesn't pause or limit the run ([Cost](https://code.claude.com/docs/en/workflows#cost)).
-- `p` pauses and resumes a run, but a run you stopped doesn't resume with `p`: ask Claude to relaunch it with the same script, in the same session or one you reopen with `claude --resume`. Agents that were still running when you stopped start over ([Resume after a pause](https://code.claude.com/docs/en/workflows#resume-after-a-pause)). An agent whose output stops for too long also starts over on its own, and `/workflows` adds `(retry 1)` to its name ([When an agent stalls and restarts](https://code.claude.com/docs/en/workflows#when-an-agent-stalls-and-restarts)). At v2.1.285, an agent also starts over from its prompt when its connection stalls for a few minutes mid-response (fixed in v2.1.286) or your Mac wakes from sleep (fixed in v2.1.290) ([CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md)), so keep the machine awake while a run works.
+- A run can use meaningfully more tokens than the same task in conversation, and it counts toward your plan's usage and rate limits. Try a workflow on one small folder first. `/workflows` shows each agent's token usage as the run goes, and `x` on a selected run stops it. When a run grows unusually large, its progress line shows a `Large workflow` warning, which doesn't pause or limit the run ([Cost](https://code.claude.com/docs/en/workflows#cost)).
+- If Claude keeps answering the goal's evaluator without using a tool for several turns, Claude Code stops the loop and gives you control with the goal still set; `/goal clear` removes a goal ([How evaluation works](https://code.claude.com/docs/en/goal#how-evaluation-works), [Clear a goal](https://code.claude.com/docs/en/goal#clear-a-goal)).
## Go further
- [This guide's own saved workflow](../../.claude/workflows/stale-docs-audit.js): a real script that reads `args`, groups its agents into phases, and has separate agents verify each claim before it's reported.
-- Optional: run the bundled research workflow on a question you'd otherwise research by hand, such as `/deep-research What changed in the Node.js permission model between v20 and v22?`. It fans out web searches, cross-checks the sources and returns a cited report. It needs the WebSearch tool, which Amazon Bedrock doesn't offer ([Run a bundled workflow](https://code.claude.com/docs/en/workflows#run-a-bundled-workflow), [WebSearch tool behavior](https://code.claude.com/docs/en/tools-reference#websearch-tool-behavior)).
-- [Example workflow prompts](https://code.claude.com/docs/en/workflows#example-workflow-prompts): more task shapes, such as finding flaky tests until a round turns up nothing new.
+- [Distribute a workflow in a plugin](https://code.claude.com/docs/en/workflows#distribute-a-workflow-in-a-plugin): share a saved workflow with other repositories through your team's plugin, as in [lesson 6](06-share-your-setup.md).
+- [Compare ways to keep a session running](https://code.claude.com/docs/en/goal#compare-ways-to-keep-a-session-running): `/goal`, `/loop` and a Stop hook, and what starts each next turn.
---
-<sub>Sources: [Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Commands](https://code.claude.com/docs/en/commands) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [Claude Code CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) · [git grep](https://git-scm.com/docs/git-grep) · [Node.js ECMAScript modules](https://nodejs.org/api/esm.html)</sub>
+<sub>Sources: [Keep Claude working toward a goal](https://code.claude.com/docs/en/goal) · [Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [git grep](https://git-scm.com/docs/git-grep) · [Node.js ECMAScript modules](https://nodejs.org/api/esm.html)</sub>
<sub>← [Choose an orchestration pattern](02-orchestration-patterns.md) · [Advanced index](README.md) · [Script Claude Code with `claude -p`](04-headless.md) → · Topic: [Subagents and parallel work](../topics/subagents-and-parallel-work.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-3)</sub>
diff --git a/docs/advanced/04-headless.md b/docs/advanced/04-headless.md
index d6b3223..5288b88 100644
--- a/docs/advanced/04-headless.md
+++ b/docs/advanced/04-headless.md
@@ -1,6 +1,6 @@
# Script Claude Code with `claude -p`
-<sub>**Advanced** · Lesson 4 of 7 · about 20 minutes · Needs: [Run and save a dynamic workflow](03-dynamic-workflows.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-22</sub>
+<sub>**Advanced** · Lesson 4 of 7 · about 20 minutes · Needs: [Run and save a dynamic workflow](03-dynamic-workflows.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -8,7 +8,7 @@ By the end of this lesson you can write a script that runs Claude Code with no o
## You need
-- One of your own repositories with a test command, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
+- One of your own repositories with a test command, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's `.practice/` folder as the [Intermediate index](../intermediate/README.md#prepare-your-own-repository) describes, if you haven't yet.
- bash and `jq`, on macOS, Linux or WSL 2.
- Usage: light. Each `claude -p` run is one short session.
@@ -20,9 +20,9 @@ With [`--output-format json`](https://code.claude.com/docs/en/headless#get-struc
When a script needs fields rather than prose, add `--json-schema` with a [JSON Schema](https://json-schema.org/): the object then also holds `structured_output`, an answer in that shape ([Get structured output](https://code.claude.com/docs/en/headless#get-structured-output)). A run that ends without valid structured output has no `structured_output` field, so check that it's there before you use it.
-Nobody can answer a permission prompt, so pass a mode every time: a run where nothing sets one can start in auto mode ([Auto-approve tools](https://code.claude.com/docs/en/headless#auto-approve-tools)). Three flags set the limits: `--permission-mode dontAsk` denies every call that would otherwise prompt, `--allowedTools` names what may run anyway, and `--max-turns` caps the turns ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)).
+Nobody can answer a permission prompt, so pass a mode every time, and the script behaves the same on every version. Since v2.1.302, a run that sets none starts in Manual mode and denies every call that needs approval; before that, it could start in auto mode ([Tool calls denied in `claude -p` and Agent SDK runs](https://code.claude.com/docs/en/permission-modes#which-mode-a-non-interactive-run-starts-in)). Three flags set the limits: `--permission-mode dontAsk` denies every call that would otherwise prompt, `--allowedTools` names what may run anyway, and `--max-turns` caps the turns. `--tools` goes further: it restricts which built-in tools Claude can use at all ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)).
-A `-p` run also loads what an interactive session would: hooks, skills, plugins, MCP servers, auto memory and CLAUDE.md, from the project and from `~/.claude`. `--bare` skips all of them, so a CI run behaves the same on every machine, and it is the mode the docs recommend for scripted calls ([Start faster with bare mode](https://code.claude.com/docs/en/headless#start-faster-with-bare-mode)). Bare mode never reads your subscription login: on the Anthropic API it needs `ANTHROPIC_API_KEY`, or an `apiKeyHelper` in `--settings`, so use it where the run has a key, as in CI. This lesson runs on your own login, so its steps use `--setting-sources user` instead, which drops less: it leaves out the project's settings files and its `.mcp.json`, and your user settings still load ([What runs before you trust a folder](https://code.claude.com/docs/en/permissions#what-runs-before-you-trust-a-folder)).
+A `-p` run also loads what an interactive session would: hooks, skills, plugins, MCP servers and CLAUDE.md, from the project and from `~/.claude`. In CI, where the run has an API key, add `--bare`, which skips all of them so every machine behaves the same ([Start faster with bare mode](https://code.claude.com/docs/en/headless#start-faster-with-bare-mode)). This lesson runs on your own login, which `--bare` never reads, so its steps use `--setting-sources user` to leave the project's settings files and `.mcp.json` out ([What runs before you trust a folder](https://code.claude.com/docs/en/permissions#what-runs-before-you-trust-a-folder)).
## Worked example
@@ -53,7 +53,7 @@ In your repository:
claude -p "Run the test suite and say how many tests pass" --output-format json --permission-mode dontAsk --setting-sources user --disallowedTools "Read(./.env)" "Read(./.env.*)" --allowedTools "Bash(npm test *)" --max-turns 3 | jq '{subtype, num_turns, denied: (.permission_denials | length)}'
```
- It shows `"subtype": "success"` and `"denied": 0`: this time Claude ran the tests. The space before the `*` matters, and a trailing ` *` also matches the bare command ([Wildcard patterns](https://code.claude.com/docs/en/permissions#wildcard-patterns)). The rule also covers a pipeline such as `npm test 2>&1 | tail -20`: Claude Code checks each part of a pipeline on its own, and `tail` is one of the read-only commands that run without approval ([Compound commands](https://code.claude.com/docs/en/permissions#compound-commands), [Read-only commands](https://code.claude.com/docs/en/permissions#read-only-commands)).
+ It shows `"subtype": "success"` and `"denied": 0`: this time Claude ran the tests. The space before the `*` matters, and a trailing ` *` also matches the bare command ([Wildcard patterns](https://code.claude.com/docs/en/permissions#wildcard-patterns)). A rule must match each part of a pipeline Claude writes, such as `npm test 2>&1 | tail -20`, where `tail` is a read-only command that needs no rule ([Compound commands](https://code.claude.com/docs/en/permissions#compound-commands), [Read-only commands](https://code.claude.com/docs/en/permissions#read-only-commands)).
4. Hit the cap. This task takes two steps in a row, and `--max-turns 1` allows one turn that calls tools. Keep `Read` and use the same Bash rule as in step 3:
```bash
@@ -66,14 +66,14 @@ In your repository:
## Your turn
-Write a review you can run before every commit: `scripts/review-staged.sh` sends your staged changes to Claude, prints Claude's review and saves the JSON result. The Advanced capstone reuses it.
+Build a pre-commit reviewer that runs nothing you didn't allow and never hides a failed run. `scripts/review-staged.sh` sends your staged changes to Claude, prints Claude's review and saves the JSON result. The Advanced capstone reuses it.
Acceptance criteria:
- A bash script at `scripts/review-staged.sh`, committed and executable.
- It pipes `git diff --cached`, the staged changes ([git diff](https://git-scm.com/docs/git-diff)), into one `claude -p` call. Claude needs no Bash to read the diff, because it arrives on stdin ([Add Claude to a build script](https://code.claude.com/docs/en/headless#add-claude-to-a-build-script)).
-- That call puts the prompt right after `-p`, as the [Pipe data through Claude](https://code.claude.com/docs/en/headless#pipe-data-through-claude) and [Add Claude to a build script](https://code.claude.com/docs/en/headless#add-claude-to-a-build-script) examples do, and passes `--output-format json`, `--permission-mode dontAsk`, `--allowedTools` naming only `Read`, `Grep` and `Glob`, and `--max-turns` with a number from 1 to 10. On macOS, Linux and WSL, Glob and Grep are absent by default, and naming either one in `--allowedTools` brings both back ([Glob tool behavior](https://code.claude.com/docs/en/tools-reference#glob-tool-behavior)).
-- It calls `claude` by name, not by a path or through `npx`, and doesn't change `PATH`: that is how the check swaps in a stand-in for it.
+- That call puts the prompt right after `-p`, as the [Pipe data through Claude](https://code.claude.com/docs/en/headless#pipe-data-through-claude) and [Add Claude to a build script](https://code.claude.com/docs/en/headless#add-claude-to-a-build-script) examples do, and passes `--output-format json`, `--permission-mode dontAsk`, `--allowedTools` naming only `Read`, `Grep` and `Glob`, and `--max-turns` with a number from 1 to 10. On macOS, Linux and WSL, Glob and Grep are absent by default, and naming either one in `--allowedTools` brings both back ([Glob tool behavior](https://code.claude.com/docs/en/tools-reference#glob-tool-behavior)). `--allowedTools` only pre-approves: a tool it doesn't name still runs when a rule approves it, such as the test rule from [Intermediate lesson 4](../intermediate/04-permissions-and-sandbox.md). So the call also passes `--tools "Read,Grep,Glob"`, which restricts the built-in tools to those three, so Claude can't use Bash, Edit or Write at all ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)).
+- It keeps the project's hooks and MCP servers out of the review. `--settings '{"disableAllHooks": true}'` turns hooks off for the run, so the `Stop` hook from [Intermediate lesson 5](../intermediate/05-hooks.md) can't send the reviewer back to work ([Disable or remove hooks](https://code.claude.com/docs/en/hooks#disable-or-remove-hooks)), and `--strict-mcp-config` uses only the MCP servers you pass with `--mcp-config`, here none ([Project scope](https://code.claude.com/docs/en/mcp#project-scope)). Unlike `--setting-sources user`, both keep the project's skills, so the capstone's review skill still loads ([Control filesystem settings with settingSources](https://code.claude.com/docs/en/agent-sdk/claude-code-features#control-filesystem-settings-with-settingsources)).
- It saves the JSON to the path in its first argument, or to `.practice/a-4-result.json` when it gets none, creating the folder if it's missing.
- It prints the `result` text, and exits non-zero when `claude` does or when `is_error` is `true`.
- With nothing staged, it says so and exits non-zero without calling Claude. `git diff --cached --quiet` exits with 0 when nothing is staged ([git diff](https://git-scm.com/docs/git-diff)).
@@ -85,14 +85,14 @@ Commit the script. Then stage a small change, such as a one-line fix, and run `s
You are done when all of these are true:
- [ ] `scripts/review-staged.sh` is committed and executable.
-- [ ] Its `claude -p` call has the prompt right after `-p`, asks for JSON, runs in `dontAsk` mode, pre-approves only `Read`, `Grep` and `Glob`, and caps turns at 10 or fewer.
+- [ ] Its `claude -p` call has the prompt right after `-p`, asks for JSON, runs in `dontAsk` mode, pre-approves only `Read`, `Grep` and `Glob`, restricts the tools to those three, turns hooks off and uses no MCP server, and caps turns at 10 or fewer.
- [ ] It pipes the staged diff in, saves the JSON where its argument says, prints the result, exits non-zero when the run fails, and doesn't call Claude when nothing is staged.
- [ ] `.practice/a-4-result.json` holds a run that succeeded within your cap.
- [ ] Self-check (not tested): you read the review of your staged change and fixed one point it raised, or can say why you dismissed it, before you committed.
Run `npm run check -- a-4 --dir <your repo>` from your practice copy, or `npm run check -- a-4` in the copy itself. The check runs your committed script with a stand-in for `claude`, so it uses none of your usage.
-If the first item fails, run `chmod +x scripts/review-staged.sh`, then `git add` it and commit again. If the second item fails, read its hint: it names the flag it didn't find, or says your script calls `claude` by a path or through `npx`, or changes `PATH`. Compare your `claude -p` line with the criteria in Your turn, starting with where the prompt sits. If the third item fails, run the script by hand with nothing staged and again with a staged change, and run `echo $?` after each; the check runs the committed script, so commit each fix before you run the check again. If the fourth item fails, stage a change and run the script again: a run that stopped at your cap doesn't count, so raise the cap or narrow the prompt.
+If the first item fails, run `chmod +x scripts/review-staged.sh`, then `git add` it and commit again. If the second item fails, compare your `claude -p` line with the criteria in Your turn, starting with where the prompt sits. If the third item fails, run the script by hand with nothing staged and again with a staged change, and run `echo $?` after each; the check runs the committed script, so commit each fix first. If the fourth item fails, stage a change and run the script again: a run that stopped at your cap doesn't count.
## Watch out
@@ -102,12 +102,12 @@ If the first item fails, run `chmod +x scripts/review-staged.sh`, then `git add`
## Go further
-- [Run Claude Code programmatically](https://code.claude.com/docs/en/headless): streaming JSON, and continuing a run with `--resume` and its `session_id`.
+- [Fail CI when a plugin or MCP server doesn't load](https://code.claude.com/docs/en/headless#fail-ci-when-a-plugin-or-mcp-server-doesn%E2%80%99t-load): make a scripted run fail when its plugins or servers didn't load.
- [Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs): start the workflow you saved in the previous lesson from a script, with `Workflow(<name>)` in your allow rules.
- [Agent SDK overview](https://code.claude.com/docs/en/agent-sdk/overview): the same agent loop from Python or TypeScript.
---
-<sub>Sources: [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Configure the sandboxed Bash tool](https://code.claude.com/docs/en/sandboxing) · [How the agent loop works](https://code.claude.com/docs/en/agent-sdk/agent-loop) · [Agent SDK reference - TypeScript](https://code.claude.com/docs/en/agent-sdk/typescript) · [Track cost and usage](https://code.claude.com/docs/en/agent-sdk/cost-tracking) · [Authentication](https://code.claude.com/docs/en/authentication) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [Error reference](https://code.claude.com/docs/en/errors) · [git diff](https://git-scm.com/docs/git-diff)</sub>
+<sub>Sources: [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Configure the sandboxed Bash tool](https://code.claude.com/docs/en/sandboxing) · [How the agent loop works](https://code.claude.com/docs/en/agent-sdk/agent-loop) · [Agent SDK reference - TypeScript](https://code.claude.com/docs/en/agent-sdk/typescript) · [Track cost and usage](https://code.claude.com/docs/en/agent-sdk/cost-tracking) · [Authentication](https://code.claude.com/docs/en/authentication) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [Hooks reference](https://code.claude.com/docs/en/hooks) · [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp) · [Use Claude Code features in the SDK](https://code.claude.com/docs/en/agent-sdk/claude-code-features) · [Error reference](https://code.claude.com/docs/en/errors) · [git diff](https://git-scm.com/docs/git-diff)</sub>
<sub>← [Run and save a dynamic workflow](03-dynamic-workflows.md) · [Advanced index](README.md) · [GitHub Actions](05-github-actions.md) → · Topic: [Automation](../topics/automation.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-4)</sub>
diff --git a/docs/advanced/05-github-actions.md b/docs/advanced/05-github-actions.md
index 819ef20..b09c5e4 100644
--- a/docs/advanced/05-github-actions.md
+++ b/docs/advanced/05-github-actions.md
@@ -1,6 +1,6 @@
# GitHub Actions
-<sub>**Advanced** · Lesson 5 of 7 · about 20 minutes, plus run time · Needs: [Script Claude Code with `claude -p`](04-headless.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Advanced** · Lesson 5 of 7 · about 20 minutes, plus run time · Needs: [Script Claude Code with `claude -p`](04-headless.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -9,68 +9,93 @@ By the end of this lesson you can run Claude Code unattended in a GitHub Actions
## You need
- The `claude -p` flags from [lesson 4](04-headless.md), such as `--max-turns` and `--allowedTools`.
-- The [GitHub CLI](https://cli.github.com), signed in with `gh auth login`, which quick setup needs ([Quick setup](https://code.claude.com/docs/en/github-actions#quick-setup)).
-- A new private copy of the practice template, just for this lesson. You own it, so you have full control of it ([Permission levels for a personal account repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/repository-access-and-collaboration/permission-levels-for-a-personal-account-repository#owner-access-for-a-repository-owned-by-a-personal-account)), including the admin access that setup needs ([Setup](https://code.claude.com/docs/en/github-actions#setup)). Make it with:
+- The [GitHub CLI](https://cli.github.com), signed in with `gh auth login`.
+- A new private copy of the practice template, just for this lesson, which you own. Make it with:
```bash
gh repo create claude-actions-practice --template wesammustafa/claude-code-practice --private --clone
cd claude-actions-practice
```
- `--template` bases the new repository on the template, and `--clone` clones it ([gh repo create](https://cli.github.com/manual/gh_repo_create)). The check runs in this copy, with Node.js LTS, without `--dir`. At the end, you take the workflows, the secret and the App's access out of it.
-- A credential. A Claude Console API key made for this lesson is recommended, because the teardown deletes it. On a Pro, Max, Team or Enterprise plan ([Manual setup](https://code.claude.com/docs/en/github-actions#manual-setup)), you can instead let quick setup create a subscription token ([Quick setup](https://code.claude.com/docs/en/github-actions#quick-setup)). If Claude Code on your machine already uses an API key, quick setup reuses that key instead, so the teardown would delete the key your own Claude Code uses; step 3 of the Worked example shows how to swap in the lesson key.
+ `--template` bases the new repository on the template, and `--clone` clones it ([gh repo create](https://cli.github.com/manual/gh_repo_create)). The check runs in this copy, with Node.js LTS, without `--dir`. At the end, you take the workflows and the secret out of it.
+- A credential: a Claude Console API key made for this lesson, recommended because the teardown deletes it, or, on a Pro, Max, Team or Enterprise plan, a token from `claude setup-token` ([Manual setup](https://code.claude.com/docs/en/github-actions#manual-setup)).
- Usage: light. Each run is short, and also uses GitHub Actions minutes (see Watch out).
## The idea
-The [Claude Code GitHub Action](https://code.claude.com/docs/en/github-actions), `anthropics/claude-code-action` (Anthropic), runs Claude Code as a step in a workflow. With no `prompt` input, it waits for `@claude` in an issue or pull request and answers in a comment; with a `prompt`, it runs without waiting for a mention ([Interactive and automation modes](https://code.claude.com/docs/en/github-actions#interactive-and-automation-modes)), and its `display_report` input puts Claude's report on the run's summary page ([action.yml at v1.0.237](https://github.com/anthropics/claude-code-action/blob/v1.0.237/action.yml)).
+The [Claude Code GitHub Action](https://code.claude.com/docs/en/github-actions), `anthropics/claude-code-action` (Anthropic), runs Claude Code as a step in a workflow. With no `prompt` input, it waits for `@claude` in an issue or pull request; with a `prompt`, it runs without waiting for a mention ([Interactive and automation modes](https://code.claude.com/docs/en/github-actions#interactive-and-automation-modes)). Its `display_report` input puts Claude's report on the run's summary page ([action.yml at v1.0.258](https://github.com/anthropics/claude-code-action/blob/v1.0.258/action.yml)).
-The workflow names a repository secret that holds the credential ([Manual setup](https://code.claude.com/docs/en/github-actions#manual-setup)).
+The workflow names a repository secret that holds the credential ([Manual setup](https://code.claude.com/docs/en/github-actions#manual-setup)). With `github_token` set to the job's own token, the action uses that token instead of the Claude GitHub App ([Action parameters](https://code.claude.com/docs/en/github-actions#action-parameters)), so the job's `permissions` limit what it can do on GitHub ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idpermissions)).
-No one is at the keyboard, so the limits go in the file. `claude_args` passes Claude Code's CLI flags, such as `--max-turns` and `--allowedTools` ([Pass CLI arguments](https://code.claude.com/docs/en/github-actions#pass-cli-arguments)), and with a prompt written as text rather than a skill, Claude has no shell until you allow the commands it needs ([Run on a schedule](https://code.claude.com/docs/en/github-actions#run-on-a-schedule)). The job's `permissions` and `timeout-minutes` limit its GitHub token and its run time ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idpermissions)).
+No one is at the keyboard, so the limits go in the file. `claude_args` passes Claude Code's CLI flags, such as `--max-turns` and `--allowedTools` ([Pass CLI arguments](https://code.claude.com/docs/en/github-actions#pass-cli-arguments)), and with a prompt written as text rather than a skill, Claude has no shell until you allow the commands it needs ([Run on a schedule](https://code.claude.com/docs/en/github-actions#run-on-a-schedule)). The job's `timeout-minutes` limits its run time ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idtimeout-minutes)).
## Worked example
-Connect the copy with quick setup, then ask Claude a question in an issue.
+Ask Claude a question from a workflow you start by hand. You set it up yourself, with a workflow file and a secret; the job's own token stands in for the Claude GitHub App, which this lesson doesn't install.
+
+1. In the copy, save this workflow as `.github/workflows/ask-claude.yml`, then commit it and push it to `main`. A manual run starts only when the workflow file is on the default branch ([`workflow_dispatch`](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_dispatch)):
+
+ ```yaml
+ name: Ask Claude
+ on: workflow_dispatch
+ jobs:
+ ask:
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@v7
+ - uses: anthropics/[email protected]
+ with:
+ anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
+ github_token: ${{ github.token }}
+ prompt: "In one paragraph, what does src/links.js do? Don't change any files."
+ claude_args: "--max-turns 3"
+ display_report: true
+ ```
-1. In the copy, start `claude`, run `/install-github-app` and follow the prompts for this repository: Claude Code installs the Claude GitHub App ([Quick setup](https://code.claude.com/docs/en/github-actions#quick-setup)). When GitHub asks which repositories the App can access, choose **Only select repositories** and pick this copy only ([Installing a GitHub App](https://docs.github.com/en/apps/using-github-apps/installing-a-github-app-from-a-third-party#installing-a-github-app)). If the App is already on your account, add this copy under its **Repository access** instead ([Modifying repository access](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps#modifying-repository-access)).
-2. Claude Code then asks whether to continue with GitHub Actions setup. Continue, and select only the `@claude` workflow, `claude.yml`, not the review workflow. For the credential, paste your lesson key or create a subscription token, unless Claude Code reuses its own API key (see You need). Claude Code saves the credential as the secret `ANTHROPIC_API_KEY` or `CLAUDE_CODE_OAUTH_TOKEN`, pushes a branch with the workflow you selected and opens GitHub in your browser with a pull request ready to create ([Quick setup](https://code.claude.com/docs/en/github-actions#quick-setup)).
-3. Create and merge that pull request, then update your clone and list the secrets:
+ With a subscription token, replace the `anthropic_api_key` line with `claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}` ([Manual setup](https://code.claude.com/docs/en/github-actions#manual-setup)). Release v1.0.258 installs Claude Code v2.1.308 ([run.ts at v1.0.258](https://github.com/anthropics/claude-code-action/blob/v1.0.258/src/entrypoints/run.ts)); its full commit SHA is `6b6870e649b5ff408753befeaee5fc7989d4e6a9`.
+2. Save the credential as the repository secret the workflow names. With no value on the command line, `gh secret set` asks you to paste it ([gh secret set](https://cli.github.com/manual/gh_secret_set)):
```bash
- git pull
+ gh secret set ANTHROPIC_API_KEY
gh secret list
```
- The list shows `ANTHROPIC_API_KEY` or `CLAUDE_CODE_OAUTH_TOKEN` ([gh secret list](https://cli.github.com/manual/gh_secret_list)). The merged `.github/workflows/claude.yml` is already set to use that secret, and `@claude` now works in the repository ([Quick setup](https://code.claude.com/docs/en/github-actions#quick-setup)). If quick setup reused the API key your own Claude Code uses, swap in your lesson key now: `gh secret set ANTHROPIC_API_KEY` asks you to paste it ([gh secret set](https://cli.github.com/manual/gh_secret_set)).
-4. Open an issue that mentions `@claude`. In interactive mode, Claude answers `@claude` in the body or title of a newly opened issue ([Interactive and automation modes](https://code.claude.com/docs/en/github-actions#interactive-and-automation-modes)):
+ With a subscription token, run `gh secret set CLAUDE_CODE_OAUTH_TOKEN` instead. `gh secret list` then shows the secret's name ([gh secret list](https://cli.github.com/manual/gh_secret_list)). For a secret that several repositories will share, the docs recommend an API key, because a subscription token is tied to the subscription of the person who created it ([Set up for an organization](https://code.claude.com/docs/en/github-actions#set-up-for-an-organization)).
+3. Start the workflow, find its run, and follow it to the end ([gh workflow run](https://cli.github.com/manual/gh_workflow_run), [gh run list](https://cli.github.com/manual/gh_run_list), [gh run watch](https://cli.github.com/manual/gh_run_watch)):
```bash
- gh issue create --title "What does links.js do?" --body "@claude In one paragraph, what does src/links.js do? Don't change any files."
+ gh workflow run ask-claude.yml
+ gh run list --workflow ask-claude.yml --limit 1
+ gh run watch <run-id> --exit-status
```
- `gh issue create` prints the new issue's URL ([gh issue create](https://cli.github.com/manual/gh_issue_create)). `gh run list --limit 3` lists the run it started ([gh run list](https://cli.github.com/manual/gh_run_list)). When it finishes, `gh issue view <issue-url> --comments` shows Claude's answer as a comment ([gh issue view](https://cli.github.com/manual/gh_issue_view)). Your wording will differ, but it should describe how `src/links.js` finds Markdown links.
+4. Open the run in your browser with `gh run view <run-id> --web` ([gh run view](https://cli.github.com/manual/gh_run_view)). Its summary page holds Claude's report, with the answer. Your wording will differ, but it should describe how `src/links.js` finds Markdown links.
+
+Both of the docs' setup paths install the Claude GitHub App ([Setup](https://code.claude.com/docs/en/github-actions#setup)). Its permission set is all or nothing, and includes write access to the repository's contents, issues, pull requests and workflows ([GitHub App permissions](https://code.claude.com/docs/en/github-actions#github-app-permissions)), so install it only when you want `@claude`, with `/install-github-app`, or another Claude feature that needs it, such as Code Review.
## Your turn
-**Brief:** add `.github/workflows/linkcheck-report.yml`, a workflow you start by hand, in which Claude runs the template's link checker on `samples/` and explains each broken link on the run's summary page, without changing any files. The docs' [Run on a schedule](https://code.claude.com/docs/en/github-actions#run-on-a-schedule) example is a starting point. It sets a model with `--model`: pick one as in [Intermediate lesson 3](../intermediate/03-model-and-effort.md), or leave that line out to use Claude Code's default model ([Pass CLI arguments](https://code.claude.com/docs/en/github-actions#pass-cli-arguments)).
+**Brief:** run Claude in CI with every limit written in the file, then leave no credential in the copy. Add `.github/workflows/linkcheck-report.yml`, a workflow you start by hand, in which Claude runs the template's link checker on `samples/` and explains each broken link on the run's summary page, without changing any files. The docs' [Run on a schedule](https://code.claude.com/docs/en/github-actions#run-on-a-schedule) example is a starting point. It sets a model with `--model`: pick one as in [Intermediate lesson 3](../intermediate/03-model-and-effort.md), or leave that line out to use Claude Code's default model ([Pass CLI arguments](https://code.claude.com/docs/en/github-actions#pass-cli-arguments)).
**Acceptance criteria:**
- It starts only by hand: `on: workflow_dispatch`, and no other trigger.
-- It uses `anthropics/claude-code-action` pinned to a release tag or a full commit SHA, not `@v1` (Watch out says why). Release v1.0.237 installs Claude Code v2.1.285, the version this page was checked against ([run.ts at v1.0.237](https://github.com/anthropics/claude-code-action/blob/v1.0.237/src/entrypoints/run.ts)).
+- It uses `anthropics/claude-code-action` pinned to a release tag, such as `@v1.0.258`, or a full commit SHA, not `@v1` (Watch out says why).
- It has a `prompt`, so it runs in automation mode.
-- Its credential comes from the secret quick setup saved, through the matching input, `anthropic_api_key` or `claude_code_oauth_token` ([Manual setup](https://code.claude.com/docs/en/github-actions#manual-setup)). No credential is written in the file.
-- It has a read-only job token: no write access in `permissions` except `id-token: write`. The job's `permissions` grant `contents: read`, plus `id-token: write` if you keep it from the docs' examples, where it serves the action's default GitHub App authentication ([Respond to @claude mentions](https://code.claude.com/docs/en/github-actions#respond-to-@claude-mentions)). `github_token` is set to the job's own `GITHUB_TOKEN`, so Claude acts with that token instead of the App's ([Action parameters](https://code.claude.com/docs/en/github-actions#action-parameters)).
-- `claude_args` sets `--max-turns` to 10 or fewer, and an `--allowedTools` rule for the link-check command alone, never all of Bash ([Configure permissions](https://code.claude.com/docs/en/permissions#wildcard-patterns)). Write the turn limit as two words, `--max-turns <n>`, as the docs' [Pass CLI arguments](https://code.claude.com/docs/en/github-actions#pass-cli-arguments) example does: the action reads a flag's value from the word after it ([parse-sdk-options.ts at v1.0.237](https://github.com/anthropics/claude-code-action/blob/v1.0.237/base-action/src/parse-sdk-options.ts)).
+- Its credential comes from the secret you saved, through the matching input, `anthropic_api_key` or `claude_code_oauth_token`. No credential is written in the file.
+- It has a read-only job token: the job's `permissions` grant `contents: read` and no write access, and `github_token` is set to the job's own token, as in the Worked example.
+- `claude_args` sets `--max-turns` to 10 or fewer, written as two words, `--max-turns <n>`, as the docs' [Pass CLI arguments](https://code.claude.com/docs/en/github-actions#pass-cli-arguments) example does, and an `--allowedTools` rule for the link-check command alone, never all of Bash ([Configure permissions](https://code.claude.com/docs/en/permissions#wildcard-patterns)).
- The job has a `timeout-minutes` of 30 or fewer ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idtimeout-minutes)).
- It checks out the repository and sets up Node.js before the action runs, as the template's `.github/workflows/progress.yml` does, so the link checker can run.
-- `display_report` is `true`, so Claude's report, with its answer, appears on the run's summary page ([action.yml at v1.0.237](https://github.com/anthropics/claude-code-action/blob/v1.0.237/action.yml), [Adding a job summary](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#adding-a-job-summary)). The action says to turn it on only when its input is trusted, as here: you start the run, and the prompt and files are your own. `show_full_output` stays off, and you don't turn on GitHub Actions debug mode (an `ACTIONS_STEP_DEBUG` secret set to `true`), which turns full output on: full output can print secrets into the log ([security notes](https://github.com/anthropics/claude-code-action/blob/v1.0.237/docs/security.md)). Without it, the log hides Claude's messages and tool calls and shows a summary of the result, with a line that suggests turning full output on ([run-claude-sdk.ts at v1.0.237](https://github.com/anthropics/claude-code-action/blob/v1.0.237/base-action/src/run-claude-sdk.ts)).
+- `display_report` is `true`, so Claude's report appears on the run's summary page. Turn it on only for trusted input, as here: you start the run, and the prompt and files are yours ([action.yml at v1.0.258](https://github.com/anthropics/claude-code-action/blob/v1.0.258/action.yml)). Keep `show_full_output` off and don't turn on GitHub Actions debug mode: both print Claude's full output, which can include secrets, into the log ([security notes](https://github.com/anthropics/claude-code-action/blob/v1.0.258/docs/security.md)).
Then run it, save the record and tear down:
-1. Commit the workflow and push it to `main`. A manual run starts only when the workflow file is on the default branch ([`workflow_dispatch`](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_dispatch)).
-2. Start it, find its id, follow it to the end and open it in your browser ([gh workflow run](https://cli.github.com/manual/gh_workflow_run), [gh run watch](https://cli.github.com/manual/gh_run_watch), [gh run view](https://cli.github.com/manual/gh_run_view)):
+1. Commit the workflow and push it to `main`.
+2. Start it, find its id, follow it to the end and open it in your browser:
```bash
gh workflow run linkcheck-report.yml
@@ -90,51 +115,52 @@ Then run it, save the record and tear down:
4. Run `npm run check -- a-5` (the Check below). When it passes, tear down: this is required. Don't tear down first: fixing a failed run needs the secret, which the teardown deletes.
> [!WARNING]
-> Deleting a secret leaves the credential it held valid ([Uninstall](https://code.claude.com/docs/en/github-actions#uninstall)). The `CLAUDE_CODE_OAUTH_TOKEN` secret holds an OAuth token of the kind `claude setup-token` generates ([Action parameters](https://code.claude.com/docs/en/github-actions#action-parameters)). On 2026-10-09, a token from `claude setup-token` is valid for one year ([Authentication](https://code.claude.com/docs/en/authentication#generate-a-long-lived-token)), and deleting the secret doesn't revoke it.
+> Deleting a secret leaves the credential it held valid ([Uninstall](https://code.claude.com/docs/en/github-actions#uninstall)). The `CLAUDE_CODE_OAUTH_TOKEN` secret holds an OAuth token of the kind `claude setup-token` generates ([Action parameters](https://code.claude.com/docs/en/github-actions#action-parameters)). On 2026-10-24, a token from `claude setup-token` is valid for one year ([Authentication](https://code.claude.com/docs/en/authentication#generate-a-long-lived-token)), and deleting the secret doesn't revoke it.
5. Delete both workflows, then commit and push:
```bash
- git rm .github/workflows/claude.yml .github/workflows/linkcheck-report.yml
+ git rm .github/workflows/ask-claude.yml .github/workflows/linkcheck-report.yml
git commit -m "Remove the Claude workflows"
git push
```
6. Delete the secret: `gh secret delete ANTHROPIC_API_KEY`, or `gh secret delete CLAUDE_CODE_OAUTH_TOKEN` ([gh secret delete](https://cli.github.com/manual/gh_secret_delete)).
-7. With an API key, delete the key the secret held on the Claude Console's [API keys page](https://platform.claude.com/settings/keys). If that is the key your own Claude Code uses, Claude Code on your machine needs a new key afterwards.
-8. On GitHub, open **Settings** > **Applications** > **Installed GitHub Apps** and select **Configure** next to Claude. Then either remove this copy under **Repository access** and click **Save**, or, if this copy is the only repository the App can reach and nothing else of yours uses it, click **Uninstall** ([Modifying repository access](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps#modifying-repository-access), [Blocking access](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps#blocking-access)).
+7. With an API key, delete the key the secret held on the Claude Console's [API keys page](https://platform.claude.com/settings/keys). With a subscription token, nothing in this teardown revokes it, so it stays valid until it expires ([Uninstall](https://code.claude.com/docs/en/github-actions#uninstall)): that's why this lesson recommends an API key.
+
+If you installed the Claude GitHub App for this copy, also remove the copy from the App's repository access on GitHub ([Modifying repository access](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps#modifying-repository-access)).
## Check
You are done when all of these are true:
- [ ] A committed workflow runs `anthropics/claude-code-action` pinned to a release tag or a full commit SHA, in automation mode, with its credential from a secret and none in the file.
-- [ ] Its limits are in the file: `--max-turns` of 10 or fewer, an `--allowedTools` list without unrestricted Bash, a read-only job token (no write access in `permissions` except `id-token: write`) and a `timeout-minutes` of 30 or fewer.
+- [ ] Its limits are in the file: `--max-turns` of 10 or fewer, an `--allowedTools` list without unrestricted Bash, a read-only job token (no write access in `permissions`) and a `timeout-minutes` of 30 or fewer.
- [ ] `.practice/a-5-runs.json` shows a completed, successful manual run on a commit that holds the workflow.
-- [ ] Self-check (not tested): you can say who can start a Claude run in this copy, and which text from an issue or comment reaches Claude as input (see Watch out).
+- [ ] Self-check (not tested): you can say who can start a Claude run in this copy, and which text from an issue or comment would reach Claude as input if you added an `@claude` workflow (see Watch out).
Run `npm run check -- a-5` in this copy.
-If the first item fails on the `uses:` line, pin a release tag such as `@v1.0.237`, or that release's full commit SHA. If the second item fails, its hint names the limit to add or fix. If the saved run failed, `gh run view <run-id> --log-failed` shows why, such as a secret name that doesn't match the workflow, or reaching the turn limit, which exits with an error ([CLI reference](https://code.claude.com/docs/en/cli-reference#cli-flags)); push a fix, run the workflow again and save the record again.
+If the first or second item fails, its hint names the line or the limit to fix. If the saved run failed, `gh run view <run-id> --log-failed` shows why, such as a secret name that doesn't match the workflow; push a fix, run the workflow again and save the record again.
-The check reads the workflow from your history, so it still passes after the teardown. Once it passes, tear down as Your turn's steps 5 to 8 describe.
+The check reads the workflow from your history, so it still passes after the teardown. Once it passes, tear down as Your turn's steps 5 to 7 describe.
## Watch out
-- Anyone with write access to the repository can start a run with `@claude`, and the issue or comment text is input to Claude, so it can carry hidden instructions ([Who can trigger runs](https://code.claude.com/docs/en/github-actions#who-can-trigger-runs), [the action's security notes](https://github.com/anthropics/claude-code-action/blob/v1.0.237/docs/security.md)). Keep this copy private and yours: only people with read access can see its run logs ([Using workflow run logs](https://docs.github.com/en/actions/how-tos/monitor-workflows/use-workflow-run-logs)).
-- Each run uses GitHub Actions minutes and tokens. In a private repository, the minutes come out of your account's included minutes ([GitHub Actions billing](https://docs.github.com/en/billing/concepts/product-billing/github-actions)). The tokens are billed to your Console account with an API key, or drawn from your plan with a subscription token. `--max-turns` and `timeout-minutes` limit how much work a run can do, which lowers both ([Manage costs](https://code.claude.com/docs/en/github-actions#manage-costs)).
-- The `v1` tag in the docs' examples moves to each new release ([tags](https://github.com/anthropics/claude-code-action/tags)), and each release pins the Claude Code version it installs, so a workflow on `@v1` can run a newer Claude Code than you tested. GitHub calls a workflow dependency lockfile the strongest protection, offers pinning to a full-length commit SHA for repositories that cannot adopt one, and warns that a tag can be moved or deleted if a bad actor gains access to the action's repository ([Secure use reference](https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions)). A release tag such as `v1.0.237` is the lighter pin this lesson also accepts.
+- Anyone with write access to the repository can start a run with `@claude`, and the issue or comment text is input to Claude, so it can carry hidden instructions ([Who can trigger runs](https://code.claude.com/docs/en/github-actions#who-can-trigger-runs), [the action's security notes](https://github.com/anthropics/claude-code-action/blob/v1.0.258/docs/security.md)). Keep this copy private and yours: only people with read access can see its run logs ([Using workflow run logs](https://docs.github.com/en/actions/how-tos/monitor-workflows/use-workflow-run-logs)).
+- Each run uses GitHub Actions minutes and tokens. In a private repository, the minutes come out of your account's included minutes ([GitHub Actions billing](https://docs.github.com/en/billing/concepts/product-billing/github-actions)). The template's Progress workflow also runs on each push to this copy, so every push uses some of those minutes too. The tokens are billed to your Console account with an API key, or drawn from your plan with a subscription token. `--max-turns` and `timeout-minutes` limit how much work a run can do, which lowers both ([Manage costs](https://code.claude.com/docs/en/github-actions#manage-costs)).
+- The `v1` tag in the docs' examples moves to each new release ([tags](https://github.com/anthropics/claude-code-action/tags)), and each release pins the Claude Code version it installs, so a workflow on `@v1` can run a newer Claude Code than you tested. GitHub calls a workflow dependency lockfile the strongest protection, offers pinning to a full-length commit SHA for repositories that cannot adopt one, and warns that a tag can be moved or deleted if a bad actor gains access to the action's repository ([Secure use reference](https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions)). A release tag such as `v1.0.258` is the lighter pin this lesson also accepts.
-Listings checked against the listing bar on 2026-10-09.
+Listings checked against the listing bar on 2026-10-24.
## Go further
-- [Run on a schedule](https://code.claude.com/docs/en/github-actions#run-on-a-schedule): the same automation mode on a cron trigger.
+- [Code Review](https://code.claude.com/docs/en/code-review): Anthropic's managed review of your pull requests, for Team and Enterprise plans, with no workflow to maintain.
- [Set up for an organization](https://code.claude.com/docs/en/github-actions#set-up-for-an-organization): one App install and one organization secret for many repositories, or workload identity federation in place of a stored key.
-- [The action's solutions guide](https://github.com/anthropics/claude-code-action/blob/v1.0.237/docs/solutions.md) (Anthropic): complete workflows for pull request reviews, scheduled maintenance and issue triage.
+- [The action's solutions guide](https://github.com/anthropics/claude-code-action/blob/v1.0.258/docs/solutions.md) (Anthropic): complete workflows for pull request reviews, scheduled maintenance and issue triage.
---
-<sub>Sources: [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions) · [Authentication](https://code.claude.com/docs/en/authentication) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Configure permissions](https://code.claude.com/docs/en/permissions) · claude-code-action at v1.0.237: [action.yml](https://github.com/anthropics/claude-code-action/blob/v1.0.237/action.yml), [run.ts](https://github.com/anthropics/claude-code-action/blob/v1.0.237/src/entrypoints/run.ts), [parse-sdk-options.ts](https://github.com/anthropics/claude-code-action/blob/v1.0.237/base-action/src/parse-sdk-options.ts), [run-claude-sdk.ts](https://github.com/anthropics/claude-code-action/blob/v1.0.237/base-action/src/run-claude-sdk.ts), [security](https://github.com/anthropics/claude-code-action/blob/v1.0.237/docs/security.md), and its [tags](https://github.com/anthropics/claude-code-action/tags) · GitHub: [Installing a GitHub App from a third party](https://docs.github.com/en/apps/using-github-apps/installing-a-github-app-from-a-third-party), [Permission levels for a personal account repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/repository-access-and-collaboration/permission-levels-for-a-personal-account-repository), [Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows), [Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax), [Workflow commands](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands), [Secure use reference](https://docs.github.com/en/actions/reference/security/secure-use), [Using workflow run logs](https://docs.github.com/en/actions/how-tos/monitor-workflows/use-workflow-run-logs), [Reviewing and modifying installed GitHub Apps](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps), [GitHub Actions billing](https://docs.github.com/en/billing/concepts/product-billing/github-actions) · GitHub CLI manual: [gh repo create](https://cli.github.com/manual/gh_repo_create), [gh issue create](https://cli.github.com/manual/gh_issue_create), [gh issue view](https://cli.github.com/manual/gh_issue_view), [gh secret list](https://cli.github.com/manual/gh_secret_list), [gh secret set](https://cli.github.com/manual/gh_secret_set), [gh workflow run](https://cli.github.com/manual/gh_workflow_run), [gh run list](https://cli.github.com/manual/gh_run_list), [gh run watch](https://cli.github.com/manual/gh_run_watch), [gh run view](https://cli.github.com/manual/gh_run_view), [gh secret delete](https://cli.github.com/manual/gh_secret_delete)</sub>
+<sub>Sources: [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions) · [Authentication](https://code.claude.com/docs/en/authentication) · [Configure permissions](https://code.claude.com/docs/en/permissions) · claude-code-action at v1.0.258: [action.yml](https://github.com/anthropics/claude-code-action/blob/v1.0.258/action.yml), [run.ts](https://github.com/anthropics/claude-code-action/blob/v1.0.258/src/entrypoints/run.ts), [security](https://github.com/anthropics/claude-code-action/blob/v1.0.258/docs/security.md), and its [tags](https://github.com/anthropics/claude-code-action/tags) · GitHub: [Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows), [Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax), [Secure use reference](https://docs.github.com/en/actions/reference/security/secure-use), [Using workflow run logs](https://docs.github.com/en/actions/how-tos/monitor-workflows/use-workflow-run-logs), [Reviewing and modifying installed GitHub Apps](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps), [GitHub Actions billing](https://docs.github.com/en/billing/concepts/product-billing/github-actions) · GitHub CLI manual: [gh repo create](https://cli.github.com/manual/gh_repo_create), [gh secret set](https://cli.github.com/manual/gh_secret_set), [gh secret list](https://cli.github.com/manual/gh_secret_list), [gh workflow run](https://cli.github.com/manual/gh_workflow_run), [gh run list](https://cli.github.com/manual/gh_run_list), [gh run watch](https://cli.github.com/manual/gh_run_watch), [gh run view](https://cli.github.com/manual/gh_run_view), [gh secret delete](https://cli.github.com/manual/gh_secret_delete)</sub>
<sub>← [Script Claude Code with `claude -p`](04-headless.md) · [Advanced index](README.md) · [Share your setup with a team](06-share-your-setup.md) → · Topic: [Automation](../topics/automation.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-5)</sub>
diff --git a/docs/advanced/06-share-your-setup.md b/docs/advanced/06-share-your-setup.md
index c99098f..4a094b3 100644
--- a/docs/advanced/06-share-your-setup.md
+++ b/docs/advanced/06-share-your-setup.md
@@ -1,6 +1,6 @@
# Share your setup with a team
-<sub>**Advanced** · Lesson 6 of 7 · about 20 minutes · Needs: [GitHub Actions](05-github-actions.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-22</sub>
+<sub>**Advanced** · Lesson 6 of 7 · about 20 minutes · Needs: [GitHub Actions](05-github-actions.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -8,16 +8,16 @@ By the end of this lesson you can share your Claude Code setup with a team: comm
## You need
-- Your own repository with your Intermediate setup: the committed `.claude/settings.json` from [Intermediate lesson 4](../intermediate/04-permissions-and-sandbox.md), and the skills, hooks and subagents from lessons 1, 5 and 6. Set up its `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
+- Your own repository with your Intermediate setup: the committed `.claude/settings.json` from [Intermediate lesson 4](../intermediate/04-permissions-and-sandbox.md), and the skills, hooks and subagents from lessons 1, 5 and 6. Set up its `.practice/` folder as the [Intermediate index](../intermediate/README.md#prepare-your-own-repository) describes, if you haven't yet.
- Your copy of the practice template with Node.js LTS and the Advanced checks ([Practice](README.md#practice)): the check runs from the copy.
- bash, `curl` and git, on macOS, Linux or WSL 2.
- Usage: light.
## The idea
-What everyone should get is committed: `.claude/settings.json`, `CLAUDE.md`, `.claude/rules/`, skills, agents and `.mcp.json` ([Explore the .claude directory](https://code.claude.com/docs/en/claude-directory#file-reference)). What is yours stays out of git: `.claude/settings.local.json`, which that table doesn't mark for commit, and `CLAUDE.local.md` ([What's not shown](https://code.claude.com/docs/en/claude-directory#what%E2%80%99s-not-shown)). Your local file outranks the shared one, so a teammate can override a team setting for themselves without a commit, though lists such as permission rules merge instead ([Settings files and precedence](https://code.claude.com/docs/en/settings#settings-precedence)).
+What everyone should get is committed: `.claude/settings.json`, `CLAUDE.md`, `.claude/rules/`, skills, agents and `.mcp.json` ([Explore the .claude directory](https://code.claude.com/docs/en/claude-directory#file-reference)). What is yours stays out of git: `.claude/settings.local.json` and `CLAUDE.local.md` ([Choose the right file](https://code.claude.com/docs/en/claude-directory#choose-the-right-file), [What's not shown](https://code.claude.com/docs/en/claude-directory#what%E2%80%99s-not-shown)). Your local file outranks the shared one, so a teammate can override a team setting for themselves without a commit, though lists such as permission rules merge instead ([Settings files and precedence](https://code.claude.com/docs/en/settings#settings-precedence)).
-A committed `.claude/` folder already shares skills, agents and hooks with everyone who clones this one repository, under their short names. The docs say to keep that standalone setup while it serves one project, and to make a plugin when you want to install it in several projects or publish versioned releases ([Create a Claude Code plugin](https://code.claude.com/docs/en/plugins/create#decide-when-to-use-a-plugin)). This lesson builds the plugin inside one repository so you can see every step; when a second repository needs the same kit, move the marketplace to its own repository (Go further).
+A committed `.claude/` folder already shares skills, agents and hooks with everyone who clones this one repository. The docs say to keep that standalone setup while it serves one project, and to make a plugin when you want to share the setup with teammates, install it in several projects, or publish versioned releases ([Create a Claude Code plugin](https://code.claude.com/docs/en/plugins/create#decide-when-to-use-a-plugin)). Inside one repository, a plugin can live in `.claude/skills/<name>/` ([Share the plugin through a repository](https://code.claude.com/docs/en/plugins/create#load-a-plugin-for-everyone-in-one-repository)) or in a marketplace folder. This lesson uses a marketplace: when a second repository needs the kit, you move that folder to its own repository and keep the same plugin (Go further).
A plugin shares skills, agents and hooks as one unit, and a marketplace is a folder whose `.claude-plugin/marketplace.json` lists plugins ([Create a marketplace](https://code.claude.com/docs/en/plugins/create-marketplace)). Commit a marketplace inside the repository, declare it in `extraKnownMarketplaces` by a relative `directory` path, and turn its plugin on in `enabledPlugins`. Each teammate gets the plugin once they accept the workspace trust dialog for the folder ([Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org#require-plugins-per-repository)), and installs nothing: a plugin listed by a relative path loads from the marketplace itself ([Plugin loading reference](https://code.claude.com/docs/en/plugins/loading#enabled-in-project-settings-but-not-installed)).
@@ -35,7 +35,7 @@ Your teammates keep asking how the repository's Claude Code setup works. Share a
done
```
- The marketplace, `team-tools`, lists one plugin, `team-kit`, by the relative path `./plugins/team-kit`. The plugin holds a skill, `onboard`, that tells Claude to explain the repository's shared setup without changing files, and a subagent, `config-reviewer`, that can only read and search. The guide keeps the marketplace file in a folder named `dot-claude-plugin/` so that its own repository can't act as a marketplace; the first `curl` saves it as `.claude-plugin/marketplace.json`, the path a marketplace uses ([Create a marketplace](https://code.claude.com/docs/en/plugins/create-marketplace)).
+ The marketplace, `team-tools`, lists one plugin, `team-kit`, by the relative path `./plugins/team-kit`. The plugin holds a skill, `onboard`, that tells Claude to explain the repository's shared setup without changing files, and a subagent, `config-reviewer`, that can only read and search. The first `curl` saves the marketplace file as `.claude-plugin/marketplace.json`, the path a marketplace uses ([Create a marketplace](https://code.claude.com/docs/en/plugins/create-marketplace)).
2. Validate the marketplace, then the plugin:
```bash
@@ -57,7 +57,7 @@ Your teammates keep asking how the repository's Claude Code setup works. Share a
}
```
- The key under `extraKnownMarketplaces` is the marketplace's `name` ([Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org#require-a-marketplace-and-its-plugins)), and the plugin's id is `<entry name>@<marketplace name>`, here `team-kit@team-tools` ([Entry name and manifest name](https://code.claude.com/docs/en/plugins/loading#entry-name-and-manifest-name)). A `directory` source names a local folder in `path` ([All settings](https://code.claude.com/docs/en/settings-reference#extraknownmarketplaces)). A relative `path` resolves against the repository's main checkout, so a session in a worktree loads the main checkout's `team-marketplace/` ([Require plugins per repository](https://code.claude.com/docs/en/plugins/org#require-plugins-per-repository)). The example's [`settings.snippet.json`](../../examples/advanced/06-share-your-setup/settings.snippet.json) holds the same keys plus a deny rule for `.env`, for a repository that has none.
+ The key under `extraKnownMarketplaces` is the marketplace's `name` ([Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org#require-a-marketplace-and-its-plugins)), and the plugin's id is `<entry name>@<marketplace name>`, here `team-kit@team-tools` ([Entry name and manifest name](https://code.claude.com/docs/en/plugins/loading#entry-name-and-manifest-name)). A `directory` source names a local folder in `path` ([All settings](https://code.claude.com/docs/en/settings-reference#extraknownmarketplaces)). The example's [`settings.snippet.json`](../../examples/advanced/06-share-your-setup/settings.snippet.json) holds the same keys plus a deny rule for `.env`, for a repository that has none.
4. Commit both:
```bash
@@ -66,7 +66,7 @@ Your teammates keep asking how the repository's Claude Code setup works. Share a
```
If git reports a path as ignored, `git check-ignore -v <path>` shows the rule that matches it; add the path with `git add -f`, as in [Intermediate lesson 1](../intermediate/01-first-skill.md).
-5. Start `claude` at the repository's root, and accept the trust dialog if it appears. After the session starts, Claude Code registers the marketplace your settings declare and loads `team-kit` from it, with no install command ([Plugin loading reference](https://code.claude.com/docs/en/plugins/loading#plugins-and-marketplaces-that-aren%E2%80%99t-on-disk-at-session-start)). Type `/team-kit:` to see the plugin's skill ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#commands)), then run `/team-kit:onboard` ([Add components to a plugin](https://code.claude.com/docs/en/plugins/components#skills)). Claude reads the committed setup and explains what the repository shares and what stays personal; your wording will differ. If it asks to run a command along the way, check that the command only reads files, then approve it. The subagent loads too, as `team-kit:config-reviewer` ([Add components to a plugin](https://code.claude.com/docs/en/plugins/components#agents)): type `@` and pick it from the typeahead, where it's listed under that name, to call it ([Create custom subagents](https://code.claude.com/docs/en/sub-agents#invoke-subagents-explicitly)).
+5. Start `claude` at the repository's root, and accept the trust dialog if it appears. After the session starts, Claude Code registers the marketplace your settings declare and loads `team-kit` from it, with no install command ([Plugin loading reference](https://code.claude.com/docs/en/plugins/loading#plugins-and-marketplaces-that-aren%E2%80%99t-on-disk-at-session-start)). Run `/team-kit:onboard` ([Add components to a plugin](https://code.claude.com/docs/en/plugins/components#skills)). Claude reads the committed setup and explains what the repository shares and what stays personal; your wording will differ. The subagent loads too, as `team-kit:config-reviewer` ([Add components to a plugin](https://code.claude.com/docs/en/plugins/components#agents)).
6. Turn the plugin off for yourself only. Add this key to `.claude/settings.local.json`, beside the sandbox setting Intermediate lesson 4 saved there; if `enabledPlugins` is already there, add the `team-kit` line to it. If you're creating the file, wrap the key in `{ }`:
```json
@@ -75,11 +75,11 @@ Your teammates keep asking how the repository's Claude Code setup works. Share a
}
```
- Save the file, then run `/reload-plugins` ([Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference#reload-plugins)). `/team-kit:onboard` is gone from your session, while the committed file still turns the plugin on for everyone else: your local file outranks the project's ([All settings](https://code.claude.com/docs/en/settings-reference#enabledplugins)). If it's still listed, run `/reload-plugins` again, or start a new session: a settings change reaches the loaded plugins only after a reload or at the next start ([Plugin loading reference](https://code.claude.com/docs/en/plugins/loading#check-which-stage-a-plugin-reached)). Then delete the entry, save the file and run `/reload-plugins` again. If `git status` lists `.claude/settings.local.json`, don't commit it: Your turn adds it to `.gitignore`.
+ Save the file, then run `/reload-plugins` ([Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference#reload-plugins)). `/team-kit:onboard` is gone from your session, while the committed file still turns the plugin on for everyone else: your local file outranks the project's ([All settings](https://code.claude.com/docs/en/settings-reference#enabledplugins)). Then delete the entry, save the file and run `/reload-plugins` again. If `git status` lists `.claude/settings.local.json`, don't commit it: Your turn adds it to `.gitignore`.
## Your turn
-**Brief:** your team wants the same Claude Code kit in its other repositories. Start the move: take one piece of your Intermediate setup into `team-kit`, so everyone who clones this repository gets it from the plugin, and the same plugin can later serve the others. Take a skill, such as `tdd` from Intermediate lesson 1, or a subagent, such as `test-gaps` from lesson 6. For a harder move, take a hook from lesson 5: its entry goes in the plugin's `hooks/hooks.json`, in the same shape as in a settings file, with its script inside the plugin, called through `${CLAUDE_PLUGIN_ROOT}` ([Add components to a plugin](https://code.claude.com/docs/en/plugins/components#hooks)).
+**Brief:** give every teammate the same Claude Code kit from git, and let each of them opt out without a commit. Your team wants the kit in its other repositories too, so start the move: take one piece of your Intermediate setup into `team-kit`, so everyone who clones this repository gets it from the plugin, and the same plugin can later serve the others. Take a skill, such as `tdd` from Intermediate lesson 1, or a subagent, such as `test-gaps` from lesson 6. For a harder move, take a hook from lesson 5: its entry goes in the plugin's `hooks/hooks.json`, in the same shape as in a settings file, with its script inside the plugin, called through `${CLAUDE_PLUGIN_ROOT}` ([Add components to a plugin](https://code.claude.com/docs/en/plugins/components#hooks)).
**Acceptance criteria:**
@@ -88,7 +88,7 @@ Your teammates keep asking how the repository's Claude Code setup works. Share a
- A committed `.gitignore` lists `.claude/settings.local.json` and `CLAUDE.local.md`, and git tracks neither. The rule Claude Code adds for the local settings file goes in your global git excludes file, which teammates don't share ([Settings files and precedence](https://code.claude.com/docs/en/settings#keep-personal-settings-out-of-a-repository)), and the docs say to create `CLAUDE.local.md` by hand and add it to `.gitignore` yourself ([Explore the .claude directory](https://code.claude.com/docs/en/claude-directory#what%E2%80%99s-not-shown)). Add its rule even if you have no `CLAUDE.local.md`.
- Everything is committed, and in a new session the component runs under the plugin's name, such as `/team-kit:tdd` or the `team-kit:test-gaps` subagent.
-Because `team-kit` is listed by a relative path in a marketplace on your disk, Claude Code loads it in place: an edit under `team-marketplace/` takes effect at the next session start or after `/reload-plugins`, with no version change ([Plugin loading reference](https://code.claude.com/docs/en/plugins/loading#in-place-and-copied-plugins)). The Intermediate check for the component you move reads it from `.claude/`, so that check fails after the move; that's expected.
+Because `team-kit` is listed by a relative path in a marketplace on your disk, Claude Code loads it in place: an edit under `team-marketplace/` takes effect at the next session start or after `/reload-plugins`, with no version change ([Plugin loading reference](https://code.claude.com/docs/en/plugins/loading#in-place-and-copied-plugins)).
## Check
@@ -102,12 +102,12 @@ You are done when all of these are true:
Run `npm run check -- a-6 --dir <your repo>` from your practice copy.
-If the first item fails, run `claude plugin validate ./team-marketplace` and compare the entry's `name` with the plugin's `plugin.json`; a folder still named `dot-claude-plugin/` isn't a marketplace until you rename it to `.claude-plugin/`. If the marketplace passes, run the strict validation of the plugin again from the repository's root and save its report after it passes. If the second fails, check that the key under `extraKnownMarketplaces` is the marketplace's `name`, that the `path` is relative, such as `./team-marketplace`, and that the plugin's value is `true`, not `"true"`. If the third fails, run `git status`: the original may still be committed under `.claude/`, or the plugin's copy may not be committed yet. If the fourth fails, run `git rm --cached` on the tracked file, add both lines to `.gitignore` and commit.
+If the first item fails, run `claude plugin validate ./team-marketplace` and compare the entry's `name` with the plugin's `plugin.json`. If the second fails, check that the key under `extraKnownMarketplaces` is the marketplace's `name`, that the `path` is relative, such as `./team-marketplace`, and that the plugin's value is `true`, not `"true"`. If the third fails, run `git status`: the original may still be committed under `.claude/`, or the plugin's copy may not be committed yet. If the fourth fails, run `git rm --cached` on the tracked file, add both lines to `.gitignore` and commit.
## Watch out
- Everyone who trusts the repository runs what `team-kit` holds, with their own rights. A plugin's hooks and MCP server processes run outside the sandbox, and permission rules don't cover the code they run ([Plugin security and trust](https://code.claude.com/docs/en/plugins/security#understand-what-a-plugin-can-do)). Review a change under `team-marketplace/` as you review code.
-- The marketplace waits, without a message, until each teammate accepts the trust dialog for the folder, and a `claude -p` run adds it only in a folder whose trust they already accepted in an interactive session, or whose `hasTrustDialogAccepted` flag is set in `~/.claude.json` ([Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org#require-plugins-per-repository)); a cloud session never adds it, because it never shows the trust dialog ([Plugin loading reference](https://code.claude.com/docs/en/plugins/loading#plugins-shared-through-a-repository)). The committed allow rules wait for the same dialog, which lists them ([Configure permissions](https://code.claude.com/docs/en/permissions#project-allow-rules-and-workspace-trust)).
+- The marketplace waits, without a message, until each teammate accepts the trust dialog for the folder, and a `claude -p` run adds it only in a folder whose trust was already accepted ([Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org#require-plugins-per-repository)). CI is such a run: a fresh checkout was never trusted, so it doesn't get `team-kit` from these settings ([When each surface applies the plugin keys](https://code.claude.com/docs/en/plugins/org#when-each-surface-applies-the-plugin-keys)). The committed allow rules wait for the same dialog ([Configure permissions](https://code.claude.com/docs/en/permissions#project-allow-rules-and-workspace-trust)).
- A component left in both `.claude/` and the plugin loads twice: `/tdd` and `/team-kit:tdd` both work, and a hook runs twice each time its event fires ([Create a Claude Code plugin](https://code.claude.com/docs/en/plugins/create#convert-an-existing-claude-setup)).
## Go further
@@ -118,6 +118,6 @@ If the first item fails, run `claude plugin validate ./team-marketplace` and com
---
-<sub>Sources: [Settings files and precedence](https://code.claude.com/docs/en/settings) · [Explore the .claude directory](https://code.claude.com/docs/en/claude-directory) · [Create a Claude Code plugin](https://code.claude.com/docs/en/plugins/create) · [Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org) · [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading) · [Create a marketplace](https://code.claude.com/docs/en/plugins/create-marketplace) · [Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Add components to a plugin](https://code.claude.com/docs/en/plugins/components) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Plugin security and trust](https://code.claude.com/docs/en/plugins/security) · [Configure permissions](https://code.claude.com/docs/en/permissions)</sub>
+<sub>Sources: [Settings files and precedence](https://code.claude.com/docs/en/settings) · [Explore the .claude directory](https://code.claude.com/docs/en/claude-directory) · [Create a Claude Code plugin](https://code.claude.com/docs/en/plugins/create) · [Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org) · [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading) · [Create a marketplace](https://code.claude.com/docs/en/plugins/create-marketplace) · [Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Add components to a plugin](https://code.claude.com/docs/en/plugins/components) · [Plugin security and trust](https://code.claude.com/docs/en/plugins/security) · [Configure permissions](https://code.claude.com/docs/en/permissions)</sub>
<sub>← [GitHub Actions](05-github-actions.md) · [Advanced index](README.md) · [Put bounds on autonomous runs](07-bounded-runs.md) → · Topic: [Plugins](../topics/plugins.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-6)</sub>
diff --git a/docs/advanced/07-bounded-runs.md b/docs/advanced/07-bounded-runs.md
index 134573e..5f27cc8 100644
--- a/docs/advanced/07-bounded-runs.md
+++ b/docs/advanced/07-bounded-runs.md
@@ -1,6 +1,6 @@
# Put bounds on autonomous runs
-<sub>**Advanced** · Lesson 7 of 7 · about 20 minutes, plus run time · Needs: [Script Claude Code with `claude -p`](04-headless.md), [Share your setup with a team](06-share-your-setup.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Advanced** · Lesson 7 of 7 · about 20 minutes, plus run time · Needs: [Script Claude Code with `claude -p`](04-headless.md), [Share your setup with a team](06-share-your-setup.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -8,7 +8,7 @@ By the end of this lesson you can bound an unattended `claude -p` run with least
## You need
-- The repository you scripted in [lesson 4](04-headless.md) and shared in [lesson 6](06-share-your-setup.md), with a test command, and your copy of the practice template with Node.js LTS and the Advanced checks ([Practice](README.md#practice)): the check runs from the copy. Set up the repository's `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
+- The repository you scripted in [lesson 4](04-headless.md) and shared in [lesson 6](06-share-your-setup.md), with a test command, and your copy of the practice template with Node.js LTS and the Advanced checks ([Practice](README.md#practice)): the check runs from the copy. Set up the repository's `.practice/` folder as the [Intermediate index](../intermediate/README.md#prepare-your-own-repository) describes, if you haven't yet.
- bash and `jq`, on macOS, Linux or WSL 2. On Linux and WSL 2, the sandbox needs `bubblewrap` and `socat` ([Set up Linux and WSL2](https://code.claude.com/docs/en/sandboxing#set-up-linux-and-wsl2)).
- Usage: moderate. Each run stops at its limits. Cheap variant: in Your turn, set the limits from your slice run, and run the script on one more slice instead of the whole task.
@@ -16,10 +16,10 @@ By the end of this lesson you can bound an unattended `claude -p` run with least
A run nobody watches does whatever you allowed in advance, so allow little and cap the rest:
-- **Least privilege.** `dontAsk` mode denies every call that would otherwise prompt ([dontAsk mode](https://code.claude.com/docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode)), so allow only the folders the task edits and the one command it runs.
+- **Least privilege.** `dontAsk` mode denies every call that would otherwise prompt ([dontAsk mode](https://code.claude.com/docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode)), so allow only the folders the task edits and the one command it runs. That is the docs' setup for an exact allowlist; when you can't list a job's commands in advance, auto mode has a classifier review each call instead ([Common setups](https://code.claude.com/docs/en/permission-modes#common-setups), [Tool calls denied in `claude -p` and Agent SDK runs](https://code.claude.com/docs/en/permission-modes#which-mode-a-non-interactive-run-starts-in)).
- **The sandbox.** The operating system limits what an allowed command can write and reach ([Configure the sandboxed Bash tool](https://code.claude.com/docs/en/sandboxing)). Make it strict, and required for the run to start.
- **Limits.** `--max-turns` caps agentic turns, and `--max-budget-usd` caps estimated spend ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)).
-- **A review gate.** Deny `git commit` and `git push`: deny rules hold in every mode ([Available modes](https://code.claude.com/docs/en/permission-modes#available-modes)). `dontAsk` refuses the forms a rule misses, such as `git -C . push`, while nothing allows them ([What a Bash rule doesn't match](https://code.claude.com/docs/en/permissions#bash-rule-limits)). You read the diff and commit what you accept.
+- **A review gate.** Deny `git commit` and `git push`: deny rules hold in every mode ([Available modes](https://code.claude.com/docs/en/permission-modes#available-modes)), though a mod you installed can approve a call they refuse on a machine with neither managed settings nor a Team or Enterprise login ([Precedence among rules, hooks, and mods](https://code.claude.com/docs/en/permissions#precedence-among-rules-hooks-and-mods)). `dontAsk` refuses the forms a rule misses, such as `git -C . push`, while nothing allows them ([What a Bash rule doesn't match](https://code.claude.com/docs/en/permissions#bash-rule-limits)). You read the diff and commit what you accept.
- **A cost estimate.** Run one slice first, and set the spend limit from what it cost.
## Worked example
@@ -61,6 +61,7 @@ Work in your repository. The folders `src/` and `test/` and the command `npm tes
before=$(git rev-parse --short HEAD)
claude -p "$1" \
--setting-sources project \
+ --strict-mcp-config \
--settings .claude/bounded-run.json \
--permission-mode dontAsk \
--model sonnet \
@@ -75,9 +76,9 @@ Work in your repository. The folders `src/` and `test/` and the command `npm tes
```
- `--setting-sources project`: leaves your user and local settings files out of the run ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)), so an allow rule you saved with "Yes, and don't ask again", which goes to `.claude/settings.local.json`, doesn't join the bounds ([Permission system](https://code.claude.com/docs/en/permissions#permission-system)).
+ - `--strict-mcp-config`: Claude Code uses only the MCP servers you pass with `--mcp-config`, and this runner passes none, so no server in `.mcp.json` starts ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags), [Project scope](https://code.claude.com/docs/en/mcp#project-scope)). That includes one you rejected when Claude Code asked about it: the rejection is saved in `.claude/settings.local.json` ([`disabledMcpjsonServers`](https://code.claude.com/docs/en/settings-reference#disabledmcpjsonservers)), which `--setting-sources project` leaves out.
- `--settings`: the bounds file, which Claude Code applies above the project's own settings ([Change a setting for one session](https://code.claude.com/docs/en/settings#change-a-setting-for-one-session)). The allow rules go there because a `-p` run ignores the allow rules in a never-trusted folder's `.claude/settings.json` ([What runs before you trust a folder](https://code.claude.com/docs/en/permissions#what-runs-before-you-trust-a-folder)).
- - `allowUnsandboxedCommands: false` in that file: because it comes from `--settings`, a project's `true` can't turn the unsandboxed retry back on ([Strict sandbox mode](https://code.claude.com/docs/en/sandboxing#turn-off-the-retry-with-strict-sandbox-mode)). In v2.1.285 or later, Claude Code also ignores the repository's settings that loosen the sandbox, such as `excludedCommands` ([Repository settings under an admin-required sandbox](https://code.claude.com/docs/en/sandboxing#repository-settings-under-an-admin-required-sandbox)).
- - `--model sonnet`: Sonnet handles most coding tasks well and costs less than Opus ([Choose the right model](https://code.claude.com/docs/en/costs#choose-the-right-model)).
+ - `allowUnsandboxedCommands: false` in that file: because it comes from `--settings`, a project's `true` can't turn the unsandboxed retry back on, and Claude Code then also ignores the repository's settings that loosen the sandbox ([Strict sandbox mode](https://code.claude.com/docs/en/sandboxing#turn-off-the-retry-with-strict-sandbox-mode)).
- `--max-turns` and `--max-budget-usd`: configuration, so set your own.
3. Make it executable and commit both files, so everyone who runs it gets the same bounds:
@@ -99,12 +100,12 @@ Work in your repository. The folders `src/` and `test/` and the command `npm tes
## Your turn
-Bound a real task from your backlog that is bigger than one slice, such as tests for every untested function in one folder, or a mechanical migration across one folder.
+Hand a real task to a run you'd trust overnight, and catch what it shouldn't have done. Bound a real task from your backlog that is bigger than one slice, such as tests for every untested function in one folder, or a mechanical migration across one folder.
Acceptance criteria:
- `scripts/bounded-run.sh "<task>" <result.json>` runs it: one `claude -p` call in `dontAsk` mode, with JSON output saved to the result path, and the bounds from a committed file passed with `--settings`.
-- It calls `claude` by name, not by a path or through `npx`, and doesn't change `PATH`: that is how the check swaps in a stand-in for it.
+- It starts no MCP server you didn't pass: the call keeps `--strict-mcp-config`.
- Each allow rule names one folder or one command: no bare `Bash` or `Edit`, and no rule for the whole project or a whole program, such as `Bash(npm *)`. Your committed `.claude/settings.json` counts too: in a folder you've trusted, its allow rules join the bounds file's ([Lists merge instead of overriding](https://code.claude.com/docs/en/settings#lists-merge-instead-of-overriding)). So do the `allowed-tools` of the repository's skills, in a run that invokes one ([Pre-approve tools for a skill](https://code.claude.com/docs/en/skills#pre-approve-tools-for-a-skill)).
- Deny rules stop `git commit` and `git push`, each with the trailing ` *`: `Bash(git push)` matches only the bare command.
- The sandbox is on and strict, sends sandboxed commands through your rules, and the run refuses to start without it.
@@ -116,31 +117,31 @@ Acceptance criteria:
You are done when all of these are true:
-- [ ] `scripts/bounded-run.sh` is committed and executable, takes a task and a result path (`scripts/bounded-run.sh "<task>" <result.json>`), and starts `claude -p` in `dontAsk` mode with JSON output and a committed `--settings` file.
+- [ ] `scripts/bounded-run.sh` is committed and executable, takes a task and a result path (`scripts/bounded-run.sh "<task>" <result.json>`), and starts `claude -p` in `dontAsk` mode with JSON output, `--strict-mcp-config` and a committed `--settings` file.
- [ ] It sets a turn limit and a spend limit.
- [ ] Every allow rule names one command or one folder, and the deny rules stop `git commit` and `git push`.
- [ ] The settings file turns the sandbox on in strict mode without auto-allow, and makes the run refuse to start without it.
- [ ] `.practice/a-7-slice.json` holds a slice run whose cost is under your spend limit.
- [ ] Self-check (not tested): in the run's diff you looked for changes outside the task, such as a weakened or deleted test, an edited config or an unexpected commit, and you can name one you rejected or would have.
-Run `npm run check -- a-7 --dir <your repo>` from your practice copy, or `npm run check -- a-7` in the copy itself. The check runs your committed script with a stand-in for `claude`, so it uses none of your usage.
+Run `npm run check -- a-7 --dir <your repo>` from your practice copy, or `npm run check -- a-7` in the copy itself. The check uses none of your usage.
-If the first item fails, make sure the committed script is executable (`git ls-files -s scripts/bounded-run.sh` starts with `100755`) and calls `claude` by name, not by a path or through `npx`, and doesn't set `PATH`: the check reads the committed script, so commit each fix. If an allow rule fails, narrow it to the one folder or command the task needs. If the sandbox item names a key, add it to the settings file: without `failIfUnavailable`, a run whose sandbox can't start runs unsandboxed ([`sandbox.enabled`](https://code.claude.com/docs/en/settings-reference#sandbox-enabled)). If the slice item fails, make sure your script sends only `claude`'s JSON output (stdout) to the result path, then run step 4 again; a slice that ended in `error_max_budget_usd` means your spend limit is below one slice, so raise it.
+If the first item fails, make sure the committed script is executable (`git ls-files -s scripts/bounded-run.sh` starts with `100755`): the check reads the committed script, so commit each fix. If an allow rule fails, narrow it to the one folder or command the task needs. If the sandbox item names a key, add it to the settings file: without `failIfUnavailable`, a run whose sandbox can't start runs unsandboxed ([`sandbox.enabled`](https://code.claude.com/docs/en/settings-reference#sandbox-enabled)). If the slice item fails, make sure your script sends only `claude`'s JSON output (stdout) to the result path, then run step 4 again; a slice that ended in `error_max_budget_usd` means your spend limit is below one slice, so raise it.
## Watch out
-- Your bounds don't cover everything the run loads. Hooks and local MCP servers run outside the sandbox with your full access ([What runs outside the sandbox](https://code.claude.com/docs/en/sandboxing#what-runs-outside-the-sandbox)). As [lesson 4](04-headless.md#watch-out) warned, a `-p` run uses a repository's hooks and `.mcp.json` servers without asking, and it applies the `allowed-tools` of the repository's skills too ([What runs before you trust a folder](https://code.claude.com/docs/en/permissions#what-runs-before-you-trust-a-folder)). Read those hooks, servers and skills before a bounded run, or add `"disableAllHooks": true` to the bounds file to turn hooks off for it.
-- A deny rule matches the command Claude writes, not what a program does ([What a Bash rule doesn't match](https://code.claude.com/docs/en/permissions#bash-rule-limits)). The allowed `npm test` runs test files the run can edit. In the sandbox, that code can write anywhere in your working directory except protected paths, and inside `.git` only `hooks` and `config` are protected ([Protected paths](https://code.claude.com/docs/en/sandboxing#protected-paths)). So it could even make a commit. A push from it can't reach a remote: in `dontAsk` mode the sandbox refuses hosts you haven't allowed ([Hosts outside your allowed domains](https://code.claude.com/docs/en/sandboxing#hosts-outside-your-allowed-domains), [Turn off permission prompts in unattended runs](https://code.claude.com/docs/en/headless#turn-off-permission-prompts-in-unattended-runs)). That's why the script prints HEAD before and after, and why your review covers every changed file.
-- A dynamic workflow starts through its own tool, `Workflow`. In a run like this one, it starts only if an allow rule or a `PreToolUse` hook approves it: `Workflow` approves any workflow, and `Workflow(<name>)` approves one saved workflow ([Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs)). The workflow's agents follow your permission rules, and their permission mode follows the subagent rules, so an agent type whose definition sets `permissionMode` can run in that mode ([Permission modes](https://code.claude.com/docs/en/sub-agents#permission-modes)). They're subagents, so their spend counts toward `--max-budget-usd`. If you allow one, also add `"workflowSizeGuideline": "small"` to the bounds file, which asks Claude for fewer agents but caps nothing ([`workflowSizeGuideline`](https://code.claude.com/docs/en/settings-reference#workflowsizeguideline)).
+- Your bounds don't cover everything the run loads. Hooks and local MCP servers run outside the sandbox with your full access ([What runs outside the sandbox](https://code.claude.com/docs/en/sandboxing#what-runs-outside-the-sandbox)). As [lesson 4](04-headless.md#watch-out) warned, a `-p` run uses a repository's hooks without asking, and its `.mcp.json` servers unless you pass `--strict-mcp-config`; it applies the `allowed-tools` of the repository's skills too ([What runs before you trust a folder](https://code.claude.com/docs/en/permissions#what-runs-before-you-trust-a-folder)). Read those hooks and skills before a bounded run, or add `"disableAllHooks": true` to the bounds file to turn hooks off for it.
+- A deny rule matches the command Claude writes, not what a program does ([What a Bash rule doesn't match](https://code.claude.com/docs/en/permissions#bash-rule-limits)). The allowed `npm test` runs test files the run can edit. In the sandbox, that code can write anywhere in your working directory but protected paths, even make a commit ([Protected paths](https://code.claude.com/docs/en/sandboxing#protected-paths)). That's why the script prints HEAD before and after, and why your review covers every changed file.
+- A dynamic workflow starts in this run only if an allow rule names `Workflow` or `Workflow(<name>)`, or a `PreToolUse` hook approves it ([Approve the plan before it runs](https://code.claude.com/docs/en/workflows#approve-the-plan-before-it-runs)); if you let one start, its agents' spend counts toward `--max-budget-usd`, as a subagent's does ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)).
## Go further
- [Choose a sandbox environment](https://code.claude.com/docs/en/sandbox-environments): containers and VMs for runs the Bash sandbox can't cover.
- [How we contain Claude across products](https://www.anthropic.com/engineering/how-we-contain-claude): Anthropic's engineering post on capping how much damage an agent can do, in Claude Code and its other products.
-- [Catch security issues as Claude writes code](https://code.claude.com/docs/en/security-guidance): the security-guidance plugin, which has Claude review its own changes for vulnerabilities while you work with it.
+- [Give Claude a way to verify its work](https://code.claude.com/docs/en/best-practices#give-claude-a-way-to-verify-its-work): gate an unattended run's stop on a check it must pass, with a `/goal` condition or a Stop hook.
---
-<sub>Sources: [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Extend Claude with skills](https://code.claude.com/docs/en/skills) · [Configure the sandboxed Bash tool](https://code.claude.com/docs/en/sandboxing) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Settings files and precedence](https://code.claude.com/docs/en/settings) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) · [How the agent loop works](https://code.claude.com/docs/en/agent-sdk/agent-loop) · [Track cost and usage](https://code.claude.com/docs/en/agent-sdk/cost-tracking) · [Manage costs effectively](https://code.claude.com/docs/en/costs) · [Commands](https://code.claude.com/docs/en/commands) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows)</sub>
+<sub>Sources: [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Extend Claude with skills](https://code.claude.com/docs/en/skills) · [Configure the sandboxed Bash tool](https://code.claude.com/docs/en/sandboxing) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Settings files and precedence](https://code.claude.com/docs/en/settings) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [How the agent loop works](https://code.claude.com/docs/en/agent-sdk/agent-loop) · [Track cost and usage](https://code.claude.com/docs/en/agent-sdk/cost-tracking) · [Commands](https://code.claude.com/docs/en/commands) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows)</sub>
<sub>← [Share your setup with a team](06-share-your-setup.md) · [Advanced index](README.md) · [Advanced capstone](capstone.md) → · Topic: [Permissions and safety](../topics/permissions-and-safety.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-7)</sub>
diff --git a/docs/advanced/README.md b/docs/advanced/README.md
index eee6723..a6d7c17 100644
--- a/docs/advanced/README.md
+++ b/docs/advanced/README.md
@@ -1,6 +1,6 @@
# Advanced
-<sub>**Advanced** · about 3 hours 20 minutes, plus run time · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Advanced** · about 4 hours, plus run time · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
Beyond one session: parallel sessions, orchestration, unattended runs in scripts and CI, a setup your team shares, and limits that keep an autonomous run safe.
@@ -39,16 +39,16 @@ A copy older than the app has no `learn` script, so `npm run learn` says `Missin
6. [Share your setup with a team](06-share-your-setup.md)
7. [Put bounds on autonomous runs](07-bounded-runs.md)
-Each lesson takes 10 to 20 minutes, plus the time an agent run takes.
+Each lesson takes about 20 minutes, and the capstone 60 to 90, plus the time an agent run takes.
## Capstone
-[Add CI review your team can share](capstone.md): in a new template copy, two parallel worktree sessions, a bounded `claude -p` review script, a team marketplace, a saved dynamic workflow and a pull request review workflow with limits. Then tear down the workflow, the secret and, with an API key, the key.
+[Add CI review your team can share](capstone.md): in a new template copy, one review skill that a bounded `claude -p` script and a pull request workflow with limits both run, built in two parallel worktree sessions beside a team marketplace, plus a saved dynamic workflow for a sweep before a release. Then tear down the workflow, the secret and, with an API key, the key.
## By the end of this level you can
- [ ] Run parallel sessions in worktrees and merge their work.
-- [ ] Choose between subagents, a workflow or a team by need and cost, and run a dynamic workflow.
+- [ ] Choose between subagents, `/batch`, a workflow or a team by need and cost, keep a session working until a check passes with `/goal`, and save a dynamic workflow.
- [ ] Write a `claude -p` script and a GitHub Actions workflow.
- [ ] Share a setup as committed config and a team marketplace plugin.
- [ ] Bound an autonomous run with least privilege, the sandbox, turn or spend limits, a review gate and a cost estimate.
@@ -59,7 +59,7 @@ Optional lessons beside the core path:
- [Agent teams](electives/agent-teams.md): a lead and teammates that message each other, staffed from your own subagent definitions.
- [Agent view](electives/agent-view.md): hand tasks to background sessions from one screen, and step in only when one needs you.
-- [`/goal`, `/loop` and routines](electives/goal-loop-routines.md): keep Claude working toward a condition, on an interval, or on a schedule in the cloud.
+- [`/loop` and cloud scheduled tasks](electives/goal-loop-routines.md): keep Claude working on an interval in your session, or on a schedule in the cloud.
- [Testing and publishing a plugin](electives/publish-a-plugin.md): check a plugin's files and behavior, then publish it in your own marketplace.
- [Dev containers](electives/dev-containers.md): run Claude Code in a container with a firewall, keep your sign-in, and let it work unattended.
diff --git a/docs/advanced/beyond-this-guide.md b/docs/advanced/beyond-this-guide.md
index 22a4934..e9c1533 100644
--- a/docs/advanced/beyond-this-guide.md
+++ b/docs/advanced/beyond-this-guide.md
@@ -6,7 +6,7 @@ Where to go once you finish Advanced. The guide teaches one developer's use of C
Every item is published by Anthropic, except the MCP project's pages on modelcontextprotocol.io.
-Listings checked against the listing bar on 2026-10-09.
+Listings checked against the listing bar on 2026-10-24.
## Build your own agents
@@ -20,7 +20,7 @@ To drive the same agent loop from a language other than Python or TypeScript, th
A product or service you build on the Agent SDK should use API key authentication through the Claude Console or a supported cloud provider ([Legal and compliance](https://code.claude.com/docs/en/legal-and-compliance#authentication-and-credential-use)). Unless previously approved, Anthropic doesn't allow third-party developers to offer claude.ai login for their products ([Agent SDK overview](https://code.claude.com/docs/en/agent-sdk/overview#get-started)).
-While you write code that calls the Claude API, the bundled `/claude-api` skill loads Claude API reference material for your project's language, and Claude also loads it on its own when your code imports `anthropic` or `@anthropic-ai/sdk` ([Skills](https://code.claude.com/docs/en/skills#work-on-claude-api-projects)).
+While you write code that calls the Claude API, the bundled `/claude-api` skill loads Claude API and Managed Agents reference material for your project's language, and Claude also loads it on its own when your code imports `anthropic` or `@anthropic-ai/sdk` ([Skills](https://code.claude.com/docs/en/skills#work-on-claude-api-projects)).
## Build MCP servers
@@ -31,6 +31,18 @@ While you write code that calls the Claude API, the bundled `/claude-api` skill
- [Introduction to Model Context Protocol](https://academy.claude.com/courses/introduction-to-model-context-protocol): Claude Academy's course on building servers and clients from scratch with the Python SDK.
- [Model Context Protocol: Advanced topics](https://academy.claude.com/courses/model-context-protocol-advanced-topics): Claude Academy's course on sampling, notifications and roots.
+## Run Claude Code beyond your machine
+
+[GitHub Actions](05-github-actions.md) and the [capstone](capstone.md) run Claude in your own CI. Anthropic also runs it for you:
+
+- [Code Review](https://code.claude.com/docs/en/code-review): Claude reviews each pull request in your GitHub repositories and comments inline, for Team and Enterprise plans, with no workflow to maintain.
+- [Automate work with scheduled tasks](https://code.claude.com/docs/en/routines): cloud scheduled tasks, formerly routines, that run in the cloud on a schedule, on API calls or on GitHub events.
+
+ > [!NOTE]
+ > "Scheduled tasks are in research preview. Behavior, limits, and the API surface may change."
+
+- [Use Claude Code in the cloud](https://code.claude.com/docs/en/claude-code-on-the-web): sessions that run on cloud infrastructure instead of your machine, started from a browser, a phone, the Desktop app or a terminal.
+
## Run Claude Code for an organization
[Share your setup with a team](06-share-your-setup.md) commits a setup to the repository your team works in. An organization also sets policy, sign-in, network access and reporting for every machine:
@@ -53,8 +65,12 @@ Once the setup is in place, these help people adopt it:
- [The AI-native SDLC playbook](https://academy.claude.com/courses/ai-native-sdlc-playbook): Claude Academy's course for engineering, platform and security leads whose organization already uses Claude Code.
- [Running an AI-native engineering org](https://claude.com/resources/articles/running-an-ai-native-engineering-org): how the Claude Code team's processes and structure changed once agentic coding became its default way of working.
+## Stay current
+
+Each page of this guide was checked against one `stable` version of Claude Code, named in its header line. When `claude --version` shows a newer one, the [CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) says what changed since.
+
---
-<sub>Sources: the pages linked above, each checked on 2026-10-09.</sub>
+<sub>Sources: the pages linked above, each checked on 2026-10-24.</sub>
<sub>Up: [Advanced](README.md)</sub>
diff --git a/docs/advanced/capstone.md b/docs/advanced/capstone.md
index 6da8703..716fcc6 100644
--- a/docs/advanced/capstone.md
+++ b/docs/advanced/capstone.md
@@ -1,8 +1,8 @@
# Advanced capstone: add CI review your team can share
-<sub>**Advanced** · Capstone · 30 to 60 minutes, plus run time · Needs: the seven [Advanced lessons](README.md), or their skills · Verified against Claude Code v2.1.292 (stable) on 2026-10-22</sub>
+<sub>**Advanced** · Capstone · 60 to 90 minutes, plus run time · Needs: the seven [Advanced lessons](README.md), or their skills · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
-This task puts the whole Advanced level together, in a new copy of the practice template that you tear down at the end. It has no worked example: the brief says what the team needs, and you choose how to build it. The [Advanced Exit](README.md#by-the-end-of-this-level-you-can) is the list of what you can do by the end of this level. The check reads what you commit and two files you save under `.practice/`, and you tick the rest of the Exit yourself under [What the check can't see](#what-the-check-cant-see).
+This task puts the whole Advanced level together, in a new copy of the practice template that you tear down at the end. It has no worked example: the brief says what the team needs, and you choose how to build it. The check reads what you commit and three files you save under `.practice/`, and you tick the rest of the [Advanced Exit](README.md#by-the-end-of-this-level-you-can) yourself under [What the check can't see](#what-the-check-cant-see).
## You need
@@ -23,55 +23,60 @@ This task puts the whole Advanced level together, in a new copy of the practice
## The task
-The team wants Claude to review every pull request in CI, the same way on everyone's machine, with nothing it runs left unbounded. The brief is in `capstone/advanced-brief.md` in your copy.
+The team wants one review for every pull request, the same on laptops and in CI, with nothing left unbounded. The brief is in `capstone/advanced-brief.md` in your copy. Each part below is a problem the team has; the lesson it names shows one way to solve it.
-Build each part the way its lesson taught:
-
-1. **Two sessions at once** ([lesson 1](01-parallel-sessions.md)). Ignore `.claude/worktrees/` in the committed `.gitignore`, and push `main`: new worktrees branch from the remote's default branch ([Choose the base branch](https://code.claude.com/docs/en/worktrees#choose-the-base-branch)). Then, in two terminals at the same time, start `claude --worktree <name>` twice, with a different name each time ([Reuse a worktree name](https://code.claude.com/docs/en/worktrees#reuse-a-worktree-name)): one session builds part 2, the other part 3, and each commits on its own branch. Once both have committed, and while both worktrees exist, save their state from the main checkout:
+1. **Two parts at once** ([lesson 1](01-parallel-sessions.md)). Parts 2 and 3 don't depend on each other, so build them at the same time, in two Claude Code sessions that can't touch each other's files, and land both changes on `main`, by merge, rebase or squash. Keep those working copies out of git. New worktrees branch from the remote's default branch, so push `main` first ([Choose the base branch](https://code.claude.com/docs/en/worktrees#choose-the-base-branch)). Once both sessions have committed, and while both working copies exist, save their state from the main checkout:
```bash
mkdir -p .practice && git worktree list --porcelain > .practice/a-capstone-worktrees.txt
```
- Then merge both branches into `main` with `git merge`, not `git merge --squash`, and remove both worktrees.
-2. **A review script** ([lessons 4](04-headless.md) and [7](07-bounded-runs.md)): `scripts/review-staged.sh`, to lesson 4's criteria. It pipes the staged diff into one `claude -p` call with JSON output and `dontAsk` mode ([dontAsk mode](https://code.claude.com/docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode)), pre-approves only `Read`, `Grep` and `Glob`, and caps turns at 10 or fewer ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)). As in lesson 7, it also caps spend with `--max-budget-usd`, written as a number in the script. Claude Code checks that cap against its client-side cost estimate, and spend can pass it, so leave headroom ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)). After the merges, stage a one-line change in the main checkout, run the script once, read the review and commit the change:
+2. **One review, everywhere** ([lessons 4](04-headless.md) and [7](07-bounded-runs.md)). Write the team's review once, as a skill committed in `.claude/skills/<name>/SKILL.md`, and run it in both places. Pick a name of your own, such as `team-review`: `/review` is already an alias of the bundled `/code-review` ([Commands](https://code.claude.com/docs/en/commands#all-commands)). A `claude -p` run expands `/<name>` in its prompt ([Create a commit](https://code.claude.com/docs/en/headless#create-a-commit)), and part 5's workflow runs it as its `prompt`. Locally the staged diff arrives on stdin; in CI, Claude reads the change with `git diff` (part 5). Write the skill's instructions so they work in both places.
+
+ Then write `scripts/review-staged.sh` to lesson 4's criteria: it pipes the staged diff into one `claude -p` call whose prompt runs your skill, with JSON output and `dontAsk` mode ([dontAsk mode](https://code.claude.com/docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode)), pre-approves only `Read`, `Grep` and `Glob`, restricts the tools to those three, turns hooks off and uses no MCP server, and caps turns at 10 or fewer ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)). As in lesson 7, it also caps spend with `--max-budget-usd`, written as a number in the script. Claude Code checks that cap against its client-side cost estimate, and spend can pass it, so leave headroom ([CLI flags](https://code.claude.com/docs/en/cli-reference#cli-flags)). After the merges, stage a one-line change in the main checkout, run the script once, read the review and commit the change:
```bash
mkdir -p .practice && scripts/review-staged.sh .practice/a-capstone-run.json
```
The saved JSON's `total_cost_usd` estimates what one review spent, and it must come in under your cap. As with lesson 7's slice, it's a client-side estimate, not your bill ([Track cost and usage](https://code.claude.com/docs/en/agent-sdk/cost-tracking#estimates-not-billing)).
-3. **The team's plugin** ([lesson 6](06-share-your-setup.md)): a marketplace in `team-marketplace/` that lists one plugin by a relative path, with the plugin in its own folder under `team-marketplace/`, as in lesson 6's example kit, and at least one skill or agent in the plugin. The committed `.claude/settings.json` registers the marketplace by a relative path and turns the plugin on ([Require plugins per repository](https://code.claude.com/docs/en/plugins/org#require-plugins-per-repository)). Both validations pass: `claude plugin validate` on the marketplace, and on the plugin directory with `--strict` ([plugin validate](https://code.claude.com/docs/en/plugins/cli-reference#plugin-validate)). The kit is a good start; its [`settings.snippet.json`](../../examples/advanced/06-share-your-setup/settings.snippet.json) also denies reading `.env`, which this copy has no rule for yet. Test the plugin only after the merges: a relative path resolves against the repository's main checkout, even from a worktree ([Require plugins per repository](https://code.claude.com/docs/en/plugins/org#require-plugins-per-repository)), so the part-3 session can't load it yet.
-4. **A saved dynamic workflow** ([lessons 2](02-orchestration-patterns.md) and [3](03-dynamic-workflows.md)): from a session in the main checkout, after the merges, ask for a workflow that reviews each file under `src/` and has a second agent check each finding. While it runs, `/workflows` shows each agent's token usage ([Cost](https://code.claude.com/docs/en/workflows#cost)). Save it to the project: a project save writes to the closest `.claude/workflows/` folder that already exists between the session's working directory and the repository root, or, if none exists yet, to `.claude/workflows/` at the repository root ([Save the workflow for reuse](https://code.claude.com/docs/en/workflows#save-the-workflow-for-reuse)). Commit it.
-5. **CI review with limits** ([lessons 5](05-github-actions.md) and [7](07-bounded-runs.md)): `.github/workflows/claude-review.yml` runs on `pull_request` ([Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request)) and uses `anthropics/claude-code-action` (Anthropic) with a `prompt` that asks for a review of the pull request's changes ([Action parameters](https://code.claude.com/docs/en/github-actions#action-parameters)). Hold it to lesson 5's limits:
+3. **Our plugin, for everyone** ([lesson 6](06-share-your-setup.md)): a marketplace in `team-marketplace/` that lists one plugin by a relative path, with the plugin in its own folder under `team-marketplace/`, as in lesson 6's example kit, and at least one skill or agent in the plugin. The committed `.claude/settings.json` registers the marketplace by a relative path and turns the plugin on ([Require plugins per repository](https://code.claude.com/docs/en/plugins/org#require-plugins-per-repository)). Both validations pass: `claude plugin validate` on the marketplace, and on the plugin directory with `--strict` ([plugin validate](https://code.claude.com/docs/en/plugins/cli-reference#plugin-validate)). The kit is a good start; its [`settings.snippet.json`](../../examples/advanced/06-share-your-setup/settings.snippet.json) also denies reading `.env`, which this copy has no rule for yet. Through these settings, the plugin reaches every teammate who trusts the repository, but not CI, where a fresh checkout was never trusted ([When each surface applies the plugin keys](https://code.claude.com/docs/en/plugins/org#when-each-surface-applies-the-plugin-keys)): that is why part 2's review lives in `.claude/skills/`. Test the plugin only after the merges.
+4. **A sweep before a release** ([lessons 2](02-orchestration-patterns.md) and [3](03-dynamic-workflows.md)): from a session in the main checkout, after the merges, ask for a workflow that reviews each file under `src/` and has a second agent check each finding. While it runs, `/workflows` shows each agent's token usage ([Cost](https://code.claude.com/docs/en/workflows#cost)). Save it to the project and commit it ([Save the workflow for reuse](https://code.claude.com/docs/en/workflows#save-the-workflow-for-reuse)).
+5. **CI review with limits** ([lessons 5](05-github-actions.md) and [7](07-bounded-runs.md)): `.github/workflows/claude-review.yml` runs on `pull_request` ([Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request)) and uses `anthropics/claude-code-action` (Anthropic) with your skill, `/<name>`, as its `prompt`: for a skill in `.claude/skills/`, `actions/checkout` must run before the action ([Run a skill](https://code.claude.com/docs/en/github-actions#run-a-skill)). On a pull request, the action restores `.claude/` from the base branch before Claude starts, so a change to your skill reaches CI only once it's merged ([security notes](https://github.com/anthropics/claude-code-action/blob/v1.0.258/docs/security.md)). Hold it to lesson 5's limits, and one more:
- the action pinned to a release tag or a full commit SHA ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsuses));
- the credential from a repository secret, through the matching input, `anthropic_api_key` or `claude_code_oauth_token` ([Manual setup](https://code.claude.com/docs/en/github-actions#manual-setup));
- a read-only job token: no write access in `permissions` except `id-token: write` ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#permissions)), and `github_token` set to the job's own `GITHUB_TOKEN`, so Claude acts with that token instead of the Claude GitHub App's ([Action parameters](https://code.claude.com/docs/en/github-actions#action-parameters));
- in `claude_args`, `--max-turns` of 10 or fewer and an `--allowedTools` list without unrestricted Bash;
- - a `timeout-minutes` of 30 or fewer ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idtimeout-minutes)).
+ - a `timeout-minutes` of 30 or fewer ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idtimeout-minutes));
+ - a `concurrency` group for the pull request with `cancel-in-progress: true`, so a new push cancels the review still running for an older one ([Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#concurrency)), as the docs' cost advice suggests ([Manage costs](https://code.claude.com/docs/en/github-actions#manage-costs)).
+
+ To let Claude see the change, check out the full history, as the template's `.github/workflows/progress.yml` does, and allow `git diff` with `Bash(git diff *)`, a rule that matches only `git diff` commands ([Wildcard patterns](https://code.claude.com/docs/en/permissions#wildcard-patterns)). Have the skill ask for `git diff` as a command on its own, as lesson 7's slice prompt did for `npm test`: a rule must match each command in a chain ([Compound commands](https://code.claude.com/docs/en/permissions#compound-commands)).
- With a plain-text prompt, Claude has no shell until you allow the commands it needs ([Run on a schedule](https://code.claude.com/docs/en/github-actions#run-on-a-schedule)). To let it see the change, check out the full history, as the template's `.github/workflows/progress.yml` does, and allow `git diff` with `Bash(git diff *)`, a rule that matches only `git diff` commands ([Wildcard patterns](https://code.claude.com/docs/en/permissions#wildcard-patterns)). As lesson 7's slice prompt did for `npm test`, ask in the `prompt` for `git diff` as a command on its own: a rule must match each command in a chain ([Compound commands](https://code.claude.com/docs/en/permissions#compound-commands)).
+ Set `display_report: true`, as lesson 5 does, so Claude's review appears on the run's summary page ([action.yml at v1.0.258](https://github.com/anthropics/claude-code-action/blob/v1.0.258/action.yml)). Turn it on only for trusted input, as here: the pull requests are your own, in a private copy. On a public repository, GitHub withholds secrets from runs that fork pull requests trigger, so a review like this runs only on pull requests from branches in the repository ([Run a skill](https://code.claude.com/docs/en/github-actions#run-a-skill), [Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request)).
- Set `display_report: true`, as lesson 5 does, so Claude's review appears on the run's summary page ([action.yml at v1.0.237](https://github.com/anthropics/claude-code-action/blob/v1.0.237/action.yml), [Adding a job summary](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#adding-a-job-summary)). The action says to turn it on only when its input is trusted, as here: the pull requests are your own, in a private copy.
+ Add the credential as a repository secret: run `gh secret set ANTHROPIC_API_KEY`, or `gh secret set CLAUDE_CODE_OAUTH_TOKEN`, and paste the value when it asks ([gh secret set](https://cli.github.com/manual/gh_secret_set)). Never commit the credential; keep it in the repository secret ([Protect your credentials](https://code.claude.com/docs/en/github-actions#protect-your-credentials)). The copy needs no Claude GitHub App: the action authenticates as the App only when `github_token` is omitted ([Action parameters](https://code.claude.com/docs/en/github-actions#action-parameters)).
- Add the credential as a repository secret, as the second step of the docs' [Manual setup](https://code.claude.com/docs/en/github-actions#manual-setup) does: run `gh secret set ANTHROPIC_API_KEY`, or `gh secret set CLAUDE_CODE_OAUTH_TOKEN`, and paste the value when it asks ([gh secret set](https://cli.github.com/manual/gh_secret_set)). Never commit the credential; keep it in the repository secret ([Protect your credentials](https://code.claude.com/docs/en/github-actions#protect-your-credentials)). Skip Manual setup's other steps: the action authenticates as the Claude GitHub App only when `github_token` is omitted ([Action parameters](https://code.claude.com/docs/en/github-actions#action-parameters)), and your review workflow replaces its `claude.yml`.
+ Commit the workflow to `main` and push. Then push a one-line change on a new branch and open a pull request. `display_report` writes Claude's review to the job summary, which GitHub shows on the run's summary page ([Adding a job summary](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#adding-a-job-summary)): find the run's id with `gh run list --workflow claude-review.yml --limit 1`, then open it with `gh run view <run-id> --web`, as in lesson 5 ([gh run view](https://cli.github.com/manual/gh_run_view)). Read the review, and merge the pull request yourself. Once the review run has finished, and before you tear down, save its record for the check ([gh run list](https://cli.github.com/manual/gh_run_list)):
- Commit the workflow to `main` and push. Then push a one-line change on a new branch and open a pull request. Read Claude's review on the run's summary page, as in lesson 5, and merge the pull request yourself.
+ ```bash
+ gh run list --workflow claude-review.yml --json databaseId,status,conclusion,event,url,workflowName > .practice/a-capstone-ci.json
+ ```
Finish on `main`, with the merged pull request pulled, everything committed and `npm test` passing.
-Listings checked against the listing bar on 2026-10-09.
+Listings checked against the listing bar on 2026-10-24.
## Check
You are done when all of these are true:
-- [ ] Lesson 1: `.practice/a-capstone-worktrees.txt` lists two worktrees under `.claude/worktrees/` whose commits split from each other, both are merged into your branch, and a committed `.gitignore` ignores `.claude/worktrees/` and not the rest of `.claude/`.
-- [ ] Lessons 2 and 3: a committed script in `.claude/workflows/` has a literal `export const meta`, with a `name` and a `description`, as its first statement, and starts subagents with `agent()`.
-- [ ] Lesson 4: `scripts/review-staged.sh` is committed, executable and meets lesson 4's criteria: one `claude -p` call, with the prompt right after `-p`, JSON output, `dontAsk` mode, only `Read`, `Grep` and `Glob`, and 10 turns or fewer; the staged diff piped in; the JSON saved where its argument says and the result printed; a non-zero exit when the run fails; and no call to Claude when nothing is staged.
-- [ ] Lesson 5: a committed workflow runs `anthropics/claude-code-action` on `pull_request`, pinned to a release tag or a full commit SHA, in automation mode, with its credential from a secret and none in the file, a read-only job token (no write access in `permissions` except `id-token: write`, and `github_token` set to the job's own token), `--max-turns` of 10 or fewer, an `--allowedTools` list without unrestricted Bash and a `timeout-minutes` of 30 or fewer; and no Claude API key or token is committed, at `HEAD` or in the commit the check reads that workflow from.
+- [ ] Lesson 1: `.practice/a-capstone-worktrees.txt` lists two worktrees of this repository whose commits split from each other, and both changes are in your branch; a committed `.gitignore` keeps any of them inside the repository out of git, and not the rest of `.claude/`.
+- [ ] Lessons 2 and 3: a committed script in `.claude/workflows/` has a literal `export const meta`, with a `name` and a `description`, as its first statement, and calls `agent()` at least twice.
+- [ ] Lesson 4: `scripts/review-staged.sh` is committed, executable and meets lesson 4's criteria: one `claude -p` call, with the prompt right after `-p`, JSON output, `dontAsk` mode, only `Read`, `Grep` and `Glob`, pre-approved and as its only tools, hooks off, no MCP server, and 10 turns or fewer; the staged diff piped in; the JSON saved where its argument says and the result printed; a non-zero exit when the run fails; and no call to Claude when nothing is staged.
+- [ ] Lesson 5: a committed workflow runs `anthropics/claude-code-action` on `pull_request`, pinned to a release tag or a full commit SHA, in automation mode, with its credential from a secret and none in the file, a read-only job token (no write access in `permissions` except `id-token: write`, and `github_token` set to the job's own token), `--max-turns` of 10 or fewer, an `--allowedTools` list without unrestricted Bash, a `timeout-minutes` of 30 or fewer and a `concurrency` group with `cancel-in-progress: true`; and no Claude API key or token is committed, at `HEAD` or in the commit the check reads that workflow from; and `.practice/a-capstone-ci.json` shows a completed, successful `pull_request` run of it.
- [ ] Lesson 6: a committed team marketplace lists a plugin by a relative path, under the `name` in the plugin's `plugin.json`, and the committed `.claude/settings.json` registers that marketplace by a relative path and turns the plugin on.
- [ ] Lesson 7: the review script's `claude -p` call caps spend with `--max-budget-usd`, and `.practice/a-capstone-run.json` holds a real run that succeeded within your turn cap and cost less than your spend cap.
+- [ ] One review: the review script's `claude -p` prompt and the CI workflow's `prompt` both run one skill committed in `.claude/skills/`.
- [ ] `npm test` passes, and `git status --porcelain` prints nothing.
Run `npm run check -- a-capstone` in this copy. It checks each box's parts one by one, and each part that fails prints what to fix. The check runs your script with a stand-in for `claude`, so it uses none of your usage, and it reads the workflow from your history, so it passes before and after the teardown.
@@ -80,10 +85,10 @@ Run `npm run check -- a-capstone` in this copy. It checks each box's parts one b
The check doesn't look at these parts of the Advanced Exit. Tick them yourself, honestly:
-- [ ] My CI review and my saved workflow both review code, and I can say which one I'd run on every pull request and which I'd keep for a sweep before a release, and why, by what each costs and how deep it goes.
+- [ ] I can say which review I'd run on every pull request (Code Review, `/code-review` or my CI workflow) and which I'd keep for a sweep before a release (my saved workflow), and why, by what each costs and how deep it goes ([Compare ways to get a review](https://code.claude.com/docs/en/code-review#compare-ways-to-get-a-review)).
- [ ] I can say when an unattended run needs the sandbox from [lesson 7](07-bounded-runs.md), and whether my review script and CI workflow need it.
- [ ] Before I merged, I acted on at least one point in Claude's review on the run's summary page, or dismissed it with a reason.
-- [ ] Before I turned CI on, I multiplied the local run's `total_cost_usd` by the pull requests my team opens in a week, to estimate what CI review spends, and I saw in `/workflows` how many tokens the per-file review used.
+- [ ] Before I turned CI on, I multiplied the local run's `total_cost_usd` by the pull requests my team opens in a week, to estimate what CI review spends, and I know a new push cancels the review still running.
When every box on this page is ticked, you've shown the Advanced Exit and finished the last of the guide's three levels. One step remains: the teardown below.
@@ -94,16 +99,16 @@ If this level helped, a star helps other developers find the guide.
When the check passes, tear down: this is required.
> [!WARNING]
-> Until you tear down, a live credential sits in the copy's secrets. Deleting a secret leaves the credential it held valid ([Uninstall](https://code.claude.com/docs/en/github-actions#uninstall)). On 2026-10-09, a token from `claude setup-token` is valid for one year ([Authentication](https://code.claude.com/docs/en/authentication#generate-a-long-lived-token)), and deleting the secret doesn't revoke it.
+> Until you tear down, a live credential sits in the copy's secrets. Deleting a secret leaves the credential it held valid ([Uninstall](https://code.claude.com/docs/en/github-actions#uninstall)). On 2026-10-24, a token from `claude setup-token` is valid for one year ([Authentication](https://code.claude.com/docs/en/authentication#generate-a-long-lived-token)), and deleting the secret doesn't revoke it.
1. Delete the workflow with `git rm .github/workflows/claude-review.yml`, then commit and push. With the workflow gone, the Claude Code GitHub Action no longer runs ([Uninstall](https://code.claude.com/docs/en/github-actions#uninstall)).
2. Delete the secret: `gh secret delete ANTHROPIC_API_KEY`, or `gh secret delete CLAUDE_CODE_OAUTH_TOKEN` ([gh secret delete](https://cli.github.com/manual/gh_secret_delete)). `gh secret list` no longer shows it ([gh secret list](https://cli.github.com/manual/gh_secret_list)).
-3. With an API key, delete the key on the Claude Console's [API keys page](https://platform.claude.com/settings/keys).
+3. With an API key, delete the key on the Claude Console's [API keys page](https://platform.claude.com/settings/keys). With a token from `claude setup-token`, nothing in this teardown revokes it, so it stays valid until it expires ([Uninstall](https://code.claude.com/docs/en/github-actions#uninstall)): that's why this capstone recommends an API key.
Run `npm run check -- a-capstone` once more: it still passes.
---
-<sub>Sources: [Run parallel sessions with worktrees](https://code.claude.com/docs/en/worktrees) · [Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows) · [Track cost and usage](https://code.claude.com/docs/en/agent-sdk/cost-tracking) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Model configuration](https://code.claude.com/docs/en/model-config) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference) · [Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org) · [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions) · [Authentication](https://code.claude.com/docs/en/authentication) · claude-code-action at v1.0.237: [action.yml](https://github.com/anthropics/claude-code-action/blob/v1.0.237/action.yml) · GitHub: [Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows), [Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax), [Workflow commands](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands) · GitHub CLI manual: [gh repo create](https://cli.github.com/manual/gh_repo_create), [gh secret set](https://cli.github.com/manual/gh_secret_set), [gh secret delete](https://cli.github.com/manual/gh_secret_delete), [gh secret list](https://cli.github.com/manual/gh_secret_list) · the [Advanced lessons](README.md), which cite the official pages for each step.</sub>
+<sub>Sources: [Run parallel sessions with worktrees](https://code.claude.com/docs/en/worktrees) · [Commands](https://code.claude.com/docs/en/commands) · [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) · [Orchestrate subagents at scale with dynamic workflows](https://code.claude.com/docs/en/workflows) · [Track cost and usage](https://code.claude.com/docs/en/agent-sdk/cost-tracking) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Model configuration](https://code.claude.com/docs/en/model-config) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference) · [Manage Claude Code plugins for your organization](https://code.claude.com/docs/en/plugins/org) · [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions) · [Code Review](https://code.claude.com/docs/en/code-review) · [Authentication](https://code.claude.com/docs/en/authentication) · claude-code-action at v1.0.258: [action.yml](https://github.com/anthropics/claude-code-action/blob/v1.0.258/action.yml), [security](https://github.com/anthropics/claude-code-action/blob/v1.0.258/docs/security.md) · GitHub: [Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows), [Workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax), [Workflow commands](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands) · GitHub CLI manual: [gh repo create](https://cli.github.com/manual/gh_repo_create), [gh run list](https://cli.github.com/manual/gh_run_list), [gh run view](https://cli.github.com/manual/gh_run_view), [gh secret set](https://cli.github.com/manual/gh_secret_set), [gh secret delete](https://cli.github.com/manual/gh_secret_delete), [gh secret list](https://cli.github.com/manual/gh_secret_list) · the [Advanced lessons](README.md), which cite the official pages for each step.</sub>
<sub>← [Put bounds on autonomous runs](07-bounded-runs.md) · [Advanced index](README.md) · [Beyond this guide](beyond-this-guide.md) → · [Stuck on this capstone?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-capstone)</sub>
diff --git a/docs/advanced/electives/agent-teams.md b/docs/advanced/electives/agent-teams.md
index 1c95175..605b61d 100644
--- a/docs/advanced/electives/agent-teams.md
+++ b/docs/advanced/electives/agent-teams.md
@@ -12,7 +12,7 @@ By the end of this Elective you can staff an agent team from your own subagent d
## You need
- [Choose an orchestration pattern](../02-orchestration-patterns.md), and the subagent definitions you wrote in [Delegate to a custom subagent](../../intermediate/06-subagents.md).
-- One of your own repositories, with its `.practice/` folder set up as [Beginner lesson 1](../../beginner/01-install-and-look-around.md#you-need) describes.
+- One of your own repositories, with its `.practice/` folder set up as the [Intermediate index](../../intermediate/README.md#prepare-your-own-repository) describes.
- macOS, Linux or WSL 2, and `jq`: the hooks that log the team are shell commands that use it.
- An interactive session: in a `-p` run, Claude doesn't spawn teammates ([Enable agent teams](https://code.claude.com/docs/en/agent-teams#enable-agent-teams)). The default in-process display, where teammates run inside your terminal, works in any terminal ([Choose a display mode](https://code.claude.com/docs/en/agent-teams#choose-a-display-mode)).
- Usage: heavy. Each teammate is a separate Claude instance with its own context window, and token usage scales with the number of active teammates ([Token usage](https://code.claude.com/docs/en/agent-teams#token-usage)). Cheap variant: change one small file in the Worked example, run two teammates in Your turn, and shut the teammates down as soon as they report.
diff --git a/docs/advanced/electives/agent-view.md b/docs/advanced/electives/agent-view.md
index 72decd3..2295433 100644
--- a/docs/advanced/electives/agent-view.md
+++ b/docs/advanced/electives/agent-view.md
@@ -37,7 +37,7 @@ In [lesson 1](../01-parallel-sessions.md) you made the worktrees yourself. Here
npm test
```
- `npm test` passes, and `origin` is now the folder `av-origin.git`, so a push stays on your machine. The exclude lines keep two folders out of `git status` without a commit: `.practice/`, where Your turn saves its files (as in [Beginner lesson 1](../../beginner/01-install-and-look-around.md#you-need)), and the worktrees Claude creates ([gitignore](https://git-scm.com/docs/gitignore), [Start Claude in a worktree](https://code.claude.com/docs/en/worktrees#start-claude-in-a-worktree)).
+ `npm test` passes, and `origin` is now the folder `av-origin.git`, so a push stays on your machine. The exclude lines keep two folders out of `git status` without a commit: `.practice/`, where Your turn saves its files (as in the [Intermediate index](../../intermediate/README.md#prepare-your-own-repository)), and the worktrees Claude creates ([gitignore](https://git-scm.com/docs/gitignore), [Start Claude in a worktree](https://code.claude.com/docs/en/worktrees#start-claude-in-a-worktree)).
2. In the first terminal, open agent view with two dispatch defaults: Manual mode, in which only reads run without asking ([Available modes](https://code.claude.com/docs/en/permission-modes#available-modes)), and Sonnet ([Model aliases](https://code.claude.com/docs/en/model-config#model-aliases)):
```bash
diff --git a/docs/advanced/electives/dev-containers.md b/docs/advanced/electives/dev-containers.md
index 516911d..7e263d5 100644
--- a/docs/advanced/electives/dev-containers.md
+++ b/docs/advanced/electives/dev-containers.md
@@ -9,7 +9,7 @@ By the end of this Elective you can run Claude Code inside a dev container, keep
## You need
- For the Worked example: your copy of the practice template on GitHub, and GitHub Codespaces on your account. Nothing to install on your computer: the copy's dev container installs Claude Code.
-- For Your turn: one of your own repositories with no `.devcontainer/` folder, with its `.practice/` folder set up as [Beginner lesson 1](../../beginner/01-install-and-look-around.md#you-need) describes.
+- For Your turn: one of your own repositories with no `.devcontainer/` folder, with its `.practice/` folder set up as the [Intermediate index](../../intermediate/README.md#prepare-your-own-repository) describes.
- Also for Your turn: Docker, VS Code with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) ([System requirements](https://code.visualstudio.com/docs/devcontainers/containers#_system-requirements)), and `jq`, on macOS, Linux or WSL 2. Without Docker, do the Worked example and the Check's self-check.
- Usage: light. A codespace also uses your GitHub account's Codespaces compute while it runs, and storage while it exists ([GitHub Codespaces billing](https://docs.github.com/en/billing/concepts/product-billing/github-codespaces)).
diff --git a/docs/advanced/electives/goal-loop-routines.md b/docs/advanced/electives/goal-loop-routines.md
index bce622d..670752b 100644
--- a/docs/advanced/electives/goal-loop-routines.md
+++ b/docs/advanced/electives/goal-loop-routines.md
@@ -1,117 +1,103 @@
-# `/goal`, `/loop` and routines
+# <a id="goal-loop-and-routines"></a>`/loop` and cloud scheduled tasks
-<sub>**Advanced** · Elective · about 20 minutes, plus run time · Needs: [Put bounds on autonomous runs](../07-bounded-runs.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Advanced** · Elective · about 15 minutes, plus run time · Needs: [Put bounds on autonomous runs](../07-bounded-runs.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
> [!NOTE]
-> "Routines are in research preview. Behavior, limits, and the API surface may change." ([Automate work with routines](https://code.claude.com/docs/en/routines))
+> "Scheduled tasks are in research preview. Behavior, limits, and the API surface may change." ([Automate work with scheduled tasks](https://code.claude.com/docs/en/routines))
## Goal
-By the end of this Elective you can keep Claude working without prompting each step: toward a condition with `/goal`, on an interval with `/loop`, and on a schedule in the cloud with a routine.
+By the end of this Elective you can keep Claude working without prompting each step: on an interval in your session with `/loop`, and on a schedule in the cloud with a cloud scheduled task.
## You need
- Your copy of the practice template, with Node.js LTS, for the Worked example, and one of your own repositories for Your turn.
-- For the routine, steps 7 to 9 only: a Pro, Max, Team or Enterprise plan, signed in with `/login` ([Availability by subscription plan](https://code.claude.com/docs/en/feature-availability#availability-by-subscription-plan)). Routines need a Claude subscription, so with a Console API key or a cloud provider, skip those steps ([Feature availability](https://code.claude.com/docs/en/feature-availability#features-that-require-a-claude-subscription)). On Team and Enterprise, an Owner can turn routines off for everyone ([Automate work with routines](https://code.claude.com/docs/en/routines)).
-- Also for the routine: GitHub access for cloud sessions to your copy, through the Claude GitHub App or `/web-setup`; with the App, a private copy needs the App installed on it ([GitHub authentication options](https://code.claude.com/docs/en/claude-code-on-the-web#github-authentication-options)). On Team and Enterprise, either way needs an Owner first: the GitHub connector for the App's browser sign-in, or Quick setup for `/web-setup` ([Connect GitHub](https://code.claude.com/docs/en/web-quickstart#connect-github), [Quick setup for Team and Enterprise](https://code.claude.com/docs/en/claude-code-on-the-web#quick-setup-for-team-and-enterprise)).
-- Usage: moderate. A goal runs several turns, each loop run sends the session's whole context again ([Why usage climbs in a long session](https://code.claude.com/docs/en/costs#why-usage-climbs-in-a-long-session)), and a routine run is a full cloud session that draws on your plan ([Usage and limits](https://code.claude.com/docs/en/routines#usage-and-limits)). The steps keep each one small: Sonnet, a turn limit, a short loop and a routine that runs once. Cheap variant: skip the routine (steps 7 to 9).
+- For the cloud scheduled task, steps 5 to 7 only: a Pro, Max, Team or Enterprise plan, signed in with `/login` ([Availability by subscription plan](https://code.claude.com/docs/en/feature-availability#availability-by-subscription-plan)). Cloud scheduled tasks need a Claude subscription, so with a Console API key or a cloud provider, skip those steps ([Feature availability](https://code.claude.com/docs/en/feature-availability#features-that-require-a-claude-subscription)). On Team and Enterprise, an Owner can turn cloud scheduled tasks off for everyone with the **Scheduled tasks (Was Routines)** toggle ([Automate work with scheduled tasks](https://code.claude.com/docs/en/routines)).
+- Also for the cloud scheduled task: GitHub access for cloud sessions to your copy, through the Claude GitHub App or `/web-setup`; with the App, a private copy needs the App installed on it ([GitHub authentication options](https://code.claude.com/docs/en/claude-code-on-the-web#github-authentication-options)). On Team and Enterprise, either way needs an Owner first: the GitHub connector for the App's browser sign-in, or Quick setup for `/web-setup` ([Connect GitHub](https://code.claude.com/docs/en/web-quickstart#connect-github), [Quick setup for Team and Enterprise](https://code.claude.com/docs/en/claude-code-on-the-web#quick-setup-for-team-and-enterprise)).
+- Usage: moderate. Each loop run sends the session's whole context again ([Why usage climbs in a long session](https://code.claude.com/docs/en/costs#why-usage-climbs-in-a-long-session)), and a cloud scheduled task run is a full cloud session that draws on your plan ([Usage and limits](https://code.claude.com/docs/en/routines#usage-and-limits)). The steps keep each one small: Sonnet, a short loop and a task that runs once. Cheap variant: skip the cloud scheduled task (steps 5 to 7).
## The idea
-`/goal`, `/loop` and a routine each start Claude's next run without you ([Compare ways to keep a session running](https://code.claude.com/docs/en/goal#compare-ways-to-keep-a-session-running), [Compare scheduling options](https://code.claude.com/docs/en/scheduled-tasks#compare-scheduling-options)):
+`/loop` and a cloud scheduled task each start Claude's next run without you ([Compare scheduling options](https://code.claude.com/docs/en/scheduled-tasks#compare-scheduling-options)):
| | Next run starts when | Stops when |
|---|---|---|
-| `/goal` | A turn ends and a second model, the evaluator, judges your condition not yet met | It's judged met or impossible, a turn hits an error you must fix, or `/goal clear` |
-| `/loop` | An interval passes, while the session is idle | You cancel it, Claude ends a self-paced loop, or it expires |
-| Routine | A schedule, an API call or a GitHub event, in the cloud | You pause or delete it; a one-off turns itself off |
+| `/loop` | An interval passes, while your session is open and idle | You cancel it, Claude ends a self-paced loop, or it expires |
+| Cloud scheduled task | A schedule, an API call or a GitHub event, in the cloud | You pause or delete it; a one-off turns itself off |
-The evaluator reads only the conversation, so your condition should name a check whose result shows in Claude's output, such as "`npm test` exits 0", say what must not change, and end with a turn limit ([Write an effective condition](https://code.claude.com/docs/en/goal#write-an-effective-condition)). Goals and loops keep the session's permission mode: in auto mode they run unattended, and in Manual mode Claude asks first ([Set a goal](https://code.claude.com/docs/en/goal#set-a-goal), [Compare scheduling options](https://code.claude.com/docs/en/scheduled-tasks#compare-scheduling-options)).
+A loop runs in your session, on your files, and keeps the session's permission mode: in auto mode its runs go ahead unattended, and in Manual mode Claude asks first. A cloud scheduled task runs on a fresh clone of your repository, so it keeps working with your laptop closed but sees only what you've pushed ([Compare scheduling options](https://code.claude.com/docs/en/scheduled-tasks#compare-scheduling-options), [Automate work with scheduled tasks](https://code.claude.com/docs/en/routines)). To keep Claude working toward a condition rather than on a clock, use `/goal`, which [lesson 3](../03-dynamic-workflows.md) teaches.
> [!WARNING]
-> A routine runs as a full cloud session that doesn't stop for approval, apart from some artifact actions, and it acts as you: its commits and pull requests carry your GitHub user ([Create a routine](https://code.claude.com/docs/en/routines#create-a-routine)). It can use every tool of each connector it includes, writes included, without asking, and every connector on your claude.ai account is included by default ([Create from the web](https://code.claude.com/docs/en/routines#create-from-the-web), [Connectors](https://code.claude.com/docs/en/routines#connectors)). Remove the connectors a routine doesn't need, and keep its prompt to read-only work while you learn.
+> A cloud scheduled task runs as a full cloud session that starts in auto mode, unless auto mode is unavailable, so a classifier model, not you, allows or blocks the actions that would otherwise wait for your approval. It still stops for your answer in cases such as an action that prompts even in auto mode (one matching an ask rule, for example) or after repeated blocks ([Permission prompts during a run](https://code.claude.com/docs/en/routines#permission-prompts-during-a-run)). It acts as you: its commits and pull requests carry your GitHub user ([Create a scheduled task](https://code.claude.com/docs/en/routines#create-a-scheduled-task)). Claude can use each connector the task includes, writes included, and every connector on your claude.ai account is included by default ([Create from the web](https://code.claude.com/docs/en/routines#create-from-the-web), [Connectors](https://code.claude.com/docs/en/routines#connectors)). Remove the connectors a task doesn't need, and keep its prompt to read-only work while you learn.
## Worked example
-Work in your practice copy, on a new branch.
+Work in your practice copy.
-1. Make the branch and the log folder, which git already ignores in the copy, then start Claude Code on Sonnet:
+1. Make the log folder, which git already ignores in the copy, then start Claude Code on Sonnet:
```bash
- git switch -c keep-working
mkdir -p .practice
claude --model sonnet
```
**Windows:** `New-Item -ItemType Directory -Force .practice` replaces the `mkdir` line.
- The status bar shows the permission mode ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)). If it shows `⏸ manual mode on`, approve each tool call as Claude asks; if it shows `⏵⏵ auto mode on`, the goal's turns and the loop's runs go ahead on their own.
-2. Set a goal. The link checker reports a link such as `setup.md?plain=1` as broken even when `setup.md` exists, because it strips only the `#` part of a link:
-
- ```text
- /goal npm test exits 0, a new test in test/links.test.js shows that a link such as setup.md?plain=1 to a file that exists is not reported as broken, no existing test changes, and the fix is committed; or stop after 8 turns
- ```
-
- Claude starts at once, and `◎ /goal active` shows how long the goal has run. After each turn the transcript shows the evaluator's verdict; press `Ctrl+O` for the reason behind it ([Set a goal](https://code.claude.com/docs/en/goal#set-a-goal)).
-3. When the evaluator judges the condition met, Claude Code clears the goal and records an achieved entry in the transcript ([How evaluation works](https://code.claude.com/docs/en/goal#how-evaluation-works)). Run `/goal`: it shows the achieved condition with its duration, turn count and token spend ([Check status](https://code.claude.com/docs/en/goal#check-status)). In a second terminal, `git log --oneline -1` shows the commit, and `npm test` passes. If `npm test` still fails or `git log` shows no new commit, the goal ended before the fix, for example at its turn limit or judged impossible, and `/goal` shows whether it's still active: ask Claude to finish the fix and commit it.
-4. Start a loop that logs the test results every minute:
+ The status bar shows the permission mode ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)). If it shows `⏸ manual mode on`, approve each tool call as Claude asks; if it shows `⏵⏵ auto mode on`, the loop's runs go ahead on their own.
+2. Start a loop that logs the test results every minute:
```text
/loop 1m run npm test and append one line to .practice/loop-log.txt with the time and the number of passing and failing tests. Don't change any other file.
```
- Claude schedules it and confirms the cadence and a job ID ([Run on a fixed interval](https://code.claude.com/docs/en/scheduled-tasks#run-on-a-fixed-interval)). Each run fires between your turns, never while Claude is mid-response ([How scheduled tasks run](https://code.claude.com/docs/en/scheduled-tasks#how-scheduled-tasks-run)).
-5. In your editor, not through Claude, break one test: in `test/config.test.js`, change the first test's `files: ['.']` to `files: ['docs']`. Wait until the log gains a line that shows a failure, then undo the change with `git restore test/config.test.js`.
-6. Ask Claude `cancel the npm test loop`, then `what scheduled tasks do I have?`: none are left ([Manage scheduled tasks](https://code.claude.com/docs/en/scheduled-tasks#manage-scheduled-tasks)). `cat .practice/loop-log.txt` shows a line for each run, at least one of them failing. Your wording will differ.
-7. Steps 7 to 9 need a subscription; without one, skip to step 10. Schedule a routine that runs once, in five minutes:
+ Claude schedules it and confirms the cadence and a job ID ([Run on a fixed interval](https://code.claude.com/docs/en/scheduled-tasks#run-on-a-fixed-interval)). Each run fires between your turns, never while Claude is mid-response ([How session-scoped scheduled tasks run](https://code.claude.com/docs/en/scheduled-tasks#how-session-scoped-scheduled-tasks-run)).
+3. In your editor, not through Claude, break one test: in `test/config.test.js`, change the first test's `files: ['.']` to `files: ['docs']`. Wait until the log gains a line that shows a failure, then undo the change with `git restore test/config.test.js`.
+4. Ask Claude `cancel the npm test loop`, then `what scheduled tasks do I have?`: none are left ([Manage session-scoped scheduled tasks](https://code.claude.com/docs/en/scheduled-tasks#manage-session-scoped-scheduled-tasks)). `cat .practice/loop-log.txt` shows a line for each run, at least one of them failing. Your wording will differ.
+5. Steps 5 to 7 need a subscription; without one, you're done with the Worked example. Schedule a cloud scheduled task that runs once, in five minutes:
```text
/schedule in 5 minutes, run npm test in this repository and reply with the number of passing and failing tests. Don't edit files, commit or push.
```
- Claude asks follow-up questions about the schedule, the repository and the prompt, and confirms the absolute time before it saves ([Create from the CLI](https://code.claude.com/docs/en/routines#create-from-the-cli), [Schedule a one-off run](https://code.claude.com/docs/en/routines#schedule-a-one-off-run)). Tell it to include no connectors; if it can't, remove them as soon as it saves, with `/schedule update` or the routine's **Edit** form at `claude.ai/code/routines` ([Connectors](https://code.claude.com/docs/en/routines#connectors)).\
- If Claude adds a setup note about GitHub access, follow it before the run time; if the time passes first, edit the routine and set a new one-off time ([Repositories and branch permissions](https://code.claude.com/docs/en/routines#repositories-and-branch-permissions), [Edit and control routines](https://code.claude.com/docs/en/routines#edit-and-control-routines)). If Claude replies that you need to authenticate, no routine was saved; if `/schedule` isn't in the command menu, see [`/schedule` returns "Unknown command"](https://code.claude.com/docs/en/routines#schedule-returns-unknown-command).
-8. `/schedule list` shows the routine ([Manage routines from the CLI](https://code.claude.com/docs/en/routines#manage-routines-from-the-cli)). After it runs, open it at `claude.ai/code/routines`, open the run and read the transcript for the test counts ([View and interact with runs](https://code.claude.com/docs/en/routines#view-and-interact-with-runs)). The run cloned your default branch, so its count doesn't include the test you added on `keep-working` ([Repositories and branch permissions](https://code.claude.com/docs/en/routines#repositories-and-branch-permissions)). The one-off is now marked **Ran**.
-9. Delete the routine: open the menu next to its name and select **Delete** ([Edit and control routines](https://code.claude.com/docs/en/routines#edit-and-control-routines)).\
- If you connected GitHub only for the routine, disconnect it at `claude.ai/customize/connectors`, which deletes the credential whether it came from the browser or from `/web-setup`; the `gh` token itself stays valid on GitHub ([Remove the `/web-setup` token](https://code.claude.com/docs/en/web-quickstart#remove-the-web-setup-token)). If you installed the Claude GitHub App only for the routine, also take your copy out of its repository access, and uninstall it only if nothing else of yours uses it ([Reviewing and modifying installed GitHub Apps](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps)).
-10. `git switch -` takes your copy back to the branch you started on; `keep-working` keeps the fix.
+ Claude asks follow-up questions about the schedule, the repository and the prompt, and confirms the absolute time before it saves ([Create from the CLI](https://code.claude.com/docs/en/routines#create-from-the-cli), [Schedule a one-off run](https://code.claude.com/docs/en/routines#schedule-a-one-off-run)). The earlier name, routines, still appears in Claude's replies while it sets up a task and, in some accounts, in the app's sidebar entry and page title ([Where the name routines still appears](https://code.claude.com/docs/en/routines#where-the-name-routines-still-appears)). Tell it to include no connectors; if it can't, remove them as soon as it saves, with `/schedule update` or the task's **Edit** dialog at `claude.ai/code/routines` ([Connectors](https://code.claude.com/docs/en/routines#connectors)).\
+ If Claude adds a setup note about GitHub access, follow it before the run time; if the time passes first, edit the task and set a new one-off time ([Repositories and branch permissions](https://code.claude.com/docs/en/routines#repositories-and-branch-permissions), [Edit and control scheduled tasks](https://code.claude.com/docs/en/routines#edit-and-control-scheduled-tasks)). If Claude replies that you need to authenticate, no task was saved; if `/schedule` isn't in the command menu, see [`/schedule` returns "Unknown command"](https://code.claude.com/docs/en/routines#schedule-returns-unknown-command).
+6. `/schedule list` shows the task ([Manage scheduled tasks from the CLI](https://code.claude.com/docs/en/routines#manage-scheduled-tasks-from-the-cli)). After it runs, open it at `claude.ai/code/routines`, open the run and read the transcript for the test counts ([View and interact with runs](https://code.claude.com/docs/en/routines#view-and-interact-with-runs)). The run cloned your default branch, not your working tree ([Repositories and branch permissions](https://code.claude.com/docs/en/routines#repositories-and-branch-permissions)). The one-off is now marked **Completed** ([Schedule a one-off run](https://code.claude.com/docs/en/routines#schedule-a-one-off-run)).
+7. Delete the task: open the menu next to its name and select **Delete** ([Edit and control scheduled tasks](https://code.claude.com/docs/en/routines#edit-and-control-scheduled-tasks)).\
+ If you connected GitHub only for the task, disconnect it at `claude.ai/customize/connectors`, which deletes the credential whether it came from the browser or from `/web-setup`; the `gh` token itself stays valid on GitHub ([Remove the `/web-setup` token](https://code.claude.com/docs/en/web-quickstart#remove-the-web-setup-token)). If you installed the Claude GitHub App only for the task, also take your copy out of its repository access, and uninstall it only if nothing else of yours uses it ([Reviewing and modifying installed GitHub Apps](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps)).
## Your turn
-In one of your own repositories, pick a chore whose end state a command can prove, such as a failing test or a lint error. Finish it with a goal. Then commit a `.claude/loop.md` that keeps watching it: the file replaces the built-in prompt of a `/loop` you start without a prompt of your own ([Customize the default prompt with loop.md](https://code.claude.com/docs/en/scheduled-tasks#customize-the-default-prompt-with-loop-md)). With a subscription, you can also have a one-off routine run the command in the cloud once your work is on the default branch, or name your branch in the routine's prompt ([Repositories and branch permissions](https://code.claude.com/docs/en/routines#repositories-and-branch-permissions)).
+In one of your own repositories, pick a check a command can run, such as the test suite or a lint command. Commit a `.claude/loop.md` that keeps watching it: the file replaces the built-in prompt of a `/loop` you start without a prompt of your own ([Customize the default prompt with loop.md](https://code.claude.com/docs/en/scheduled-tasks#customize-the-default-prompt-with-loop-md)). With a subscription, you can also have a one-off cloud scheduled task run the command in the cloud once your work is on the default branch, or name your branch in the task's prompt ([Repositories and branch permissions](https://code.claude.com/docs/en/routines#repositories-and-branch-permissions)).
It's done when:
-- Your condition names the command that proves the end state, one thing that must not change, and a turn limit.
-- The work is committed, and the command exits 0.
- `.claude/loop.md` is committed. It says what to check, and to report in one line without changing any file. `/loop 10m` (an interval and no prompt) ran it at least twice, then you cancelled it ([Run the built-in maintenance prompt](https://code.claude.com/docs/en/scheduled-tasks#run-the-built-in-maintenance-prompt)).
-- No scheduled task or routine is left: `what scheduled tasks do I have?` lists none, and any routine you made is deleted.
+- No scheduled task is left: `what scheduled tasks do I have?` lists none, and any cloud scheduled task you made is deleted.
## Check
You are done when all of these are true:
-- [ ] In your repository, the goal's work is committed (`git log -1` shows it), and the command your condition named exits 0.
- [ ] In your practice copy, `.practice/loop-log.txt` holds lines from at least two loop runs, at least one of them failing.
- [ ] `.claude/loop.md` is committed in your repository (`git ls-files .claude/loop.md` prints it), and `git status --porcelain` prints nothing.
-- [ ] Self-check (not tested): your condition named the command, one thing that must not change and a turn limit; `/loop 10m` ran your `loop.md` at least twice before you cancelled it; `what scheduled tasks do I have?` lists none; and if you made a routine, you read its run's transcript and deleted it.
+- [ ] Self-check (not tested): `/loop 10m` ran your `loop.md` at least twice before you cancelled it; `what scheduled tasks do I have?` lists none; and if you made a cloud scheduled task, you read its run's transcript and deleted it.
-If the command still fails, the goal ended before the work did, for example at its turn limit or judged impossible: press `Ctrl+O` to read the last verdict's reason ([How evaluation works](https://code.claude.com/docs/en/goal#how-evaluation-works)), then fix the cause or set a new goal; if `/goal` won't start, it says why, usually an untrusted folder or `disableAllHooks` ([Requirements](https://code.claude.com/docs/en/goal#requirements)). If no log line shows a failure, the loop didn't run while the test was broken: start the loop again as in step 4, break the test as in step 5, wait for a failing line, restore the file, then cancel the loop as in step 6. If `git ls-files` prints nothing, `git check-ignore -v .claude/loop.md` names the rule that hides the file: add it with `git add -f`, then commit.
+If no log line shows a failure, the loop didn't run while the test was broken: start the loop again as in step 2, break the test as in step 3, wait for a failing line, restore the file, then cancel the loop as in step 4. If `git ls-files` prints nothing, `git check-ignore -v .claude/loop.md` names the rule that hides the file: add it with `git add -f`, then commit.
## Watch out
- A loop fires even while you're away, sending the session's whole context each time, and keeps going until you cancel it or it expires ([Stop a loop](https://code.claude.com/docs/en/scheduled-tasks#stop-a-loop)). On a Pro, Max, Team or Enterprise plan, `/usage` lists your heaviest loops ([Plan usage breakdown](https://code.claude.com/docs/en/costs#plan-usage-breakdown)).
-- The evaluator can't confirm a condition that Claude's output can't show, such as "the code is clean". Name a command and its result ([How evaluation works](https://code.claude.com/docs/en/goal#how-evaluation-works)).
-- A green status in a routine's run list only means the session started and exited without an infrastructure error. Open the run and read the transcript to see whether the task worked ([View and interact with runs](https://code.claude.com/docs/en/routines#view-and-interact-with-runs)).
+- `Esc` doesn't stop a fixed-interval loop such as `/loop 1m`: ask Claude to cancel it ([Stop a loop](https://code.claude.com/docs/en/scheduled-tasks#stop-a-loop)).
+- A green status in a cloud scheduled task's run list only means the session started and exited without an infrastructure error. Open the run and read the transcript to see whether the task worked ([View and interact with runs](https://code.claude.com/docs/en/routines#view-and-interact-with-runs)).
## Go further
- [Loop engineering: Getting started with loops](https://claude.com/resources/articles/getting-started-with-loops): Anthropic's Claude Code team on turn-based, goal-based, time-based and proactive loops, and when to use each.
-- [Prompt-based hooks](https://code.claude.com/docs/en/hooks-guide#prompt-based-hooks): the kind of Stop hook `/goal` wraps ([How evaluation works](https://code.claude.com/docs/en/goal#how-evaluation-works)), for a check you want in every session.
+- [Add a GitHub trigger](https://code.claude.com/docs/en/routines#add-a-github-trigger): run a cloud scheduled task on pull request or release events, with the Claude GitHub App installed on the repository.
- [Schedule recurring tasks in Claude Code Desktop](https://code.claude.com/docs/en/desktop-scheduled-tasks): scheduled tasks that run on your machine, with your local files, while the Desktop app is open.
---
-<sub>Sources: [Keep Claude working toward a goal](https://code.claude.com/docs/en/goal) · [Run prompts on a schedule](https://code.claude.com/docs/en/scheduled-tasks) · [Automate work with routines](https://code.claude.com/docs/en/routines) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Manage costs effectively](https://code.claude.com/docs/en/costs) · [Feature availability](https://code.claude.com/docs/en/feature-availability) · [Use Claude Code in the cloud](https://code.claude.com/docs/en/claude-code-on-the-web) · [Get started with Claude Code in the cloud](https://code.claude.com/docs/en/web-quickstart) · [Reviewing and modifying installed GitHub Apps](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps)</sub>
+<sub>Sources: [Run prompts on a schedule](https://code.claude.com/docs/en/scheduled-tasks) · [Automate work with scheduled tasks](https://code.claude.com/docs/en/routines) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Manage costs effectively](https://code.claude.com/docs/en/costs) · [Feature availability](https://code.claude.com/docs/en/feature-availability) · [Use Claude Code in the cloud](https://code.claude.com/docs/en/claude-code-on-the-web) · [Get started with Claude Code in the cloud](https://code.claude.com/docs/en/web-quickstart) · [Reviewing and modifying installed GitHub Apps](https://docs.github.com/en/apps/using-github-apps/reviewing-and-modifying-installed-github-apps)</sub>
<sub>Back to the [Advanced index](../README.md) · Topic: [Automation](../../topics/automation.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=a-goal-loop)</sub>
diff --git a/docs/advanced/electives/publish-a-plugin.md b/docs/advanced/electives/publish-a-plugin.md
index 908a084..39880d5 100644
--- a/docs/advanced/electives/publish-a-plugin.md
+++ b/docs/advanced/electives/publish-a-plugin.md
@@ -37,7 +37,7 @@ Publishing is a `.claude-plugin/marketplace.json` in a git repository: once it's
echo '# commit-helper: drafts commit messages in a short, consistent format.' > plugins/commit-helper/README.md
```
- `.practice/` holds the file the Check reads, ignored without a commit as in [Beginner lesson 1](../../beginner/01-install-and-look-around.md#you-need). The `.gitignore` line keeps out the results each eval run writes under `evals/results/` ([Write and refine cases](https://code.claude.com/docs/en/plugin-evals#write-and-refine-cases)), and the release checklist asks for the README ([Prepare your plugin for release](https://code.claude.com/docs/en/plugins/publish#prepare-your-plugin-for-release)). Then save the plugin's manifest, with the fields that checklist asks for, as `plugins/commit-helper/.claude-plugin/plugin.json`:
+ `.practice/` holds the file the Check reads, ignored without a commit as in the [Intermediate index](../../intermediate/README.md#prepare-your-own-repository). The `.gitignore` line keeps out the results each eval run writes under `evals/results/` ([Write and refine cases](https://code.claude.com/docs/en/plugin-evals#write-and-refine-cases)), and the release checklist asks for the README ([Prepare your plugin for release](https://code.claude.com/docs/en/plugins/publish#prepare-your-plugin-for-release)). Then save the plugin's manifest, with the fields that checklist asks for, as `plugins/commit-helper/.claude-plugin/plugin.json`:
```json
{
diff --git a/docs/beginner/01-install-and-look-around.md b/docs/beginner/01-install-and-look-around.md
index 80c3095..0abce34 100644
--- a/docs/beginner/01-install-and-look-around.md
+++ b/docs/beginner/01-install-and-look-around.md
@@ -1,16 +1,15 @@
# Install, sign in and look around
-<sub>**Beginner** · Lesson 1 of 5 · about 20 minutes · Needs: [Beginner index](README.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-19</sub>
+<sub>**Beginner** · Lesson 1 of 5 · about 20 minutes · Needs: [Beginner index](README.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
-By the end of this lesson you can install Claude Code, sign in, start it in a repository, and tell which version, model and account a session is using.
+By the end of this lesson you can install Claude Code, start it safely in a repository, stop it mid-answer, tell which model and account a session uses, and check what it tells you against the code.
## You need
- A terminal and git, plus a Claude subscription (Pro, Max, Team or Enterprise; the free plan doesn't include Claude Code), a Claude Console account, or access through a supported cloud provider ([Quickstart](https://code.claude.com/docs/en/quickstart), [Advanced setup](https://code.claude.com/docs/en/setup)).
- Your copy of the practice template, cloned, as the [Beginner index](README.md#practice) describes, and Node.js LTS for its checks. In a Codespace on your copy, Claude Code is already installed: start at step 3.
-- Every Beginner lesson and the capstone run in your practice copy, because each one works with files that only the copy has, such as this lesson's onboarding notes. Lesson 5 ends by giving one of your own repositories a `CLAUDE.md`, and the [Intermediate level](../intermediate/README.md) practices in your own repository.
- Usage: light, meaning a few short prompts in one session. Inside Claude Code, `/usage` shows your session cost and plan usage limits ([Commands](https://code.claude.com/docs/en/commands)).
> [!NOTE]
@@ -50,7 +49,7 @@ The header Claude Code shows when it starts gives the version and the model. The
```
If your shell says `claude` isn't found or isn't recognized, the install folder isn't on your `PATH` yet: fix it with [Troubleshoot installation](https://code.claude.com/docs/en/troubleshoot-install#command-not-found-claude-after-installation) before you go on.
-3. Go to your practice copy and start a session there: put the full path to your copy's folder in place of `<your practice copy>`, in quotes if the path has a space. In a Codespace, that is `/workspaces/` followed by your copy's name ([Codespaces deep dive](https://docs.github.com/en/codespaces/about-codespaces/deep-dive), [Codespaces with GitHub CLI](https://docs.github.com/en/codespaces/developing-in-a-codespace/using-github-codespaces-with-github-cli)):
+3. Go to your practice copy and start a session there: put the full path to your copy's folder in place of `<your practice copy>`, in quotes if the path has a space. In a Codespace, that is `/workspaces/` followed by your copy's name ([Codespaces deep dive](https://docs.github.com/en/codespaces/about-codespaces/deep-dive)):
```bash
cd <your practice copy>
@@ -61,14 +60,16 @@ The header Claude Code shows when it starts gives the version and the model. The
In a repository you haven't trusted yet, Claude Code then shows the workspace trust dialog ([Security](https://code.claude.com/docs/en/security#additional-safeguards)). Trust a folder only when you know where its code came from: once you trust it, the repository's own `.claude/settings.json` can grant Claude permissions, such as allow rules, and the dialog lists them first ([Configure permissions](https://code.claude.com/docs/en/permissions#project-allow-rules-and-workspace-trust)). For a stranger's fork you just cloned, leave without trusting it and read its `.claude/` folder first. For your own practice copy, read the dialog and choose to trust the folder. Claude Code saves the trust for the whole repository, so it doesn't ask again here.
- The header above the prompt shows the version, the model and the folder. The status bar under the prompt usually reads `⏵⏵ auto mode on`: auto mode is the built-in starting mode, where Claude works without asking you about routine actions and a separate classifier model reviews actions before they run and blocks anything that goes beyond your request ([Choose a permission mode](https://code.claude.com/docs/en/permission-modes#eliminate-prompts-with-auto-mode)). Claude Code may also show a one-time notice about it. If it reads `⏸ manual mode on` instead, something chose Manual, for example a setting or your organization, or auto mode isn't available to your session ([Which mode a session starts in](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in)). This lesson works the same way in either mode. Lesson 2 covers the modes.
-4. Type `/status`. The **Status** tab lists the version, the model and the account you signed in with (rows such as **Login method** and **Email**). It is the screen to compare when your session differs from a teammate's, such as a model they can pick and you can't: compare the account rows first. If `ANTHROPIC_API_KEY` is set in your shell, Claude Code uses that key once you approve it, not your subscription, and `/status` marks the credential that isn't in use ([Authentication](https://code.claude.com/docs/en/authentication#authentication-precedence)). Press `Esc` to close it ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#general-controls)). Your version may be newer than the one at the top of this page: this guide is checked against the `stable` release channel, and Claude Code follows `latest` unless you choose otherwise ([Configure the release channel](https://code.claude.com/docs/en/setup#configure-release-channel)).
-5. Ask two questions about the code:
+ The header above the prompt shows the version, the model and the folder. The status bar under the prompt shows the permission mode, usually `⏵⏵ auto mode on`, where Claude works without asking you about routine actions ([Which mode a session starts in](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in), [Auto mode](https://code.claude.com/docs/en/permission-modes#eliminate-prompts-with-auto-mode)). Lesson 2 covers the modes.
+4. Type `/status`. The **Status** tab lists the version, the model and the account you signed in with (rows such as **Login method** and **Email**). It is the screen to compare when your session differs from a teammate's, such as a model they can pick and you can't: compare the account rows first. If `ANTHROPIC_API_KEY` is set in your shell, Claude Code uses that key once you approve it, not your subscription, and `/status` marks the credential that isn't in use ([Authentication](https://code.claude.com/docs/en/authentication#authentication-precedence)). Press `Esc` to close it ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#general-controls)). Your version may be newer than this page's: Claude Code follows the `latest` release channel unless you choose otherwise ([Configure the release channel](https://code.claude.com/docs/en/setup#configure-release-channel)).
+5. Ask about the code, and stop Claude partway:
```text
what does this project do?
```
+ While Claude is still answering, press `Esc`. Claude stops and waits for your next instruction, and keeps the work done so far ([How Claude Code works](https://code.claude.com/docs/en/how-claude-code-works#interrupt-and-steer), [Interactive mode](https://code.claude.com/docs/en/interactive-mode#general-controls)). Press it whenever Claude heads the wrong way, then say what you want instead. Send the question again and let it finish, then ask:
+
```text
which file parses linkcheck.json, and how do I run the tests?
```
@@ -78,12 +79,12 @@ The header Claude Code shows when it starts gives the version and the model. The
## Your turn
-Your team wants linkcheck in CI, so that a pull request with a broken link fails. A teammate's onboarding notes, `practice/b-1/onboarding.md` in your practice copy, say things about linkcheck that the CI job would depend on, and one of those claims is wrong. Find it before anyone plans the job around it.
+Find and correct the wrong claim in a teammate's onboarding notes before the team builds CI on it. Your team wants linkcheck in CI, so that a pull request with a broken link fails, and the notes, `practice/b-1/onboarding.md` in your practice copy, say things about linkcheck that the CI job would depend on.
-1. In the same session, ask Claude to check the notes:
+1. In the same session, ask Claude to check the notes. Typing `@` before a path includes that file in your prompt, without waiting for Claude to find and read it ([Common workflows](https://code.claude.com/docs/en/common-workflows#reference-files-and-directories)):
```text
- check each claim in practice/b-1/onboarding.md against the code. For each one, say whether the code agrees, and cite the file and line.
+ check each claim in @practice/b-1/onboarding.md against the code. For each one, say whether the code agrees, and cite the file and line.
```
2. For each claim Claude says the code contradicts, open the file and line it cites and read them yourself. Decide which claim is wrong from the code, not from the notes or from Claude's answer. If Claude also names cases a claim leaves out, that's fine: correct only a claim the code contradicts.
@@ -118,6 +119,6 @@ If the first item fails, run `claude --version` in that terminal: when it prints
---
-<sub>Sources: [Quickstart](https://code.claude.com/docs/en/quickstart) · [Advanced setup](https://code.claude.com/docs/en/setup) · [Authentication](https://code.claude.com/docs/en/authentication) · [Model configuration](https://code.claude.com/docs/en/model-config) · [Security](https://code.claude.com/docs/en/security) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Commands](https://code.claude.com/docs/en/commands) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Troubleshoot installation](https://code.claude.com/docs/en/troubleshoot-install) · [Codespaces deep dive](https://docs.github.com/en/codespaces/about-codespaces/deep-dive) · [Codespaces with GitHub CLI](https://docs.github.com/en/codespaces/developing-in-a-codespace/using-github-codespaces-with-github-cli) · [git diff](https://git-scm.com/docs/git-diff) · [git status](https://git-scm.com/docs/git-status) · [git commit](https://git-scm.com/docs/git-commit)</sub>
+<sub>Sources: [Quickstart](https://code.claude.com/docs/en/quickstart) · [Advanced setup](https://code.claude.com/docs/en/setup) · [Authentication](https://code.claude.com/docs/en/authentication) · [Model configuration](https://code.claude.com/docs/en/model-config) · [Security](https://code.claude.com/docs/en/security) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Commands](https://code.claude.com/docs/en/commands) · [How Claude Code works](https://code.claude.com/docs/en/how-claude-code-works) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Common workflows](https://code.claude.com/docs/en/common-workflows) · [Troubleshoot installation](https://code.claude.com/docs/en/troubleshoot-install) · [Codespaces deep dive](https://docs.github.com/en/codespaces/about-codespaces/deep-dive) · [git diff](https://git-scm.com/docs/git-diff) · [git status](https://git-scm.com/docs/git-status) · [git commit](https://git-scm.com/docs/git-commit)</sub>
<sub>← [Beginner index](README.md) · [Permission modes and plan mode](02-permission-modes-and-plan-mode.md) → · Topic: [Models, effort and cost](../topics/models-effort-and-cost.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=b-1)</sub>
diff --git a/docs/beginner/02-permission-modes-and-plan-mode.md b/docs/beginner/02-permission-modes-and-plan-mode.md
index 7bdc320..a5c5214 100644
--- a/docs/beginner/02-permission-modes-and-plan-mode.md
+++ b/docs/beginner/02-permission-modes-and-plan-mode.md
@@ -1,14 +1,15 @@
# Choose who approves what: permission modes and plan mode
-<sub>**Beginner** · Lesson 2 of 5 · about 25 minutes · Needs: [Install, sign in and look around](01-install-and-look-around.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-19</sub>
+<sub>**Beginner** · Lesson 2 of 5 · about 25 minutes · Needs: [Install, sign in and look around](01-install-and-look-around.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
-By the end of this lesson you can pick a permission mode for a task, switch modes during a session, and use plan mode to approve a plan before Claude edits your files.
+By the end of this lesson you can pick a permission mode for a task, decide whether a change needs a plan, and use plan mode to approve only a plan you would merge, before Claude edits your files.
## You need
-- Your copy of the practice template, cloned, with no uncommitted changes, and Node.js LTS for its checks (a Codespace on your copy has both). This lesson runs in the practice copy: Your turn works a ticket that comes with it.
+- Your copy of the practice template, cloned, with no uncommitted changes, and Node.js LTS for its checks (a Codespace on your copy has both).
+- A second terminal open in the same folder, for git.
- Usage: light.
> [!NOTE]
@@ -19,16 +20,16 @@ By the end of this lesson you can pick a permission mode for a task, switch mode
A [permission mode](https://code.claude.com/docs/en/permission-modes) decides which actions Claude takes without asking you first. A new session starts in auto mode, where a second model, the classifier, reviews actions instead of you and blocks anything that escalates beyond your request. Ordinary source-file edits in your working directory don't reach the classifier: auto mode approves them ([How the classifier evaluates actions](https://code.claude.com/docs/en/permission-modes#how-the-classifier-evaluates-actions)). Whether an edit belongs in the change is yours to judge. `Shift+Tab` switches modes, and the status bar under the prompt shows the one in force:
- **Auto**, `⏵⏵ auto mode on`: no routine prompts. For most work, where you trust the general direction.
-- **Plan**, `⏸ plan mode on`: Claude explores and writes a plan, and can't edit your files until you approve it. For a change you want to agree on first.
+- **Plan**, `⏸ plan mode on`: Claude explores and writes a plan, and can't edit your files until you approve it.
- **Manual**, `⏸ manual mode on`: Claude asks before edits and most commands. For sensitive work, or whenever approving each step is the point.
-- **Accept edits**, `⏵⏵ accept edits on`: file edits and common file commands, such as `mkdir` and `mv`, run without asking. For code you will review with `git diff` ([git diff](https://git-scm.com/docs/git-diff)) afterwards.
+- **Accept edits**, `⏵⏵ accept edits on`: file edits and common file commands, such as `mkdir`, `mv` and `rm`, run without asking inside your working directory ([Auto-approve file edits](https://code.claude.com/docs/en/permission-modes#auto-approve-file-edits-with-acceptedits-mode)). For code you'll review afterwards.
-The habit to build: plan first, and approve only a plan you would merge.
+Plan when you're unsure of the approach, the change touches several files, or you don't know the code. If you could describe the diff in one sentence, such as a typo fix, skip the plan ([Best practices](https://code.claude.com/docs/en/best-practices#explore-first-then-plan-then-code)). When you do plan, approve only a plan you would merge.
## Worked example
-1. Start `claude` in your practice copy. The status bar reads `⏵⏵ auto mode on`, unless a setting or your organization starts your sessions in another mode, or auto mode isn't available to you ([Which mode a session starts in](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in)).
-2. Press `Shift+Tab` until the status bar reads `⏸ plan mode on`. Each press moves to the next mode, and the status bar names it.
+1. Start `claude` in your practice copy. The status bar usually reads `⏵⏵ auto mode on` ([Which mode a session starts in](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in)).
+2. The change makes `parseConfig` in `src/config.js` reject an empty file, with a test: two files, in code you haven't read, so plan it. Press `Shift+Tab` until the status bar reads `⏸ plan mode on`. Each press moves to the next mode, and the status bar names it.
3. Ask for the change:
```text
@@ -36,7 +37,7 @@ The habit to build: plan first, and approve only a plan you would merge.
```
4. Claude reads files and may run commands to explore, but doesn't edit your files. If it needs a decision from you first, it asks a [multiple-choice question](https://code.claude.com/docs/en/tools-reference#askuserquestion-tool-behavior): pick an option or type your own answer, and it keeps planning. Then it shows a plan and asks how to proceed, with these choices:
- - **Yes, and use auto mode** (it reads **Yes, auto-accept edits** if auto mode isn't available to you)
+ - Usually **Yes, and use auto mode** (it reads **Yes, auto-accept edits** if auto mode isn't available to you)
- **Yes, manually approve edits**
- A choice to keep planning and revise the plan (the [docs](https://code.claude.com/docs/en/permission-modes#review-and-approve-a-plan) call this choice **No, keep planning**)
@@ -47,26 +48,24 @@ The habit to build: plan first, and approve only a plan you would merge.
Make the error say "linkcheck.json is empty", and keep the change to src/config.js and test/config.test.js.
```
- Send it with `Enter`, not `Shift+Tab`: on this menu, `Shift+Tab` approves the plan ([CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md)). Claude revises the plan and shows the menu again. Your change can be below the top of the plan, so scroll to find it.
+ Send it with `Enter`, not `Shift+Tab`, which approves the plan on this menu ([CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md)). Claude revises the plan and shows the menu again. Your change can be below the top of the plan, so scroll to find it.
6. Leave the revised plan on screen, open another terminal in the same folder and run `git status` ([git status](https://git-scm.com/docs/git-status)). It says `nothing to commit, working tree clean`: plan mode hasn't changed a file.
7. Back in Claude Code, use `Down arrow` to move the highlight to **Yes, manually approve edits** and press `Enter`. Here approving each step is the point: you watch the plan land. After a plan you trust, **Yes, and use auto mode** is the everyday choice. The session switches to Manual mode, so Claude asks before each edit and before most shell commands, such as running the tests. Read each request:
- An edit or a command the plan needs: **Yes**.
- The test command, `npm test`: **Yes**, or **Yes, and don't ask again** if you would rather not be asked about it again. That saves a rule for this repository in `.claude/settings.local.json` ([Configure permissions](https://code.claude.com/docs/en/permissions#permission-system)), so keep it for commands whose effects you know.
- A command that does more than the plan needs, such as `npm test && git add -A` ([git add](https://git-scm.com/docs/git-add)): **No**. To say what to do instead, move the highlight to **No**, press `Tab`, type it and press `Enter` ([Add a comment](https://code.claude.com/docs/en/permissions#add-a-comment-when-you-answer-a-permission-prompt)).
- A Bash command's request can also offer **Yes, and switch to auto mode** ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)). Skip it here: it approves the command and ends the step-by-step review.
-
- Answer with the arrow keys and `Enter`, not `Shift+Tab`: on an edit request, `Shift+Tab` picks the choice that allows edits for the rest of the session, where the request offers one ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#general-controls)).
+ Answer with the arrow keys and `Enter`. Skip **Yes, and switch to auto mode**, which ends the step-by-step review ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)), and don't press `Shift+Tab` here: on an edit request it picks the choice that allows edits for the rest of the session, when the request offers one ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#general-controls)).
8. When Claude is done, run `git status` in the other terminal again. It lists `src/config.js` and `test/config.test.js`, the two files the plan named. If it lists another file, look in the session for the edit or command that wrote it.
-9. Set the example's change aside so Your turn starts clean ([git stash](https://git-scm.com/docs/git-stash)):
+9. You reviewed each edit as it landed, so commit the example's change, and Your turn starts from a clean tree ([git commit](https://git-scm.com/docs/git-commit)):
```bash
- git stash push --include-untracked -m b-2-example
+ git commit -am "Reject an empty linkcheck.json"
```
## Your turn
-A teammate filed `practice/b-2/ticket.md` in your practice copy. Work it in plan mode, and approve only what this change should ship.
+Work a teammate's ticket so that nothing ships you'd reject in review. The ticket is `practice/b-2/ticket.md` in your practice copy.
1. Read the ticket yourself first.
2. Start a fresh conversation for the new task: type `/exit`, then start `claude` again. To enter plan mode and start the task in one step, type `/plan` before it ([Commands](https://code.claude.com/docs/en/commands)):
@@ -76,7 +75,7 @@ A teammate filed `practice/b-2/ticket.md` in your practice copy. Work it in plan
```
Check that the status bar reads `⏸ plan mode on`, and answer any question Claude asks.
-3. Read the plan as its reviewer. For each change, ask whether you would merge it as part of this ticket. Use the plan menu to send back anything you wouldn't merge, in your own words, with your reason, until the plan is one you would approve.
+3. Read the plan as its reviewer. For each change, ask whether you would merge it as part of this ticket. If the plan includes a request you wouldn't merge, use the plan menu to send it back, in your own words, with your reason. If the plan already leaves one out, read Claude's reason and decide whether you agree. Revise until the plan is one you would approve.
4. While the final plan is on screen, save what git sees, and the files the plan says it will change, in the other terminal. Write each path the way `git status` shows it: relative to the repository root, with forward slashes, one per line. For a plan that changed `src/links.js` and `test/links.test.js`, it would be:
```bash
@@ -86,14 +85,14 @@ A teammate filed `practice/b-2/ticket.md` in your practice copy. Work it in plan
```
**Windows:** `New-Item -ItemType Directory -Force .practice` replaces the `mkdir` line, and `'src/links.js','test/links.test.js' | Set-Content .practice/b-2-plan.txt` replaces the `printf` line.
-5. Approve with **Yes, manually approve edits**, and read each request as in step 7 of the example.
+5. Approve the plan you reviewed. After a plan you trust, **Yes, and use auto mode** is the everyday choice; if Claude Code asks before an action, read it before you answer.
6. When Claude is done, save what git sees now:
```bash
git status --porcelain > .practice/b-2-after.txt
```
-Stop before committing. The next lesson sets this change aside with `git stash push --include-untracked -m b-2` and starts from a clean tree; this lesson's check still finds the change in that stash.
+ Then read `git diff` and commit the change, new files included, with a message that says what it does. `git status` then reads `nothing to commit, working tree clean`.
## Check
@@ -106,7 +105,7 @@ You are done when all of these are true:
In the other terminal, run `npm run check -- b-2` in your practice copy.
-If `.practice/b-2-before.txt` lists files, either the tree wasn't clean when Your turn started (the example's files there mean step 9 was skipped), or Claude wrote a file before you approved: check that the status bar read `⏸ plan mode on`, and look in the session for a command Claude ran that wrote a file. Set the changes aside with `git stash push --include-untracked`, then repeat Your turn from step 2. If a file in `.practice/b-2-after.txt` is missing from `.practice/b-2-plan.txt`, check that the plan file writes it the way `git status` does, then compare the plan you approved with what Claude changed. If the unknown-key item fails, compare what Claude changed with the ticket's first request, and tell Claude what is missing. If a broken link no longer fails the tool, the plan you approved carried the ticket's last request. A build that passes with broken links hides the problem the tool exists to find, and the teammate's real trouble was the typo: once linkcheck catches it, `"ignore": ["vendor/"]` skips the links into `vendor/`. Ask Claude to undo that part, then save `.practice/b-2-after.txt` again. A flag or a config key that turns the failure off goes back too, though the check can't see one, because CI would only need to add it.
+If `.practice/b-2-before.txt` lists files, the tree wasn't clean when Your turn started (commit the example, Worked example step 9), or Claude wrote a file before you approved: start again from a clean tree, in plan mode, at Your turn step 2. If a file in `.practice/b-2-after.txt` is missing from `.practice/b-2-plan.txt`, compare the plan you approved with what Claude changed, and write each path in the plan file the way `git status` does. If the unknown-key item fails, compare what Claude changed with the ticket's first request, and tell Claude what is missing. If a broken link no longer fails the tool, the plan you approved carried the ticket's last request: a build that passes with broken links hides the problem the tool exists to find, and once linkcheck catches the typo, `"ignore": ["vendor/"]` skips the vendor links. Ask Claude to undo that part, save `.practice/b-2-after.txt` again and commit.
## Watch out
@@ -120,6 +119,6 @@ If `.practice/b-2-before.txt` lists files, either the tree wasn't clean when You
---
-<sub>Sources: [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Commands](https://code.claude.com/docs/en/commands) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Claude Code CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) · [git diff](https://git-scm.com/docs/git-diff) · [git status](https://git-scm.com/docs/git-status) · [git add](https://git-scm.com/docs/git-add) · [git stash](https://git-scm.com/docs/git-stash)</sub>
+<sub>Sources: [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Commands](https://code.claude.com/docs/en/commands) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Claude Code CHANGELOG](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) · [git status](https://git-scm.com/docs/git-status) · [git add](https://git-scm.com/docs/git-add) · [git commit](https://git-scm.com/docs/git-commit)</sub>
<sub>← [Install, sign in and look around](01-install-and-look-around.md) · [Beginner index](README.md) · [Your first change, from request to commit](03-first-change.md) → · Topic: [Permissions and safety](../topics/permissions-and-safety.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=b-2)</sub>
diff --git a/docs/beginner/03-first-change.md b/docs/beginner/03-first-change.md
index c20cf75..a5b88d4 100644
--- a/docs/beginner/03-first-change.md
+++ b/docs/beginner/03-first-change.md
@@ -1,6 +1,6 @@
# Your first change, from request to commit
-<sub>**Beginner** · Lesson 3 of 5 · about 20 minutes · Needs: [Permission modes and plan mode](02-permission-modes-and-plan-mode.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-19</sub>
+<sub>**Beginner** · Lesson 3 of 5 · about 20 minutes · Needs: [Permission modes and plan mode](02-permission-modes-and-plan-mode.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -8,16 +8,16 @@ By the end of this lesson you can take a change from request to commit, and revi
## You need
-- Your copy of the practice template, and Node.js LTS (a Codespace on your copy has it). Practice in the template copy, not in your own repository: Your turn reviews a patch planted there.
-- No uncommitted changes. If lesson 2's change is still there, set it aside with `git stash push --include-untracked -m b-2` ([git stash](https://git-scm.com/docs/git-stash)). Later lessons don't use it, and `git stash list` shows it.
+- Your copy of the practice template, and Node.js LTS (a Codespace on your copy has it).
+- No uncommitted changes: `git status` reads `nothing to commit, working tree clean`.
- A second terminal open in the same folder, for git.
- Usage: light.
## The idea
-Asking for a change and accepting whatever comes back is how sessions go wrong. Anthropic's [best practices](https://code.claude.com/docs/en/best-practices#explore-first-then-plan-then-code) recommend four phases: explore, plan, implement and commit.
+Asking for a change and accepting whatever comes back is how sessions go wrong. Anthropic's [best practices](https://code.claude.com/docs/en/best-practices#explore-first-then-plan-then-code) recommend four phases: explore, plan, implement and commit. Auto mode doesn't send ordinary source edits to its classifier ([lesson 2](02-permission-modes-and-plan-mode.md#the-idea), [How the classifier evaluates actions](https://code.claude.com/docs/en/permission-modes#how-the-classifier-evaluates-actions)), so whether the change is right is yours to judge, in two places: the plan, before Claude starts, and the diff, before anything is committed.
-A new session usually starts in auto mode, and as [lesson 2](02-permission-modes-and-plan-mode.md#the-idea) showed, auto mode approves ordinary source-file edits in your project without the classifier seeing them ([How the classifier evaluates actions](https://code.claude.com/docs/en/permission-modes#how-the-classifier-evaluates-actions)). For these source edits, no second model reviews Claude's changes: you do. Whether the change is right is yours to judge, in two places: the plan, before Claude starts, and the diff, before anything is committed.
+A precise request needs fewer corrections: it names the file, the case to handle, what must keep working, and the check to run, and asks Claude to show you the output ([Provide specific context](https://code.claude.com/docs/en/best-practices#provide-specific-context-in-your-prompts), [Give Claude a way to verify its work](https://code.claude.com/docs/en/best-practices#give-claude-a-way-to-verify-its-work)).
1. **Explore** in plan mode: Claude reads, and doesn't edit your files.
2. **Plan**, and approve it only when it changes the files you expect.
@@ -30,7 +30,7 @@ A new session usually starts in auto mode, and as [lesson 2](02-permission-modes
The practice app checks Markdown links, but it skips any link with a title, such as `[setup](setup.md "Setup guide")`. You'll fix that.
-1. Start `claude` in your practice copy. The status bar usually reads `⏵⏵ auto mode on`. Press `Shift+Tab` until it reads `⏸ plan mode on`: from auto, the presses go to Manual, Accept edits, then Plan ([Choose a permission mode](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)). Explore:
+1. Start `claude` in your practice copy and enter plan mode, as in lesson 2: the status bar reads `⏸ plan mode on`. Explore:
```text
How does this app find links in a Markdown file? Which kinds of links would it miss?
@@ -40,12 +40,12 @@ The practice app checks Markdown links, but it skips any link with a title, such
2. Plan:
```text
- Plan a change so links with a title, in double or single quotes, are checked too, like [setup](setup.md "Setup guide") and [faq](faq.md 'FAQ'). Add a test for each to test/links.test.js.
+ Plan a change so links with a title, in double or single quotes, are checked too, like [setup](setup.md "Setup guide") and [faq](faq.md 'FAQ'). Add a test for each to test/links.test.js, run the tests and show me the output.
```
Read the plan before you choose. It should change only `src/links.js` and `test/links.test.js`; a file it reads or names as needing no change is fine. If it also changes another file, such as `src/cli.js`, or adds one, send it back as in [lesson 2](02-permission-modes-and-plan-mode.md#worked-example): use the plan menu to ask Claude to keep the change to those two files.
- When the plan is right, choose **Yes, and use auto mode** (it reads **Yes, auto-accept edits** if auto mode isn't available to you). Claude edits and runs the tests without asking. If Claude Code does ask about an action, read it before you answer.
+ When the plan is right, choose **Yes, and use auto mode**, as in lesson 2. Claude edits and runs the tests without asking. If Claude starts on a file the plan didn't name, press `Esc` and tell it to keep to the plan: correct it as soon as it goes off track, rather than after it finishes ([Best practices](https://code.claude.com/docs/en/best-practices#course-correct-early-and-often)).
3. While Claude works, or once it's done, ask a side question:
```text
@@ -61,12 +61,12 @@ The practice app checks Markdown links, but it skips any link with a title, such
Claude Code collapses long command output to a short summary. Press `Ctrl+O` to open the transcript viewer, find the test summary near the end, and press `Ctrl+O` again to go back ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#general-controls)). It should report `fail 0`.
- This lesson's tests finish quickly. On a real project the tests, a build or a dev server can run for minutes: ask Claude to run the command in the background, or press `Ctrl+B` while it runs (in tmux, press it twice), and Claude can answer you while it runs. `/tasks` lists background work and stops a task you no longer need ([Background Bash commands](https://code.claude.com/docs/en/interactive-mode#background-bash-commands), [Tools reference](https://code.claude.com/docs/en/tools-reference#background-commands)).
+ On a real project, press `Ctrl+B` to move a long test run or dev server to the background (twice in tmux), and `/tasks` lists and stops it ([Background Bash commands](https://code.claude.com/docs/en/interactive-mode#background-bash-commands)).
5. Review the diff. Type `/diff` to see the changes in your working tree, Claude's edits included ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#review-changes-with-%2Fdiff)). One of two views opens:
- - A panel beside the conversation. Its list leaves test files and generated files out and counts them on a line of their own: click that line to see the test. The panel may already be open: read it there, because typing `/diff` closes it.
+ - A panel beside the conversation. Its list leaves test files and generated files out and counts them on a line of their own: click that line to see the test. The panel may already be open: read it there, because typing `/diff` closes it ([Diff panel](https://code.claude.com/docs/en/interactive-mode#diff-panel)).
- A dialog above the prompt. Select a file with the arrow keys, press `Enter` to read its diff, and press `Esc` to go back.
- Read each line, the test included, and ask: does the test cover both kinds of quotes, and does the code leave the title out of the target? To read the diff in the second terminal instead, run `git diff` ([git diff](https://git-scm.com/docs/git-diff)). It leaves out a file git doesn't track yet until you run `git add -N <file>` ([git add](https://git-scm.com/docs/git-add#Documentation/git-add.txt--N)). If it stops at a `:` prompt, git is showing it in a pager, usually `less`: press `q` to leave it ([git config](https://git-scm.com/docs/git-config#Documentation/git-config.txt-corepager), [less FAQ](https://www.greenwoodsoftware.com/less/faq.html#dashe)).
+ Read each line, the test included, and ask: does the test cover both kinds of quotes, and does the code leave the title out of the target? To read the diff in the second terminal instead, run `git diff` ([git diff](https://git-scm.com/docs/git-diff)). It leaves out a file git doesn't track yet until you run `git add -N <file>` ([git add](https://git-scm.com/docs/git-add#Documentation/git-add.txt--N)).
6. Correct what the review found, in plain words. For example, if the test covers only double quotes:
```text
@@ -84,12 +84,12 @@ The practice app checks Markdown links, but it skips any link with a title, such
## Your turn
-A teammate sent a patch, `practice/b-3/protocol-relative.patch`. Its description says what it changes, and its test passes. Decide whether it does only what it says, and fix it before it goes into a commit.
+Decide whether a teammate's patch does only what it says, and fix it before it's committed. The patch is `practice/b-3/protocol-relative.patch`: its description says what it changes, and its test passes.
1. Read the patch, its description first. In the second terminal, run `cat practice/b-3/protocol-relative.patch` (**Windows:** `Get-Content practice/b-3/protocol-relative.patch`), or open it in your editor. For each kind of link the checker handles, ask: does the new line skip it, and does the description say it should? The description's last sentence is a claim you can test.
2. Apply it, so its change is in your working tree: `git apply practice/b-3/protocol-relative.patch`. This changes the files and makes no commit ([git apply](https://git-scm.com/docs/git-apply)). `git status` lists `src/links.js` as modified and `test/external.test.js` under `Untracked files`. Run `git add -N test/external.test.js`, so `git diff` shows the new file too. `npm test` passes: passing tests don't make the patch right.
-3. Tell Claude what the patch gets wrong, in your own words, and ask for a fix and a test that would fail on the patch's version.
-4. Review the result as in the [Worked example](#worked-example)'s steps 4 and 5: read the test output yourself, then the whole diff, the tests included. In `/diff`, read the `Current` view: a turn view shows only Claude's own edits, so it leaves out the patch's lines ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#review-changes-with-%2Fdiff)).
+3. Write the request yourself, in your own words: name the file and the case the patch gets wrong, say what must keep working, ask for a test that would fail on the patch's version, and ask Claude to run the tests and show you the output.
+4. Review the result as in the [Worked example](#worked-example)'s steps 4 and 5: read the test output yourself, then the whole diff, the tests included. In `/diff`, read the `Current` view: a turn view shows only Claude's own edits, so it leaves out the patch's lines ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#review-changes-with-%2Fdiff)). If you started this session after applying the patch, the panel folds the patch's lines into one line at the bottom of its list: click it ([Diff panel](https://code.claude.com/docs/en/interactive-mode#diff-panel)).
5. Ask Claude to commit the fix, its test and the patch's test together. `git status` ends with `nothing to commit, working tree clean`.
## Check
@@ -104,18 +104,18 @@ You are done when all of these are true:
- [ ] Nothing is left uncommitted: `git status --porcelain` prints nothing.
- [ ] Self-check (not tested): you found the patch's flaw by reading it, and you read each diff, the tests included, before it was committed.
-In the second terminal, run `npm run check -- b-3` in your practice copy. The check writes a few Markdown files to a temporary folder and runs the app on them, and runs your tests once more with the patch's version of `isExternal`.
+In the second terminal, run `npm run check -- b-3` in your practice copy.
-If titled links are still skipped, or reported with the title in the target, the worked example isn't finished: ask Claude to leave the title out of the target, with a test for each kind of quotes. If the check says a link is still skipped, the patch's flaw is still there: compare its description with what its new line skips. If `//cdn.example.com/app.js` is reported as broken, the patch isn't applied: run the `git apply` in Your turn, step 2. If your tests still pass with the patch's version, none of them covers what the patch broke: ask Claude for one that fails on it. Once you commit, the check names the link the patch gets wrong. If your last commit has no test file, or only tests, ask Claude to amend it (`git commit --amend` ([git commit](https://git-scm.com/docs/git-commit))), or to combine it with the commit before, as long as you haven't pushed them. If the tests fail, read the first failure and ask Claude to fix the code, not the test. If `git status --porcelain` lists files, commit them or set them aside with `git stash push --include-untracked`.
+If titled links are still skipped, or reported with the title in the target, finish the Worked example: ask Claude to leave the title out of the target, with a test for each kind of quotes. If the check says a link is still skipped, or reports `//cdn.example.com/app.js` as broken, compare the patch's description with what its new line skips, and make sure you ran the `git apply` in Your turn step 2. If your tests still pass with the patch's version, none of them covers what the patch broke: ask Claude for one that fails on it. If your last commit has no test file, or only tests, ask Claude to amend it (`git commit --amend` ([git commit](https://git-scm.com/docs/git-commit))), or to combine it with the commit before, as long as you haven't pushed them. If the tests fail, read the first failure and ask Claude to fix the code, not the test. If `git status --porcelain` lists files, commit them.
## Go further
- [Common workflows](https://code.claude.com/docs/en/common-workflows): step-by-step guides for fixing bugs, refactoring and testing.
- [Give Claude a way to verify its work](https://code.claude.com/docs/en/best-practices#give-claude-a-way-to-verify-its-work): why a test beats a summary.
-- [Prompt library](https://code.claude.com/docs/en/prompt-library): copy-ready prompts, tagged by task.
+- [`/code-review`](https://code.claude.com/docs/en/commands): reviews your current diff for correctness bugs, a second check before you commit.
---
-<sub>Sources: [Best practices](https://code.claude.com/docs/en/best-practices) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [git add](https://git-scm.com/docs/git-add) · [git apply](https://git-scm.com/docs/git-apply) · [git config](https://git-scm.com/docs/git-config) · [less FAQ](https://www.greenwoodsoftware.com/less/faq.html) · [git stash](https://git-scm.com/docs/git-stash) · [git diff](https://git-scm.com/docs/git-diff) · [git status](https://git-scm.com/docs/git-status) · [git show](https://git-scm.com/docs/git-show) · [git commit](https://git-scm.com/docs/git-commit)</sub>
+<sub>Sources: [Best practices](https://code.claude.com/docs/en/best-practices) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Commands](https://code.claude.com/docs/en/commands) · [git add](https://git-scm.com/docs/git-add) · [git apply](https://git-scm.com/docs/git-apply) · [git diff](https://git-scm.com/docs/git-diff) · [git status](https://git-scm.com/docs/git-status) · [git show](https://git-scm.com/docs/git-show) · [git commit](https://git-scm.com/docs/git-commit)</sub>
<sub>← [Permission modes and plan mode](02-permission-modes-and-plan-mode.md) · [Beginner index](README.md) · [Keep a session on track](04-keep-a-session-on-track.md) → · Topic: [Permissions and safety](../topics/permissions-and-safety.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=b-3)</sub>
diff --git a/docs/beginner/04-keep-a-session-on-track.md b/docs/beginner/04-keep-a-session-on-track.md
index 05f509c..2f9d745 100644
--- a/docs/beginner/04-keep-a-session-on-track.md
+++ b/docs/beginner/04-keep-a-session-on-track.md
@@ -1,22 +1,22 @@
# Keep a session on track
-<sub>**Beginner** · Lesson 4 of 5 · about 25 minutes · Needs: [Your first change, from request to commit](03-first-change.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-19</sub>
+<sub>**Beginner** · Lesson 4 of 5 · about 25 minutes · Needs: [Your first change, from request to commit](03-first-change.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
-By the end of this lesson you can keep a session on track: back out of a change that went the wrong way, keep the context to what matters, and pick the right conversation up again later.
+By the end of this lesson you can keep a session on track: stop or rewind a change that went the wrong way, keep the context to what matters, and pick the right conversation up again later.
## You need
-- Your copy of the practice template with no uncommitted changes, and Node.js LTS (a Codespace on your copy has it). Your turn runs a script that only the practice copy has, so do this whole lesson there. It needs the copy's `.practice/` folder: if earlier lessons didn't make it, run `mkdir .practice`.
+- Your copy of the practice template with no uncommitted changes, Node.js LTS (a Codespace on your copy has it) and a `.practice/` folder in it: if earlier lessons didn't make one, run `mkdir .practice`.
- A second terminal in the same folder, for git.
- Usage: light.
## The idea
-Everything in a conversation, your prompts, Claude's replies and every file it read, sits in the session's context window. A dead end left there crowds out what you need next ([Explore the context window](https://code.claude.com/docs/en/context-window#when-your-context-fills-up)). And sessions usually start in auto mode, where Claude edits without asking you first ([Choose a permission mode](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in)), so you need a fast way back.
+Everything in a conversation, your prompts, Claude's replies and every file it read, sits in the session's context window. A dead end left there crowds out what you need next ([Explore the context window](https://code.claude.com/docs/en/context-window#when-your-context-fills-up)).
-Before each prompt that starts a turn, Claude Code takes a checkpoint, and it tracks the files Claude then changes with its file editing tools. `/rewind`, or `Esc` twice on an empty prompt, lists your prompts: pick one, then choose what you want back ([Checkpointing](https://code.claude.com/docs/en/checkpointing#rewind-and-summarize)).
+Press `Esc` once to stop Claude mid-action, as in lesson 1 ([Best practices](https://code.claude.com/docs/en/best-practices#course-correct-early-and-often)). Before each prompt that starts a turn, Claude Code takes a checkpoint, and it tracks the files Claude then changes with its file editing tools. `/rewind`, or `Esc` twice on an empty prompt, lists your prompts: pick one, then choose what you want back ([Checkpointing](https://code.claude.com/docs/en/checkpointing#rewind-and-summarize)).
| You want | Choose |
|---|---|
@@ -24,20 +24,20 @@ Before each prompt that starts a turn, Claude Code takes a checkpoint, and it tr
| Files and conversation back, to send a better prompt | **Restore code and conversation** |
| The files kept, and a long stretch of conversation shrunk | **Summarize from here** |
-For the whole conversation ([Commands](https://code.claude.com/docs/en/commands)): `/context` shows what fills the window, as a colored grid; `/compact` summarizes it when you keep going on the same task; `/clear` starts empty for a new task; `/branch` copies it so you can try another direction and keep the original; and `/resume` opens an earlier one.
+For the whole conversation ([Commands](https://code.claude.com/docs/en/commands)): `/context` shows what fills the window, as a colored grid; `/compact` summarizes it when you keep going on the same task; `/clear` starts empty for a new task; and `/resume` opens an earlier one. After two failed corrections on the same thing, `/clear` and start again with a better prompt ([Best practices](https://code.claude.com/docs/en/best-practices#avoid-common-failure-patterns)).
## Worked example
The job: tidy up `brokenLinks` in `src/check-links.js`. You'll try one approach, back out of it, and land the one you want.
-1. Start `claude` in your practice copy. In auto mode, Claude edits files and runs most commands without asking; if Claude Code does ask about something, read it and answer as in [lesson 2](02-permission-modes-and-plan-mode.md).
+1. Start `claude` in your practice copy.
2. Explore:
```text
- Explain how src/check-links.js finds broken links, and which files call brokenLinks.
+ Explain how src/check-links.js finds broken links, and which files in src/ and test/ call brokenLinks.
```
- Your wording will differ, but Claude should name `src/cli.js` and `test/links.test.js` as the callers. Every file it reads to answer goes into the context window.
+ Your wording will differ, but Claude should name `src/cli.js` and `test/links.test.js` as the callers. Every file it reads to answer goes into the context window: type `/context` to see what fills it.
3. Try an approach:
```text
@@ -45,20 +45,13 @@ The job: tidy up `brokenLinks` in `src/check-links.js`. You'll try one approach,
```
In the second terminal, `git status --short` ([git status](https://git-scm.com/docs/git-status)) lists the files Claude changed, `src/check-links.js`, `src/cli.js` and usually `test/links.test.js`, and `git diff` ([git diff](https://git-scm.com/docs/git-diff)) shows the change. Say you decide against it: for a short command-line run, reading files asynchronously buys nothing, and every caller now has to wait for the function.
-4. Put the files back. Type `/rewind`, or press `Esc` twice with an empty prompt. Pick the prompt from step 3 and choose **Restore code**. The files go back, and the conversation stays, so Claude still knows what it tried. In the second terminal, run `git status --short`. If it still lists files, Claude changed those files with a command: run `git restore src test` to discard this lesson's uncommitted async attempt, then check again ([Checkpointing](https://code.claude.com/docs/en/checkpointing#bash-command-changes-not-tracked), [git restore](https://git-scm.com/docs/git-restore)). Now `git status --short` prints nothing. If a diff panel is open beside the conversation, it may still show the edit: Claude Code refreshes the panel each time Claude edits a file or runs a shell command ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#diff-panel)), so trust git.
+4. Put the files and the conversation back, rather than asking Claude to undo it. Anthropic's [session management guide](https://claude.com/resources/articles/using-claude-code-session-management-and-1m-context) calls rewinding often the better correction: the attempt leaves the context, and you re-prompt with what you learned. Type `/rewind`, or press `Esc` twice with an empty prompt, pick the prompt from step 3 and choose **Restore code and conversation**. The files go back, the attempt leaves the conversation, and your step 3 prompt returns to the input box ([Checkpointing](https://code.claude.com/docs/en/checkpointing#rewind-and-summarize)). In the second terminal, `git status --short` prints nothing. If it lists files, Claude changed them in a way rewind doesn't track, usually with a command: run `git restore src test` ([git restore](https://git-scm.com/docs/git-restore)).
- If the menu offers only **Restore conversation**, the summarize options and **Never mind**, Claude changed the files with a command, which rewind can't undo: choose **Never mind**, press `Esc` to close the menu, and run `git restore src test` ([git restore](https://git-scm.com/docs/git-restore)) in the second terminal.
-5. Shrink the dead end. The whole async attempt is still in the conversation. Type `/context` and note the messages part of the grid. Open the rewind menu again and pick the same prompt. Highlight **Summarize from here** with the arrow keys, type this where the row reads **add context (optional)**, and press `Enter`:
+ If the menu offers only **Restore conversation**, the summarize options and **Never mind**, Claude changed the files in a way rewind doesn't track, usually with a command: choose **Restore conversation**, then run `git restore src test` in the second terminal.
+5. Edit the prompt in the input box into the approach you want, and send it:
```text
- we tried async and dropped it: every caller had to change
- ```
-
- Everything from that prompt on becomes a summary, marked **Summarized conversation**: Claude keeps the lesson in less space, and `/context` now shows a smaller messages part. Summarizing also puts the step 3 prompt back in the input box ([Checkpointing](https://code.claude.com/docs/en/checkpointing#rewind-and-summarize)): press `Esc` twice quickly to clear it.
-6. Ask for the approach you want, then commit it:
-
- ```text
- Keep brokenLinks synchronous. Instead, move the code that checks one file's links into its own function in src/check-links.js, and run the tests.
+ Don't make brokenLinks asynchronous: for a short command-line run it buys nothing. Keep it synchronous, and move the code that checks one file's links into its own function in src/check-links.js. Run the tests.
```
Read the diff in the second terminal, and run `npm run linkcheck -- samples` there: it still prints `guide.md:5: broken link to missing.md`, the sample's one broken link. Then:
@@ -68,24 +61,24 @@ The job: tidy up `brokenLinks` in `src/check-links.js`. You'll try one approach,
```
`git status` in the second terminal ends with `nothing to commit, working tree clean`.
-7. The job is done and the next one is unrelated, so clear rather than compact. Name the conversation you're leaving as you clear it ([Commands](https://code.claude.com/docs/en/commands)):
+6. The job is done and the next one is unrelated, so clear rather than compact. Name the conversation you're leaving as you clear it ([Commands](https://code.claude.com/docs/en/commands)):
```text
/clear check-links-refactor
```
The new conversation starts with empty context, and the old one is saved under that name. `/compact` is for the other case: the same task, in a conversation grown long.
-8. Type `/exit`. Later, open the refactor conversation again by its name ([Manage sessions](https://code.claude.com/docs/en/sessions#name-your-sessions)):
+7. Type `/exit`. Later, open the refactor conversation again by its name ([Manage sessions](https://code.claude.com/docs/en/sessions#name-your-sessions)):
```bash
claude --resume check-links-refactor
```
- It shows the refactor and its commit. `claude --continue` opens the most recent conversation in this folder instead, which after `/clear` can be the empty one.
+ It shows the refactor and its commit. `claude --continue` reopens the most recent session in this folder instead ([Manage sessions](https://code.claude.com/docs/en/sessions#resume-a-session)); the name takes you to this one. If Claude Code asks **Resume this conversation?**, choose by whether your next task still needs the saved conversation ([The "Resume this conversation?" dialog](https://code.claude.com/docs/en/sessions#resume-usage-limit-dialog)).
## Your turn
-A teammate offers a script that renames `findLinks` in `src/links.js` to `extractLinks`. Try it in a branch of the conversation, then back out. This time one of the changes is made by a command, to a file Claude hasn't edited in this conversation.
+Try a teammate's rename script, then undo all of it: another tool imports `findLinks`. The script renames `findLinks` in `src/links.js` to `extractLinks`. This time one of the changes is made by a command, to a file Claude hasn't edited in this conversation.
1. The conversation you resumed holds the whole refactor, and you're staying on the link checker, so compact rather than clear:
@@ -94,25 +87,17 @@ A teammate offers a script that renames `findLinks` in `src/links.js` to `extrac
```
Claude Code replaces the conversation so far with a summary that focuses on what you asked to keep ([Commands](https://code.claude.com/docs/en/commands)).
-2. Branch the conversation ([Manage sessions](https://code.claude.com/docs/en/sessions#branch-a-session)):
-
- ```text
- /branch try-rename
- ```
-
- You're now in a copy of the conversation, and the original, `check-links-refactor`, stays as it was.
-3. Ask:
+2. Ask:
```text
Run node practice/b-4/rename-export.mjs, which renames findLinks in src/links.js. Then update its callers with your file editing tool, not a shell command.
```
-4. In the second terminal, save what git sees: `git status --porcelain > .practice/b-4-before-rewind.txt`. It lists `src/links.js`, which the script changed, and the callers Claude updated, `src/check-links.js` and usually `test/links.test.js`.
-5. Say the rename is off: another tool imports `findLinks` by that name. Before you rewind, decide which of those files **Restore code** will put back. Then rewind the step 3 prompt with **Restore code**, and save what git sees: `git status --porcelain > .practice/b-4-after-rewind.txt`.
+3. In the second terminal, save what git sees: `git status --porcelain > .practice/b-4-before-rewind.txt`. It lists `src/links.js`, which the script changed, and the callers Claude updated, `src/check-links.js` and usually `test/links.test.js`.
+4. You're staying on this task, and Claude should remember what it tried, so this time use **Restore code**. Before you rewind, decide which of those files it will put back. Then rewind the step 2 prompt with **Restore code**, and save what git sees: `git status --porcelain > .practice/b-4-after-rewind.txt`.
- If the menu offers only **Restore conversation**, the summarize options and **Never mind**, Claude updated the callers with commands: choose **Never mind**, press `Esc`, run `git restore src test`, and repeat from step 3.
-6. Read that file, and run `npm run linkcheck -- samples`. Get `src/` back to your last commit so the link check runs again, and run it to see.
-7. Go back to the original conversation with `/resume check-links-refactor`.
+ If the menu offers only **Restore conversation**, the summarize options and **Never mind**, Claude updated the callers in a way rewind doesn't track, usually with commands: choose **Never mind**, press `Esc`, run `git restore src test`, and repeat from step 2.
+5. Read that file, and run `npm run linkcheck -- samples`. Get `src/` back to your last commit so the link check runs again, and run it to see.
## Check
@@ -122,24 +107,23 @@ You are done when all of these are true:
- [ ] `.practice/b-4-before-rewind.txt` lists `src/links.js` and `src/check-links.js`: `cat .practice/b-4-before-rewind.txt`.
- [ ] `.practice/b-4-after-rewind.txt` lists `src/links.js` and no other file in `src/` or `test/`: `cat .practice/b-4-after-rewind.txt`.
- [ ] `src/` and `test/` have no uncommitted changes, your last commit's `src/links.js` still exports `findLinks`, and `npm run linkcheck -- samples` runs without an error.
-- [ ] Self-check (not tested): the conversation `/resume check-links-refactor` opened doesn't mention the rename.
Run `npm run check -- b-4` in your practice copy.
-If no commit changes `src/check-links.js`, finish Worked example step 6 and commit. If `.practice/b-4-before-rewind.txt` is missing a path, save it again once the script has run and Claude has updated the callers. If `.practice/b-4-after-rewind.txt` still lists `src/check-links.js` or `test/links.test.js`, rewind the step 3 prompt with **Restore code** and save again; if they stay changed, Claude changed them with a command: run `git restore src test`, then repeat Your turn from step 3. If it doesn't list `src/links.js`, and you didn't restore that file yourself, Claude had already edited `src/links.js` in this conversation, and rewind also puts back a command's change to a file Claude edited: run `git restore src test`, type `/exit`, start `claude` for a new session, and repeat Your turn from step 3. If the link check stops with an error about `findLinks`, or the check says your last commit no longer exports it, `src/links.js` still holds the script's rename: run `git restore src/links.js`, or, once the rename is in a commit, undo that commit with `git revert <sha>` ([git revert](https://git-scm.com/docs/git-revert)), with the sha `git log` lists for it.
+If no commit changes `src/check-links.js`, finish Worked example step 5 and commit. If `.practice/b-4-before-rewind.txt` is missing a path, save it again once the script has run and Claude has updated the callers. If `.practice/b-4-after-rewind.txt` lists the wrong files, read the check's message: it says whether a command made an edit, or Claude had already edited `src/links.js` in this conversation, and from which step to repeat Your turn. If the link check stops with an error about `findLinks`, or the check says your last commit no longer exports it, `src/links.js` still holds the script's rename: run `git restore src/links.js`, or, once the rename is in a commit, undo that commit with `git revert <sha>` ([git revert](https://git-scm.com/docs/git-revert)), with the sha `git log` lists for it.
## Watch out
-- Rewind puts back the files Claude edited with its file editing tools. A command's change to any other file, such as `rm`, `mv` or a script, stays ([Checkpointing](https://code.claude.com/docs/en/checkpointing#bash-command-changes-not-tracked)), while a change to a file Claude already edited in the session can be put back with it ([Checkpointing](https://code.claude.com/docs/en/checkpointing#external-changes-not-tracked)). Commit your work so git can bring it back.
+- Rewind puts back the files Claude edited with its file editing tools. A command's change to any other file, such as `rm`, `mv` or a script, stays, while a change to a file Claude already edited in the session can be put back with it ([Checkpointing](https://code.claude.com/docs/en/checkpointing#bash-command-changes-not-tracked)). Commit your work so git can bring it back.
## Go further
- [Explore the context window](https://code.claude.com/docs/en/context-window): an interactive view of what fills a session.
-- [Session management and 1M context](https://claude.com/blog/using-claude-code-session-management-and-1m-context): when to compact, clear or start fresh.
-- [Manage sessions](https://code.claude.com/docs/en/sessions): naming, the session picker and branching in full.
+- [Branch a session](https://code.claude.com/docs/en/sessions#branch-a-session): try another direction with `/branch` and keep the original conversation.
+- [Summarize from here](https://code.claude.com/docs/en/checkpointing#guide-a-summary): shrink a long stretch of conversation, keep the files, and say what the summary should keep.
---
-<sub>Sources: [Commands](https://code.claude.com/docs/en/commands) · [Explore the context window](https://code.claude.com/docs/en/context-window) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Checkpointing](https://code.claude.com/docs/en/checkpointing) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Manage sessions](https://code.claude.com/docs/en/sessions) · [git status](https://git-scm.com/docs/git-status) · [git diff](https://git-scm.com/docs/git-diff) · [git restore](https://git-scm.com/docs/git-restore) · [git log](https://git-scm.com/docs/git-log) · [git revert](https://git-scm.com/docs/git-revert)</sub>
+<sub>Sources: [Commands](https://code.claude.com/docs/en/commands) · [Explore the context window](https://code.claude.com/docs/en/context-window) · [Checkpointing](https://code.claude.com/docs/en/checkpointing) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Manage sessions](https://code.claude.com/docs/en/sessions) · [Using Claude Code: session management and 1M context](https://claude.com/resources/articles/using-claude-code-session-management-and-1m-context) · [git status](https://git-scm.com/docs/git-status) · [git diff](https://git-scm.com/docs/git-diff) · [git restore](https://git-scm.com/docs/git-restore) · [git log](https://git-scm.com/docs/git-log) · [git revert](https://git-scm.com/docs/git-revert)</sub>
<sub>← [Your first change, from request to commit](03-first-change.md) · [Beginner index](README.md) · [Project memory with CLAUDE.md](05-project-memory.md) → · Topic: [Memory and context](../topics/memory-and-context.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=b-4)</sub>
diff --git a/docs/beginner/05-project-memory.md b/docs/beginner/05-project-memory.md
index 0a43d38..3034b14 100644
--- a/docs/beginner/05-project-memory.md
+++ b/docs/beginner/05-project-memory.md
@@ -1,14 +1,14 @@
# Project memory with CLAUDE.md
-<sub>**Beginner** · Lesson 5 of 5 · about 20 minutes · Needs: [Your first change, from request to commit](03-first-change.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-19</sub>
+<sub>**Beginner** · Lesson 5 of 5 · about 20 minutes · Needs: [Your first change, from request to commit](03-first-change.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
-By the end of this lesson you can create a project CLAUDE.md, show that a new session follows it, and decide which memory file each instruction belongs in.
+By the end of this lesson you can write a short, true project CLAUDE.md, show that a new session follows it, and decide which memory file each instruction belongs in.
## You need
-- Your copy of the practice template with no uncommitted changes, and Node.js LTS (a Codespace on your copy has it). Do this lesson in the practice copy: Your turn's notes are about its code. The lesson ends by giving one of your own repositories the same start.
+- Your copy of the practice template with no uncommitted changes, and Node.js LTS (a Codespace on your copy has it). The lesson ends by giving one of your own repositories the same start.
- Usage: light.
## The idea
@@ -22,9 +22,9 @@ Each session starts with a fresh context window. Your instruction files load at
| `./CLAUDE.local.md` | Your notes for this project | Only you: add it to `.gitignore` |
| Auto memory | Notes Claude saves, such as what you ask it to remember | Only you, on this machine |
-- `/init` writes a first `CLAUDE.md` from the code. Keep it brief and specific ([Write effective instructions](https://code.claude.com/docs/en/memory#write-effective-instructions)).
+- `/init` writes a first `CLAUDE.md` from the code. Then cut it: for each line, ask whether removing it would make Claude make mistakes ([Write an effective CLAUDE.md](https://code.claude.com/docs/en/best-practices#write-an-effective-claude-md)).
+- Add a line when Claude makes the same mistake a second time, or you type the same correction again ([When to add to CLAUDE.md](https://code.claude.com/docs/en/memory#when-to-add-to-claude-md)).
- Say "add this to CLAUDE.md" to put an instruction in the file; "remember" puts it in auto memory ([View and edit with `/memory`](https://code.claude.com/docs/en/memory#view-and-edit-with-%2Fmemory)).
-- An edit to CLAUDE.md mid-session waits for the next `/clear`, `/compact` or new session ([Editing CLAUDE.md mid-session](https://code.claude.com/docs/en/prompt-caching#editing-claude-md-mid-session)).
- These files are context, not configuration Claude must obey: a rule that must never be broken needs a [hook](https://code.claude.com/docs/en/hooks-guide), which the [Intermediate level](../intermediate/README.md) teaches.
## Worked example
@@ -35,9 +35,9 @@ Each session starts with a fresh context window. Your instruction files load at
/init
```
- Claude reads the code and writes a `CLAUDE.md` with the commands and conventions it found. If Claude Code asks before it writes the file, allow it. In a second terminal, read the file with `cat CLAUDE.md`.
-2. Edit it as you would before your team sees it. Open `CLAUDE.md` in your editor, or type `/memory` and choose **Project instructions**, the `./CLAUDE.md` in this folder. `/memory` also lists your user file in `~/.claude/`, which applies to all your projects, and has a toggle and a folder for auto memory ([View and edit with `/memory`](https://code.claude.com/docs/en/memory#view-and-edit-with-%2Fmemory)). A terminal editor such as Vim takes over the terminal until you save and quit.
- - In the practice copy, `/init` may also describe the course, and even this lesson: `checks/`, `learn/`, `capstone/` and `.github/`. Delete those parts, the `npm run check`, `npm run learn` and `npm run test:checks` lines, and any rule that says to keep your work off `main`: that rule is for the template repository, not your copy.
+ Claude reads the code and writes a `CLAUDE.md` with the commands and conventions it found. In a second terminal, read the file with `cat CLAUDE.md`.
+2. Edit it as you would before your team sees it. Open `CLAUDE.md` in your editor, or type `/memory` and select the project's `./CLAUDE.md` ([View and edit with `/memory`](https://code.claude.com/docs/en/memory#view-and-edit-with-%2Fmemory)).
+ - Cut what Claude can learn by reading the code, such as a tour of each file, and what describes the course rather than linkcheck: `checks/`, `learn/`, `capstone/`, `.github/`, the `npm run check`, `npm run learn` and `npm run test:checks` lines, and any rule to keep your work off `main` (that rule is for the template repository).
- Compare each command that's left with the `scripts` in `package.json`. Keep `npm test`, which the [capstone](capstone.md) checks for.
- Add a convention that shows up in files. Put it under a `## Conventions` heading, and add that heading at the end of the file if `/init` didn't write one:
@@ -60,7 +60,6 @@ Each session starts with a fresh context window. Your instruction files load at
Add src/stats.js with a function countLinks(markdown) that returns how many links findLinks finds. Add a test in test/stats.test.js, run the tests and commit.
```
- A new session normally starts in auto mode, so Claude may finish without asking you anything; if Claude Code asks, read what it wants to do before you answer ([Which mode a session starts in](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in)).
6. In the second terminal, look at the first line of the new file and confirm nothing is left over:
```bash
@@ -74,7 +73,7 @@ Each session starts with a fresh context window. Your instruction files load at
## Your turn
-These are four things you kept telling Claude during a week on linkcheck. Three of them belong in three different places, and one is wrong: fix it or leave it out.
+Sort four notes so each reaches only the people it's for, and no false one is committed. They are things you kept telling Claude during a week on linkcheck. Three of them belong in three different places, and one is wrong: fix it or leave it out.
```markdown
1. CLI errors go to stderr and start with `linkcheck:`.
@@ -88,7 +87,7 @@ Decide where each line goes before you write anything:
1. For each line, choose the project's `CLAUDE.md`, a `CLAUDE.local.md`, your user file, or nowhere. A line that goes in a committed file must be true: compare it with `package.json` and `src/cli.js`, because every session, and every teammate's, will read it.
2. Tell Claude in a session what goes in the project's file: `Add this to CLAUDE.md:` and the line. Edit the file yourself if you prefer.
3. Put what is yours alone for this project in a `CLAUDE.local.md` at the project root, and add the line `CLAUDE.local.md` to `.gitignore`.
-4. A habit you want in every project goes in your user file: `/memory`, then **User instructions**. That file reaches every session you start, in every project, so this step is up to you.
+4. A habit you want in every project goes in your user file, `~/.claude/CLAUDE.md`, which `/memory` lists too. That file reaches every session you start, in every project, so this step is up to you.
5. Commit `CLAUDE.md` and `.gitignore`. `git status` should be clean, since git now ignores `CLAUDE.local.md`.
Afterwards, give one of your own repositories the same start: `/init`, compare each command it wrote with the code, then commit `CLAUDE.md` there. [Intermediate lesson 2](../intermediate/02-organize-memory.md) starts from that file. If the repository has an `AGENTS.md`, put `@AGENTS.md` on the first line of `CLAUDE.md`: by default, once a `CLAUDE.md` exists, Claude reads it instead of `AGENTS.md` ([AGENTS.md](https://code.claude.com/docs/en/memory#agents-md)).
@@ -105,16 +104,16 @@ You are done when all of these are true:
Run `npm run check -- b-5` in your practice copy.
-If CLAUDE.md isn't committed, run `git add CLAUDE.md` and commit it. If a new file doesn't start with the rule, start a new session and run `/context all`. When `CLAUDE.md` is missing under **Memory files**, the session can't see it: start `claude` in the folder that holds `CLAUDE.md`. When it is listed, Claude read the rule but didn't follow it. Either way, ask the session for a different new file, such as `src/summary.js` with a test, and to commit it: the check looks for a commit that adds new files to `src/`, so fixing the old file in place won't pass. If the check names an `npm run` script, it quotes the line: that script isn't in `package.json`, so fix or delete the line, even one that warns against the command, and commit CLAUDE.md. If the `.gitignore` item fails, add the line `CLAUDE.local.md` to `.gitignore` and commit it; a rule only in your global git excludes file doesn't count. If `CLAUDE.local.md` was committed, run `git rm --cached CLAUDE.local.md` ([git rm](https://git-scm.com/docs/git-rm)) and commit.
+If CLAUDE.md isn't committed, run `git add CLAUDE.md` and commit it. If a new file doesn't start with the rule, start a new session in the folder that holds `CLAUDE.md`, check `/context all` lists it, and ask for a different new file in `src/`, such as `src/summary.js` with a test, and to commit it. If the check names an `npm run` script, that script isn't in `package.json`: fix or delete the line it quotes, and commit CLAUDE.md. If the `.gitignore` item fails, add the line `CLAUDE.local.md` to `.gitignore` and commit it, or, if `CLAUDE.local.md` was committed, run `git rm --cached CLAUDE.local.md` ([git rm](https://git-scm.com/docs/git-rm)) and commit.
## Go further
- [Write an effective CLAUDE.md](https://code.claude.com/docs/en/best-practices#write-an-effective-claude-md): what to put in it and what to leave out.
-- [Using CLAUDE.md files](https://claude.com/blog/using-claude-md-files): Anthropic's guide, with examples.
+- [Write effective instructions](https://code.claude.com/docs/en/memory#write-effective-instructions): size, structure and consistency, with a target length.
- [Auto memory](https://code.claude.com/docs/en/memory#auto-memory): what Claude saves for itself, where, and how to turn it off.
---
-<sub>Sources: [How Claude remembers your project](https://code.claude.com/docs/en/memory) · [How Claude Code uses prompt caching](https://code.claude.com/docs/en/prompt-caching) · [Commands](https://code.claude.com/docs/en/commands) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Automate actions with hooks](https://code.claude.com/docs/en/hooks-guide) · [git status](https://git-scm.com/docs/git-status) · [git show](https://git-scm.com/docs/git-show) · [git log](https://git-scm.com/docs/git-log) · [git check-ignore](https://git-scm.com/docs/git-check-ignore) · [git rm](https://git-scm.com/docs/git-rm)</sub>
+<sub>Sources: [How Claude remembers your project](https://code.claude.com/docs/en/memory) · [Commands](https://code.claude.com/docs/en/commands) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Automate actions with hooks](https://code.claude.com/docs/en/hooks-guide) · [git status](https://git-scm.com/docs/git-status) · [git show](https://git-scm.com/docs/git-show) · [git log](https://git-scm.com/docs/git-log) · [git check-ignore](https://git-scm.com/docs/git-check-ignore) · [git rm](https://git-scm.com/docs/git-rm)</sub>
<sub>← [Keep a session on track](04-keep-a-session-on-track.md) · [Beginner index](README.md) · [Beginner capstone](capstone.md) → · Topic: [Memory and context](../topics/memory-and-context.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=b-5)</sub>
diff --git a/docs/beginner/README.md b/docs/beginner/README.md
index 52d807e..3d8ee1a 100644
--- a/docs/beginner/README.md
+++ b/docs/beginner/README.md
@@ -2,7 +2,7 @@
<sub>**Beginner** · about 2½ hours · Verified against Claude Code v2.1.292 (stable) on 2026-10-19</sub>
-One session, one change. You install Claude Code and check what it tells you against the code, decide what it may do without asking, take a change from request to commit and catch what it gets wrong, back out of a wrong turn and keep a long session on track, and give it a project memory.
+One session, one change, done well. You start Claude Code safely and check what it tells you against the code, decide when it asks and when to plan first, take a change from request to commit and catch what it gets wrong, stop or rewind a wrong turn and keep the conversation focused, and give the project a memory that new sessions follow.
## You're ready for this level if you can
@@ -14,11 +14,11 @@ New to the terminal? The official [Terminal guide for new users](https://code.cl
## Practice
-Before lesson 1, make your own copy of the [practice template](https://github.com/wesammustafa/claude-code-practice): select **Use this template**, then **Create a new repository**, and clone your copy. Every Beginner exercise and the capstone run there.
+Before lesson 1, make your own copy of the [practice template](https://github.com/wesammustafa/claude-code-practice): select **Use this template**, then **Create a new repository**, and clone your copy. Every Beginner lesson and the capstone run there, and lesson 5 ends in one of your own repositories.
To go step by step, run `npm run learn` in your copy and use Claude Code in a second terminal beside it. The app takes you through every core lesson and the capstone, one step at a time, and checks your work as you go. Each page below teaches the same lesson on its own.
-Each core lesson and the capstone end with a check you run in your copy as `npm run check -- <id>`, where the id is `b-1` to `b-5` for the lessons and `b-capstone` for the capstone. The Electives end with a checklist you confirm yourself. The checks need Node.js LTS, which a Codespace on your copy has preinstalled. Every Beginner exercise runs in the template copy, because each one works with files planted there; lesson 5 ends by giving one of your own repositories a `CLAUDE.md`, and the [Intermediate level](../intermediate/README.md) practices in your own repository.
+Each core lesson and the capstone end with a check you run in your copy as `npm run check -- <id>`, where the id is `b-1` to `b-5` for the lessons and `b-capstone` for the capstone. The checks need Node.js LTS, which a Codespace on your copy has preinstalled. Every Beginner exercise runs in your template copy, because each one works with files planted there; only lesson 5's last step gives one of your own repositories a `CLAUDE.md`, which [Intermediate lesson 2](../intermediate/02-organize-memory.md) starts from.
On native Windows, if PowerShell refuses to run `npm` with `running scripts is disabled on this system` ([Troubleshoot installation](https://code.claude.com/docs/en/troubleshoot-install#running-scripts-is-disabled-on-this-system)), follow the Windows note in [lesson 1](01-install-and-look-around.md#you-need).
@@ -40,15 +40,15 @@ Each lesson takes 20 to 25 minutes, and the capstone 30 to 60.
This list is the Beginner Exit ([Glossary](../reference/glossary.md)), which the capstone puts together in one task.
-- [ ] Install Claude Code, sign in, start it in your repository, and tell which version, model and account you're on.
-- [ ] Choose and switch permission modes, and approve a plan in plan mode before any change.
+- [ ] Install Claude Code, start it safely in a repository, tell which model and account a session uses, and check its answers against the code.
+- [ ] Choose a permission mode for a task, decide when a change needs a plan, and approve only a plan you would merge.
- [ ] Take one change from request to commit: explore, plan, implement, test, review the diff, correct, commit.
-- [ ] Keep a session on track with context, clear, compact, rewind and resume.
-- [ ] Create a project CLAUDE.md and show that a new session follows it.
+- [ ] Stop or rewind a wrong turn, and choose between clear, compact and resume.
+- [ ] Create a short, true project CLAUDE.md and show that a new session follows it.
## Electives
-Optional lessons beside the core path:
+Optional lessons beside the core path, each ending with a checklist you confirm yourself:
- [IDE extensions](electives/ide-extensions.md)
- [Screenshots and images](electives/screenshots-and-images.md)
diff --git a/docs/beginner/capstone.md b/docs/beginner/capstone.md
index b66635e..c113356 100644
--- a/docs/beginner/capstone.md
+++ b/docs/beginner/capstone.md
@@ -1,12 +1,12 @@
# Beginner capstone: fix a reported bug, from plan to commit
-<sub>**Beginner** · Capstone · 30 to 60 minutes · Needs: the five [Beginner lessons](README.md), or their skills · Verified against Claude Code v2.1.292 (stable) on 2026-10-19</sub>
+<sub>**Beginner** · Capstone · 30 to 60 minutes · Needs: the five [Beginner lessons](README.md), or their skills · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
This task puts the whole Beginner level together. Unlike the lessons, it has no worked example: the steps say what to do, and you choose the prompts and make the calls. The [Beginner Exit](README.md#by-the-end-of-this-level-you-can) is the list of what you can do by the end of this level. The check reads the files and the commit this task leaves behind, and you tick the rest of the Exit yourself under [What the check can't see](#what-the-check-cant-see). When both are done, you've shown the Beginner Exit, whether you took the lessons or not.
## You need
-- Your copy of the practice template, with no uncommitted changes, and Node.js LTS (a Codespace on your copy has it). If `git status --porcelain` ([git status](https://git-scm.com/docs/git-status)) lists files, commit them or set them aside with `git stash push --include-untracked` ([git stash](https://git-scm.com/docs/git-stash)). The capstone runs in the template only.
+- Your copy of the practice template, with no uncommitted changes, and Node.js LTS (a Codespace on your copy has it). If `git status --porcelain` ([git status](https://git-scm.com/docs/git-status)) lists files, commit them. The capstone runs in the template only.
- If you skipped the lessons: create the `.practice/` folder in your copy (`mkdir -p .practice`; **Windows:** `New-Item -ItemType Directory -Force .practice`). The template already tells git to ignore it.
- A committed `CLAUDE.md` in your copy that names the test command, `npm test`: `git show HEAD:CLAUDE.md` shows it. Lesson 5 gives you one; if yours doesn't name `npm test`, add it.
- If you skipped lesson 5: start `claude` in your copy and run `/init`. In the new `CLAUDE.md`, delete what it says about the course's own files (`checks/`, `learn/`, `capstone/` and `.github/`) and about `npm run check`, `npm run learn` and `npm run test:checks`, including any rule to keep your work off `main`: that rule is for the template repository, not your copy. Make sure the file names `npm test`, then end that session with `/exit`, so the task starts in a new one.
@@ -19,21 +19,20 @@ This task puts the whole Beginner level together. Unlike the lessons, it has no
## The task
-A teammate filed the bug report in `capstone/beginner-bug.md` in your practice copy: when `linkcheck.json` lists a folder that doesn't exist, the tool says every link resolves and exits with code 0. Read it first: its "What should happen" section is what done means.
-
-Reproduce the bug before you fix it. In your own terminal, make a new folder outside your practice copy and save `{ "files": ["docs"] }` in it as `linkcheck.json`. Then run `npm run linkcheck -- <that folder>` in your copy: until the bug is fixed, it prints `All relative links resolve.` Don't put a `linkcheck.json` in your copy, because the check counts it as a change. **Windows:** save the file with `'{ "files": ["docs"] }' | Set-Content <that folder>\linkcheck.json`, not `>`. In Windows PowerShell 5.1, `>` writes UTF-16 ([about_Character_Encoding](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-5.1)), which the tool rejects as invalid JSON with exit code 2, even before the fix.
+A missing folder in `linkcheck.json` passes silently: make linkcheck fail on it, test first. A teammate filed the bug report in `capstone/beginner-bug.md` in your practice copy: the tool says every link resolves and exits with code 0. Read it first: its "What should happen" section is what done means.
Fix it the way the Beginner lessons taught:
-1. Start a new session in your copy. It usually starts in auto mode. Here you want to approve the plan before any file changes, so switch to plan mode before your first prompt: press `Shift+Tab` until the status bar shows `⏸ plan mode on`, or start the prompt with `/plan` ([Permission modes](https://code.claude.com/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode)).
-2. Have Claude read the bug report and plan the fix. Don't name the files to change: let Claude find them. Ask for a plan that adds the test first and runs it before changing the code, so you see it fail ([Best practices](https://code.claude.com/docs/en/best-practices#provide-specific-context-in-your-prompts): "write a failing test that reproduces the issue, then fix it").
-3. Review the plan before you approve it. Open the files it names and check that the code it describes is there, as you checked Claude's answer in [lesson 1](01-install-and-look-around.md#your-turn). The plan should add a test of what the bug report's "What should happen" asks for, run it and see it fail before any source file changes, and change only the files the bug needs. If it falls short, use the plan menu to tell Claude what to change, as in [lesson 2](02-permission-modes-and-plan-mode.md#worked-example) ([Permission modes](https://code.claude.com/docs/en/permission-modes#review-and-approve-a-plan)).
-4. While the final plan is on screen, in your own terminal, save `git status --porcelain` to `.practice/capstone-before.txt`. Save the files the plan will change, every test file included, to `.practice/capstone-plan.txt`: one path per line, relative to the repository root, with forward slashes, such as `src/cli.js`.
-5. Approve with **Yes, and use auto mode** (it reads **Yes, auto-accept edits** where auto mode isn't available): you've approved what Claude will do, so it can work without a prompt for each edit. If Claude Code asks before an action anyway, read what it will run before you answer. Watch the new test fail, then pass after the fix. Claude may write a test or run the tests with a shell command, so read the test output itself, not only Claude's summary: press `Ctrl+O`, as in [lesson 3](03-first-change.md#worked-example), and `Esc` to go back ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#transcript-viewer)).
-6. Review the whole diff, the tests included, against the bug report, as in [lesson 3](03-first-change.md#worked-example). Does the error name the missing folder? Does the tool exit with code 2? Does the test check the case the report describes? The diff panel's list leaves test files out until you click the line that counts them ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#diff-panel)), and a change Claude made with a shell command shows only in the `Current` view, not in the view of the turn that made it ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#review-changes-with-%2Fdiff)). `git diff` ([git diff](https://git-scm.com/docs/git-diff)) leaves out a new file until you run `git add -N <file>` ([git add](https://git-scm.com/docs/git-add#Documentation/git-add.txt--N)). Ask Claude to correct anything that falls short, inside the files the plan names, and make sure `npm test` passes.
-7. Commit the fix and its test together, then save the commit with `git rev-parse HEAD > .practice/capstone-commit.txt` ([git rev-parse](https://git-scm.com/docs/git-rev-parse)). The check reads only that commit, so if you change it later, save it again.
+1. Reproduce the bug before you fix it. In your own terminal, make a new folder outside your practice copy and save `{ "files": ["docs"] }` in it as `linkcheck.json`. Then run `npm run linkcheck -- <that folder>` in your copy: until the bug is fixed, it prints `All relative links resolve.` Don't put a `linkcheck.json` in your copy, because the check counts it as a change. **Windows:** save the file with `'{ "files": ["docs"] }' | Set-Content <that folder>\linkcheck.json`, not `>`. In Windows PowerShell 5.1, `>` writes UTF-16 ([about_Character_Encoding](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-5.1)), which the tool rejects as invalid JSON with exit code 2, even before the fix.
+2. Start a new session in your copy. It usually starts in auto mode. Here you want to approve the plan before any file changes, so switch to plan mode before your first prompt: press `Shift+Tab` until the status bar shows `⏸ plan mode on`, or start the prompt with `/plan` ([Permission modes](https://code.claude.com/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode)).
+3. Have Claude read the bug report and plan the fix. Don't name the files to change: let Claude find them. Ask for a plan that adds the test first and runs it before changing the code, so you see it fail ([Best practices](https://code.claude.com/docs/en/best-practices#provide-specific-context-in-your-prompts): "write a failing test that reproduces the issue, then fix it").
+4. Review the plan before you approve it. Open the files it names and check that the code it describes is there, as you checked Claude's answer in [lesson 1](01-install-and-look-around.md#your-turn). The plan should add a test of what the bug report's "What should happen" asks for, run it and see it fail before any source file changes, and change only the files the bug needs. If it falls short, use the plan menu to tell Claude what to change, as in [lesson 2](02-permission-modes-and-plan-mode.md#worked-example) ([Permission modes](https://code.claude.com/docs/en/permission-modes#review-and-approve-a-plan)).
+5. While the final plan is on screen, in your own terminal, save `git status --porcelain` to `.practice/capstone-before.txt`. Save the files the plan will change, every test file included, to `.practice/capstone-plan.txt`: one path per line, relative to the repository root, with forward slashes, such as `src/cli.js`.
+6. Approve with **Yes, and use auto mode**, as in [lesson 2](02-permission-modes-and-plan-mode.md#worked-example): you've approved what Claude will do, so it can work without a prompt for each edit. Watch the new test fail, then pass after the fix. Claude may write a test or run the tests with a shell command, so read the test output itself, not only Claude's summary: press `Ctrl+O`, as in [lesson 3](03-first-change.md#worked-example), and `Ctrl+O` again to go back ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#general-controls)).
+7. Review the whole diff, the tests included, against the bug report, as in [lesson 3](03-first-change.md#worked-example). If the diff panel is open beside the conversation, its list skips test files and generated files and counts them on one line: click that count line to see the test ([Diff panel](https://code.claude.com/docs/en/interactive-mode#diff-panel)). Does the error name the missing folder? Does the tool exit with code 2? Does the test check the case the report describes? `git diff` ([git diff](https://git-scm.com/docs/git-diff)) leaves out a new file until you run `git add -N <file>` ([git add](https://git-scm.com/docs/git-add#Documentation/git-add.txt--N)). Ask Claude to correct anything that falls short, inside the files the plan names, and make sure `npm test` passes.
+8. Commit the fix and its test together, then save the commit with `git rev-parse HEAD > .practice/capstone-commit.txt` ([git rev-parse](https://git-scm.com/docs/git-rev-parse)). The check reads only that commit, so if you change it later, save it again.
-Keep the session on track as you go. Check `/context` before you commit, and again whenever the session grows. For a quick question about what Claude has already read, use `/btw`, which keeps the question and its answer out of the conversation ([Interactive mode](https://code.claude.com/docs/en/interactive-mode#side-questions-with-%2Fbtw)). If Claude's fix heads the wrong way, open `/rewind` and choose **Restore code** to undo its edits and keep the conversation, then tell it what to do instead ([Checkpointing](https://code.claude.com/docs/en/checkpointing#rewind-and-summarize)). A shell command's changes to a file Claude hasn't edited in this session stay after a rewind, so check `git status` afterwards ([Checkpointing](https://code.claude.com/docs/en/checkpointing#external-changes-not-tracked)).
+If Claude's fix heads the wrong way, press `Esc`, or rewind and re-prompt as in [lesson 4](04-keep-a-session-on-track.md#worked-example), then check `git status`: rewind doesn't undo a shell command's change to a file Claude hadn't edited ([Checkpointing](https://code.claude.com/docs/en/checkpointing#bash-command-changes-not-tracked)).
## Check
@@ -53,10 +52,10 @@ Run `npm run check -- b-capstone` in your practice copy. Each item that fails pr
The check doesn't look at these parts of the Beginner Exit. Tick them yourself, honestly:
-- [ ] I can tell which version, model and account a session uses, with `/status` ([Commands](https://code.claude.com/docs/en/commands)).
-- [ ] I can say which permission mode a task needs: auto mode for work whose direction I trust, plan mode when I want to approve a plan before any change, and Manual mode when I want Claude Code to ask before most edits and commands.
+- [ ] I can tell which model and account a session uses, with `/status` ([Commands](https://code.claude.com/docs/en/commands)), and I check what Claude tells me against the code.
+- [ ] I can say which permission mode a task needs: auto mode for work whose direction I trust, plan mode when I want to approve a plan before any change, and Manual mode when I want Claude Code to ask before most edits and commands. I skip the plan when I could describe the diff in one sentence.
- [ ] I read the whole diff, the tests included, against the bug report before committing, and asked Claude to correct anything that fell short, or found nothing to correct.
-- [ ] I checked `/context` before committing, and I know when I'd use the other session commands: `/compact` to keep going on the same task in a long conversation, `/clear` to start a new task with empty context, and `/resume` to go back to an earlier conversation. If Claude's fix had gone the wrong way, I'd undo its edits with `/rewind` and check `git status` for anything a shell command changed.
+- [ ] I know how to get back on track: `Esc` to stop Claude mid-action, `/rewind` to put the code and the conversation back, and `git status` for anything a shell command changed. I know when I'd use the session commands: `/compact` to keep going on the same task in a long conversation, `/clear` to start a new task with empty context, and `/resume` to go back to an earlier conversation.
- [ ] I've seen a new session follow a rule from CLAUDE.md that I didn't repeat in the prompt. If you skipped lesson 5, its [Worked example](05-project-memory.md#worked-example) shows you how.
When every box on this page is ticked, you're ready for the [Intermediate level](../intermediate/README.md). Its "ready if" list is the Beginner Exit.
@@ -65,6 +64,6 @@ If this level helped, a star helps other developers find the guide.
---
-<sub>Sources: [Permission modes](https://code.claude.com/docs/en/permission-modes) · [Commands](https://code.claude.com/docs/en/commands) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Checkpointing](https://code.claude.com/docs/en/checkpointing) · [git add](https://git-scm.com/docs/git-add) · [about_Character_Encoding](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-5.1) · the [Beginner lessons](README.md), which cite the official pages for each step. · [git status](https://git-scm.com/docs/git-status) · [git stash](https://git-scm.com/docs/git-stash) · [git diff](https://git-scm.com/docs/git-diff) · [git rev-parse](https://git-scm.com/docs/git-rev-parse)</sub>
+<sub>Sources: [Permission modes](https://code.claude.com/docs/en/permission-modes) · [Commands](https://code.claude.com/docs/en/commands) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Checkpointing](https://code.claude.com/docs/en/checkpointing) · [git add](https://git-scm.com/docs/git-add) · [about_Character_Encoding](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-5.1) · the [Beginner lessons](README.md), which cite the official pages for each step. · [git status](https://git-scm.com/docs/git-status) · [git diff](https://git-scm.com/docs/git-diff) · [git rev-parse](https://git-scm.com/docs/git-rev-parse)</sub>
<sub>← [Project memory with CLAUDE.md](05-project-memory.md) · [Beginner index](README.md) · [Intermediate index](../intermediate/README.md) → · [Stuck on this capstone?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=b-capstone)</sub>
diff --git a/docs/intermediate/01-first-skill.md b/docs/intermediate/01-first-skill.md
index bf7c262..da05534 100644
--- a/docs/intermediate/01-first-skill.md
+++ b/docs/intermediate/01-first-skill.md
@@ -1,6 +1,6 @@
# Turn a repeated workflow into a skill
-<sub>**Intermediate** · Lesson 1 of 8 · about 20 minutes · Needs: [Intermediate index](README.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-20</sub>
+<sub>**Intermediate** · Lesson 1 of 8 · about 20 minutes · Needs: [Intermediate index](README.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -8,7 +8,7 @@ By the end of this lesson you can turn a workflow you keep repeating into a proj
## You need
-- One of your own repositories with a test command and no uncommitted changes, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
+- One of your own repositories with a test command and no uncommitted changes, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's `.practice/` folder as the [Intermediate index](README.md#prepare-your-own-repository) describes, if you haven't yet.
- Usage: light to moderate. The Your turn builds one small feature.
> [!NOTE]
@@ -16,7 +16,7 @@ By the end of this lesson you can turn a workflow you keep repeating into a proj
## The idea
-A [skill](https://code.claude.com/docs/en/skills) is a folder holding a `SKILL.md` file: YAML frontmatter that says what the skill is for, then the instructions Claude follows. A project skill lives in `.claude/skills/<name>/SKILL.md`. Commit it, and everyone who works in the repository gets it.
+Write a [skill](https://code.claude.com/docs/en/skills) when you paste the same playbook into chat for the third time ([Build your setup over time](https://code.claude.com/docs/en/features-overview#build-your-setup-over-time)). A skill is a folder holding a `SKILL.md` file: YAML frontmatter that says what the skill is for, then the instructions Claude follows. A project skill lives in `.claude/skills/<name>/SKILL.md`. Commit it, and everyone who works in the repository gets it.
Claude decides whether to load a skill from its description, plus any `when_to_use` text, in the skill listing, not from the skill body ([Frontmatter reference](https://code.claude.com/docs/en/skills#frontmatter-reference)). Invoking the skill loads the full instructions:
@@ -30,7 +30,7 @@ flowchart LR
```
- `$ARGUMENTS` receives the text after the skill's name ([Pass arguments to skills](https://code.claude.com/docs/en/skills#pass-arguments-to-skills)).
-- `disable-model-invocation: true` makes invocation manual. Keep it for a workflow whose timing you must control, such as deployment ([Control who invokes a skill](https://code.claude.com/docs/en/skills#control-who-invokes-a-skill)).
+- Each skill Claude can load on its own sits in the skill listing, which adds to your context on every turn. `disable-model-invocation: true` makes invocation manual and keeps the description out. Use it for a workflow with side effects or whose timing you must control, such as a commit or a deploy ([Control who invokes a skill](https://code.claude.com/docs/en/skills#control-who-invokes-a-skill)).
## Worked example
@@ -41,7 +41,7 @@ flowchart LR
curl -fsSL https://raw.githubusercontent.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/main/examples/intermediate/01-first-skill/dot-claude/skills/five-whys/SKILL.md -o .claude/skills/five-whys/SKILL.md
```
- Leaving out the comment lines at the top of its frontmatter, the file holds:
+ Without its header comments, it starts:
```markdown
---
@@ -72,17 +72,17 @@ flowchart LR
## Your turn
-The team wants a test-first workflow for requested features, while explanation-only questions should stay read-only. Decide what should trigger this coding workflow, then finish and test it in your repository.
+The team wants a test-first workflow for requested features, while explanation-only questions should stay read-only. Make test-first load for feature requests, never for questions, and leave the commit to you.
-1. Download the partial [`tdd` skill](../../examples/intermediate/01-first-skill/dot-claude/skills/tdd/SKILL.md):
+1. Download the partial [`tdd` skill](../../examples/intermediate/01-first-skill/dot-claude/skills/tdd/SKILL.md) and read it:
```bash
mkdir -p .claude/skills/tdd
curl -fsSL https://raw.githubusercontent.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/main/examples/intermediate/01-first-skill/dot-claude/skills/tdd/SKILL.md -o .claude/skills/tdd/SKILL.md
```
- This is the same example path as `five-whys`, with `tdd` in its place. Read it: the frontmatter has `description: TODO` and `disable-model-invocation: true`, and the Green and Refactor steps are unfinished.
-2. Decide which requests should load this skill before you edit it. Write the description for requested feature work; keep explanation-only questions outside its stated scope. Allow automatic loading for that boundary; keep deployment workflows manual.
+ The frontmatter has `description: TODO` and `disable-model-invocation: true`, and the Green and Refactor steps are unfinished. The skill ends by showing the diff, not by committing.
+2. Decide which requests should load this skill before you edit it. Write the description for requested feature work; keep explanation-only questions outside its stated scope. The skill stops at a diff you review, so it has no side effect that needs a manual trigger, and it can load on its own.
In your editor, finish it:
- replace `TODO` in the description with what the skill does followed by "Use when" and the feature requests it fits;
@@ -102,12 +102,10 @@ The team wants a test-first workflow for requested features, while explanation-o
/tdd a slugify(heading) function in src/slug.js that turns a Markdown heading into its link anchor: lowercase, punctuation dropped, spaces turned into hyphens
```
- Keep auto mode. It can approve edits and test runs without a prompt; if Claude Code asks, review the action before approving ([Permission modes](https://code.claude.com/docs/en/permission-modes)). Read the failing test output, the final passing result and the complete change before keeping the commit.
+ Keep auto mode. Read the failing test output, the passing run and the complete diff. After Claude responds, Claude Code can suggest your next prompt; start typing to dismiss a suggestion you don't want, because the commit is yours to make ([Prompt suggestions](https://code.claude.com/docs/en/interactive-mode#prompt-suggestions)). If the change is what you asked for, commit the test and the code together in a terminal in your repository, then save that commit: [`git rev-parse HEAD > .practice/i-1-commit.txt`](https://git-scm.com/docs/git-rev-parse).
+5. Probe the trigger both ways: on a request the skill should load for, and on one it shouldn't ([Evaluate and iterate on a skill](https://code.claude.com/docs/en/skills#evaluate-and-iterate-on-a-skill)). Run `/clear` and ask for another small feature test-first without naming the skill, such as `Add a countHeadings(markdown) function, test-first.` Press `Esc` as soon as the `Skill` tool call for `tdd` appears, before it starts editing ([Interactive mode](https://code.claude.com/docs/en/interactive-mode)). Run `/clear` again and ask a question, such as `Explain how isExternal decides that a link is external.` No `Skill` call for `tdd` should appear.
- In a terminal in your repository, inspect the current branch with [`git branch --show-current`](https://git-scm.com/docs/git-branch) and the commit with [`git show HEAD`](https://git-scm.com/docs/git-show). Confirm it holds the intended test and code, then save that commit: [`git rev-parse HEAD > .practice/i-1-commit.txt`](https://git-scm.com/docs/git-rev-parse). Keep the branch you reviewed; later lessons use this same repository.
-5. Start with a clean repository. Clear the conversation first. Run `/clear` and ask for another small feature test-first without naming the skill, such as `Add a countHeadings(markdown) function, test-first.` Press `Esc` as soon as the `Skill` tool call for `tdd` appears, before it starts editing ([Interactive mode](https://code.claude.com/docs/en/interactive-mode)). This probe checks the trigger, so let no second feature accumulate.
-
- If no call appears, revise the description and retry in a cleared conversation. Check `git status --short` afterward. If edits already happened, inspect them and recover only this experiment as in [Beginner lesson 4](../beginner/04-keep-a-session-on-track.md). Rewind does not track Bash edits ([Checkpointing](https://code.claude.com/docs/en/checkpointing#bash-command-changes-not-tracked)). Finish with a clean repository.
+ If either probe fails, revise the description, commit it and repeat both. Then run `git status --short` and undo anything the probes changed, so the repository is clean.
## Check
@@ -116,11 +114,11 @@ You are done when all of these are true:
- [ ] The finished skill is committed with no TODO left: `git grep -n TODO HEAD -- .claude/skills/tdd` prints nothing.
- [ ] It can run as `/tdd` and load on its own: `git show HEAD:.claude/skills/tdd/SKILL.md` shows a description of what it does and when to use it, and no `disable-model-invocation: true`.
- [ ] The commit saved in `.practice/i-1-commit.txt` holds a test and the code it tests: `git show --stat $(cat .practice/i-1-commit.txt)` lists both.
-- [ ] Self-check (not tested): `/tdd` ran the skill, its trigger fits feature requests, and a cleared conversation loaded `tdd` on its own before you stopped the probe.
+- [ ] Self-check (not tested): `/tdd` ran the skill, a cleared conversation loaded `tdd` on its own for a feature request, and a question didn't load `tdd`.
Run `npm run check -- i-1 --dir <your repo>` from your practice copy, or `npm run check -- i-1` in the copy itself.
-If the skill isn't committed, run `git check-ignore -v .claude/skills/tdd/SKILL.md`: an ignore rule that matches `.claude`, in a `.gitignore`, `.git/info/exclude` or your global excludes file, hides the folder from `git add`, so add the file with `git add -f`. If the invocation item fails, rewrite the description as what the skill does followed by "Use when" and the feature requests it fits, then commit again. If the commit item fails, run `/tdd` on a new small feature and let it commit the test with the code before saving that commit.
+If the skill isn't committed, run `git check-ignore -v .claude/skills/tdd/SKILL.md`: an ignore rule that matches `.claude`, in a `.gitignore`, `.git/info/exclude` or your global excludes file, hides the folder from `git add`, so add the file with `git add -f`. If the invocation item fails, rewrite the description as what the skill does followed by "Use when" and the feature requests it fits, then commit again. If the commit item fails, run `/tdd` on a new small feature, review the diff, and commit the test with the code before you save that commit.
## Watch out
@@ -135,6 +133,6 @@ If the skill isn't committed, run `git check-ignore -v .claude/skills/tdd/SKILL.
---
-<sub>Sources: [Extend Claude with skills](https://code.claude.com/docs/en/skills) · [Advanced setup](https://code.claude.com/docs/en/setup) · [Commands](https://code.claude.com/docs/en/commands) · [Security](https://code.claude.com/docs/en/security) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [Permission modes](https://code.claude.com/docs/en/permission-modes) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Checkpointing](https://code.claude.com/docs/en/checkpointing) · [git-status](https://git-scm.com/docs/git-status) · [git-branch](https://git-scm.com/docs/git-branch) · [git-show](https://git-scm.com/docs/git-show) · [git-add](https://git-scm.com/docs/git-add) · [git-commit](https://git-scm.com/docs/git-commit) · [git-rev-parse](https://git-scm.com/docs/git-rev-parse)</sub>
+<sub>Sources: [Extend Claude with skills](https://code.claude.com/docs/en/skills) · [Extend Claude Code](https://code.claude.com/docs/en/features-overview) · [Advanced setup](https://code.claude.com/docs/en/setup) · [Commands](https://code.claude.com/docs/en/commands) · [Security](https://code.claude.com/docs/en/security) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [git-status](https://git-scm.com/docs/git-status) · [git-add](https://git-scm.com/docs/git-add) · [git-commit](https://git-scm.com/docs/git-commit) · [git-rev-parse](https://git-scm.com/docs/git-rev-parse)</sub>
<sub>← [Intermediate index](README.md) · [Organize project memory and see what loaded](02-organize-memory.md) → · Topic: [Skills](../topics/skills.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-1)</sub>
diff --git a/docs/intermediate/02-organize-memory.md b/docs/intermediate/02-organize-memory.md
index 63a856d..48f9a75 100644
--- a/docs/intermediate/02-organize-memory.md
+++ b/docs/intermediate/02-organize-memory.md
@@ -1,6 +1,6 @@
# Organize project memory and see what loaded
-<sub>**Intermediate** · Lesson 2 of 8 · about 20 minutes · Needs: [Turn a repeated workflow into a skill](01-first-skill.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Intermediate** · Lesson 2 of 8 · about 20 minutes · Needs: [Turn a repeated workflow into a skill](01-first-skill.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -8,7 +8,7 @@ By the end of this lesson you can split a project's instructions into imports an
## You need
-- One of your own repositories with a committed `CLAUDE.md`, as [Beginner lesson 5](../beginner/05-project-memory.md) leaves it, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
+- One of your own repositories with a committed `CLAUDE.md`, as [Beginner lesson 5](../beginner/05-project-memory.md) leaves it, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's `.practice/` folder as the [Intermediate index](README.md#prepare-your-own-repository) describes, if you haven't yet.
- `jq`, for the load log in the Worked example.
- Usage: light.
@@ -23,7 +23,7 @@ A long `CLAUDE.md` is hard to maintain, and every line of it loads into every se
|---|---|
| `CLAUDE.md` at the project root, and a rule without `paths:` | When the session starts |
| A file named in an `@path` import | With the file that imports it |
-| A rule with `paths:` | When Claude reads, writes or edits a matching file with its Read, Write or Edit tool |
+| A rule with `paths:` | When Claude reads, writes or edits a matching file, including viewing one with a single-file shell read such as `cat` or `head` ([Path-specific rules](https://code.claude.com/docs/en/memory#path-specific-rules)) |
When Claude ignores an instruction, first find out whether its file loaded. If it did, the wording is the likely problem: make it concrete, and remove any instruction that contradicts it ([Debug your configuration](https://code.claude.com/docs/en/debug-your-config#see-what-loaded-into-context)).
@@ -35,7 +35,6 @@ When Claude ignores an instruction, first find out whether its file loaded. If i
- npm scripts: @package.json
```
- An import's path runs until the first space, so don't put a period right after it.
2. Save a rule for your test files as `.claude/rules/testing.md`. Change the pattern to match where your tests live, and the instruction to name your project's test tools:
```markdown
@@ -58,10 +57,10 @@ When Claude ignores an instruction, first find out whether its file loaded. If i
```
4. End your current Claude session. Start a session with the log, `claude --settings .practice/i-2-hook.json` ([CLI reference](https://code.claude.com/docs/en/cli-reference#cli-flags)), and run `/context all`: plain `/context` can collapse its list, and `all` expands it ([Commands](https://code.claude.com/docs/en/commands)). Under **Memory files** it lists the instruction files that loaded at the start, such as `CLAUDE.md` ([Set up a project CLAUDE.md](https://code.claude.com/docs/en/memory#set-up-a-project-claude-md)). The scoped rule isn't among them: nothing has read a test file yet. The log also has an `include` line for your imported file.
-5. Ask Claude to read a test file with its Read tool. Replace the example's file with a test file your rule covers. Name the tool: Claude sometimes reads a file through a shell command, which doesn't load scoped rules at this lesson's baseline. The [changelog places the fix in v2.1.293](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#21293).
+5. Ask Claude to read a test file your rule covers. Replace the example's file with one of yours:
```text
- Use your Read tool to read test/config.test.js, then tell me in one sentence what it checks.
+ Read test/config.test.js, then tell me in one sentence what it checks.
```
In a terminal in your repository, `cat .practice/i-2-loaded.txt` shows every load with its reason: `session_start` for `CLAUDE.md`, `include` for `package.json`, and now `path_glob_match` for the rule. The hook runs asynchronously, so if a line has not appeared yet, wait briefly and read the log again.
@@ -83,28 +82,28 @@ A teammate's rule never takes effect. Find out why, and fix it.
- Print errors to stderr, starting with `linkcheck:`.
```
-2. End the example's session. Start a logged session, `claude --settings .practice/i-2-hook.json`. Ask Claude to use its Read tool on `src/cli.js`, or on a file in your folder:
+2. End the example's session. Start a logged session, `claude --settings .practice/i-2-hook.json`. Ask Claude to read `src/cli.js`, or a file in your folder:
```text
- Use your Read tool to read src/cli.js, then tell me in one sentence what it does.
+ Read src/cli.js, then tell me in one sentence what it does.
```
3. In a terminal in your repository, read `.practice/i-2-loaded.txt`. The log appends to earlier attempts: inspect the lines added by this session. Compare its pattern with the files that exist, `git ls-files src`. Use your own source folder in place of `src`. Decide whether to change the pattern, the instruction, or the way the file was read. Use the load log and the actual paths as your evidence.
4. Fix the mismatch you found. End the session, start a new logged session and repeat step 2. The log now has a `path_glob_match` line for `cli.md`.
-5. Commit `CLAUDE.md` and `.claude/rules/`. Delete `.practice/i-2-hook.json` when you no longer need the log.
+5. Before you commit, decide where three instructions belong: a command every session needs, a convention for test files only, and a multi-step release procedure. The first goes in `CLAUDE.md`, the second in a scoped rule, the third in a skill: keep `CLAUDE.md` to facts Claude should hold in every session ([When to add to CLAUDE.md](https://code.claude.com/docs/en/memory#when-to-add-to-claude-md)). Then commit `CLAUDE.md` and `.claude/rules/`. Delete `.practice/i-2-hook.json` when you no longer need the log.
## Check
You are done when all of these are true:
- [ ] The committed `CLAUDE.md` imports a file that exists: `git show HEAD:CLAUDE.md | grep '@'` shows the import.
-- [ ] Every committed rule with `paths:` matches a file: for each pattern, `git ls-files ':(glob)<pattern>'` lists at least one file. With the `:(glob)` prefix, git's `*` stays inside one folder and `**/` matches any number of folders, as in rules ([gitglossary: pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec)). Git doesn't expand braces, which rules do ([Path-specific rules](https://code.claude.com/docs/en/memory#path-specific-rules)), so check a pattern such as `src/**/*.{ts,tsx}` one extension at a time.
+- [ ] Every committed rule with `paths:` matches a file: for each pattern, `git ls-files ':(glob)<pattern>'` lists at least one file.
- [ ] The log shows the import and a scoped rule loading: `grep -E '^(include|path_glob_match)' .practice/i-2-loaded.txt` prints at least one line of each kind.
- [ ] Self-check (not tested): you can say which of your instruction files load at the start and which load later, and how you saw each one load.
Run `npm run check -- i-2 --dir <your repo>` from your practice copy, or `npm run check -- i-2` in the copy itself.
-If the import check fails, look for punctuation right after the path, or a path written relative to the wrong folder: an import resolves from the file that holds it. If a rule matches no file, its pattern is relative to the project root, so `source/**` matches nothing in a project whose code is in `src/`. If the log has no `path_glob_match` line, start the session with `--settings .practice/i-2-hook.json` and ask for the Read tool by name.
+If the import check fails, look for punctuation right after the path, or a path written relative to the wrong folder: an import resolves from the file that holds it. If a rule matches no file, its pattern is relative to the project root, so `source/**` matches nothing in a project whose code is in `src/`. If the log has no `path_glob_match` line, start the session with `--settings .practice/i-2-hook.json` and check that the pattern, read from the project root, matches the file Claude read.
## Watch out
@@ -120,6 +119,6 @@ If the import check fails, look for punctuation right after the path, or a path
---
-<sub>Sources: [How Claude remembers your project](https://code.claude.com/docs/en/memory) · [Hooks reference](https://code.claude.com/docs/en/hooks) · [Debug your configuration](https://code.claude.com/docs/en/debug-your-config) · [How Claude Code uses prompt caching](https://code.claude.com/docs/en/prompt-caching) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Commands](https://code.claude.com/docs/en/commands) · [Claude Code changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#21293) · [gitglossary](https://git-scm.com/docs/gitglossary)</sub>
+<sub>Sources: [How Claude remembers your project](https://code.claude.com/docs/en/memory) · [Hooks reference](https://code.claude.com/docs/en/hooks) · [Debug your configuration](https://code.claude.com/docs/en/debug-your-config) · [How Claude Code uses prompt caching](https://code.claude.com/docs/en/prompt-caching) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Commands](https://code.claude.com/docs/en/commands)</sub>
<sub>← [Turn a repeated workflow into a skill](01-first-skill.md) · [Intermediate index](README.md) · [Pick the model and effort](03-model-and-effort.md) → · Topic: [Memory and context](../topics/memory-and-context.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-2)</sub>
diff --git a/docs/intermediate/03-model-and-effort.md b/docs/intermediate/03-model-and-effort.md
index 6159234..e7c39f4 100644
--- a/docs/intermediate/03-model-and-effort.md
+++ b/docs/intermediate/03-model-and-effort.md
@@ -1,6 +1,6 @@
# Pick the model and effort
-<sub>**Intermediate** · Lesson 3 of 8 · about 20 minutes · Needs: [Turn a repeated workflow into a skill](01-first-skill.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-21</sub>
+<sub>**Intermediate** · Lesson 3 of 8 · about 20 minutes · Needs: [Turn a repeated workflow into a skill](01-first-skill.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -11,9 +11,12 @@ By the end of this lesson you can diagnose a weak result before changing models,
- The repository where you did [lesson 1](01-first-skill.md), with its committed skills, and a small change you intend to make. Use a terminal in that repository for edits and Git; use your practice copy only for the final check.
- Usage: light. You will request a short investigation and a changelog entry.
+> [!NOTE]
+> On Claude Platform on AWS, Amazon Bedrock, Google Cloud's Agent Platform and Microsoft Foundry, `haiku` resolves to Haiku 4.5, which auto mode doesn't support, and a skill model that auto mode doesn't support leaves the session model in use ([Model aliases](https://code.claude.com/docs/en/model-config#model-aliases), [Auto mode](https://code.claude.com/docs/en/permission-modes#eliminate-prompts-with-auto-mode), [skill model overrides](https://code.claude.com/docs/en/skills#frontmatter-reference)). There, give the changelog skill a model from auto mode's list for your provider.
+
## The idea
-The [model aliases](https://code.claude.com/docs/en/model-config#model-aliases) include `sonnet` for daily coding and `opus` for complex reasoning. Model choice sets the capability you start with; [effort](https://code.claude.com/docs/en/model-config#choose-an-effort-level) changes how much reasoning and verification Claude applies. See the [model descriptions](https://platform.claude.com/docs/en/about-claude/models/overview).
+The [model aliases](https://code.claude.com/docs/en/model-config#model-aliases) include `sonnet` for daily coding, `opus` for complex reasoning and `haiku` for simple tasks. Model choice sets the capability you start with; [effort](https://code.claude.com/docs/en/model-config#choose-an-effort-level) changes how much reasoning and verification Claude applies. See the [model descriptions](https://platform.claude.com/docs/en/about-claude/models/overview). Anthropic's guidance is to start from the model's default effort, and to look at the context you gave Claude before you turn a knob ([Choosing a Claude model and effort level in Claude Code](https://claude.com/blog/claude-model-and-effort-level-in-claude-code)).
Before escalating, inspect the evidence:
@@ -26,11 +29,11 @@ Before escalating, inspect the evidence:
Change one variable, then compare against the same success criterion. Higher effort cannot supply a missing fixture.
-A skill's [`model:` and `effort:` frontmatter](https://code.claude.com/docs/en/skills#frontmatter-reference) overrides the session while it is active. It need not give every task the same settings.
+A skill's [`model:` and `effort:` frontmatter](https://code.claude.com/docs/en/skills#frontmatter-reference) overrides the session while it is active.
## Worked example
-1. Start `claude` in your repository. Run `/status`: it shows the model. Run `/effort status`: it prints the effort level in force ([Commands](https://code.claude.com/docs/en/commands)). Notice what your session actually shows; the account and provider affect the available models.
+1. Start `claude` in your repository. Run `/status`: it shows the model. Run `/effort status`: it prints the effort level in force ([Commands](https://code.claude.com/docs/en/commands)).
2. Switch the model for this session only: run `/model`, move to Sonnet and press `s`. Run `/status` again to check the selected model. Your default for new sessions is unchanged ([Setting your model](https://code.claude.com/docs/en/model-config#setting-your-model)). Stay in auto mode for this lesson.
3. Investigate an error path in your own repository, without making an edit:
@@ -49,7 +52,7 @@ A skill's [`model:` and `effort:` frontmatter](https://code.claude.com/docs/en/s
## Your turn
-Tune a routine writing task differently from the diagnostic task. Decide what counts as a useful entry before you run it: the entry must describe the staged change for someone using your project.
+A changelog entry is routine work: give it only what it needs, and keep root-cause work thorough. Decide what counts as a useful entry before you run it: the entry must describe the staged change for someone using your project.
1. Save this partial skill as `.claude/skills/changelog/SKILL.md`. Its `disable-model-invocation: true` field keeps invocation under your control ([Control who invokes a skill](https://code.claude.com/docs/en/skills#control-who-invokes-a-skill)).
@@ -65,8 +68,8 @@ Tune a routine writing task differently from the diagnostic task. Decide what co
Read the staged changes with `git diff --staged`. Add one list item (`- `) under `## Unreleased` in CHANGELOG.md that says what changed for someone using the tool, creating the file and the heading if they don't exist. Change no other file.
```
-2. Choose the settings for a short entry whose input is an exact staged diff and whose output you will review. Use `model: sonnet` for this auto-mode exercise, and choose `effort: low` or `effort: medium`. Explain why this task needs different settings from a cause investigation. At this lesson's baseline, Haiku is not supported in auto mode, and an unsupported skill model leaves the session model in use ([Auto mode](https://code.claude.com/docs/en/permission-modes#eliminate-prompts-with-auto-mode), [skill model overrides](https://code.claude.com/docs/en/skills#frontmatter-reference)).
-3. Make a small intended change in your repository. Review and stage only that change, keeping unrelated work out of the staged diff. Run `/changelog`. Review any permission request if one appears; auto mode may allow the edit without one. If the skill is unknown, run `/reload-skills` and retry. Read the new entry against the staged diff. If it invents a benefit or names only an internal implementation detail, correct the entry before committing.
+2. Choose the settings for a short entry whose input is an exact staged diff and whose output you will review. Set `model: haiku`: on the Anthropic API it resolves to Haiku 5.5, which auto mode supports. Set `effort: low`: `medium` is already Claude Code's default for Haiku 5.5 and Sonnet 5.5 ([Adjust effort level](https://code.claude.com/docs/en/model-config#adjust-effort-level)). Explain why this task needs different settings from a cause investigation.
+3. Make a small intended change in your repository. In your practice copy, leave the malformed percent escape bug alone, such as a link to `bad%.md`: the [Intermediate capstone](capstone.md) fixes it. Review and stage only that change, keeping unrelated work out of the staged diff. Run `/changelog`. Review any permission request if one appears; auto mode may allow the edit without one. If the skill is unknown, run `/reload-skills` and retry. Read the new entry against the staged diff. If it invents a benefit or names only an internal implementation detail, correct the entry before committing.
4. Review the complete diff. Commit it with `CHANGELOG.md` and both skills. Check that the commit includes the diagnostic skill's effort line too.
## Check
@@ -84,7 +87,7 @@ If the skill check says the model is larger than the task needs, revisit the pre
## Watch out
- `/model <alias>` and `/effort <level>` save your choice as the default for new sessions. To change only the current session, press `s` in the picker or the slider.
-- A model switch makes the next request read the conversation without cache hits. Claude Code may ask you to confirm while the cache is warm ([Switching models](https://code.claude.com/docs/en/prompt-caching#switching-models)).
+- A model switch makes the next request read the conversation without cache hits. Claude Code may ask you to confirm while the cache is warm ([Switching models](https://code.claude.com/docs/en/prompt-caching#switching-models)). A skill whose `model:` differs from the session's is a switch too, for that turn: its next request reads the whole conversation with no cache hits.
## Go further
@@ -94,6 +97,6 @@ If the skill check says the model is larger than the task needs, revisit the pre
---
-<sub>Sources: [Model configuration](https://code.claude.com/docs/en/model-config) · [Models overview](https://platform.claude.com/docs/en/about-claude/models/overview) · [Commands](https://code.claude.com/docs/en/commands) · [Extend Claude with skills](https://code.claude.com/docs/en/skills) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [How Claude Code uses prompt caching](https://code.claude.com/docs/en/prompt-caching)</sub>
+<sub>Sources: [Model configuration](https://code.claude.com/docs/en/model-config) · [Models overview](https://platform.claude.com/docs/en/about-claude/models/overview) · [Choosing a Claude model and effort level in Claude Code](https://claude.com/blog/claude-model-and-effort-level-in-claude-code) · [Commands](https://code.claude.com/docs/en/commands) · [Extend Claude with skills](https://code.claude.com/docs/en/skills) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [How Claude Code uses prompt caching](https://code.claude.com/docs/en/prompt-caching)</sub>
<sub>← [Organize project memory and see what loaded](02-organize-memory.md) · [Intermediate index](README.md) · [Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md) → · Topic: [Models, effort and cost](../topics/models-effort-and-cost.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-3)</sub>
diff --git a/docs/intermediate/04-permissions-and-sandbox.md b/docs/intermediate/04-permissions-and-sandbox.md
index fc1f9e5..c2c8027 100644
--- a/docs/intermediate/04-permissions-and-sandbox.md
+++ b/docs/intermediate/04-permissions-and-sandbox.md
@@ -1,6 +1,6 @@
# Permissions, settings scopes and the sandbox
-<sub>**Intermediate** · Lesson 4 of 8 · about 20 minutes · Needs: [Organize project memory and see what loaded](02-organize-memory.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Intermediate** · Lesson 4 of 8 · about 20 minutes · Needs: [Organize project memory and see what loaded](02-organize-memory.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -24,7 +24,7 @@ The file a rule goes in decides who it affects ([Settings](https://code.claude.c
| `.claude/settings.local.json`, kept out of git | You, in this project | Personal choices |
| Managed settings | Your organization | Organization policy |
-When the same key is set in more than one place, the higher level wins: managed, then the command line, then local, then shared project, then user ([Settings precedence](https://code.claude.com/docs/en/settings#settings-precedence)). Rule lists such as `permissions.allow` merge across the files instead. Among the rules, deny is checked first, then ask, then allow, and the first match decides ([Configure permissions](https://code.claude.com/docs/en/permissions#manage-permissions)).
+When the same key is set in more than one place, the higher level wins: managed, then the command line, then local, then shared project, then user ([Settings precedence](https://code.claude.com/docs/en/settings#settings-precedence)). Rule lists such as `permissions.allow` merge across the files instead. Among the rules, deny is checked first, then ask, then allow, and the first match decides ([Configure permissions](https://code.claude.com/docs/en/permissions#manage-permissions)). In auto mode, an action that matches one of your rules resolves before the classifier sees it, apart from a few exceptions such as writes to protected paths: deny blocks it, ask prompts you, allow lets it run. Auto mode drops broad allow rules, such as package-manager run commands, and keeps narrow ones like `Bash(npm test)` ([How auto mode evaluates actions](https://code.claude.com/docs/en/permission-modes#how-auto-mode-evaluates-actions)).
By default, the [sandbox](https://code.claude.com/docs/en/sandboxing) restricts shell writes to the project, a per-user temporary folder and added directories, using an operating-system boundary.
@@ -33,46 +33,60 @@ By default, the [sandbox](https://code.claude.com/docs/en/sandboxing) restricts
In your practice copy:
1. Open a terminal in your practice copy and start a Manual session with `claude --permission-mode default`. Check that the footer says `manual mode on`. Manual is the deliberate exercise here: auto mode can approve a test run without a prompt, so the missing prompt alone would not demonstrate an allow rule ([Choose a permission mode](https://code.claude.com/docs/en/permission-modes#available-modes)). Then run `/status`. Its `Setting sources` line lists the settings files this session loaded. Open `/sandbox`; keep the sandbox off for the rule comparison, then close the panel.
-2. Save the team's rules as `.claude/settings.json`. Merge this block with any settings already there, rather than replacing unrelated keys. These are the docs' rules for keeping Claude out of `.env` files ([Exclude sensitive files](https://code.claude.com/docs/en/settings-reference#exclude-sensitive-files)), plus the exact test command:
+2. Save the team's rules as `.claude/settings.json`. Merge this block with any settings already there, rather than replacing unrelated keys. These are the docs' rules for keeping Claude out of `.env` files ([Exclude sensitive files](https://code.claude.com/docs/en/settings-reference#exclude-sensitive-files)), plus the exact test command and an ask rule for pushes:
```json
{
"permissions": {
"allow": ["Bash(npm test)"],
+ "ask": ["Bash(git push *)"],
"deny": ["Read(./.env)", "Read(./.env.*)"]
}
}
```
- Claude Code reloads permission rules when the file changes ([When edits take effect](https://code.claude.com/docs/en/settings#when-edits-take-effect)). Run `/permissions`: it lists `Bash(npm test)` among the allow rules and the two `Read` rules among the deny rules. Check their source file too.
+ Auto mode on its own lets Claude read `.env` ([What the classifier blocks by default](https://code.claude.com/docs/en/permission-modes#what-the-classifier-blocks-by-default)): the deny rules are what stop it. The ask rule makes Claude Code prompt before a push, even in auto mode ([Add a human checkpoint](https://code.claude.com/docs/en/auto-mode-config#add-a-human-checkpoint)). Claude Code reloads permission rules when the file changes ([When edits take effect](https://code.claude.com/docs/en/settings#when-edits-take-effect)). Run `/permissions`: it lists every rule and the settings file it comes from.
+
+ The practice copy has no `.env`, so make a dummy one with a fake value, and ask Claude to read it:
+
+ ```bash
+ echo "DEMO_TOKEN=not-a-real-secret" > .env
+ ```
+
+ ```text
+ Read .env and tell me what it holds.
+ ```
+
+ The deny rule blocks the read: deny rules prevent Claude Code from using the tool on that path. Delete the dummy file afterwards: `rm .env`.
3. Ask Claude to `Run npm test`. Read the test result. In Manual mode, with the sandbox off and no matching ask or deny rule, this exact command runs without a permission prompt because the allow rule covers it. If it asks, inspect the command and rule sources instead of approving a broader grant.
-4. Turn on the sandbox. Run `/sandbox` and, on the Mode tab, select auto-allow. Claude Code saves the setting to `.claude/settings.local.json`, your personal file ([Get started](https://code.claude.com/docs/en/sandboxing#get-started)). Sandboxed commands can now run without routine permission prompts; this is separate from auto permission mode. Permission approval and that boundary answer different questions: may this command run, and what can it reach? If `/sandbox` shows only a Dependencies tab, install `bubblewrap` and `socat`, restart Claude Code and run `/sandbox` again.
+4. Turn on the sandbox. Run `/sandbox` and, on the Mode tab, select auto-allow. Claude Code saves the setting to `.claude/settings.local.json`, your personal file ([Get started](https://code.claude.com/docs/en/sandboxing#get-started)). Permission approval and that boundary answer different questions: may this command run, and what can it reach? If `/sandbox` shows only a Dependencies tab, install `bubblewrap` and `socat`, restart Claude Code and run `/sandbox` again.
5. Ask Claude to try a write outside the project:
```text
Run this exact command and show me its output: touch ~/sandbox-probe
```
- Read the tool's output: `Operation not permitted` on macOS, or `Read-only file system` on Linux and WSL 2 ([Confirm commands run inside the sandbox](https://code.claude.com/docs/en/sandboxing#confirm-commands-run-inside-the-sandbox)). If Claude offers to retry outside the sandbox, decline. The rejected write is the useful evidence, not whether a permission prompt appeared.
+ Read the tool's output: `Operation not permitted` on macOS, or `Read-only file system` on Linux and WSL 2 ([Confirm commands run inside the sandbox](https://code.claude.com/docs/en/sandboxing#confirm-commands-run-inside-the-sandbox)). If Claude offers to retry outside the sandbox, decline. The rejected write is the useful evidence, not whether a permission prompt appeared. If the `touch` succeeds, delete `~/sandbox-probe` and run `/sandbox` to check that the sandbox is on.
## Your turn
-Audit a proposed team setup in your own repository. A teammate suggests `Bash(npm *)` so tests run without prompts, and wants your personal sandbox choice committed too. Decide what belongs in shared settings before editing.
+Audit a proposed team setup in your own repository. A teammate suggests `Bash(npm *)` so tests run without prompts, wants your personal sandbox choice committed too, and asks Claude in the conversation not to push without asking. Keep `.env` from Claude for everyone, keep tests prompt-free, and make pushes ask first.
-1. Choose the exact command from your repository's test script. Share that narrow rule and the `.env` denies; keep your personal sandbox choice local. `Bash(npm *)` would also approve unrelated npm commands. Finish this partial block in `.claude/settings.json`, preserving existing settings. Use the Worked example's deny rules for both the base file and the `.env.*` family:
+1. Choose the exact command from your repository's test script. Share that narrow rule, an ask rule for pushes and the `.env` denies; keep your personal sandbox choice local. `Bash(npm *)` would also approve unrelated npm commands. A request made in the conversation can be lost when compaction drops the message; an ask rule always prompts for a matching command, even in auto mode ([Add a human checkpoint](https://code.claude.com/docs/en/auto-mode-config#add-a-human-checkpoint)). Finish this partial block in `.claude/settings.json`, preserving existing settings. Use the Worked example's deny rules for both the base file and the `.env.*` family:
```json
{
"permissions": {
"allow": ["TODO: the command that runs your tests"],
+ "ask": ["TODO: a command the team approves each time"],
"deny": ["TODO: reading .env", "TODO: reading .env.local and the other .env.* files"]
}
}
```
- Replace every `TODO` before saving the final file. Allow only the one command that runs your tests, such as `Bash(npm test)` or `Bash(pytest)`.
-2. Review and commit the team's rules. Use your repository's terminal. Check that the commit contains the narrow test rule and both deny rules, while preserving the earlier lessons' settings.
-3. In a Claude Code session in your repository, turn on the sandbox with `/sandbox` in auto-allow mode. Check the Config tab: a local `"enabled": false` overrides a shared `true`. Ask Claude to `Run this exact command and show me its output: touch ~/sandbox-probe`, and inspect the actual failure. If Claude offers to retry outside the sandbox, decline.
+ Replace every `TODO` before saving the final file. Allow only the one command that runs your tests, such as `Bash(npm test)` or `Bash(pytest)`, and ask before pushes with `Bash(git push *)`.
+2. Review and commit the team's rules. Use your repository's terminal. Check that the commit contains the narrow test rule, the ask rule and both deny rules, while preserving the earlier lessons' settings.
+3. In a Claude Code session in your repository, turn on the sandbox with `/sandbox` in auto-allow mode. The Config tab shows the resolved sandbox settings ([Get started](https://code.claude.com/docs/en/sandboxing#get-started)). Your local file outranks the shared one, so a local `"enabled": false` overrides a shared `true` ([Settings precedence](https://code.claude.com/docs/en/settings#settings-precedence)): `jq .sandbox .claude/settings.local.json` shows what yours holds. Ask Claude to `Run this exact command and show me its output: touch ~/sandbox-probe`, and inspect the actual failure. If Claude offers to retry outside the sandbox, decline.
4. Run [`git status --short`](https://git-scm.com/docs/git-status) and [`git ls-files .claude/settings.local.json`](https://git-scm.com/docs/git-ls-files) in your repository's terminal. Your personal file should appear in neither output. Claude Code keeps it out of git when it creates it; if you created it by hand, add it to `.gitignore` yourself ([Keep personal settings out of a repository](https://code.claude.com/docs/en/settings#keep-personal-settings-out-of-a-repository)). Leave Manual mode when the exercise is finished: press `Shift+Tab` until the footer shows `auto mode on`, if auto mode is available ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)).
## Check
@@ -80,17 +94,18 @@ Audit a proposed team setup in your own repository. A teammate suggests `Bash(np
You are done when all of these are true:
- [ ] The committed `.claude/settings.json` denies reading `.env` and `.env.*` files and allows one test command: `git show HEAD:.claude/settings.json | jq .permissions` shows them.
+- [ ] It asks before a command the team approves each time, such as `Bash(git push *)`, in `permissions.ask`.
- [ ] The sandbox is on, and your personal file stays out of git: `jq .sandbox .claude/settings.local.json` shows `"enabled": true`, and `git ls-files .claude/settings.local.json` prints nothing.
- [ ] Self-check (not tested): you inspected the active rules and sandbox configuration, and Claude's attempted write outside the project failed without an unsandboxed retry.
Run `npm run check -- i-4 --dir <your repo>` from your practice copy, or `npm run check -- i-4` in the copy itself.
-If the rules item fails, review Your turn step 1, then commit the corrected settings. If the sandbox item fails, revisit Your turn step 3 in the repository the check reads; a local disable wins over a shared enable.
+If the rules item fails, review Your turn step 1, then commit the corrected settings. If the ask item fails, add the rule to `permissions.ask`, not `deny`: a deny rule would block the push you want. If the sandbox item fails, revisit Your turn step 3 in the repository the check reads; a local disable wins over a shared enable.
## Watch out
- The sandbox wraps shell commands only. Claude's file and web tools follow permission rules; hooks and local MCP servers run outside it with your full access ([What runs outside the sandbox](https://code.claude.com/docs/en/sandboxing#what-runs-outside-the-sandbox)). If the sandbox can't start, Claude Code runs commands unsandboxed unless `sandbox.failIfUnavailable` is `true`.
-- A `Read` deny rule doesn't stop an arbitrary script from opening files itself ([Read and Edit](https://code.claude.com/docs/en/permissions#read-and-edit)). With the sandbox on, Claude Code also adds your `Read` deny paths to the sandbox's [`filesystem.denyRead`](https://code.claude.com/docs/en/settings-reference#sandbox-filesystem-denyread). If a container reports `Can't mount proc on /newroot/proc`, follow [Bubblewrap fails to start inside a container](https://code.claude.com/docs/en/sandboxing#bubblewrap-fails-to-start-inside-a-container) before treating the sandbox as working.
+- A `Read` deny rule doesn't stop an arbitrary script from opening files itself ([Read and Edit](https://code.claude.com/docs/en/permissions#read-and-edit)). With the sandbox on, Claude Code also adds your `Read` deny paths to the sandbox's [`filesystem.denyRead`](https://code.claude.com/docs/en/settings-reference#sandbox-filesystem-denyread).
## Go further
@@ -100,6 +115,6 @@ If the rules item fails, review Your turn step 1, then commit the corrected sett
---
-<sub>Sources: [Settings files and precedence](https://code.claude.com/docs/en/settings) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Configure the sandboxed Bash tool](https://code.claude.com/docs/en/sandboxing) · [git status](https://git-scm.com/docs/git-status) · [git ls-files](https://git-scm.com/docs/git-ls-files)</sub>
+<sub>Sources: [Settings files and precedence](https://code.claude.com/docs/en/settings) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Configure auto mode](https://code.claude.com/docs/en/auto-mode-config) · [Configure the sandboxed Bash tool](https://code.claude.com/docs/en/sandboxing) · [git status](https://git-scm.com/docs/git-status) · [git ls-files](https://git-scm.com/docs/git-ls-files)</sub>
<sub>← [Pick the model and effort](03-model-and-effort.md) · [Intermediate index](README.md) · [Enforce a rule with a hook](05-hooks.md) → · Topic: [Permissions and safety](../topics/permissions-and-safety.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-4)</sub>
diff --git a/docs/intermediate/05-hooks.md b/docs/intermediate/05-hooks.md
index c5e35d0..d27a650 100644
--- a/docs/intermediate/05-hooks.md
+++ b/docs/intermediate/05-hooks.md
@@ -1,27 +1,27 @@
# Enforce a rule with a hook
-<sub>**Intermediate** · Lesson 5 of 8 · about 20 minutes · Needs: [Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Intermediate** · Lesson 5 of 8 · about 20 minutes · Needs: [Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
-By the end of this lesson you can add a hook that enforces a rule on Claude's Edit and Write tools, and show it firing.
+By the end of this lesson you can enforce a rule with a hook that fails closed, and send Claude back to work when it stops while your tests fail.
## You need
-- The repository from [lesson 4](04-permissions-and-sandbox.md), with its `.claude/settings.json`, and your copy of the practice template with Node.js LTS: the check runs from the copy.
+- The repository from [lesson 4](04-permissions-and-sandbox.md), with its `.claude/settings.json` and a test command, and your copy of the practice template with Node.js LTS: the check runs from the copy.
- `jq`, which the hook scripts use, and `python3`, which `format-after-edit.sh` uses.
- Usage: light.
## The idea
-A `CLAUDE.md` rule is advice that Claude can miss. A [hook](https://code.claude.com/docs/en/hooks-guide) is your own command that Claude Code runs at a fixed point in a session, every time, whatever Claude decides. Claude Code passes the hook JSON about the event on stdin. A `PreToolUse` hook runs before a tool call; if it exits with code 2, the call is blocked, and what it printed to stderr goes to Claude as the reason ([Hooks reference](https://code.claude.com/docs/en/hooks#exit-code-2-behavior-per-event), [Block edits to protected files](https://code.claude.com/docs/en/hooks-guide#block-edits-to-protected-files)).
+A `CLAUDE.md` rule is advice that Claude can miss. A [hook](https://code.claude.com/docs/en/hooks-guide) is your own command that Claude Code runs at a fixed point in a session, every time, whatever Claude decides. Claude Code passes the hook JSON about the event on stdin. A hook that exits with code 2 blocks: a `PreToolUse` hook stops the tool call, and a `Stop` hook stops Claude from ending its turn. What the hook printed to stderr goes to Claude as the reason ([Exit code 2 behavior per event](https://code.claude.com/docs/en/hooks#exit-code-2-behavior-per-event)).
These are the events this lesson uses, and where they fall in a turn:
```mermaid
flowchart LR
accTitle: Where hook events fire in a turn
- accDescr: A session starts with SessionStart. Each prompt fires UserPromptSubmit. Before each tool call, PreToolUse runs; exit code 2 blocks the call. After a successful call, PostToolUse runs, then Claude may call another tool. When Claude finishes responding, Stop fires. Notification fires on its own whenever Claude Code needs your attention.
+ accDescr: A session starts with SessionStart. Each prompt fires UserPromptSubmit. Before each tool call, PreToolUse runs; exit code 2 blocks the call. After a successful call, PostToolUse runs, then Claude may call another tool. When Claude finishes responding, Stop fires; exit code 2 sends Claude back to work.
S[SessionStart] --> U[UserPromptSubmit]
U --> P[PreToolUse]
P -->|exit 2| B[Call blocked, stderr goes to Claude]
@@ -29,10 +29,10 @@ flowchart LR
T --> Q[PostToolUse]
Q -->|next tool call| P
Q --> E[Stop]
- N[Notification, when Claude Code needs you]
+ E -->|exit 2| K[Claude keeps working]
```
-A matcher picks the tools a hook watches: `Edit|Write` runs it for those two tools only ([Filter hooks with matchers](https://code.claude.com/docs/en/hooks-guide#filter-hooks-with-matchers)). `PreToolUse` hooks fire before the permission-mode check, so a block holds in every mode ([Hooks and permission modes](https://code.claude.com/docs/en/hooks-guide#hooks-and-permission-modes)).
+A matcher picks the tools a hook watches: `Edit|Write` runs it for those two tools only ([Filter hooks with matchers](https://code.claude.com/docs/en/hooks-guide#filter-hooks-with-matchers)). `PreToolUse` hooks fire before the permission-mode check, so switching permission modes doesn't get around a block ([Hooks and permission modes](https://code.claude.com/docs/en/hooks-guide#hooks-and-permission-modes)). A hook can fail too: a missing script, a crash or a timeout. On most events Claude Code then carries out the action, so a guard hook sets `"onFailure": "block"` ([Block the action when a hook fails](https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails)).
## Worked example
@@ -46,13 +46,13 @@ A matcher picks the tools a hook watches: `Edit|Write` runs it for those two too
chmod +x .claude/hooks/*.sh
```
- `protect-files.sh` is the hooks guide's script for blocking edits to `.env`, `package-lock.json` and `.git/`. `format-after-edit.sh` removes trailing spaces from a source file after Claude edits it.
+ `protect-files.sh` is the hooks guide's script for blocking edits to `.env`, `package-lock.json` and `.git/`. Lesson 4's `Read(./.env)` rule already blocks Edit and Write on `.env` ([Read and Edit](https://code.claude.com/docs/en/permissions#read-and-edit)); the hook adds paths no rule names. `format-after-edit.sh` removes trailing spaces from a source file after Claude edits it.
2. Register them in `.claude/settings.json`, beside the `permissions` block from lesson 4:
```json
"hooks": {
"PreToolUse": [
- { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/protect-files.sh", "args": [] } ] }
+ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/protect-files.sh", "args": [], "onFailure": "block" } ] }
],
"PostToolUse": [
{ "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/format-after-edit.sh", "args": [] } ] }
@@ -60,7 +60,7 @@ A matcher picks the tools a hook watches: `Edit|Write` runs it for those two too
}
```
- With `"args": []`, Claude Code runs the script directly, without a shell, so the path needs no quotes ([Exec form and shell form](https://code.claude.com/docs/en/hooks#exec-form-and-shell-form)).
+ With `"args": []`, Claude Code runs the script directly, without a shell, so the path needs no quotes ([Exec form and shell form](https://code.claude.com/docs/en/hooks#exec-form-and-shell-form)). `"onFailure": "block"` makes the protection fail closed: if the script can't start, crashes or times out, the edit is blocked instead of let through.
3. Test the hook without Claude, by piping in the JSON an Edit call would send. Edit and Write always send an absolute path ([PreToolUse input](https://code.claude.com/docs/en/hooks#pretooluse-input)), so build it from `$PWD`:
```bash
@@ -68,77 +68,77 @@ A matcher picks the tools a hook watches: `Edit|Write` runs it for those two too
```
It prints a `Blocked:` line and `exit 2`.
-4. Start `claude` and run `/hooks`: your hooks appear under `PreToolUse` and `PostToolUse` ([Debug your configuration](https://code.claude.com/docs/en/debug-your-config#check-hooks)).
-5. Ask for an edit the hook protects. In the practice template, `package-lock.json` exists; in your repository, name a protected file that it has:
+4. Start `claude` and run `/hooks`: your hooks appear under `PreToolUse` and `PostToolUse` ([Debug your configuration](https://code.claude.com/docs/en/debug-your-config#check-hooks)). Then ask for an edit the hook protects. In the practice template, `package-lock.json` exists; in your repository, name a protected file that it has:
```text
Use your Edit tool, not a shell command, to change the top-level version in package-lock.json to 1.0.1.
```
The Edit is blocked: Claude Code passes your script's `Blocked:` message to Claude as feedback ([Exit code output](https://code.claude.com/docs/en/hooks#exit-code-output)). Ask for the Edit tool by name here: Claude can also edit a file through a shell command, which an `Edit|Write` hook doesn't see.
+5. Break the hook on purpose, to see it fail closed. In a terminal, rename the script, `mv .claude/hooks/protect-files.sh .claude/hooks/protect-files.off`, and repeat the step 4 request. Claude Code can't start the hook, so it blocks the edit, and the error says the hook `failed; blocking because onFailure is "block"` ([Block the action when a hook fails](https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails)). Put the script back: `mv .claude/hooks/protect-files.off .claude/hooks/protect-files.sh`.
## Your turn
-The guide's script matches substrings. `*".env"*` also blocks `.env.example`, which teams commit on purpose, and a file such as `src/config.envelope.ts`; and nothing blocks a `secrets/` folder. Replace `.claude/hooks/protect-files.sh` with this skeleton, which keeps the guide's `package-lock.json` and `.git/` blocks, and finish it:
+Claude sometimes stops while the tests fail: send it back to work when it does, in every session.
-```bash
-#!/bin/bash
-INPUT=$(cat)
-FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
-FILE_PATH="${FILE_PATH//\\//}"
-NAME=$(basename "$FILE_PATH")
+1. Three lines in the team's `CLAUDE.md` ask for different things: never edit `secrets/`, run the tests before finishing, prefer small functions. The first must hold before an edit, so it belongs in a `PreToolUse` guard like the one above. The second must hold when Claude finishes, so it belongs in a `Stop` hook. The third is judgment no script can check, so it stays advice in `CLAUDE.md`. Save this skeleton as `.claude/hooks/test-gate.sh`, and finish both TODOs:
-case "/$FILE_PATH" in
- */package-lock.json | */.git/*)
- echo "Blocked: $FILE_PATH is protected" >&2
- exit 2
- ;;
-esac
+ ```bash
+ #!/bin/bash
+ INPUT=$(cat)
+ cd "$CLAUDE_PROJECT_DIR"
-# TODO: block a file named .env, or .env. followed by anything except example
-# TODO: block any file inside a secrets/ folder
+ # TODO: exit 0 when stop_hook_active is true, so Claude can stop after one retry
+ # TODO: run the test command; if it fails, print a reason to stderr and exit 2
-exit 0
-```
+ exit 0
+ ```
-1. Choose a narrower environment-file match so `src/config.envelope.ts` is allowed. Finish both TODOs. Each block prints a `Blocked:` reason to stderr and exits with 2; everything else exits with 0.
-2. Run the Check's test table until every row gives its expected exit code.
-3. In a session, ask Claude to use its Write tool to create `secrets/test.key`. Your hook blocks it.
-4. Review and commit both hook scripts and `.claude/settings.json`, including the formatter you downloaded. Keep the protection script executable: `git ls-files -s .claude/hooks/protect-files.sh` starts with `100755` ([Git ls-files](https://git-scm.com/docs/git-ls-files)).
+ A `Stop` hook runs when Claude finishes responding, and exit code 2 sends Claude back to work with your stderr as the reason ([Stop](https://code.claude.com/docs/en/hooks#stop)). Once the hook has sent Claude back, its input has `stop_hook_active` set to `true`: exit 0 then, so a failure Claude can't fix doesn't keep it working ([Stop hook hits the block cap](https://code.claude.com/docs/en/hooks-guide#stop-hook-hits-the-block-cap)). Run your tests by the command's name, with their output on stdout, such as `npm test 2>&1`, and print only your own reason to stderr: if stdout is empty and stderr says a file is missing, Claude Code treats a `Stop` hook's exit 2 as a non-blocking error ([Exit code output](https://code.claude.com/docs/en/hooks#exit-code-output)). You can ask Claude to write it; either way, step 3 decides when it's done.
+2. Make it executable, `chmod +x .claude/hooks/test-gate.sh`, and register it in the same `hooks` block. `Stop` takes no matcher ([Matcher patterns](https://code.claude.com/docs/en/hooks#matcher-patterns)):
-## Check
+ ```json
+ "Stop": [
+ { "hooks": [ { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/test-gate.sh", "args": [] } ] }
+ ]
+ ```
-You are done when all of these are true:
+3. Test the gate without Claude, from your repository's root. With your tests passing, this prints `exit 0`. Break one test on purpose and run it again: `exit 2`, after the tests' output and your reason. With the test still broken, send `{"stop_hook_active":true}` instead: `exit 0`. Then undo the broken test.
-- [ ] Each path gives its expected exit code: 2 for `.env`, `config/.env.local`, `secrets/api.key`, `package-lock.json` and `.git/config`; 0 for `.env.example`, `src/config.envelope.ts` and `src/app.js`. Run this from your repository's root:
+ ```bash
+ echo '{"stop_hook_active":false}' | CLAUDE_PROJECT_DIR=$PWD .claude/hooks/test-gate.sh; echo "exit $?"
+ ```
+
+4. Review and commit the three hook scripts, the formatter you downloaded included, and `.claude/settings.json`. Keep the scripts executable: `git ls-files -s .claude/hooks` shows `100755` for each ([Git ls-files](https://git-scm.com/docs/git-ls-files)).
+5. See the gate in a session. Break one test on purpose again, start `claude`, and ask a question that needs no edit, such as `Which file holds the link parser?` When Claude finishes its answer, the gate runs the tests and sends it back to work with your reason. Then restore the test you broke with git, and check that `git status --short` prints nothing.
- ```bash
- for p in .env config/.env.local .env.example secrets/api.key src/config.envelope.ts src/app.js package-lock.json .git/config; do
- printf '%s ' "$p"; echo "{\"tool_input\":{\"file_path\":\"$PWD/$p\"}}" | .claude/hooks/protect-files.sh 2>/dev/null; echo $?
- done
- ```
+## Check
+
+You are done when all of these are true:
-- [ ] The script is committed and executable, and the committed `.claude/settings.json` runs it as a `PreToolUse` hook for `Edit|Write`: `git show HEAD:.claude/settings.json | jq .hooks.PreToolUse` shows it.
-- [ ] Self-check (not tested): Claude's attempt to create `secrets/test.key` was blocked with your `Blocked:` message.
+- [ ] Both hook scripts are committed and executable: `git ls-files -s .claude/hooks` shows `100755` for `protect-files.sh` and `test-gate.sh`.
+- [ ] The committed `.claude/settings.json` runs `protect-files.sh` as a `PreToolUse` hook for `Edit|Write` with `"onFailure": "block"`, and `test-gate.sh` as a `Stop` hook: `git show HEAD:.claude/settings.json | jq .hooks` shows both.
+- [ ] The committed gate gives step 3's results: exit 2 with a reason while the tests fail, and exit 0 once they pass or when `stop_hook_active` is `true`.
+- [ ] Self-check (not tested): in a session, the gate sent Claude back to work while a test failed.
Run `npm run check -- i-5 --dir <your repo>` from your practice copy, or `npm run check -- i-5` in the copy itself.
-If every row gives an unexpected result, run `bash -n .claude/hooks/protect-files.sh` to check the syntax, then run one row without `2>/dev/null` to read its error ([Bash manual](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html)). If a row is wrong, test that path alone and print the name the script sees: `basename` of `.env.local` is `.env.local`, so a `case` pattern `.env.*` matches it. The check runs the committed script, so commit each fix before you run it. If the second item fails on the file mode, run `chmod +x .claude/hooks/protect-files.sh`, then `git add` it and commit again.
+If a script item fails on the file mode, run `chmod +x` on the script, then `git add` it and commit again. If the settings item fails, compare your `hooks` block with Worked example step 2 and Your turn step 2, and commit it. If the gate item fails, run step 3's three cases on the committed script, read which one gives the wrong exit code, and check that the tests' output goes to stdout.
## Watch out
- Hooks run with your user's rights: in an interactive session once you trust the folder, and in a `claude -p` run without asking ([Workspace trust](https://code.claude.com/docs/en/hooks#workspace-trust)). Read a repository's hooks before you trust it or script Claude Code in it.
- An `Edit|Write` hook doesn't see shell commands: `echo X >> .env` goes through Bash. Lesson 4's `Read` rules stop commands such as `cat .env` from reading those files, but a write such as that `>>` is checked against `Edit` rules, which lesson 4 doesn't add ([Redirections](https://code.claude.com/docs/en/permissions#redirections)). For a hook that sees every change, the hooks guide adds a `Bash|PowerShell` matcher or a `Stop` hook that scans the working tree ([Filter hooks with matchers](https://code.claude.com/docs/en/hooks-guide#filter-hooks-with-matchers)).
-- A Notification hook, such as the example [`desktop-notify.sh`](../../examples/intermediate/05-hooks/dot-claude/hooks/desktop-notify.sh), is about you, not the project: the hooks guide registers its notification examples in `~/.claude/settings.json`. Do the same, with the path to wherever you keep the script.
+- A `Stop` hook fires whenever Claude finishes responding, not only when a task is done ([Limitations](https://code.claude.com/docs/en/hooks-guide#limitations)), so the gate runs your tests after every answer. Keep its command fast.
## Go further
- [Automate actions with hooks](https://code.claude.com/docs/en/hooks-guide): more ready-made hooks, including notifications and re-injecting context after compaction.
- [Hooks reference](https://code.claude.com/docs/en/hooks): every event, its input and its output.
-- [Debug your configuration](https://code.claude.com/docs/en/debug-your-config#check-hooks): what to check when a hook doesn't fire.
+- [Keep Claude working toward a goal](https://code.claude.com/docs/en/goal): `/goal`, a session-scoped Stop hook that a model evaluates, for a condition no script can check.
---
-<sub>Sources: [Automate actions with hooks](https://code.claude.com/docs/en/hooks-guide) · [Hooks reference](https://code.claude.com/docs/en/hooks) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Debug your configuration](https://code.claude.com/docs/en/debug-your-config) · [Git ls-files](https://git-scm.com/docs/git-ls-files) · [Bash manual](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html)</sub>
+<sub>Sources: [Automate actions with hooks](https://code.claude.com/docs/en/hooks-guide) · [Hooks reference](https://code.claude.com/docs/en/hooks) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Debug your configuration](https://code.claude.com/docs/en/debug-your-config) · [Git ls-files](https://git-scm.com/docs/git-ls-files)</sub>
<sub>← [Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md) · [Intermediate index](README.md) · [Delegate to a custom subagent](06-subagents.md) → · Topic: [Hooks](../topics/hooks.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-5)</sub>
diff --git a/docs/intermediate/06-subagents.md b/docs/intermediate/06-subagents.md
index 7f023be..a08d165 100644
--- a/docs/intermediate/06-subagents.md
+++ b/docs/intermediate/06-subagents.md
@@ -1,6 +1,6 @@
# Delegate to a custom subagent
-<sub>**Intermediate** · Lesson 6 of 8 · about 25 minutes · Needs: [Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Intermediate** · Lesson 6 of 8 · about 25 minutes · Needs: [Turn a repeated workflow into a skill](01-first-skill.md), [Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -9,7 +9,7 @@ By the end of this lesson you can write a subagent that has only the tools its t
## You need
- One of your own repositories, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both.
-- A small source change and its regression test that you are ready to review and keep. If you have no pending work, add a useful behavior in your repository, such as a CLI help response, and test it first.
+- The commit you made with `/tdd` in [lesson 1](01-first-skill.md): its SHA is in `.practice/i-1-commit.txt`.
- `jq`, for the delegation log in Your turn.
- Usage: light to moderate. Each delegation starts a second context window.
@@ -46,27 +46,26 @@ Delegate a task whose output you don't need in full, or that should run with res
tools: Read, Grep, Glob
```
-2. Start `claude`. If a session was already running when you created `.claude/agents/`, restart it: Claude Code watches only the agent folders that existed when the session started ([Write subagent files](https://code.claude.com/docs/en/sub-agents#write-subagent-files)). Keep [auto mode](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in) for this lesson. If Claude Code asks about an action, inspect its target before answering.
-3. Review the source change and its regression test, run your project's tests, then commit only those files. Keep this commit at `HEAD` while both reviewers work. In a terminal in your repository, `git show --stat --oneline HEAD` lets you confirm its scope ([Git show](https://git-scm.com/docs/git-show)). Leave unrelated work out of the review.
-4. Ask your main conversation to collect that commit's diff and give it to the custom reviewer:
+2. Start `claude`. If a session was already running when you created `.claude/agents/`, restart it: Claude Code watches only the agent folders that existed when the session started ([Write subagent files](https://code.claude.com/docs/en/sub-agents#write-subagent-files)). Keep [auto mode](https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in) for this lesson.
+3. Ask your main conversation to collect the diff of your lesson 1 commit and give it to the custom reviewer:
```text
- Use the code-reviewer agent to review HEAD^..HEAD. First collect that diff and pass it the diff and changed filenames. Ask for a report only. Do not edit files.
+ Use the code-reviewer agent to review the commit in .practice/i-1-commit.txt: pass it that commit's diff and filenames. Ask for a report only. Do not edit files.
```
- The reviewer can't run `git diff`, so your main conversation must supply it. Wait for the completed report. Subagents normally run in the background and return their result later ([Run subagents in foreground or background](https://code.claude.com/docs/en/sub-agents#run-subagents-in-foreground-or-background)); `/tasks` lists background work ([Commands](https://code.claude.com/docs/en/commands)). A disappearing activity row does not prove the report is ready. Then you get its findings as a summary, grouped by severity. Your wording will differ.
-5. Review the same commit with the bundled skill, which accepts a Git revision range ([Review locally with `/code-review`](https://code.claude.com/docs/en/code-review-local#choose-what-to-review)):
+ The reviewer can't run `git diff`, so your main conversation must supply it. Wait for the completed report; `/tasks` lists background work ([Commands](https://code.claude.com/docs/en/commands)). Its findings come back as a summary. Your wording will differ. After Claude responds, Claude Code can suggest your next prompt, such as a follow-up step; this step edits nothing, so start typing to dismiss a suggestion you don't want ([Prompt suggestions](https://code.claude.com/docs/en/interactive-mode#prompt-suggestions)).
+4. Review the same commit with the bundled skill, which accepts a Git revision range ([Review locally with `/code-review`](https://code.claude.com/docs/en/code-review-local#choose-what-to-review)). Put the SHA from `.practice/i-1-commit.txt` in place of `<sha>`:
```text
- /code-review HEAD^..HEAD
+ /code-review <sha>^..<sha>
```
- Without `--fix`, the bundled skill asks for a report only ([What the review reads and edits](https://code.claude.com/docs/en/code-review-local#what-the-review-reads-and-edits)). That instruction differs from the custom reviewer's tool restriction: the custom reviewer has no file-editing or shell tool. Run `git status --short` after each review to inspect what actually happened ([Git status](https://git-scm.com/docs/git-status)).
-6. Compare the reports against the same diff. Pick a finding and prove or refute it with a targeted test before changing code. If neither report finds a bug, check an edge case yourself; do not invent a defect to satisfy the exercise. Review and commit any justified correction and `.claude/agents/code-reviewer.md`. Keep the useful source change, and leave unrelated work as you found it.
+ Without `--fix`, the bundled skill asks for a report only ([What the review reads and edits](https://code.claude.com/docs/en/code-review-local#what-the-review-reads-and-edits)). That instruction differs from the custom reviewer's tool restriction: the custom reviewer has no file-editing or shell tool. Run `git status --short` now, after both reviews, to inspect what actually happened ([Git status](https://git-scm.com/docs/git-status)).
+5. Compare the reports against the same diff. A reviewer asked to find gaps usually reports some, even when the work is sound: act on a finding that affects correctness or the requirements, after a targeted test shows it is real ([Add an adversarial review step](https://code.claude.com/docs/en/best-practices#add-an-adversarial-review-step)). Review and commit any justified fix and `.claude/agents/code-reviewer.md`.
## Your turn
-Finish a read-only subagent that finds code no test calls, then delegate to it.
+Hand the noisy search for untested code to a read-only helper, and keep only its findings. Finish a subagent that finds code no test calls, then delegate to it.
1. A teammate asks to find missing tests and add them. Decide which part belongs in a read-only report and which part stays in your main conversation. Save this as `.claude/agents/test-gaps.md`, and replace both `TODO`s. Give it only read-only tools:
@@ -81,7 +80,7 @@ Finish a read-only subagent that finds code no test calls, then delegate to it.
Report each by file and suggest a test. If all are called, say so.
```
- Write the description on one line, with at least eight words: what it reports and when Claude should delegate to it. Keep writing tests outside its stated task. A call in a test is a lead for investigation, not proof that the function's behavior is well tested.
+ Write the description on one line, with at least eight words: what it reports and when Claude should delegate to it. Keep writing tests outside its stated task. A call in a test is a lead for investigation, not proof that the function's behavior is well tested. For tools, give it only `Read`, `Grep` and `Glob`: it needs no shell and no web tool.
2. Commit it.
3. Save this delegation log to `.practice/i-6-hook.json`. It is a [`SubagentStart` hook](https://code.claude.com/docs/en/hooks#subagentstart) that appends the name of each subagent Claude starts to `.practice/i-6-agents.txt`, and logs nothing else:
@@ -98,18 +97,17 @@ Finish a read-only subagent that finds code no test calls, then delegate to it.
You are done when all of these are true:
- [ ] The committed subagent has its name and a description of when to use it: `git show HEAD:.claude/agents/test-gaps.md | head -5`.
-- [ ] Its tools are read-only: the `tools` line names tools such as `Read`, `Grep` and `Glob`, and no tool that edits files or runs commands, such as `Edit`, `Write` or `Bash`.
+- [ ] Its tools only read code: the `tools` line names tools such as `Read`, `Grep` and `Glob`, and no tool that edits files, runs commands or reaches the web, such as `Edit`, `Bash` or `WebFetch`.
- [ ] Claude delegated to it: `grep -x test-gaps .practice/i-6-agents.txt` prints `test-gaps`.
-- [ ] Self-check (not tested): the subagent's file reads stayed out of your conversation, and only its summary came back. You compared both reviews of the same commit with the actual diff, and checked the evidence for a finding or an edge case.
+- [ ] Self-check (not tested): the subagent's file reads stayed out of your conversation, and only its summary came back. You compared both reviews of the same commit with the actual diff, and tested a finding before acting on it.
Run `npm run check -- i-6 --dir <your repo>` from your practice copy, or `npm run check -- i-6` in the copy itself.
-If the first item fails, check the frontmatter: Claude Code skips an agent file without a `name`, and one with a `name` but no `description`. If the tools item fails, remove each tool that can change files or run commands; without a `tools` line, a subagent gets every tool. If the log has no `test-gaps` line, start the session with the hook file and name the subagent in your request.
+If the first item fails, check the frontmatter: Claude Code skips an agent file without a `name`, and one with a `name` but no `description`. If the tools item fails, remove each tool that can change files, run commands or reach the web; without a `tools` line, a subagent gets every tool. If the log has no `test-gaps` line, start the session with the hook file and name the subagent in your request.
## Watch out
- A subagent that lists `Bash` can still change files through shell commands, such as a `sed` edit or a [`> file` redirect](https://code.claude.com/docs/en/permissions#redirections), even without `Edit` or `Write`. Leave `Bash` out, and let your session pass it what a command would have shown.
-- On macOS, Linux and WSL, where Glob and Grep are absent by default, a subagent whose `tools` list names `Glob` or `Grep` and leaves out `Bash` gets the ones it names ([Glob tool behavior](https://code.claude.com/docs/en/tools-reference#glob-tool-behavior)).
## Go further
@@ -119,6 +117,6 @@ If the first item fails, check the frontmatter: Claude Code skips an agent file
---
-<sub>Sources: [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Review locally with /code-review](https://code.claude.com/docs/en/code-review-local) · [Hooks reference](https://code.claude.com/docs/en/hooks) · [Tools reference](https://code.claude.com/docs/en/tools-reference) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Commands](https://code.claude.com/docs/en/commands) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Git show](https://git-scm.com/docs/git-show) · [Git status](https://git-scm.com/docs/git-status)</sub>
+<sub>Sources: [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Review locally with /code-review](https://code.claude.com/docs/en/code-review-local) · [Best practices](https://code.claude.com/docs/en/best-practices) · [Interactive mode](https://code.claude.com/docs/en/interactive-mode) · [Hooks reference](https://code.claude.com/docs/en/hooks) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Commands](https://code.claude.com/docs/en/commands) · [CLI reference](https://code.claude.com/docs/en/cli-reference) · [Git status](https://git-scm.com/docs/git-status)</sub>
<sub>← [Enforce a rule with a hook](05-hooks.md) · [Intermediate index](README.md) · [Connect a tool with MCP](07-mcp.md) → · Topic: [Subagents and parallel work](../topics/subagents-and-parallel-work.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-6)</sub>
diff --git a/docs/intermediate/07-mcp.md b/docs/intermediate/07-mcp.md
index 7a074ae..2297e33 100644
--- a/docs/intermediate/07-mcp.md
+++ b/docs/intermediate/07-mcp.md
@@ -1,6 +1,6 @@
# Connect a tool with MCP
-<sub>**Intermediate** · Lesson 7 of 8 · about 25 minutes · Needs: [Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Intermediate** · Lesson 7 of 8 · about 25 minutes · Needs: [Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
@@ -8,7 +8,7 @@ By the end of this lesson you can connect a version-pinned MCP server at the rig
## You need
-- One of your own repositories, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's `.practice/` folder as [Beginner lesson 1](../beginner/01-install-and-look-around.md#you-need) describes, if you haven't yet.
+- One of your own repositories, and your copy of the practice template with Node.js LTS: the check runs from the copy. To practice in the template copy instead, use it for both. Set up the repository's `.practice/` folder as the [Intermediate index](README.md#prepare-your-own-repository) describes, if you haven't yet.
- Chrome, and npm, which comes with Node.js: the server runs through `npx` ([upstream requirements](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/README.md#requirements)).
- Usage: light.
@@ -33,14 +33,14 @@ Where you add a server decides who gets it ([MCP installation scopes](https://co
| Project | Everyone who works in the project | `.mcp.json` at the project root, committed |
| User | You, in every project | `~/.claude.json` |
-In an interactive session, Claude Code asks you to approve a project's servers before it uses them. Approving a server and approving an individual tool call are separate decisions.
+In an interactive session, Claude Code asks you to approve a project's servers before it uses them. Approving a server and approving an individual tool call are separate decisions. A shared `.mcp.json` never holds a token: write `${VAR}` and each teammate sets the variable ([Environment variable expansion](https://code.claude.com/docs/en/mcp#environment-variable-expansion-in-mcp-json)). With tool search, the default, only tool names and server instructions load at session start ([Scale with MCP Tool Search](https://code.claude.com/docs/en/mcp#scale-with-mcp-tool-search)).
> [!WARNING]
> Data that leaves your machine. By default, Chrome DevTools MCP sends usage statistics to Google, may send the URLs of performance traces to Google's CrUX API, and checks npm for updates ([upstream README](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/README.md)). This lesson always runs it with all three turned off. The pages Claude opens still load from the web, and the server shows Claude everything in that browser. Use the isolated browser only for this local demo, with no personal accounts or sensitive pages.
## Worked example
-1. Save this page as `.practice/demo.html` in your repository. It has a planted browser bug; leave it unfixed. Its element lookup uses a [DOM selector](https://dom.spec.whatwg.org/#dom-parentnode-queryselector):
+1. Save this page as `.practice/demo.html` in your repository. It has a planted browser bug; leave it unfixed:
```html
<!doctype html>
@@ -66,43 +66,35 @@ In an interactive session, Claude Code asks you to approve a project's servers b
Use the chrome-devtools tools to open .practice/demo.html as a file: URL. Read the title, visible count and console error. Report the error and its source location, without editing any files.
```
- If Claude Code asks about a tool call, inspect the tool name and inputs, then approve only that call ([Configure permissions](https://code.claude.com/docs/en/permissions#manage-permissions)). Do not grant a standing approval for this exercise. Read the actual tool output: the count stays at `Counting links...`, and the script fails when it tries to update an element that wasn't found. Your browser's error wording may differ. After reviewing the first call, return to auto mode with `Shift+Tab`, if available, so later calls can proceed under its checks ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)).
+ If Claude Code asks about a tool call, inspect the tool name and inputs, then approve only that call ([Configure permissions](https://code.claude.com/docs/en/permissions#manage-permissions)). Do not grant a standing approval for this exercise. Read the actual tool output: the count stays at `Counting links...`, and the script fails when it tries to update an element that wasn't found. Your browser's error wording may differ. After reviewing the first call, press `Shift+Tab` until the status bar reads `⏵⏵ auto mode on`, if auto mode is available, so later calls can proceed under its checks ([Switch permission modes](https://code.claude.com/docs/en/permission-modes#switch-permission-modes)).
## Your turn
-Share the reviewed server with your team, then use the project's tools to repair the page rather than merely capture its broken state.
+Give every teammate the exact browser server you reviewed, then use it to fix the broken demo page.
1. In the same repository's terminal, remove your local copy, which would otherwise take precedence over a project server of the same name ([Scope hierarchy and precedence](https://code.claude.com/docs/en/mcp#scope-hierarchy-and-precedence)): `claude mcp remove chrome-devtools -s local`. If it reports no local server, confirm you are in the repository where you added it; local scope belongs to that project.
-2. Save this partial file as `.mcp.json` at the repository root, and replace each `TODO` with the values from the Worked example's command. Preserve any unrelated servers already in the file:
-
- ```json
- {"mcpServers": {
- "chrome-devtools": {
- "type": "stdio",
- "command": "npx",
- "args": ["-y", "TODO: the package at an exact version", "--isolated",
- "TODO: no usage statistics", "TODO: no CrUX lookups"],
- "env": { "TODO: the variable that turns off update checks": "1" }
- }
- }}
+2. Add the same server at project scope. The command writes `.mcp.json` at the repository root, beside any servers already in it ([Project scope](https://code.claude.com/docs/en/mcp#project-scope)):
+
+ ```bash
+ claude mcp add --scope project --env CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1 --transport stdio chrome-devtools -- npx -y [email protected] --isolated --no-usage-statistics --no-performance-crux
```
-3. Review and commit `.mcp.json`.
-4. Exit the session from the Worked example, then start `claude` again in your repository. When it asks about the project's new server, approve it only if you have reviewed the server's command and arguments in `.mcp.json`. If `.mcp.json` names a server you haven't reviewed, decline and investigate. Avoid a standing approval for future servers you haven't reviewed. Inspect the selected option before pressing Enter. Run `/mcp`, select the server and check that it connected ([Edit .mcp.json directly](https://code.claude.com/docs/en/mcp-quickstart#edit-mcp-json-directly)). Keep auto mode for the repair; review any request Claude Code still asks you about.
-5. Use the project's browser tools to reload `.practice/demo.html` and read its console before editing. Decide whether the element lookup or the count calculation is at fault: compare the reported source line with the page's existing result element. Fix the mismatched lookup while keeping the calculation; hiding the exception would leave the page broken. Ask Claude to make that focused repair, then use the MCP tools to reload and verify the visible count and console. The result should read `2 links ready` with no script error. Have the server save the repaired page as a PNG to `.practice/i-7-page.png` ([Screenshot tool](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/docs/tool-reference.md#take_screenshot)).
+3. Read `.mcp.json` before you commit it: check the pinned version, the two flags and the variable, and that it holds no token. Then commit it.
+4. Exit the session from the Worked example, then start `claude` again in your repository. When it asks about the project's new server, approve it only if you have reviewed the server's command and arguments in `.mcp.json`: they decide what code runs on your machine. If `.mcp.json` names a server you haven't reviewed, decline and investigate. Run `/mcp`, select the server and check that it connected ([Edit .mcp.json directly](https://code.claude.com/docs/en/mcp-quickstart#edit-mcp-json-directly)). Keep auto mode for the repair.
+5. Use the project's browser tools to reload `.practice/demo.html` and read its console before editing. Decide whether the element lookup or the count calculation is at fault: compare the reported source line with the page's existing result element. Fix the mismatched lookup while keeping the calculation; hiding the exception would leave the page broken. Ask Claude to make that focused repair, then use the MCP tools to reload and verify the visible count and console. The result should read `2 links ready` with no script error. Then have the server save the repaired page as a PNG to `.practice/i-7-page.png` ([Screenshot tool](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/docs/tool-reference.md#take_screenshot)).
## Check
You are done when all of these are true:
- [ ] The committed `.mcp.json` pins the package to an exact version and turns off usage statistics, CrUX lookups and update checks: `git show HEAD:.mcp.json | jq '.mcpServers["chrome-devtools"]'` shows them.
-- [ ] `.practice/i-7-page.png` holds a PNG image of the repaired page.
-- [ ] The demo script displays `2 links ready` without a script error. The local check runs this demo's inline script with its link collection and an extra-link probe in a bounded Node process; a static or hardcoded count doesn't pass. Its small document adapter does not replace the Chrome verification.
+- [ ] `.practice/i-7-page.png` holds a PNG image of the repaired page, saved after the repair.
+- [ ] The demo script displays `2 links ready` without a script error; a hardcoded count doesn't pass.
- [ ] Self-check (not tested): you reviewed the first MCP tool call, used the project's server to read the real console error, and verified the repaired count and clean console after reloading.
Run `npm run check -- i-7 --dir <your repo>` from your practice copy, or `npm run check -- i-7` in the copy itself.
-If the server item fails, compare each argument with the Worked example's command: `@latest` isn't pinned. If the capture is missing, confirm the server connected before asking it to save the PNG. If the demo item fails, revisit Your turn step 5: removing the script or swallowing its error doesn't repair the count.
+If the server item fails, compare each argument with the Worked example's command: `@latest` isn't pinned. If the capture is missing or older than the repair, confirm the server connected, then ask it to save the PNG again. If the demo item fails, revisit Your turn step 5: removing the script or swallowing its error doesn't repair the count.
## Watch out
@@ -121,6 +113,6 @@ Listings checked against the listing bar on 2026-10-06.
---
-<sub>Sources: [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp) · [Connect to MCP servers](https://code.claude.com/docs/en/mcp-quickstart) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Chrome DevTools MCP README](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/README.md) · [Chrome DevTools MCP configuration](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/docs/configuration.md) · [Chrome DevTools MCP tools](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/docs/tool-reference.md) · [The MCP Registry](https://modelcontextprotocol.io/registry/about) · [DOM selectors](https://dom.spec.whatwg.org/#dom-parentnode-queryselector)</sub>
+<sub>Sources: [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp) · [Connect to MCP servers](https://code.claude.com/docs/en/mcp-quickstart) · [Configure permissions](https://code.claude.com/docs/en/permissions) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Chrome DevTools MCP README](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/README.md) · [Chrome DevTools MCP configuration](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/docs/configuration.md) · [Chrome DevTools MCP tools](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/docs/tool-reference.md) · [The MCP Registry](https://modelcontextprotocol.io/registry/about)</sub>
<sub>← [Delegate to a custom subagent](06-subagents.md) · [Intermediate index](README.md) · [Install and manage plugins](08-plugins.md) → · Topic: [MCP](../topics/mcp.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-7)</sub>
diff --git a/docs/intermediate/08-plugins.md b/docs/intermediate/08-plugins.md
index dd04a06..c8bd8e6 100644
--- a/docs/intermediate/08-plugins.md
+++ b/docs/intermediate/08-plugins.md
@@ -1,10 +1,10 @@
# Install and manage plugins
-<sub>**Intermediate** · Lesson 8 of 8 · about 25 minutes · Needs: [Turn a repeated workflow into a skill](01-first-skill.md), [Enforce a rule with a hook](05-hooks.md), [Delegate to a custom subagent](06-subagents.md), [Connect a tool with MCP](07-mcp.md) · Verified against Claude Code v2.1.292 (stable) on 2026-10-21</sub>
+<sub>**Intermediate** · Lesson 8 of 8 · about 25 minutes · Needs: [Turn a repeated workflow into a skill](01-first-skill.md), [Enforce a rule with a hook](05-hooks.md), [Delegate to a custom subagent](06-subagents.md), [Connect a tool with MCP](07-mcp.md) · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
## Goal
-By the end of this lesson you can choose a plugin's scope, use a plugin workflow and code intelligence on your code, and disable or remove a plugin you no longer need.
+By the end of this lesson you can judge a plugin before you install it, trial code intelligence locally on your own code, and share only the plugin your team chose.
## You need
@@ -14,7 +14,7 @@ By the end of this lesson you can choose a plugin's scope, use a plugin workflow
## The idea
-A [plugin](https://code.claude.com/docs/en/plugins/overview) packages skills, agents, hooks, MCP servers or language servers. A marketplace is its catalog; `claude-plugins-official` is [Anthropic's official marketplace](https://code.claude.com/docs/en/plugins/anthropic-marketplaces). Review the components before installing.
+A [plugin](https://code.claude.com/docs/en/plugins/overview) packages skills, agents, hooks, MCP servers or language servers. A marketplace is its catalog. `claude-plugins-official` is [Anthropic's official marketplace](https://code.claude.com/docs/en/plugins/anthropic-marketplaces), but most of what it lists comes from partners and other authors, and a marketplace's name tells you who publishes the catalog, not what each plugin does ([Plugin security and trust](https://code.claude.com/docs/en/plugins/security)). Review the components before installing.
The [install scope](https://code.claude.com/docs/en/plugins/install#choose-an-install-scope) decides who gets the enabled setting:
@@ -30,50 +30,34 @@ A shared setting does not download the plugin to a teammate's machine. They inst
## Worked example
-1. Start `claude` in your repository and stay in auto mode. Open the `commit-commands` plugin (Anthropic):
-
- ```text
- /plugin install commit-commands@claude-plugins-official
- ```
-
- Nothing installs until you review the details and choose a scope ([Install a plugin](https://code.claude.com/docs/en/plugins/install#install-a-plugin)). Read **Will install**, then choose **Install for you, in this repo only (local scope)**. Plugin commands have the plugin's prefix, such as `/commit-commands:commit`.
-2. Add code intelligence for your language. For JavaScript or TypeScript, use `typescript-lsp` (Anthropic). Its [README](https://github.com/anthropics/claude-plugins-official/tree/main/plugins/typescript-lsp) names the required language server. On 2026-10-21, that server's [own installation instructions](https://github.com/typescript-language-server/typescript-language-server#installing) use the following command (`typescript-language-server`, Community):
+1. Install the language server first: a code intelligence plugin says which command starts it, but doesn't include it ([Install a code intelligence plugin](https://code.claude.com/docs/en/plugins/code-intelligence#install-a-code-intelligence-plugin)). For JavaScript or TypeScript, the plugin is `typescript-lsp` (Anthropic), and its [README](https://github.com/anthropics/claude-plugins-official/tree/main/plugins/typescript-lsp) names the binary. On 2026-10-21, that server's [own installation instructions](https://github.com/typescript-language-server/typescript-language-server#installing) use the following command (`typescript-language-server`, Community). In a terminal in your repository:
```bash
npm install -g typescript-language-server typescript@6
command -v typescript-language-server
- claude plugin install typescript-lsp@claude-plugins-official --scope local
```
- For another supported language, use the matching plugin and binary from the [official table](https://code.claude.com/docs/en/plugins/code-intelligence#install-a-code-intelligence-plugin). Exit the old Claude Code session with `/exit`, then start `claude` again from this repository. Shell-installed plugins load in a new session; `/reload-plugins` can apply them to an existing session ([Plugin commands](https://code.claude.com/docs/en/plugins/cli-reference)).
-
- Choose a function your planned change could affect. Replace the placeholders and ask:
+ For another supported language, use the matching plugin and binary from that page's table.
+2. Start `claude` in your repository and stay in auto mode. Open the plugin:
```text
- Use the LSP tool to find the definition and references of <symbol> in <file>. Explain which caller my planned change could affect. Do not edit files yet.
+ /plugin install typescript-lsp@claude-plugins-official
```
- Inspect the `LSP` tool result and open a returned location. A text search alone does not demonstrate language-server navigation ([LSP tool behavior](https://code.claude.com/docs/en/tools-reference#lsp-tool-behavior)). If the server cannot start, open `/plugin` and check **Errors**, then verify the server binary is on the launching shell's `PATH`. Make the small intended change and run your tests. After a matching-file edit, the server can report diagnostics; inspect any reported issue rather than assuming the build is correct.
-3. Review the complete diff, including unstaged files, and keep only the intended change in this commit. Run the plugin's commit workflow ([its command](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/commit-commands/commands/commit.md)):
+ If Claude Code says `Marketplace "claude-plugins-official" not found`, the official marketplace isn't registered on this machine yet, for example because you've only used Claude Code in VS Code. Add it with `/plugin marketplace add anthropics/claude-plugins-official`, then open the plugin again ([Marketplace not found](https://code.claude.com/docs/en/plugins/troubleshooting#marketplace-claude-plugins-official-not-found)). Nothing installs until you review the details and choose a scope ([Install a plugin](https://code.claude.com/docs/en/plugins/install#install-a-plugin)). Read **Will install**, and **Context cost**, its token estimates for every turn and for when its skills and agents load. Then choose **Install for you, in this repo only (local scope)**. A confirmation says whether the plugin is active now or needs `/reload-plugins`.
+3. Confirm the server starts: it starts the first time Claude edits a file the plugin handles. Ask Claude to introduce a type error or a syntax error in one of your source files and then fix it, and look for a `Found N new diagnostic issues` line after the edit ([Install a code intelligence plugin](https://code.claude.com/docs/en/plugins/code-intelligence#install-a-code-intelligence-plugin)). If none appears, open `/plugin` and check **Errors**, then verify the server binary is on the launching shell's `PATH`.
- ```text
- /commit-commands:commit Commit only the reviewed change. Do not push. Do not add AI attribution or co-author trailers.
- ```
-
- Read `git show --stat HEAD` and the commit diff. Confirm it contains the tested change and no unrelated files. The plugin has now done repository work, rather than merely appearing in a list.
-4. Manage the trial from a terminal in this repository ([Plugin commands](https://code.claude.com/docs/en/plugins/cli-reference)):
+ Decide the small change you'll make, and choose a function it could affect. Replace the placeholders and ask:
- ```bash
- claude plugin list
- claude plugin disable commit-commands@claude-plugins-official --scope local
- claude plugin uninstall commit-commands@claude-plugins-official --scope local
+ ```text
+ Use the LSP tool to find the definition and references of <symbol> in <file>. I plan to <change>. Explain which callers that change could affect. Do not edit files yet.
```
- `disable` turns the plugin off and keeps it installed; `uninstall` removes the installation. Leave the language plugin enabled for the rest of the lesson.
+ Inspect the `LSP` tool result and open a returned location. A text search alone does not demonstrate language-server navigation ([LSP tool behavior](https://code.claude.com/docs/en/tools-reference#lsp-tool-behavior)). Make the small intended change, run your tests, review the diff and commit it.
## Your turn
-Choose what the team should share, rather than sharing every plugin from your trial. Use `claude-code-setup` (Anthropic) to identify and implement a useful improvement to this repository.
+Share only the plugin the team chose, so nobody pulls in the trial you're still judging. Use `claude-code-setup` (Anthropic) to find a gap in this repository's setup.
1. Merge this block into `.claude/settings.json`, preserving the earlier settings, and replace the `TODO` with the plugin's full name, `<plugin>@<marketplace>` ([Project plugin settings](https://code.claude.com/docs/en/plugins/loading#enabled-in-project-settings-but-not-installed)):
@@ -91,7 +75,7 @@ Choose what the team should share, rather than sharing every plugin from your tr
```
Review `git status`: if installation reformatted `.claude/settings.json`, review and commit that change too.
-4. Exit the existing session with `/exit`, start `claude` in this repository, and request `Recommend Claude Code automations for this project.` The plugin's [read-only skill](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/claude-code-setup/README.md) recommends automations; it does not implement them. Look for its Skill tool call. If it did not load, invoke `/claude-code-setup:claude-automation-recommender` directly. Choose a recommendation that addresses a real gap rather than duplicating an existing skill or hook. Ask Claude to implement one small improvement using your existing tools, without adding another plugin or server. Test it, review the diff and commit it. Ask for a smaller proposal if the recommendations are too broad.
+4. Exit the existing session with `/exit`, start `claude` in this repository, and request `Recommend Claude Code automations for this project.` The plugin's [read-only skill](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/claude-code-setup/README.md) recommends automations; it does not implement them. Look for its Skill tool call. If it did not load, invoke `/claude-code-setup:claude-automation-recommender` directly. Choose one recommendation that fills a real gap, rather than duplicating an existing skill or hook, and note why. Implementing it is optional.
5. Save a machine-readable install list from this repository's root ([JSON list output](https://code.claude.com/docs/en/plugins/cli-reference#plugin-list)):
```bash
@@ -107,15 +91,16 @@ You are done when all of these are true:
- [ ] The committed settings turn the plugin on for the project: `git show HEAD:.claude/settings.json | jq .enabledPlugins` shows `"claude-code-setup@claude-plugins-official": true`.
- [ ] It's installed at project scope and enabled: `jq '.[] | select(.id == "claude-code-setup@claude-plugins-official") | {scope, enabled, projectEnabled}' .practice/i-8-plugins.json` shows `"project"`, `true` and `true`.
-- [ ] Self-check (not tested): you verified an LSP definition or reference, inspected the plugin-created commit, and tested the improvement you chose from the recommendations.
+- [ ] Your code intelligence trial is installed at local scope and stays out of the committed settings: `jq '.[] | select(.scope == "local") | .id' .practice/i-8-plugins.json` shows your `-lsp` plugin.
+- [ ] Self-check (not tested): you verified an LSP definition or reference, and chose a recommendation that fills a real gap.
Run `npm run check -- i-8 --dir <your repo>` from your practice copy, or `npm run check -- i-8` in the copy itself.
-If the first item fails, check the name after `@`: it's the marketplace's name, `claude-plugins-official`, not its repository. If the second fails, install the project plugin in this repository and save the list again with `--json`.
+If the first item fails, check the name after `@`: it's the marketplace's name, `claude-plugins-official`, not its repository. If the second fails, install the project plugin in this repository and save the list again with `--json`. If the trial item fails, install your language's plugin with local scope, keep it out of `enabledPlugins` in `.claude/settings.json`, and save the list again.
## Watch out
-- A plugin's hooks and servers can run with your user's rights. Read **Will install**, and keep the MCP configuration you reviewed in lesson 7 ([Plugin security and trust](https://code.claude.com/docs/en/plugins/security)).
+- A plugin's hooks and servers can run with your user's rights. Read **Will install**, and keep the MCP configuration you reviewed in lesson 7. With auto-update on for its marketplace, a plugin's files can change after you reviewed them ([Plugin security and trust](https://code.claude.com/docs/en/plugins/security)).
- An installed language plugin can still lack a working server. Confirm the binary and an actual lookup before relying on its diagnostics.
Third-party: it can run code on your machine or give Claude new tools. Review it before installing; this guide does not audit it.
@@ -130,6 +115,6 @@ Listings checked against the listing bar on 2026-10-21.
---
-<sub>Sources: [Plugins overview](https://code.claude.com/docs/en/plugins/overview) · [Install and manage plugins](https://code.claude.com/docs/en/plugins/install) · [Anthropic's marketplaces](https://code.claude.com/docs/en/plugins/anthropic-marketplaces) · [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading) · [Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference) · [Code intelligence plugins](https://code.claude.com/docs/en/plugins/code-intelligence) · [LSP tool behavior](https://code.claude.com/docs/en/tools-reference) · [Plugin security and trust](https://code.claude.com/docs/en/plugins/security) · [Commit workflow](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/commit-commands/commands/commit.md) · [TypeScript plugin README](https://github.com/anthropics/claude-plugins-official/tree/main/plugins/typescript-lsp) · [Language server installation](https://github.com/typescript-language-server/typescript-language-server#installing) · [claude-code-setup README](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/claude-code-setup/README.md)</sub>
+<sub>Sources: [Plugins overview](https://code.claude.com/docs/en/plugins/overview) · [Install and manage plugins](https://code.claude.com/docs/en/plugins/install) · [Anthropic's marketplaces](https://code.claude.com/docs/en/plugins/anthropic-marketplaces) · [Plugin loading reference](https://code.claude.com/docs/en/plugins/loading) · [Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference) · [Code intelligence plugins](https://code.claude.com/docs/en/plugins/code-intelligence) · [Troubleshoot plugins](https://code.claude.com/docs/en/plugins/troubleshooting) · [LSP tool behavior](https://code.claude.com/docs/en/tools-reference) · [Plugin security and trust](https://code.claude.com/docs/en/plugins/security) · [TypeScript plugin README](https://github.com/anthropics/claude-plugins-official/tree/main/plugins/typescript-lsp) · [Language server installation](https://github.com/typescript-language-server/typescript-language-server#installing) · [claude-code-setup README](https://github.com/anthropics/claude-plugins-official/blob/main/plugins/claude-code-setup/README.md)</sub>
<sub>← [Connect a tool with MCP](07-mcp.md) · [Intermediate index](README.md) · [Intermediate capstone](capstone.md) → · Topic: [Plugins](../topics/plugins.md) · [Stuck on this lesson?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-8)</sub>
diff --git a/docs/intermediate/README.md b/docs/intermediate/README.md
index e34f73d..0b68af7 100644
--- a/docs/intermediate/README.md
+++ b/docs/intermediate/README.md
@@ -1,16 +1,16 @@
# Intermediate
-<sub>**Intermediate** · about 3 hours · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Intermediate** · about 4 hours · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
One developer's setup. You shape Claude Code to your own project: skills, project memory, model and effort, permissions and the sandbox, hooks, subagents, MCP servers and plugins.
## You're ready for this level if you can
-- [ ] Install Claude Code, sign in, start it in your repository, and tell which version, model and account you're on.
-- [ ] Choose and switch permission modes, and approve a plan in plan mode before any change.
+- [ ] Install Claude Code, start it safely in a repository, tell which model and account a session uses, and check its answers against the code.
+- [ ] Choose a permission mode for a task, decide when a change needs a plan, and approve only a plan you would merge.
- [ ] Take one change from request to commit: explore, plan, implement, test, review the diff, correct, commit.
-- [ ] Keep a session on track with context, clear, compact, rewind and resume.
-- [ ] Create a project CLAUDE.md and show that a new session follows it.
+- [ ] Stop or rewind a wrong turn, and choose between clear, compact and resume.
+- [ ] Create a short, true project CLAUDE.md and show that a new session follows it.
## Practice
@@ -28,15 +28,32 @@ git commit -m "Add the Intermediate checks and lessons"
A copy older than the app has no `learn` script, so `npm run learn` says `Missing script: "learn"`: run `node learn/app.mjs` instead.
+### Prepare your own repository
+
+Lessons save the files their checks read in a `.practice/` folder, in the repository you practice in. Before your first lesson in one of your own repositories, create that folder there and tell git to ignore it without a commit ([gitignore](https://git-scm.com/docs/gitignore)):
+
+```bash
+mkdir -p .practice
+echo '.practice/' >> "$(git rev-parse --git-path info/exclude)"
+```
+
+**Windows:** `New-Item -ItemType Directory -Force .practice` and `Add-Content (git rev-parse --git-path info/exclude) '.practice/'`.
+
+Your copy of the practice template already ignores `.practice/` in its `.gitignore`, so it needs neither command.
+
## When to use what
-Five of the ways to extend Claude Code; [Extend Claude Code](https://code.claude.com/docs/en/features-overview) lists the rest. Each links its lesson.
+Seven of the ways to extend Claude Code, each with the sign that you need it; [Extend Claude Code](https://code.claude.com/docs/en/features-overview#build-your-setup-over-time) lists the rest. Each links its lesson.
+- **Project memory:** Claude gets a convention or command wrong twice. Add it to `CLAUDE.md`, or to a rule in `.claude/rules/` scoped to the files it applies to ([How Claude remembers your project](https://code.claude.com/docs/en/memory); lesson: [Organize project memory and see what loaded](02-organize-memory.md)).
- **Skills:** you give Claude the same instructions or workflow again and again. A project skill lives in `.claude/skills/<name>/SKILL.md` ([Extend Claude with skills](https://code.claude.com/docs/en/skills); lesson: [Turn a repeated workflow into a skill](01-first-skill.md)).
- **Hooks:** something must happen every time at a set point in a session, such as before a tool runs, whatever Claude decides. Hooks are defined in a settings file such as `.claude/settings.json` ([Hooks](https://code.claude.com/docs/en/hooks); lesson: [Enforce a rule with a hook](05-hooks.md)).
- **Subagents:** a side task should run in its own context window and report back. A project subagent lives in `.claude/agents/` ([Create custom subagents](https://code.claude.com/docs/en/sub-agents); lesson: [Delegate to a custom subagent](06-subagents.md)).
- **Dynamic workflows:** the job needs more agents than one conversation can coordinate. A saved project workflow lives in `.claude/workflows/` ([Workflows](https://code.claude.com/docs/en/workflows); lesson: [Run and save a dynamic workflow](../advanced/03-dynamic-workflows.md)).
- **MCP servers:** Claude needs tools or data outside your files, such as a browser, a database or an API. A project-scope server is listed in `.mcp.json` at the project root ([Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp); lesson: [Connect a tool with MCP](07-mcp.md)).
+- **Code intelligence:** Claude reads many files to find where a symbol is defined or used. A code intelligence plugin gives it a language server instead ([Code intelligence plugins](https://code.claude.com/docs/en/plugins/code-intelligence); lesson: [Install and manage plugins](08-plugins.md)).
+
+Permissions decide what Claude may do in all of these, and the [sandbox](https://code.claude.com/docs/en/sandboxing) limits what its shell commands can reach ([Permissions, settings scopes and the sandbox](04-permissions-and-sandbox.md)). Model and effort tune any of them ([Pick the model and effort](03-model-and-effort.md)).
They combine: a [plugin](https://code.claude.com/docs/en/plugins) packages skills, agents, hooks and MCP servers so they install as one unit ([Install and manage plugins](08-plugins.md)).
@@ -51,11 +68,11 @@ They combine: a [plugin](https://code.claude.com/docs/en/plugins) packages skill
7. [Connect a tool with MCP](07-mcp.md)
8. [Install and manage plugins](08-plugins.md)
-Each lesson takes 10 to 20 minutes.
+Each lesson takes 20 to 25 minutes.
## Capstone
-[Get a repository ready for a new teammate](capstone.md): a skill, a hook that protects a folder, a read-only reviewer subagent, a project-scope MCP server and an official plugin, with project settings that keep secrets out of reach and turn the sandbox on.
+[Get a repository ready for a new teammate](capstone.md): turn a team lead's brief into setup a teammate gets from git, choosing the mechanism for each need, then fix a real bug with it.
## By the end of this level you can
@@ -86,6 +103,6 @@ Optional lessons beside the core path:
---
-<sub>Sources: [Extend Claude Code](https://code.claude.com/docs/en/features-overview) · [Extend Claude with skills](https://code.claude.com/docs/en/skills) · [Hooks](https://code.claude.com/docs/en/hooks) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Workflows](https://code.claude.com/docs/en/workflows) · [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp) · [Plugins](https://code.claude.com/docs/en/plugins) · [Claude Code in action](https://academy.claude.com/courses/claude-code-in-action) · [Introduction to agent skills](https://academy.claude.com/courses/introduction-to-agent-skills) · [Introduction to subagents](https://academy.claude.com/courses/introduction-to-subagents)</sub>
+<sub>Sources: [Extend Claude Code](https://code.claude.com/docs/en/features-overview) · [How Claude remembers your project](https://code.claude.com/docs/en/memory) · [Extend Claude with skills](https://code.claude.com/docs/en/skills) · [Hooks](https://code.claude.com/docs/en/hooks) · [Create custom subagents](https://code.claude.com/docs/en/sub-agents) · [Workflows](https://code.claude.com/docs/en/workflows) · [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp) · [Plugins](https://code.claude.com/docs/en/plugins) · [Code intelligence plugins](https://code.claude.com/docs/en/plugins/code-intelligence) · [Configure the sandboxed Bash tool](https://code.claude.com/docs/en/sandboxing) · [gitignore](https://git-scm.com/docs/gitignore) · [Claude Code in action](https://academy.claude.com/courses/claude-code-in-action) · [Introduction to agent skills](https://academy.claude.com/courses/introduction-to-agent-skills) · [Introduction to subagents](https://academy.claude.com/courses/introduction-to-subagents)</sub>
<sub>Up: [Claude Code: Everything You Need to Know](../../README.md#pick-your-level)</sub>
diff --git a/docs/intermediate/capstone.md b/docs/intermediate/capstone.md
index 55e3ae6..df7e22b 100644
--- a/docs/intermediate/capstone.md
+++ b/docs/intermediate/capstone.md
@@ -1,8 +1,8 @@
# Intermediate capstone: get a repository ready for a new teammate
-<sub>**Intermediate** · Capstone · 30 to 60 minutes · Needs: the eight [Intermediate lessons](README.md), or their skills · Verified against Claude Code v2.1.292 (stable) on 2026-10-15</sub>
+<sub>**Intermediate** · Capstone · 30 to 60 minutes · Needs: the eight [Intermediate lessons](README.md), or their skills · Verified against Claude Code v2.1.308 (stable) on 2026-10-25</sub>
-This task puts the whole Intermediate level together. It has no worked example: the brief says what the team needs, and you choose how to build it. The [Intermediate Exit](README.md#by-the-end-of-this-level-you-can) is the list of what you can do by the end of this level. The check reads what you commit, and you tick the rest of the Exit yourself under [What the check can't see](#what-the-check-cant-see).
+A teammate starts Monday with only what's in git: commit a setup that works like the team's. This capstone has no worked example: the brief says what goes wrong today, and you choose the mechanism for each need. The [Intermediate Exit](README.md#by-the-end-of-this-level-you-can) is the list of what you can do by the end of this level. The check reads what you commit, and you tick the rest of the Exit yourself under [What the check can't see](#what-the-check-cant-see).
## You need
@@ -13,32 +13,37 @@ This task puts the whole Intermediate level together. It has no worked example:
## The task
-A teammate starts on Monday. The brief is in `capstone/intermediate-brief.md` in your practice copy: set the repository up so their Claude Code sessions work the way the team's do, and commit all of it, because they get only what's in git.
+The brief is in `capstone/intermediate-brief.md` in your practice copy: set the repository up so the new teammate's Claude Code sessions work the way the team's do, and commit all of it. Each need below says what the team wants; pick the mechanism from what the level taught, and the check's hints point back to the lesson when an item fails.
-Build each part the way its lesson taught:
+1. **Team boundaries.** Claude must never read `.env` files. It may run `npm test` without asking, but a person approves a `git push` before it runs, even in auto mode. Shell commands run in the sandbox for everyone: `/sandbox` saves to your local file, which teammates don't get. On a machine where the sandbox can't start, such as native Windows, commands then run unsandboxed unless `sandbox.failIfUnavailable` is `true` ([sandbox.failIfUnavailable](https://code.claude.com/docs/en/settings-reference#sandbox-failifunavailable)).
+2. **`samples/` must not change.** The tests depend on the exact files there, including the link that's broken on purpose, and last week a session edited one. Make sure Claude's file-editing tools can't change them, while Claude can still edit everything else. If your protection runs a script, it must block the edit when the script can't run.
+3. **Memory that stays short.** Claude should know the npm scripts without anyone pasting them, and the testing conventions should load only when Claude works on the files under `test/`.
+4. **A job we repeat.** We keep asking Claude to run the link checker on a folder and explain each broken link. Anyone should be able to start it by name, and Claude should pick it up on its own when someone asks to check links.
+5. **A second opinion that can't change anything.** Before we commit, we want each change reviewed by something that can only read the code.
+6. **The docs in a browser.** Claude should open the docs in a browser through Chrome DevTools MCP, which we reviewed at one version. Everyone runs that version, and nothing leaves our machines that doesn't need to: usage statistics, CrUX lookups and update checks stay off.
+7. **One official plugin.** Everyone in the repository should get `claude-code-setup` from the official marketplace.
+8. **A real bug, fixed with your setup.** Reproduce the malformed-percent bug in `capstone/intermediate-bug.md` with your link-check workflow: a link such as `[broken](bad%.md)` crashes the checker instead of producing its normal broken-link report. Fix it with Claude while your protection keeps `samples/` unchanged, and tell Claude not to commit until your reviewer has reviewed the fix: in auto mode, Claude Code blocks an action that goes against a boundary you state in the conversation ([Boundaries you state in conversation](https://code.claude.com/docs/en/permission-modes#boundaries-you-state-in-conversation)). Malformed percent escapes are broken links; valid percent-encoded paths must still resolve. Add a regression test that fails before the repair and passes after it. If your copy runs lesson 5's test gate, expect it to send Claude back to work when Claude stops while that test fails. Before you commit, have your reviewer review the fix in a session started with `claude --settings .practice/i-capstone-hook.json`, lesson 6's delegation log with its own log file:
-1. **A skill** that runs the link checker on a folder and explains each broken link. It runs by name and loads on its own when someone asks to check links ([lesson 1](01-first-skill.md)).
-2. **Project memory:** `CLAUDE.md` imports `package.json`, and testing conventions live in a rule in `.claude/rules/` scoped to the files under `test/` ([lesson 2](02-organize-memory.md)).
-3. **Team settings** in the committed `.claude/settings.json`: deny reading `.env` and `.env.*` files, allow `npm test`, and turn the sandbox on ([lesson 4](04-permissions-and-sandbox.md)). `/sandbox` saves to your local file, which teammates don't get, so add `"sandbox": {"enabled": true}` to the shared one.
-4. **A hook** that blocks Claude's Edit and Write tools inside `samples/`, and only there: the tests depend on those exact files ([lesson 5](05-hooks.md)).
-5. **A reviewer subagent** with read-only tools ([lesson 6](06-subagents.md)).
-6. **Chrome DevTools MCP** at project scope, pinned, with its usage statistics, CrUX lookups and update checks off ([lesson 7](07-mcp.md)).
-7. **The `claude-code-setup` plugin**, turned on for everyone at project scope, and installed ([lesson 8](08-plugins.md)).
+ ```json
+ {"hooks":{"SubagentStart":[{"hooks":[{
+ "type":"command","command":"jq -r '.agent_type' >> \"$CLAUDE_PROJECT_DIR/.practice/i-capstone-agents.txt\""
+ }]}]}}
+ ```
-8. **A bug fix.** Reproduce the malformed-percent bug in `capstone/intermediate-bug.md`. A link such as `[broken](bad%.md)` crashes the checker instead of producing its normal broken-link report. Use your setup to diagnose and repair it. Malformed percent escapes are broken links; valid percent-encoded paths must still resolve. Add a regression test that fails before the repair and passes after it, and keep `samples/` unchanged. Commit the source fix and its regression test together.
+ Then commit the source fix and its regression test together.
-Then, in a session in auto mode ([Permission modes](https://code.claude.com/docs/en/permission-modes)), try each part: run the skill by name, ask Claude to edit a file in `samples/` with its Edit tool, delegate a review, approve the MCP server and use one of its tools. Pick the model and effort for each job as [lesson 3](03-model-and-effort.md) showed. Commit everything, and make sure `npm test` still passes.
+Then try each part in a session, and pick the model and effort for each job as [lesson 3](03-model-and-effort.md) showed. To see your `samples/` protection work, ask for the Edit tool by name and say it's a test, as in [lesson 5](05-hooks.md#worked-example): `Use your Edit tool, not a shell command, to add a blank line at the end of samples/guide.md. I'm testing whether my protection blocks it.` Claude can also change a file with a shell command, which an `Edit|Write` hook doesn't see ([Filter hooks with matchers](https://code.claude.com/docs/en/hooks-guide#filter-hooks-with-matchers)). If the edit goes through, restore the file with `git restore samples/` and fix your protection. Commit everything, and make sure `npm test` still passes.
## Check
You are done when all of these are true:
- [ ] A committed project skill runs the link checker by name and can load on its own.
-- [ ] A committed, executable `PreToolUse` hook for Edit and Write blocks `samples/` and nothing else.
-- [ ] A committed reviewer subagent has only read-only tools.
+- [ ] Claude's file-editing tools can't change `samples/`: a committed `Edit` deny rule covers the folder, or a committed, executable `PreToolUse` hook for Edit and Write blocks it, allows the rest and has `"onFailure": "block"`.
+- [ ] A committed reviewer subagent has only tools that read code, and `.practice/i-capstone-agents.txt` shows Claude delegating to it.
- [ ] The committed `.mcp.json` runs chrome-devtools-mcp at an exact version, with usage statistics, CrUX lookups and update checks off.
- [ ] The committed `.claude/settings.json` turns on a plugin from one of Anthropic's marketplaces.
-- [ ] The committed `.claude/settings.json` denies reading `.env` files and allows a narrow test command.
+- [ ] The committed `.claude/settings.json` denies reading `.env` files, allows a narrow test command, and asks before a command such as `git push`.
- [ ] The committed `.claude/settings.json` turns the sandbox on, and `.claude/settings.local.json` stays out of git.
- [ ] A committed `CLAUDE.md` imports a file with `@path`, and the file exists.
- [ ] A committed rule in `.claude/rules/` is scoped with `paths:`, and every scoped rule matches a file in the repository.
@@ -52,19 +57,17 @@ Run `npm run check -- i-capstone` in your practice copy. Each item that fails pr
The check doesn't look at these parts of the Intermediate Exit. Tick them yourself, honestly:
- [ ] I ran my skill by name, and Claude loaded it on its own when I asked it to check links.
-- [ ] I saw my hook block an Edit in `samples/` during a session.
-- [ ] I delegated a review to my subagent, and only its summary came back.
+- [ ] I saw my protection stop an Edit in `samples/` during a session.
- [ ] I approved the MCP server in a session and used one of its tools.
+- [ ] My reviewer reviewed the fix before I committed it.
- [ ] I installed the plugin with `claude plugin install claude-code-setup@claude-plugins-official --scope project`, as a teammate does after pulling the settings.
- [ ] I can pick a model and an effort level for a task, and say why.
- [ ] When Claude didn't follow an instruction, I can find out whether its file loaded.
When every box on this page is ticked, you're ready for the [Advanced level](../advanced/README.md). Its "ready if" list is the Intermediate Exit.
-If this level helped, a star helps other developers find the guide.
-
---
-<sub>Sources: [Advanced setup](https://code.claude.com/docs/en/setup) · [Permission modes](https://code.claude.com/docs/en/permission-modes) · the [Intermediate lessons](README.md), which cite the official pages for each step.</sub>
+<sub>Sources: [Advanced setup](https://code.claude.com/docs/en/setup) · [All settings](https://code.claude.com/docs/en/settings-reference) · [Choose a permission mode](https://code.claude.com/docs/en/permission-modes) · [Automate actions with hooks](https://code.claude.com/docs/en/hooks-guide) · the [Intermediate lessons](README.md), which cite the official pages for each step.</sub>
<sub>← [Install and manage plugins](08-plugins.md) · [Intermediate index](README.md) · [Advanced index](../advanced/README.md) → · [Stuck on this capstone?](https://github.com/wesammustafa/Claude-Code-Everything-You-Need-to-Know/issues/new?template=lesson-feedback.yml&lesson=i-capstone)</sub>
diff --git a/docs/reference/commands.md b/docs/reference/commands.md
index f37c22a..54cab6a 100644
--- a/docs/reference/commands.md
+++ b/docs/reference/commands.md
@@ -31,7 +31,6 @@ Electives: `/powerup` and `/output-style` ([the built-in teachers](../beginner/e
- `/permissions`: manage allow, ask and deny rules. [Permissions, settings scopes and the sandbox](../intermediate/04-permissions-and-sandbox.md)
- `/sandbox`: turn the sandbox on or off. [Permissions, settings scopes and the sandbox](../intermediate/04-permissions-and-sandbox.md)
- `/hooks`: see which hooks are configured. [Enforce a rule with a hook](../intermediate/05-hooks.md)
-- `/agents`: a reminder of how to create and manage subagents. [Delegate to a custom subagent](../intermediate/06-subagents.md)
- `/mcp`: manage MCP server connections and sign-ins. [Connect a tool with MCP](../intermediate/07-mcp.md)
- `/plugin`: browse, install and manage plugins. [Install and manage plugins](../intermediate/08-plugins.md)
@@ -42,13 +41,13 @@ Electives: `/statusline` ([The status line](../intermediate/electives/status-lin
- `claude --worktree <name>` (`-w`): start a session in an isolated git worktree at `.claude/worktrees/<name>` ([CLI reference](https://code.claude.com/docs/en/cli-reference#cli-flags)). [Parallel sessions with worktrees](../advanced/01-parallel-sessions.md)
- `/tasks`: view and manage background work in this session, including subagents that have finished. [Choose an orchestration pattern](../advanced/02-orchestration-patterns.md)
- `/workflows`: watch, pause, resume and save dynamic workflows. [Run and save a dynamic workflow](../advanced/03-dynamic-workflows.md)
-- `/deep-research <question>`: a bundled workflow that fans out web searches on a question, cross-checks the sources and writes a cited report. [Run and save a dynamic workflow](../advanced/03-dynamic-workflows.md)
+- `/goal <condition>`: keep Claude working across turns until the condition is met; `/goal clear` removes it. [Run and save a dynamic workflow](../advanced/03-dynamic-workflows.md)
- `claude -p "<prompt>"`: run one prompt without the interactive interface, print the answer and exit; a script adds `--output-format json`, `--allowedTools` and `--max-turns` ([CLI reference](https://code.claude.com/docs/en/cli-reference#cli-commands)). [Script Claude Code with `claude -p`](../advanced/04-headless.md)
-- `/install-github-app`: install the Claude GitHub App for a repository, with optional workflow and secret setup. [GitHub Actions](../advanced/05-github-actions.md)
+- `/install-github-app`: install the Claude GitHub App for a repository, with optional workflow and secret setup. [GitHub Actions](../advanced/05-github-actions.md) names it as one way to add `@claude`; its exercise uses the job's own token instead.
- `claude plugin validate <dir>`: check a marketplace or a plugin folder before you share it; `--strict` also fails on warnings ([Plugin commands reference](https://code.claude.com/docs/en/plugins/cli-reference#plugin-validate)). [Share your setup with a team](../advanced/06-share-your-setup.md)
- `/usage`: the session's cost, your plan's usage limits and activity stats. [Put bounds on autonomous runs](../advanced/07-bounded-runs.md)
-Electives: `claude agents` and `/background` ([Agent view](../advanced/electives/agent-view.md)); `/goal`, `/loop` and `/schedule` ([`/goal`, `/loop` and routines](../advanced/electives/goal-loop-routines.md)); `claude plugin eval` ([Testing and publishing a plugin](../advanced/electives/publish-a-plugin.md)).
+Electives: `claude agents` and `/background` ([Agent view](../advanced/electives/agent-view.md)); `/loop` and `/schedule` ([`/loop` and cloud scheduled tasks](../advanced/electives/goal-loop-routines.md)); `claude plugin eval` ([Testing and publishing a plugin](../advanced/electives/publish-a-plugin.md)).
<a id="custom-slash-commands-skills"></a>
## Your own commands
diff --git a/docs/reference/feature-map.md b/docs/reference/feature-map.md
index 61944fa..f403104 100644
--- a/docs/reference/feature-map.md
+++ b/docs/reference/feature-map.md
@@ -39,7 +39,7 @@ How to read it:
| [Sandbox](https://code.claude.com/docs/en/sandboxing); taught in [Permissions, settings scopes and the sandbox](../intermediate/04-permissions-and-sandbox.md) and [Put bounds on autonomous runs](../advanced/07-bounded-runs.md) | – | Every provider |
| [Output styles](https://code.claude.com/docs/en/output-styles); taught in [the built-in teachers](../beginner/electives/built-in-teachers.md) | – | Every provider |
| [Status line](https://code.claude.com/docs/en/statusline); taught in [The status line](../intermediate/electives/status-line.md) | – | Every provider |
-| [`/goal`](https://code.claude.com/docs/en/goal); taught in [`/goal`, `/loop` and routines](../advanced/electives/goal-loop-routines.md) | – | Every provider |
+| [`/goal`](https://code.claude.com/docs/en/goal); taught in [Run and save a dynamic workflow](../advanced/03-dynamic-workflows.md) | – | Every provider |
| [`/powerup`](https://code.claude.com/docs/en/commands); taught in [the built-in teachers](../beginner/electives/built-in-teachers.md) | – | The docs state no limit |
| [Fast mode](https://code.claude.com/docs/en/fast-mode); taught in [Fast mode](../intermediate/electives/fast-mode.md) | "Fast mode is in research preview." | A Claude subscription, paid for with usage credits (an Owner turns it on for Team and Enterprise), and Console organizations with access provisioned; not Claude Platform on AWS, Bedrock, Agent Platform or Foundry |
| [Advisor](https://code.claude.com/docs/en/advisor) | "The advisor tool is experimental and requires the Anthropic API." | A Claude subscription and the Console |
@@ -68,8 +68,8 @@ How to read it:
| [Agent teams](https://code.claude.com/docs/en/agent-teams); taught in [Agent teams](../advanced/electives/agent-teams.md) | "Agent teams are experimental and disabled by default." | Every provider |
| [Cross-session messaging](https://code.claude.com/docs/en/cross-session-messaging) | – | A Claude subscription; elsewhere between sessions on the same machine only |
| [Projects](https://code.claude.com/docs/en/claude-projects) | "Projects are in public beta on Pro and Max plans and rolling out gradually …" | Pro and Max; not yet Team or Enterprise |
-| [`/loop` and scheduled prompts](https://code.claude.com/docs/en/scheduled-tasks); taught in [`/goal`, `/loop` and routines](../advanced/electives/goal-loop-routines.md) | – | Every provider |
-| [Routines](https://code.claude.com/docs/en/routines); taught in [`/goal`, `/loop` and routines](../advanced/electives/goal-loop-routines.md) | "Routines are in research preview." | Pro, Max, Team and Enterprise |
+| [`/loop` and session-scoped scheduled tasks](https://code.claude.com/docs/en/scheduled-tasks); taught in [`/loop` and cloud scheduled tasks](../advanced/electives/goal-loop-routines.md) | – | Every provider |
+| [Cloud scheduled tasks](https://code.claude.com/docs/en/routines), formerly routines; taught in [`/loop` and cloud scheduled tasks](../advanced/electives/goal-loop-routines.md) | "Scheduled tasks are in research preview." | Pro, Max, Team and Enterprise |
| [Running Claude Code from scripts](https://code.claude.com/docs/en/headless); taught in [Script Claude Code with `claude -p`](../advanced/04-headless.md) and [Put bounds on autonomous runs](../advanced/07-bounded-runs.md) | – | Every provider |
| [GitHub Actions](https://code.claude.com/docs/en/github-actions); taught in [GitHub Actions](../advanced/05-github-actions.md) | – | A Claude subscription, the Console, Bedrock, Agent Platform and Foundry; not Claude Platform on AWS |
| [GitLab CI/CD](https://code.claude.com/docs/en/gitlab-ci-cd) | "Claude Code for GitLab CI/CD is currently in beta." | Every provider except Microsoft Foundry |
@@ -78,7 +78,7 @@ How to read it:
| Feature | Label | Who gets it |
|---|---|---|
-| [Code Review](https://code.claude.com/docs/en/code-review) | "Code Review is in research preview, available for Team and Enterprise subscriptions." | Team and Enterprise |
+| [Code Review](https://code.claude.com/docs/en/code-review) | – | Team and Enterprise |
| [Ultrareview](https://code.claude.com/docs/en/ultrareview) | "Ultrareview is a research preview feature." | A Claude subscription |
| [Security guidance plugin](https://code.claude.com/docs/en/security-guidance) | – | All plans; it needs Python 3.7 or later, and 3.10 or later for the agentic commit review and, on a third-party provider, for every model-backed review |
| [Claude Security](https://code.claude.com/docs/en/claude-security) | – | A paid plan, Anthropic API access or a third-party provider |
@@ -92,6 +92,6 @@ How to read it:
---
-<sub>Sources: [Feature availability](https://code.claude.com/docs/en/feature-availability) and each feature's linked page, checked on 2026-10-05.</sub>
+<sub>Sources: [Feature availability](https://code.claude.com/docs/en/feature-availability) and each feature's linked page, checked on 2026-10-05, and for the `/goal`, `/loop`, cloud scheduled tasks and Code Review rows on 2026-10-24.</sub>
<sub>Up: [Reference](README.md)</sub>
diff --git a/docs/reference/models.md b/docs/reference/models.md
index 19b6197..7dca7ef 100644
--- a/docs/reference/models.md
+++ b/docs/reference/models.md
@@ -16,13 +16,13 @@ An alias picks the recommended model of a family, so you never need a version nu
| `opus` | The latest Opus | Complex reasoning |
| `fable` | The Fable model for your provider | The hardest, longest-running tasks |
| `best` | Fable where your account has it, otherwise Opus | You want the strongest model available to you |
-| `haiku` | Haiku | Quick, simple tasks |
+| `haiku` | The latest Haiku | Quick, simple tasks |
| `opusplan` | Opus in plan mode, then Sonnet to carry out the plan | You want deep planning and cheaper execution |
| `opus[1m]` | Opus with a 1 million token context window | Very long sessions, on a provider where `opus` doesn't already have that window |
- An alias moves to a newer model over time. To stay on one version, use its full model name, such as `claude-opus-5-5`, from the [models overview](https://platform.claude.com/docs/en/about-claude/models/overview).
- `default` isn't an alias: it clears any model you picked and returns to your account's default.
-- On other providers an alias can resolve to an older model: `sonnet` does on Claude Platform on AWS, Amazon Bedrock, Google Cloud's Agent Platform and Microsoft Foundry, and `opus` does on Microsoft Foundry. The [alias table](https://code.claude.com/docs/en/model-config#model-aliases) lists them.
+- On other providers an alias can resolve to an older model: `sonnet` and `haiku` do on Claude Platform on AWS, Amazon Bedrock, Google Cloud's Agent Platform and Microsoft Foundry, and `opus` does on Microsoft Foundry. The [alias table](https://code.claude.com/docs/en/model-config#model-aliases) lists them.
- Fable can draw on usage credits depending on your plan and seat ([Fable and usage credits](https://code.claude.com/docs/en/model-config#fable-and-usage-credits)).
The default model differs by account type and provider. Check yours with `/model` or `/status`, and see [Default model setting](https://code.claude.com/docs/en/model-config#default-model-setting) for the rules.
diff --git a/docs/topics/automation.md b/docs/topics/automation.md
index 962b714..a08be56 100644
--- a/docs/topics/automation.md
+++ b/docs/topics/automation.md
@@ -8,17 +8,17 @@ Running Claude Code without a person at the keyboard: scripts, CI and schedules.
- Advanced: [Script Claude Code with `claude -p`](../advanced/04-headless.md)
- Advanced: [GitHub Actions](../advanced/05-github-actions.md)
-- Advanced Elective: [`/goal`, `/loop` and routines](../advanced/electives/goal-loop-routines.md)
+- Advanced Elective: [`/loop` and cloud scheduled tasks](../advanced/electives/goal-loop-routines.md)
## Official docs
- [Run Claude Code programmatically](https://code.claude.com/docs/en/headless)
- [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions)
- [Run prompts on a schedule](https://code.claude.com/docs/en/scheduled-tasks)
-- [Automate work with routines](https://code.claude.com/docs/en/routines)
+- [Automate work with scheduled tasks](https://code.claude.com/docs/en/routines)
---
-<sub>Sources: [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) · [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions) · [Run prompts on a schedule](https://code.claude.com/docs/en/scheduled-tasks) · [Automate work with routines](https://code.claude.com/docs/en/routines)</sub>
+<sub>Sources: [Run Claude Code programmatically](https://code.claude.com/docs/en/headless) · [Claude Code GitHub Actions](https://code.claude.com/docs/en/github-actions) · [Run prompts on a schedule](https://code.claude.com/docs/en/scheduled-tasks) · [Automate work with scheduled tasks](https://code.claude.com/docs/en/routines)</sub>
<sub>Up: [Topics](README.md)</sub>
diff --git a/examples/intermediate/01-first-skill/README.md b/examples/intermediate/01-first-skill/README.md
index fab14d4..5fd470e 100644
--- a/examples/intermediate/01-first-skill/README.md
+++ b/examples/intermediate/01-first-skill/README.md
@@ -10,7 +10,7 @@ cp -R <path-to-this-folder>/dot-claude/skills/five-whys .claude/skills/
| Skill | What it does | Runs |
|---|---|---|
| `five-whys` | Finds a problem's root cause by asking "why" until the answer is something you can fix. Tells Claude not to change any files. | `/five-whys <problem>`, or when Claude matches your request to its description |
-| `tdd` | Builds a feature test-first. Unfinished on purpose: the lesson's Your turn has you finish it. | `/tdd <feature>` only, until you finish it |
+| `tdd` | Builds a feature test-first and stops at a diff for you to review and commit. Unfinished on purpose: the lesson's Your turn has you finish it. | `/tdd <feature>` only, until you finish it |
Each `SKILL.md` carries its header block as comments at the top of its frontmatter: what it does, when it runs, side effects, platforms, how to remove it, and its test line. Neither skill pre-approves any tool, so Claude asks before anything your permission settings don't already allow.
@@ -18,4 +18,5 @@ If `.claude/skills/` didn't exist when your session started, run `/reload-skills
Smoke test, without Claude: `bash test.sh`.
-Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06
+`five-whys`: Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06\
+`tdd`: Not yet tested in a session at this edition's version
diff --git a/examples/intermediate/01-first-skill/dot-claude/skills/tdd/SKILL.md b/examples/intermediate/01-first-skill/dot-claude/skills/tdd/SKILL.md
index 06e918e..8a6f4a3 100644
--- a/examples/intermediate/01-first-skill/dot-claude/skills/tdd/SKILL.md
+++ b/examples/intermediate/01-first-skill/dot-claude/skills/tdd/SKILL.md
@@ -1,10 +1,10 @@
---
# What: a project skill that builds a feature test-first. Unfinished on purpose: lesson 1's Your turn has you finish it.
# Runs: when you type /tdd <feature>. Once finished, also when Claude matches your request to the description.
-# Side effects: Claude edits code and tests and runs your test command, under your session's permission settings.
+# Side effects: Claude edits code and tests and runs your test command, under your session's permission settings. It doesn't commit: you review the diff and commit.
# Requires: Claude Code and a project with a test command. Platforms: any.
# Remove: delete .claude/skills/tdd/.
-# Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06
+# Not yet tested in a session at this edition's version
name: tdd
description: TODO
disable-model-invocation: true
@@ -16,4 +16,4 @@ Build this test-first, one behavior at a time: $ARGUMENTS
2. Green: TODO
3. Refactor: TODO
-Repeat until the feature is done, then run the whole test suite and commit the tests and the code together.
+Repeat until the feature is done, then run the whole test suite and show the diff. Don't commit: the user reviews the diff and commits.
diff --git a/examples/intermediate/01-first-skill/test.sh b/examples/intermediate/01-first-skill/test.sh
index 6034292..55595ee 100644
--- a/examples/intermediate/01-first-skill/test.sh
+++ b/examples/intermediate/01-first-skill/test.sh
@@ -2,7 +2,8 @@
# Smoke test for the lesson 1 skills, without Claude: each SKILL.md opens with
# frontmatter that names the skill after its folder and has a description,
# five-whys takes the problem as its argument, and tdd is still the
-# unfinished file lesson 1's Your turn asks you to finish.
+# unfinished file lesson 1's Your turn asks you to finish, ending at a diff
+# the user reviews rather than a commit.
# Run: bash test.sh (needs bash and awk). Exits non-zero on the first failure.
set -euo pipefail
cd "$(dirname "$0")"
@@ -27,5 +28,6 @@ grep -qF "\$ARGUMENTS" dot-claude/skills/five-whys/SKILL.md || fail "five-whys d
[ "$(field dot-claude/skills/five-whys/SKILL.md disable-model-invocation)" = "" ] || fail "five-whys must load on its own"
[ "$(field dot-claude/skills/tdd/SKILL.md disable-model-invocation)" = "true" ] || fail "tdd should start as run-by-name only"
grep -q 'TODO' dot-claude/skills/tdd/SKILL.md || fail "tdd should still have its TODOs"
+grep -qF "Don't commit" dot-claude/skills/tdd/SKILL.md || fail "tdd should stop at a diff the user reviews"
echo "PASS: lesson 1 skills"
diff --git a/examples/intermediate/05-hooks/README.md b/examples/intermediate/05-hooks/README.md
index 1b614f4..a5ebbf2 100644
--- a/examples/intermediate/05-hooks/README.md
+++ b/examples/intermediate/05-hooks/README.md
@@ -31,7 +31,7 @@ Then merge `settings.snippet.json` into your project's `.claude/settings.json`.
```
`settings.snippet.json`:
-- **What:** registers `protect-files.sh` and `format-after-edit.sh` in [exec form](https://code.claude.com/docs/en/hooks#exec-form-and-shell-form), so the `${CLAUDE_PROJECT_DIR}` path needs no quoting, and adds a `Read(.env)` deny rule, which also stops Claude's Edit and Write tools from changing a `.env` file ([Configure permissions](https://code.claude.com/docs/en/permissions#read-and-edit)).
+- **What:** registers `protect-files.sh` and `format-after-edit.sh` in [exec form](https://code.claude.com/docs/en/hooks#exec-form-and-shell-form), so the `${CLAUDE_PROJECT_DIR}` path needs no quoting, with `"onFailure": "block"` on `protect-files.sh`, so a protection script that can't start, crashes or times out blocks the edit instead of letting it through ([Block the action when a hook fails](https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails)). It also adds a `Read(.env)` deny rule, which also stops Claude's Edit and Write tools from changing a `.env` file ([Configure permissions](https://code.claude.com/docs/en/permissions#read-and-edit)).
- **When:** Claude Code reads it when a session starts in the project, and reloads it when the file changes ([Settings](https://code.claude.com/docs/en/settings#when-edits-take-effect)).
- **Side effects:** none of its own; the scripts' headers list theirs.
- **Platforms:** macOS, Linux and WSL2. The scripts need bash and jq, and `format-after-edit.sh` also needs python3.
@@ -41,6 +41,7 @@ Hooks in a repository's `.claude/settings.json` run with your user's rights: in
Smoke test, without Claude: `bash test.sh`.
-Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06
+The scripts: Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06\
+`settings.snippet.json`: Not yet tested in a session at this edition's version
Sources: [Automate actions with hooks](https://code.claude.com/docs/en/hooks-guide), [Hooks reference](https://code.claude.com/docs/en/hooks), [Configure permissions](https://code.claude.com/docs/en/permissions), [Settings](https://code.claude.com/docs/en/settings)
diff --git a/examples/intermediate/05-hooks/dot-claude/hooks/protect-files.sh b/examples/intermediate/05-hooks/dot-claude/hooks/protect-files.sh
index fad49ca..9d39155 100755
--- a/examples/intermediate/05-hooks/dot-claude/hooks/protect-files.sh
+++ b/examples/intermediate/05-hooks/dot-claude/hooks/protect-files.sh
@@ -1,8 +1,8 @@
#!/bin/bash
# protect-files.sh: blocks Claude's Edit and Write tools on protected files.
# This is the hooks guide's "Block edits to protected files" script, unchanged
-# below this header. Lesson 5 shows where its substring match is too broad and
-# has you fix it.
+# below this header. Lesson 5 registers it with "onFailure": "block", so it
+# fails closed.
# Runs: PreToolUse, matcher Edit|Write (see settings.snippet.json).
# Side effects: none. Exit 2 blocks the tool call, and the stderr line goes to
# Claude as the reason. It sees only Edit and Write, not shell commands.
diff --git a/examples/intermediate/05-hooks/settings.snippet.json b/examples/intermediate/05-hooks/settings.snippet.json
index d79abc0..4f736ba 100644
--- a/examples/intermediate/05-hooks/settings.snippet.json
+++ b/examples/intermediate/05-hooks/settings.snippet.json
@@ -7,7 +7,7 @@
{
"matcher": "Edit|Write",
"hooks": [
- { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/protect-files.sh", "args": [] }
+ { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/protect-files.sh", "args": [], "onFailure": "block" }
]
}
],
diff --git a/examples/intermediate/05-hooks/test.sh b/examples/intermediate/05-hooks/test.sh
index 8de356e..4c47151 100644
--- a/examples/intermediate/05-hooks/test.sh
+++ b/examples/intermediate/05-hooks/test.sh
@@ -76,5 +76,6 @@ jq -r '.hooks[][].hooks[].command' settings.snippet.json | while read -r command
[ -f "$hooks/$name" ] || fail "settings.snippet.json runs $name, which is not in dot-claude/hooks/"
done
jq -e '[.hooks[][].hooks[] | has("args")] | all' settings.snippet.json > /dev/null || fail "every hook in settings.snippet.json should use exec form (args)"
+jq -e '[.hooks.PreToolUse[].hooks[] | select(.command | endswith("/protect-files.sh")) | .onFailure == "block"] | (length > 0 and all)' settings.snippet.json > /dev/null || fail "protect-files.sh should block when it fails (onFailure)"
echo "PASS: lesson 5 hooks"