A /release-notes workflow skill

Validate and render the kit's /release-notes [since-ref] [audience] skill: named arguments, an inline and a fenced ! injection, a bundled script reached through ${CLAUDE_SKILL_DIR}, and disable-model-invocation: true. Each injected command goes through the course's permission engine, then the skill is rendered for real in a temp repo with a tag and seven commits. It's the Workflow Skills topic, built and run.

  • Python 3.9+
  • standard library only
  • git (the render builds a temp repo)
  • offline: the kit in core-5/workflow_skill/kit/
python3 core-5/workflow_skill.py

The kit is a print-only sibling of the session page's example: it shares the /release-notes name, so install one or the other, not both.

┌──────────────────────────────────────┐
│ Workflow skill: /release-notes (kit) │
└──────────────────────────────────────┘
[1] Validate core-5/workflow_skill/kit/.claude/skills/release-notes/SKILL.md
field                     value                                                        what it does (skills docs)                                       
────────────────────────  ───────────────────────────────────────────────────────────  ─────────────────────────────────────────────────────────────────
name                      release-notes                                                command name shown in the / menu (defaults to the directory name)
description               Draft release notes from the git history since a tag or re…  what it does and when to use it; Claude matches on it            
argument-hint             [since-ref] [audience]                                       autocomplete hint such as [issue-number]                         
arguments                 ['since', 'audience']                                        named positional arguments for $name substitution                
disable-model-invocation  True                                                         true = only you can invoke it                                    
allowed-tools             ['Bash(git rev-parse --abbrev-ref HEAD)', 'Bash(python3 ${…  pre-approved for the turn that invokes the skill                 
  ok    frontmatter: every field is documented and well-formed
[2] Injected commands (they run before Claude reads the skill, and never prompt)
where    form    command                                                           check  result
───────  ──────  ────────────────────────────────────────────────────────────────  ─────  ──────
line 18  inline  git rev-parse --abbrev-ref HEAD                                   allow  runs  
line 21  fenced  python3 <repo>/.claude/skills/release-notes/scripts/changes.py -  allow  runs  
  rules used: allowed-tools from the frontmatter, mode default
[3] Render /release-notes v0.3.0 customers in a temp copy of tiny-app
  setup: git init + 'sample: initial commit' (common.cc.temp_repo)
  setup: git tag v0.3.0
  setup: commit 'feat(pricing): accept lower-case discount codes'
  setup: commit 'test(pricing): cover lower-case discount codes'
  setup: commit 'fix(cli): reject quantities below one with a clear error'
  setup: commit 'refactor(pricing)!: rename DISCOUNTS to DISCOUNT_CODES'
  setup: commit 'docs: explain tax rounding in the README'
  setup: commit 'chore: add the release-notes skill'
  setup: commit 'Update CLAUDE.md with the release workflow'
  ran git rev-parse --abbrev-ref HEAD: exit 0, ok
  ran python3 <repo>/.claude/skills/release-notes/scripts/changes.py --since: exit 0, ok
  arguments: 'v0.3.0 customers' -> $since='v0.3.0', $audience='customers'
  ---- rendered prompt (what Claude receives) ------------------------
  | # Release notes since v0.3.0
  | 
  | ## Context collected before you read this
  | 
  | - Branch: main
  | - Changes since the latest tag, grouped by type:
  | 
  | Range: v0.3.0..HEAD (latest tag v0.3.0), 7 commits
  | 
  | ### Breaking changes
  | - pricing: rename DISCOUNTS to DISCOUNT_CODES (4027f48)
  | 
  | ### Features
  | - pricing: accept lower-case discount codes (0eb476c)
  | 
  | ### Fixes
  | - cli: reject quantities below one with a clear error (a7ea220)
  | 
  | ### Documentation
  | - explain tax rounding in the README (694251e)
  | 
  | ### Tests
  | - pricing: cover lower-case discount codes (49363e8)
  | 
  | ### Maintenance
  | - add the release-notes skill (3bb9ee5)
  | 
  | ### Other
  | - Update CLAUDE.md with the release workflow (a4f1076)
  | 
  | ## Your task
  | 
  | 1. Requested start of the range: `v0.3.0`. If it's empty, use the latest tag shown above. If it names
  |    a different tag or ref, run `python3 <repo>/.claude/skills/release-notes/scripts/changes.py --since <that ref> --max 40`
  |    to get the right list before you write anything.
  | 2. Write release notes for this audience: `customers` (if empty, write for developers). Follow the
  |    format and tone rules in [reference.md](reference.md).
  | 3. Use only the commits listed. If a commit's effect isn't clear from its subject, say so instead of
  |    guessing, and list breaking changes first.
  | 4. Print the notes in your reply. Don't create, commit, tag or push anything unless asked.
  --------------------------------------------------------------------
[4] Same render with allowed-tools removed (what pre-approval buys you)
  Shell command permission check failed for pattern "```! ..." (prompt: shell commands outside the read-only set ask)
[5] Tests for scripts/changes.py (core-5/workflow_skill/tests)
  14 tests, OK
[6] Install
  • cp -r core-5/workflow_skill/kit/.claude <your-repo>/   (adds .claude/skills/release-notes/; it doesn't touch settings.json)
  • If <your-repo>/.claude/skills/release-notes already exists, compare before copying: cp -r merges folders and overwrites files with the same name.
  • Then type /release-notes v1.2.0 developers. Claude can't start it on its own (disable-model-invocation).
  • The script needs python3 and git on PATH; a path with spaces breaks the unquoted ${CLAUDE_SKILL_DIR} command.
  1. Only you can start it: a release workflow isn't something Claude should decide to run.
  2. Both injected commands pass the permission check, because allowed-tools pre-approves them. Injected commands run before Claude reads the skill, and they never prompt.
  3. The typed arguments, mapped to the named placeholders.
  4. The ! placeholders are gone: Claude receives the script's real output from the temp repo, not a command to run.
  5. Without allowed-tools, the script command would prompt, so outside auto mode the invocation aborts and Claude gets nothing.
  6. A practical limit of the kit: the unquoted ${CLAUDE_SKILL_DIR} command breaks on a path with spaces.
  • --args 'v0.3.0 "support team"': a quoted argument stays one value, $audience='support team'.
  • --args '': no arguments, so both placeholders render empty and the heading reads # Release notes since. The skill's text tells Claude what to do then.
  • Break it: --deny 'Bash(python3 *)' marks the fenced command would abort, and the render stops: The invocation aborts; Claude never sees the skill content. A deny rule beats allowed-tools.
  • --mode auto --strip-allowed-tools: in auto mode an unapproved command doesn't abort. The prompt carries [run this command first: …] instead, and Claude's own call goes through the classifier. The docs don't publish that instruction's wording, so the lab shows its own.
  • python3 -m unittest discover -s core-5/workflow_skill/tests -v runs the bundled script's 14 tests on their own.
  • Install: cp -r core-5/workflow_skill/kit/.claude <your-repo>/, then type /release-notes v1.2.0 developers in Claude Code.
  • Injected commands are the skill's deterministic half: they run before the model sees anything, so their output is fact, not a request.
  • Pre-approve exactly the commands a skill injects. Deny rules still win, and outside auto mode anything that isn't allowed aborts the invocation.

A PostToolUse formatter hook

Exercise the kit's formatter hook (matcher Edit|Write, exec form with ${CLAUDE_PROJECT_DIR}) the way Claude Code runs it: validate the settings entry, show how each matcher is read, and feed the real script 10 payloads through common/hooks.py. It's the Deterministic Steps topic's "hooks for formatting and linting", with the failure cases included.

  • Python 3.9+
  • standard library only
  • offline: the kit in core-5/format_hook/kit/
python3 core-5/format_hook.py
┌────────────────────────────┐
│ PostToolUse formatter hook │
└────────────────────────────┘
[1] Validate the hooks in settings.json (kit)
  ok    PostToolUse matcher 'Edit|Write' is read as exact: Edit, Write
  ok    PostToolUse[0].hooks[0]: exec form (command + args, no shell), the form the docs recommend for path placeholders; needs Claude Code v2.1.139+
  info  PostToolUse[0].hooks[0]: no onFailure, so a crash fails open; fine for a formatter (PostToolUse can't stop a tool that already ran)

matcher         read as  Edit  Write  NotebookEdit  MultiEdit  Read  Bash
──────────────  ───────  ────  ─────  ────────────  ─────────  ────  ────
Edit|Write      exact    yes   yes    -             -          -     -   
Edit, Write     exact    yes   yes    -             -          -     -   
Edit.*          regex    yes   -      yes           yes        -     -   
^(Edit|Write)$  regex    yes   yes    -             -          -     -   
*               all      yes   yes    yes           yes        yes   yes 
[2] Run the hook script on 10 cases (common.hooks.run_hook, FORMAT_HOOK_FORMATTER=builtin)
  argv: python3 <project>/.claude/hooks/format_on_edit.py
  PASS  1. Write: messy .py is normalized and Claude is told to re-read
          PostToolUse: success | proceeds | context: 1 item(s)
  PASS  2. Edit: an already-formatted file stays silent
          PostToolUse: success | proceeds
  PASS  3. Write: a .py syntax error comes back as decision block (feedback, not a block)
          PostToolUse: success | decision=block | proceeds | Claude sees: "format_on_edit: tinyapp/broken.py doesn't compile: invalid syntax (line 1). Fix "
  PASS  4. Write: minified .json is re-indented
          PostToolUse: success | proceeds | context: 1 item(s)
  PASS  5. Write: invalid .json is reported and left as written
          PostToolUse: success | decision=block | proceeds | Claude sees: "format_on_edit: config/bad.json isn't valid JSON: Expecting property name enclos"
  PASS  6. Edit: Markdown keeps trailing spaces (hard line breaks), loses CRLF
          PostToolUse: success | proceeds | context: 1 item(s)
  PASS  7. Write: a file outside the project is never touched
          PostToolUse: success | proceeds
  PASS  8. Write: a path that doesn't exist is a no-op
          PostToolUse: success | proceeds
  PASS  9. Read payload (wrong tool for this hook) is a no-op
          PostToolUse: success | proceeds
  PASS 10. stdin that isn't JSON: exit 1, non-blocking error, the edit stands (fails open)
          PostToolUse: non_blocking_error | proceeds | failure (onFailure=continue)

  result: 10/10 cases behave as expected
[3] Install
  • mkdir -p <repo>/.claude && cp -Rn core-5/format_hook/kit/.claude/. <repo>/.claude/   (-n never overwrites an existing file)
  • If <repo>/.claude/settings.json already existed, cp skipped it: merge the block from `python3 core-5/format_hook.py --print-snippet` into its "hooks" object by hand.
  • Check it in a session with /hooks (read-only list), then ask Claude to write a file with trailing spaces.
  • Hooks run with your user permissions; review hooks a repository ships before you run `claude -p` there.
  1. The matcher uses only characters from the exact-match set (letters, digits, _, -, spaces, , and |), so it's an exact list: Edit and Write, nothing else. The table reads Edit, Write the same way.
  2. Exec form (command plus args, no shell) is what the docs recommend for path placeholders. With no onFailure a crash fails open, which is right for a formatter.
  3. Any character outside that set makes the matcher an unanchored regex, so Edit.* also catches NotebookEdit and misses Write.
  4. The file changed under Claude, so the hook says so through additionalContext; otherwise Claude's next edit works from stale text.
  5. On PostToolUse, decision: "block" blocks nothing: the edit already happened. It puts the reason in front of Claude.
  6. Bad stdin exits 1, a non-blocking error: the edit stands. A hook that guards something needs "onFailure": "block".
  • --print-snippet prints only the settings block to merge, with "command": "python3", "args" and "timeout": 30.
  • -v adds each case's stdout: hookSpecificOutput.additionalContext for a reformat, top-level decision and reason for a syntax error.
  • --settings core-2/samples/settings/repo/.claude/settings.json checks another file's hooks: core-2's sample project hook in shell form.
  • Break it: --settings core-2/samples/settings/broken/not-an-object.json exits 1 with ERROR no "hooks" object.
  • Install: mkdir -p <repo>/.claude && cp -Rn core-5/format_hook/kit/.claude/. <repo>/.claude/. -n never overwrites, so if settings.json already existed, merge the snippet by hand and check it with /hooks.
  • The matcher grammar: an exact list unless any other character turns it into an unanchored regex.
  • What each PostToolUse output does: additionalContext informs, decision: "block" gives feedback, and a crash fails open.
  • Hooks are defense in depth. The boundary is permission deny rules plus the sandbox.

A security checklist for a repository

Run a PASS/WARN/FAIL/MANUAL checklist over a repository before you let Claude Code work in it: credential-shaped strings (redacted), key and .env files, unpinned dependencies and install scripts, and the Claude Code config the repository ships. "Can Claude's Read tool open .env?" is answered by the course's permission engine, not by a guess. It's the deterministic pre-pass for the Security topic.

  • Python 3.9+
  • standard library only
  • offline: a seeded sample, generated in a temp dir, and common/samples/tiny-app
python3 core-5/security_review.py

The seeded repository is built at run time from string pieces, so no credential-shaped literal exists in the lab's folder; the values are fake.

┌──────────────────────────────────────────────────────────────────────────┐
│ Security checklist: seeded sample (generated in a temp dir, fake values) │
└──────────────────────────────────────────────────────────────────────────┘
  Secrets
    FAIL   S1   No credential-shaped strings in files
                .env:1  Anthropic API key  sk-a…(34 chars)
                .mcp.json:17  credentials in a URL  post…(35 chars)
                app/client.py:4  GitHub token  ghp_…(40 chars)
                app/client.py:5  hard-coded secret assignment  pass…(29 chars)
                app/settings.py:3  AWS access key ID  AKIA…(20 chars)
                app/settings.py:4  credentials in a URL  post…(33 chars)
                deploy/id_ed25519:1  private key block  ----…(35 chars)
                fix: Delete the value, rotate the credential (assume it leaked), and load it from the environment or a secret manager.
                docs: https://code.claude.com/docs/en/security#security-best-practices
…
    WARN   S4   Claude's file tools can't read the secret files
                .env  Read would be allow (reads inside the working directories need no approval)
                deploy/id_ed25519  Read would be allow (reads inside the working directories need no approval)
                fix: Add deny rules to .claude/settings.json, e.g. "permissions": {"deny": ["Read(./.env)", "Read(./deploy/**)"]}. They cover Claude's file tools and recognized Bash file commands, not every subprocess, so pair them with sandbox denyRead for OS-level blocking.
                docs: https://code.claude.com/docs/en/permissions#read-and-edit
…
  Claude Code config
    PASS   C0   Repo settings files parse
    WARN   C1   Project allow rules don't grant arbitrary execution
                .claude/settings.json:4  allow Bash
                .claude/settings.json:5  allow Bash(python3*)
                .claude/settings.json:6  allow Edit
                fix: Replace broad rules with narrow ones such as Bash(npm test) or Bash(python3 -m unittest *). They apply only once the folder is trusted (claude -p never shows the dialog, so a folder never trusted doesn't get them), but teammates who trust it get them.
                docs: https://code.claude.com/docs/en/permissions#project-allow-rules-and-workspace-trust
    FAIL   C2   Repo settings don't request bypassPermissions or auto
                .claude/settings.json:8  defaultMode bypassPermissions
                fix: Remove defaultMode from repo settings. auto and bypassPermissions don't take effect from project or local settings, but they aren't dead config: a repo bypassPermissions starts every session in Manual and a repo auto falls back to the built-in default, overriding each developer's own defaultMode in ~/.claude/settings.json. Before v2.1.257 a repo bypassPermissions took effect.
                docs: https://code.claude.com/docs/en/permission-modes#which-mode-a-session-starts-in
    WARN   C3   Committed hooks are reviewed
                .claude/settings.json:23  PostToolUse: npm run lint
                .claude/settings.json:33  SessionStart: ./scripts/bootstrap.sh
                fix: Read every hook command: hooks run with your user permissions, and in claude -p or the SDK they run even in a folder you never trusted. For headless runs in repos you didn't write, pass --settings '{"disableAllHooks": true}' or --bare.
                docs: https://code.claude.com/docs/en/permissions#what-runs-before-you-trust-a-folder
…
    FAIL   C7   .mcp.json holds no literal credentials
                .mcp.json:17  db.env.DB_URL = post…(56 chars)
                .mcp.json:7  tickets.headers.Authorization = Bear…(34 chars)
                fix: Reference variables instead, e.g. "Authorization": "Bearer ${TICKETS_TOKEN}" (supported in command, args, env, url and headers). Claude Code reads its own and cloud credentials, such as ANTHROPIC_API_KEY, as empty toward a remote server, so give the server its own variable.
                docs: https://code.claude.com/docs/en/mcp#environment-variable-expansion-in-mcp-json
    WARN   C8   MCP server packages are pinned
                .mcp.json:14  db: npx example-db-mcp (no version)
                fix: Pin the package (npx -y example-db-mcp@1.4.2); an unpinned npx/uvx server runs whatever version is newest on every start.
                docs: https://code.claude.com/docs/en/mcp
…
  summary: 6 FAIL, 11 WARN, 1 PASS, 5 MANUAL, 1 N/A

┌─────────────────────────────────────────────┐
│ Security checklist: common/samples/tiny-app │
└─────────────────────────────────────────────┘
  No WARN or FAIL items. The MANUAL items still apply: they live in your user settings and habits.

  summary: 4 PASS, 5 MANUAL, 15 N/A  (brief: only WARN/FAIL shown)

[next] Follow up
  • /security-review in Claude Code: model-based review of your pending changes
  • pip-audit -r requirements.txt and npm audit: known vulnerabilities (online)
  • Hooks and checklists are defense in depth; the boundary is permission deny rules plus the sandbox.
  1. Matches are redacted to four characters and a length, so the report itself is safe to share.
  2. With no deny rule, Claude's Read tool opens .env and the key file without asking: reads inside the working directories need no approval.
  3. It doesn't take effect from a repository, but it isn't dead config either: every session starts in Manual, overriding each developer's own defaultMode.
  4. Committed hooks run with your user permissions, and in claude -p or the SDK they run in a folder you never trusted.
  5. Literal credentials in .mcp.json. Reference variables instead, and give the server its own.
  6. tiny-app passes. The MANUAL items remain because they live in your user settings and habits, not in the repository.
  • --repo common/samples/tiny-app --strict: the full checklist for one repository, exit 0 because nothing FAILs.
  • Break it: --strict on the default run exits 1, because the seeded repository FAILs six checks. That's the CI form.
  • --json also writes the report to core-5/out/security-report.json.
  • --repo ~/code/my-app --strict --json runs it on your own repository, read-only, and saves the JSON report in core-5/out/. The commands run from labs/, so --repo . would scan the labs folder itself.
  • Every verdict comes from a rule you can read, so the model's job is to explain and propose fixes, not to decide.
  • Follow the pre-pass with /security-review in Claude Code and an online audit such as pip-audit or npm audit.