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.
JavaScript agent-skillsagentic-codingai-agentsanthropicanthropic-claudebest-practicesclaudeclaude-aiclaude-codeclaude-code-guideclaude-code-hooksclaude-code-pluginsclaude-code-skillsclaude-code-tutorialclaude-code-workflowsguidelearn-claude-codemcpsubagentstutorial
docs: add the Intermediate examples: two skills, three hooks, a reviewer subagent and an MCP config (#80)
Wesam Abousaid11cadf7ce39a
diff --git a/examples/intermediate/01-first-skill/README.md b/examples/intermediate/01-first-skill/README.mdnew file mode 100644index 0000000..fab14d4--- /dev/null+++ b/examples/intermediate/01-first-skill/README.md@@ -0,0 +1,21 @@+# Skills for Intermediate lesson 1++Two project skills for the Intermediate lesson "Turn a repeated workflow into a skill". Copy a skill's folder from `dot-claude/skills/` into `.claude/skills/` in your project, where Claude Code loads project skills ([Extend Claude with skills](https://code.claude.com/docs/en/skills#where-skills-live)):++```bash+mkdir -p .claude/skills+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 |++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.++If `.claude/skills/` didn't exist when your session started, run `/reload-skills` to load the new skill ([Extend Claude with skills](https://code.claude.com/docs/en/skills#live-change-detection)). Remove a skill by deleting its folder under `.claude/skills/`.++Smoke test, without Claude: `bash test.sh`.++Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06diff --git a/examples/intermediate/01-first-skill/dot-claude/skills/five-whys/SKILL.md b/examples/intermediate/01-first-skill/dot-claude/skills/five-whys/SKILL.mdnew file mode 100644index 0000000..63c18f4--- /dev/null+++ b/examples/intermediate/01-first-skill/dot-claude/skills/five-whys/SKILL.md@@ -0,0 +1,23 @@+---+# What: a project skill that finds a problem's root cause by asking "why" until the answer is something you can fix.+# Runs: when you type /five-whys <problem>, or when Claude matches your request to the description.+# Side effects: none intended. It tells Claude to investigate and change no files; each tool call still follows your permission settings.+# Requires: Claude Code. Platforms: any.+# Remove: delete .claude/skills/five-whys/.+# Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06+name: five-whys+description: Finds the root cause of a bug, failure or recurring problem by asking "why" until the answer is a cause you can fix. Use when the user asks why something keeps happening, or wants the root cause rather than a quick fix.+argument-hint: "[problem]"+---++Find the root cause of this problem: $ARGUMENTS++If no problem is given, ask for one in a single sentence, then stop.++1. Restate the problem as a symptom someone can observe: what happens, where and when.+2. Ask "Why does this happen?" Answer from evidence: the code, tests, logs and git history. Mark any answer you can't back with evidence as a guess.+3. Ask "Why?" of that answer, and keep going until the answer is a cause the team can change. That often takes about five rounds; stop sooner if you get there, and say so if you need more.+4. Check the chain backwards: each cause must explain the step before it.+5. Report the chain as a numbered list, the root cause in one sentence, then one fix for the root cause and one for the symptom.++Don't change any files. Propose the fixes and let the user decide.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.mdnew file mode 100644index 0000000..4add926--- /dev/null+++ b/examples/intermediate/01-first-skill/dot-claude/skills/tdd/SKILL.md@@ -0,0 +1,19 @@+---+# 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, with your usual permission prompts.+# 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+name: tdd+description: TODO+disable-model-invocation: true+---++Build this test-first, one behavior at a time: $ARGUMENTS++1. Red: write one failing test for the next behavior. Run the tests and confirm that it fails, and fails for the reason you expect. Don't change code outside the tests in this step.+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.diff --git a/examples/intermediate/01-first-skill/test.sh b/examples/intermediate/01-first-skill/test.shnew file mode 100644index 0000000..6034292--- /dev/null+++ b/examples/intermediate/01-first-skill/test.sh@@ -0,0 +1,31 @@+#!/usr/bin/env bash+# 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.+# Run: bash test.sh (needs bash and awk). Exits non-zero on the first failure.+set -euo pipefail+cd "$(dirname "$0")"++fail() { echo "FAIL: $*" >&2; exit 1; }++# The frontmatter block: the lines between the opening --- on line 1 and the next ---.+frontmatter() { awk 'NR == 1 { if ($0 != "---") exit 1; next } /^---$/ { exit } { print }' "$1"; }+field() { frontmatter "$1" | awk -v key="$2" 'index($0, key ": ") == 1 { print substr($0, length(key) + 3) }'; }++for dir in dot-claude/skills/*/; do+ skill="$dir/SKILL.md"+ name=$(basename "$dir")+ [ -f "$skill" ] || fail "$name has no SKILL.md"+ frontmatter "$skill" > /dev/null || fail "$skill does not start with ---"+ [ "$(field "$skill" name)" = "$name" ] || fail "$skill: name is not $name"+ [ -n "$(field "$skill" description)" ] || fail "$skill: no description"+ frontmatter "$skill" | grep -q '^# Not yet tested\|^# Tested in Claude Code' || fail "$skill: no test line in its header"+done++grep -qF "\$ARGUMENTS" dot-claude/skills/five-whys/SKILL.md || fail "five-whys does not use \$ARGUMENTS"+[ "$(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"++echo "PASS: lesson 1 skills"diff --git a/examples/intermediate/05-hooks/README.md b/examples/intermediate/05-hooks/README.mdnew file mode 100644index 0000000..1b614f4--- /dev/null+++ b/examples/intermediate/05-hooks/README.md@@ -0,0 +1,46 @@+# Hooks for Intermediate lesson 5++Three teaching hooks for the Intermediate lesson "Enforce a rule with a hook", and the settings that register them. Each script's header says what it does, when it runs, its side effects, platforms, how to remove it and its test line.++| Script | Event and matcher | What it does |+|---|---|---|+| `dot-claude/hooks/protect-files.sh` | `PreToolUse`, `Edit\|Write` | Blocks edits to `.env`, `package-lock.json` and `.git/`, with exit code 2. The [hooks guide](https://code.claude.com/docs/en/hooks-guide#block-edits-to-protected-files)'s script, unchanged |+| `dot-claude/hooks/format-after-edit.sh` | `PostToolUse`, `Edit\|Write` | Removes trailing spaces and tabs and leaves one final newline in the source file Claude just changed. Only common source-code extensions, such as `.js`, `.py` and `.sh`: Markdown, patches and data files stay as they are |+| `dot-claude/hooks/desktop-notify.sh` | `Notification`, every type | Shows a desktop notification for every Claude Code notification, such as a permission prompt that has waited |++## Use them++From your project's root:++```bash+mkdir -p .claude/hooks+cp <path-to-this-folder>/dot-claude/hooks/protect-files.sh <path-to-this-folder>/dot-claude/hooks/format-after-edit.sh .claude/hooks/+chmod +x .claude/hooks/*.sh+```++Then merge `settings.snippet.json` into your project's `.claude/settings.json`. If the file already has a `hooks` or `permissions` key, add these entries beside the existing ones instead of replacing them.++`desktop-notify.sh` is about you, not the project, so it goes in your user settings, where the [hooks guide](https://code.claude.com/docs/en/hooks-guide#get-notified-when-claude-needs-input) registers its notification examples. Copy it to `~/.claude/hooks/`, make it executable, and add this to `~/.claude/settings.json`, beside any keys already there. It uses shell form, so the shell expands `~`:++```json+"hooks": {+ "Notification": [+ { "matcher": "", "hooks": [ { "type": "command", "command": "~/.claude/hooks/desktop-notify.sh" } ] }+ ]+}+```++`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)).+- **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.+- **Remove:** delete the entries from `.claude/settings.json`.++Hooks in a repository's `.claude/settings.json` run with your user's rights: in an interactive session once you trust the folder, and in a `claude -p` run without asking ([Hooks reference](https://code.claude.com/docs/en/hooks#workspace-trust)). Read every script before you register it.++Smoke test, without Claude: `bash test.sh`.++Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06++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/desktop-notify.sh b/examples/intermediate/05-hooks/dot-claude/hooks/desktop-notify.shnew file mode 100755index 0000000..cbab970--- /dev/null+++ b/examples/intermediate/05-hooks/dot-claude/hooks/desktop-notify.sh@@ -0,0 +1,29 @@+#!/usr/bin/env bash+# desktop-notify.sh: shows a desktop notification for every Claude Code+# notification, for example when a permission prompt has waited, or a minute+# after Claude finished if you haven't typed since.+# Runs: Notification, every notification type (empty matcher), from your+# user settings, ~/.claude/settings.json: see this example's README.+# Side effects: one notification on this computer. Nothing is logged or sent+# anywhere else. On macOS it uses osascript; on Linux, notify-send if it is+# installed; anywhere else it asks Claude Code to ring the terminal bell.+# Requires: bash and jq. Platforms: macOS, Linux, WSL2.+# Remove: delete its Notification entry from ~/.claude/settings.json, then this file.+# Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06+set -u++input=$(cat)+title=$(jq -r '.title // "Claude Code"' <<<"$input")+message=$(jq -r '.message // "Claude Code needs your attention"' <<<"$input")++if command -v osascript > /dev/null 2>&1; then+ # The text goes in as arguments, so quotes in a message can't break the script.+ osascript -e 'on run argv' -e 'display notification (item 2 of argv) with title (item 1 of argv)' -e 'end run' \+ "$title" "$message" > /dev/null 2>&1 || true+elif command -v notify-send > /dev/null 2>&1; then+ notify-send "$title" "$message" > /dev/null 2>&1 || true+else+ # A hook has no terminal of its own, so it returns the bell for Claude Code to write.+ jq -nc '{terminalSequence: "\u0007"}'+fi+exit 0diff --git a/examples/intermediate/05-hooks/dot-claude/hooks/format-after-edit.sh b/examples/intermediate/05-hooks/dot-claude/hooks/format-after-edit.shnew file mode 100755index 0000000..0db6658--- /dev/null+++ b/examples/intermediate/05-hooks/dot-claude/hooks/format-after-edit.sh@@ -0,0 +1,50 @@+#!/usr/bin/env bash+# format-after-edit.sh: tidies a file right after Claude edits or writes it.+# It removes spaces and tabs at the ends of lines and leaves exactly one+# newline at the end of the file, keeping Windows line endings if the file+# has them.+# Runs: PostToolUse, matcher Edit|Write (see settings.snippet.json).+# Side effects: rewrites the edited file in place, only when that changes it.+# It changes only source files with an extension listed below, such as .js,+# .py or .sh, so Markdown (where two trailing spaces are a line break),+# patches, snapshots and data files stay as they are. It also skips binary+# files and files outside the project. It never blocks: it always exits 0.+# Requires: bash, jq and python3. Platforms: macOS, Linux, WSL2.+# Remove: delete its PostToolUse entry from .claude/settings.json, then this file.+# Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06+set -u++file=$(jq -r '.tool_input.file_path // empty')+project=${CLAUDE_PROJECT_DIR:-$PWD}++[ -n "$file" ] && [ -f "$file" ] || exit 0+case "$file" in+ "$project"/*) ;;+ *) exit 0 ;;+esac+case "$file" in+ *.js | *.mjs | *.cjs | *.jsx | *.ts | *.tsx | *.py | *.rb | *.go | *.rs | \+ *.java | *.kt | *.c | *.h | *.cpp | *.hpp | *.cs | *.php | *.sh | *.css | *.scss) ;;+ *) exit 0 ;;+esac++python3 - "$file" <<'PY' || true+import re, sys++path = sys.argv[1]+with open(path, "rb") as f:+ data = f.read()+if not data or b"\0" in data:+ sys.exit(0)+try:+ text = data.decode("utf-8")+except UnicodeDecodeError:+ sys.exit(0)++newline = "\r\n" if "\r\n" in text else "\n"+tidy = re.sub(r"[ \t]+(?=\r?$)", "", text, flags=re.M).rstrip("\r\n") + newline+if tidy != text:+ with open(path, "wb") as f:+ f.write(tidy.encode("utf-8"))+PY+exit 0diff --git a/examples/intermediate/05-hooks/dot-claude/hooks/protect-files.sh b/examples/intermediate/05-hooks/dot-claude/hooks/protect-files.shnew file mode 100755index 0000000..fad49ca--- /dev/null+++ b/examples/intermediate/05-hooks/dot-claude/hooks/protect-files.sh@@ -0,0 +1,28 @@+#!/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.+# 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.+# Requires: bash and jq. Platforms: macOS, Linux, WSL2.+# Remove: delete its PreToolUse entry from .claude/settings.json, then this file.+# Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06++INPUT=$(cat)+FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')++# Normalize Windows backslash separators so the patterns below match+FILE_PATH="${FILE_PATH//\\//}"++PROTECTED_PATTERNS=(".env" "package-lock.json" ".git/")++for pattern in "${PROTECTED_PATTERNS[@]}"; do+ if [[ "$FILE_PATH" == *"$pattern"* ]]; then+ echo "Blocked: $FILE_PATH matches protected pattern '$pattern'" >&2+ exit 2+ fi+done++exit 0diff --git a/examples/intermediate/05-hooks/settings.snippet.json b/examples/intermediate/05-hooks/settings.snippet.jsonnew file mode 100644index 0000000..d79abc0--- /dev/null+++ b/examples/intermediate/05-hooks/settings.snippet.json@@ -0,0 +1,23 @@+{+ "permissions": {+ "deny": ["Read(.env)"]+ },+ "hooks": {+ "PreToolUse": [+ {+ "matcher": "Edit|Write",+ "hooks": [+ { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/protect-files.sh", "args": [] }+ ]+ }+ ],+ "PostToolUse": [+ {+ "matcher": "Edit|Write",+ "hooks": [+ { "type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/format-after-edit.sh", "args": [] }+ ]+ }+ ]+ }+}diff --git a/examples/intermediate/05-hooks/test.sh b/examples/intermediate/05-hooks/test.shnew file mode 100644index 0000000..8de356e--- /dev/null+++ b/examples/intermediate/05-hooks/test.sh@@ -0,0 +1,80 @@+#!/usr/bin/env bash+# Smoke test for the lesson 5 hooks, without Claude: it pipes the JSON a hook+# receives into each script and checks the exit code, the output and the file+# on disk. It also parses settings.snippet.json and checks that each command it+# registers is one of these scripts. It shows no real notification: the+# notifier is a stand-in on a private PATH.+# Run: bash test.sh (needs bash, jq and python3). Writes only to a temporary+# folder, which it deletes.+set -euo pipefail+cd "$(dirname "$0")"+hooks=$PWD/dot-claude/hooks+tmp=$(mktemp -d)+trap 'rm -rf "$tmp"' EXIT++fail() { echo "FAIL: $*" >&2; exit 1; }+event() { jq -nc --arg p "$1" '{hook_event_name: "PreToolUse", tool_name: "Edit", tool_input: {file_path: $p}}'; }++for script in "$hooks"/*.sh; do+ [ -x "$script" ] || fail "$(basename "$script") is not executable"+done++# protect-files.sh: exit 2 and a Blocked: line on stderr for protected paths.+project=$tmp/project+mkdir -p "$project/src"+expect_exit() {+ local path=$1 want=$2 got=0+ event "$path" | "$hooks/protect-files.sh" 2> "$tmp/stderr" || got=$?+ [ "$got" = "$want" ] || fail "protect-files.sh: $path exited $got, expected $want"+ if [ "$want" = 2 ]; then grep -q '^Blocked: ' "$tmp/stderr" || fail "protect-files.sh: no Blocked: line for $path"; fi+}+expect_exit "$project/.env" 2+expect_exit "$project/package-lock.json" 2+expect_exit "$project/.git/config" 2+expect_exit "$project/src/app.js" 0+expect_exit 'C:\repo\.env' 2++# format-after-edit.sh: tidies files in the project, leaves the rest alone.+run_format() { event "$1" | CLAUDE_PROJECT_DIR=$project "$hooks/format-after-edit.sh" || fail "format-after-edit.sh exited non-zero for $1"; }+printf 'const a = 1; \nconst b = 2;\t\n\n\n' > "$project/src/a.js"+run_format "$project/src/a.js"+[ "$(od -An -c "$project/src/a.js" | tr -d ' \n')" = 'consta=1;\nconstb=2;\n' ] || fail "format-after-edit.sh did not tidy a.js to one final newline"+printf 'x = 1 \r\ny = 2\r\n\r\n' > "$project/src/win.py"+run_format "$project/src/win.py"+[ "$(od -An -c "$project/src/win.py" | tr -d ' \n')" = 'x=1\r\ny=2\r\n' ] || fail "format-after-edit.sh did not keep CRLF line endings"+printf 'Two spaces make a break \nhere\n' > "$project/notes.md"+run_format "$project/notes.md"+grep -q 'break $' "$project/notes.md" || fail "format-after-edit.sh changed Markdown"+printf ' context \n+added\n' > "$project/fix.patch"+run_format "$project/fix.patch"+grep -q '^ context $' "$project/fix.patch" || fail "format-after-edit.sh changed a patch"+printf 'outside \n' > "$tmp/outside.js"+run_format "$tmp/outside.js"+grep -q 'outside $' "$tmp/outside.js" || fail "format-after-edit.sh changed a file outside the project"+run_format "$project/missing.js"+[ ! -e "$project/missing.js" ] || fail "format-after-edit.sh created a missing file"++# desktop-notify.sh: hands title and message to the notifier as arguments.+bin=$tmp/bin+mkdir -p "$bin"+for tool in jq cat; do ln -s "$(command -v "$tool")" "$bin/$tool"; done+note='{"hook_event_name":"Notification","message":"Claude needs your \"permission\" to use Bash","notification_type":"permission_prompt"}'+printf '#!/bin/sh\nprintf "%%s\\n" "$@" > "%s"\n' "$tmp/osascript-args" > "$bin/osascript"+chmod +x "$bin/osascript"+PATH=$bin "$(command -v bash)" "$hooks/desktop-notify.sh" <<<"$note" || fail "desktop-notify.sh exited non-zero"+grep -qx 'Claude Code' "$tmp/osascript-args" || fail "desktop-notify.sh did not pass the default title"+grep -qx 'Claude needs your "permission" to use Bash' "$tmp/osascript-args" || fail "desktop-notify.sh did not pass the message intact"+rm "$bin/osascript"+out=$(PATH=$bin "$(command -v bash)" "$hooks/desktop-notify.sh" <<<"$note") || fail "desktop-notify.sh exited non-zero without a notifier"+[ "$(jq -j '.terminalSequence' <<<"$out" | od -An -tx1 | tr -d ' ')" = '07' ] || fail "desktop-notify.sh did not fall back to the terminal bell"++# settings.snippet.json: valid JSON, the .env deny rule, and only these scripts.+jq -e '.permissions.deny | index("Read(.env)")' settings.snippet.json > /dev/null || fail "settings.snippet.json has no Read(.env) deny rule"+jq -r '.hooks[][].hooks[].command' settings.snippet.json | while read -r command; do+ name=${command##*/}+ [ "$command" = "\${CLAUDE_PROJECT_DIR}/.claude/hooks/$name" ] || fail "settings.snippet.json runs $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)"++echo "PASS: lesson 5 hooks"diff --git a/examples/intermediate/06-subagents/README.md b/examples/intermediate/06-subagents/README.mdnew file mode 100644index 0000000..e2398dc--- /dev/null+++ b/examples/intermediate/06-subagents/README.md@@ -0,0 +1,18 @@+# Subagent for Intermediate lesson 6++`code-reviewer`, a read-only subagent for the Intermediate lesson "Delegate to a custom subagent". It reviews code changes in its own context window and reports findings by severity. Its only tools are Read, Grep and Glob, so it can read and search files but can't edit them or run commands ([Create custom subagents](https://code.claude.com/docs/en/sub-agents#available-tools)). Without a shell it can't run `git diff`, so the main conversation gives it the changed files or the diff.++Copy it into `.claude/agents/` in your project:++```bash+mkdir -p .claude/agents+cp <path-to-this-folder>/dot-claude/agents/code-reviewer.md .claude/agents/+```++If `.claude/agents/` didn't exist when your session started, restart Claude Code so it sees the new folder ([Create custom subagents](https://code.claude.com/docs/en/sub-agents#write-subagent-files)). Then ask for it by name: `Use the code-reviewer agent to review my changes`.++The file's header block, as comments at the top of its frontmatter, says what it does, when it runs, its side effects, platforms, how to remove it, and its test line.++Smoke test, without Claude: `bash test.sh`.++Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06diff --git a/examples/intermediate/06-subagents/dot-claude/agents/code-reviewer.md b/examples/intermediate/06-subagents/dot-claude/agents/code-reviewer.mdnew file mode 100644index 0000000..8e4a562--- /dev/null+++ b/examples/intermediate/06-subagents/dot-claude/agents/code-reviewer.md@@ -0,0 +1,25 @@+---+# What: a project subagent that reviews code changes in its own context window and reports findings. It can't edit files.+# Runs: when Claude delegates a review to it, or when you ask for it by name ("Use the code-reviewer agent to ...").+# Side effects: none. Its only tools are Read, Grep and Glob: it can read and search files, and can't edit them or run commands.+# Requires: Claude Code. Platforms: any.+# Remove: delete .claude/agents/code-reviewer.md.+# Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06+name: code-reviewer+description: Reviews code changes for bugs, missing tests, unclear code and exposed secrets, and reports findings by severity. Use after writing or changing code, before committing. Read-only; give it the changed files or the diff to review.+tools: Read, Grep, Glob+model: inherit+---++You review code changes. You never change files: you report what you find, and the main conversation decides what to fix.++1. Find the changes: the files or the diff named in your task. If your task names neither, say so and stop; you can't run git to find them.+2. Read each changed file around the change, and the tests that cover it.+3. Check for:+ - bugs: wrong logic, unhandled errors and edge cases, off-by-one mistakes;+ - tests: changed behavior without a test, or a test that can't fail;+ - clarity: names that mislead, duplicated code, dead code;+ - secrets: keys, tokens or passwords in code or config.+4. Report findings grouped as Must fix, Should fix and Consider. For each one give the file and line, the problem, and a concrete fix. If you find nothing, say so and say what you checked.++Keep the report short: no praise and no summary of the diff.diff --git a/examples/intermediate/06-subagents/test.sh b/examples/intermediate/06-subagents/test.shnew file mode 100644index 0000000..ae485a3--- /dev/null+++ b/examples/intermediate/06-subagents/test.sh@@ -0,0 +1,30 @@+#!/usr/bin/env bash+# Smoke test for the lesson 6 subagent, without Claude: the file opens with+# frontmatter that has a name and a description, as Claude Code requires, and+# its tools list leaves out Edit, Write, NotebookEdit, Bash, PowerShell and Monitor.+# Run: bash test.sh (needs bash and awk).+set -euo pipefail+cd "$(dirname "$0")"++fail() { echo "FAIL: $*" >&2; exit 1; }+frontmatter() { awk 'NR == 1 { if ($0 != "---") exit 1; next } /^---$/ { exit } { print }' "$1"; }+field() { frontmatter "$1" | awk -v key="$2" 'index($0, key ": ") == 1 { print substr($0, length(key) + 3) }'; }++for agent in dot-claude/agents/*.md; do+ frontmatter "$agent" > /dev/null || fail "$agent does not start with ---"+ [ -n "$(field "$agent" name)" ] || fail "$agent: no name, so Claude Code would skip it"+ [ -n "$(field "$agent" description)" ] || fail "$agent: no description, so Claude Code would skip it"+ frontmatter "$agent" | grep -q '^# Not yet tested\|^# Tested in Claude Code' || fail "$agent: no test line in its header"+done++agent=dot-claude/agents/code-reviewer.md+[ "$(field "$agent" name)" = code-reviewer ] || fail "the reviewer is not named code-reviewer"+tools=$(field "$agent" tools)+[ -n "$tools" ] || fail "code-reviewer has no tools list, so it would inherit every tool"+for tool in $(tr ',' ' ' <<<"$tools"); do+ case "$tool" in+ Edit | Write | NotebookEdit | Bash | PowerShell | Monitor) fail "code-reviewer can use $tool" ;;+ esac+done++echo "PASS: lesson 6 subagent"diff --git a/examples/intermediate/07-mcp/README.md b/examples/intermediate/07-mcp/README.mdnew file mode 100644index 0000000..ff3f10c--- /dev/null+++ b/examples/intermediate/07-mcp/README.md@@ -0,0 +1,29 @@+# MCP server for Intermediate lesson 7++`dot-mcp.json` adds [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) (Vendor: Google, Apache-2.0) to a project, for the Intermediate lesson "Connect a tool with MCP". It lets Claude open pages in Chrome, read console messages and network requests, take screenshots and record performance traces.++Copy it to `.mcp.json` at your project's root, the file Claude Code reads project-scope servers from ([Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp#project-scope)):++```bash+cp <path-to-this-folder>/dot-mcp.json .mcp.json+```++`dot-mcp.json`:+- **What:** one stdio server, `chrome-devtools`, started with `npx` at the pinned version `[email protected]`.+- **When:** in an interactive session, Claude Code asks you to approve a project's servers before it uses them. In a `claude -p` run it loads them without asking ([Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp#project-scope)).+- **Side effects:** `npx` downloads the package from npm the first time. The server starts Chrome when Claude first uses a browser tool. `--isolated` gives that browser a temporary profile, deleted when the browser closes, so no cookies or logins carry over between sessions ([upstream advanced usage](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/docs/advanced-usage.md#user-data-directory)).+- **Requires:** Node.js LTS with npm, and Chrome, current stable or newer ([upstream requirements](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/README.md#requirements)).+- **Remove:** delete the `chrome-devtools` entry from `.mcp.json`, or the file.++> [!WARNING]+> Data that leaves your machine. By default the server 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 config turns all three off with `--no-usage-statistics`, `--no-performance-crux` and `CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS`. The pages Claude opens are still fetched from the web as in any browser, and the server exposes everything in that browser to Claude: don't open pages with data you wouldn't paste into a session.++Third-party: it can run code on your machine or give Claude new tools. Review it before installing; this guide does not audit it.++Listings checked against the listing bar on 2026-10-06.++Smoke test, without Claude or the network: `bash test.sh`.++Tested in Claude Code v2.1.285 (stable) on macOS, 2026-10-06++Sources: [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp), [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 advanced usage](https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/chrome-devtools-mcp-v1.10.1/docs/advanced-usage.md)diff --git a/examples/intermediate/07-mcp/dot-mcp.json b/examples/intermediate/07-mcp/dot-mcp.jsonnew file mode 100644index 0000000..91c3def--- /dev/null+++ b/examples/intermediate/07-mcp/dot-mcp.json@@ -0,0 +1,12 @@+{+ "mcpServers": {+ "chrome-devtools": {+ "type": "stdio",+ "command": "npx",+ "args": ["-y", "[email protected]", "--isolated", "--no-usage-statistics", "--no-performance-crux"],+ "env": {+ "CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS": "1"+ }+ }+ }+}diff --git a/examples/intermediate/07-mcp/test.sh b/examples/intermediate/07-mcp/test.shnew file mode 100644index 0000000..5534eae--- /dev/null+++ b/examples/intermediate/07-mcp/test.sh@@ -0,0 +1,22 @@+#!/usr/bin/env bash+# Smoke test for the lesson 7 MCP config, without Claude and without starting+# the server: dot-mcp.json parses, pins chrome-devtools-mcp to an exact+# version, and keeps its outbound data flows off: usage statistics and CrUX+# lookups (Google) and update checks (npm).+# Run: bash test.sh (needs bash and jq).+set -euo pipefail+cd "$(dirname "$0")"++fail() { echo "FAIL: $*" >&2; exit 1; }+server='.mcpServers["chrome-devtools"]'++jq -e . dot-mcp.json > /dev/null || fail "dot-mcp.json is not valid JSON"+[ "$(jq -r "$server.command" dot-mcp.json)" = npx ] || fail "the server does not run through npx"+pin=$(jq -r "$server.args[] | select(startswith(\"chrome-devtools-mcp@\"))" dot-mcp.json)+[[ "$pin" =~ ^chrome-devtools-mcp@[0-9]+\.[0-9]+\.[0-9]+$ ]] || fail "the package is not pinned to an exact version: ${pin:-none}"+for flag in --no-usage-statistics --no-performance-crux --isolated; do+ jq -e --arg f "$flag" "$server.args | index(\$f)" dot-mcp.json > /dev/null || fail "missing $flag"+done+[ "$(jq -r "$server.env.CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS" dot-mcp.json)" = 1 ] || fail "update checks are not turned off"++echo "PASS: lesson 7 MCP config"