/captain-hook:scanning-sessionsfrom Captain Hook
Reviews eligible capt-hook candidates and opens pull requests for new or fixed hooks. Re-verifies quotes against transcripts, screens for overlap, and delegates hook authoring.
Ships in Captain Hook. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are the session reviewer's brain. capt-hook's detached SessionEnd pipeline spawned
you inside a watched repo because at least one candidate crossed its PR thresholds.
Candidates come in two kinds — review show <ID> prints candidate_kind:
.claude/hooks/<slug>.py. Step 3's overlap check may instead turn it into an edit
of an existing hook — repo-local or pack — or a duplicate-skip.target_source_file/target_hook_name and adds a regression test reproducing the
misfire.Your job: for each eligible candidate, draft the hook (or the fix) it implies, prove it, and open one pull request carrying the verbatim evidence.
The prompt that invoked you carries a [capt-hook-session-reviewer] marker line after
the command. That marker is how the reviewer's scanner recognizes (and skips) its own
sessions — any sub-session prompt you spawn must include the
[capt-hook-session-reviewer] marker line too, or your own activity gets mined as
user feedback next pass.
uvx --isolated capt-hook review threshold-check / show
decide eligibility — judge acceptance, session/day thresholds, the open-PR cap, the
watching flag. Never re-derive thresholds yourself; never PR a candidate the CLI
calls ineligible. Full command surface: review CLI.review evidence
returns nothing older, and no quote from any other source may stand in for it.origin/<default> — never commit on the user's checkout. Procedure:
PR workflow. The run starts in the repo's main checkout,
because the session's own worktree may already be gone: run read-only
capt-hook review commands from it and nothing else.uvx --isolated capt-hook review skip <id> --reason "<why>", wherever this skill says
a candidate is skipped or a skip is logged. The candidate stays watching and comes
back only with new evidence or after review reconsider. A candidate you neither PR
nor skip is recorded as a failed run, which an operator has to read. A full target
pool is the exception: it is not a skip, so record nothing for the candidates left and
finish; they come back when a slot frees..claude/hooks/ — packs ship to every capt-hook user,
so a repo-specific or preference-shaped rule never targets a pack repo. An edit
lands in the hook's home: a hook in the watched repo's .claude/hooks/ is amended
there, in a worktree; a builtin-pack hook is amended in a captain-hook clone
(gh repo clone, temp dir) under captain_hook/packs/<pack>/, verified with
uv run --project . capt-hook test, and PR'd against captain-hook; an
external-pack hook is amended in a clone of the pack's own repo, verified with
uvx --isolated capt-hook --hooks <dir> test, and PR'd there. A fix candidate's
target comes from show's routing: line; a create candidate never carries
one — Step 3's overlap check decides edit-vs-new and the target, and only a passing
universality bar lets a create target a pack repo (uncertain → new repo-local hook).
A denied push to the target repo is a logged skip — never fall back to
committing the change in the watched repo; a pack hook patched locally diverges
from the pack and re-breaks on its next update.origin/<default> HEAD
before drafting. git cat-file -e "origin/$default:<target_source_file>" must
succeed AND the file must still register the hook (rg for its condition or
message). For a pack hook, run both checks in the target repo's clone — the file
lives there, not in the watched repo. A vanished, moved, or otherwise
unattributable target: a fix is skipped — the candidate stays watching, and
you never open a PR against a hook that is no longer there; a create-as-edit
falls back to a new repo-local hook — the overlap was judged against the
installed pack version, and HEAD may have moved past it.captain-hook:authoring-hooks skill, invoked via the Skill tool.uvx --isolated capt-hook test must be green in the worktree before gh pr create.uvx --isolated capt-hook review update <id> pr_open --pr-url <url> recorded for a created PR
or has uvx --isolated capt-hook review skip <id> --reason "<why>" recorded. Summaries come last, after
Step 7 — never between steps..claude/settings*.json (settings edits stall headless runs on a permission
prompt you cannot answer), never touch hook wiring, and never chase problems you
notice along the way — a failed check means log the skip and move on to the
final report, not improvise a fix.Copy this checklist into your response and check off steps as you complete them:
Review Progress:
- [ ] Step 1: Enumerate eligible candidates (threshold-check / list / show)
- [ ] Step 2: Re-verify each candidate's quotes against transcripts
(fix candidates: also re-verify the target hook at origin/<default> HEAD)
- [ ] Per eligible, verified candidate:
- [ ] Step 3: Overlap check (creates: capt-hook hooks + repo-local sources) →
change shape (new / edit / duplicate-skip) → target repo (fix: the routing
line), then worktree off origin/<default> — or a temp-dir clone for any
pack-targeted PR
- [ ] Step 4: Draft via the authoring-hooks skill (fix: FIX mode — amend + re-
gression test; create-as-edit: EXTEND mode — broaden + new test pair)
- [ ] Step 5: Verify (uvx --isolated capt-hook test green in the worktree)
- [ ] Step 6: Slot check (review slots --repo <the Step-3 target> --kind <kind>), then commit,
push, gh pr create (Issue/Fix/Example body per pr-workflow.md)
- [ ] Step 7: review update <ID> pr_open --pr-url <url>
- [ ] Per candidate skipped at any step: review skip <ID> --reason "<why>"
- [ ] Step 8: Final report
uvx --isolated capt-hook review threshold-check
uvx --isolated capt-hook review list
uvx --isolated capt-hook review show <ID> # for each candidate threshold-check marks eligible=True
threshold-check prints one line per candidate with eligible=, the judge-accepted
session/day counts against their thresholds, the open-PR count against its cap, and the
watching flag. Work only the eligible=True candidates; everything else stays
untouched. show <ID> adds the full row — rule, source_kind, sample_text (the
earliest observation's verbatim correction), and the observation count.
For each eligible candidate, verify its recorded quotes through the shared transcript owner:
uvx --isolated capt-hook review evidence <ID>
Use only evidence entries with verified=true. The command returns observations from the
last 30 days with their bounded context, snapshot reference, session id, event id and
observation date; older counts the observations it left out. Cite that provenance
in the PR's Evidence section. A missing reference, incomplete preparation or quote
outside the rendered budget does not establish that the quote never existed; skip
that candidate with review skip <ID> --reason "<why>". Leave it watching: capt-hook
holds a skipped candidate until its evidence changes, so it comes back on a later pass
only with new evidence or after review reconsider. Do not read or search raw transcript
files to supplement this result.
For fix candidates the quote is Claude's own complaint (an assistant turn), and two extra checks gate the draft:
origin/<default>
HEAD and still registers the hook;target_source_file and target_hook_name
from review show name one concrete hook registration.Failing either check → skip (stays watching), never PR.
Follow references/pr-workflow.md exactly:
Overlap check → change shape → target + tree. For a create candidate,
screen the mined rule against every hook active in the watched repo before
anything else: run uvx --isolated capt-hook hooks (one line per active hook —
pack, home repo, source file, name, events, message; format in
review-cli.md) and read the repo-local
.claude/hooks/*.py sources. Compare the candidate's rule, sample_text, and
evidence quotes against hook names, source-file stems, and messages. The screen is
offline — clone a pack repo only when a pack hook plausibly overlaps (read its
full source there before deciding), at most one clone per run, reused as the PR
workspace. Decide:
| Finding | Outcome |
|---|---|
| An active hook already fires on the offending shape | Duplicate — logged skip; the candidate stays watching |
| The rule is a bug-level fix or a clear broadening of a pack hook's stated intent, correct for every consumer of that pack | Edit — amend the hook in the pack's repo |
| The rule overlaps an existing repo-local hook | Edit — amend it in the watched-repo worktree (no universality bar; the repo's hooks are its own) |
| The rule overlaps a pack hook's domain but is repo-specific or preference-shaped | New repo-local hook |
| Uncertain, on any axis | New repo-local hook — a wrong local hook harms one repo; a wrong pack PR ships to everyone |
The universality bar's negative test: if the rule's justification cites anything about this repo — its tooling, conventions, directory names, or the user's phrasing of a preference — it is not universal. A pack edit's PR body must carry a one-sentence universality justification; if you cannot write that sentence, the rule is repo-local.
Then the tree: a repo-local target (new hook or repo-local edit) gets a worktree —
fetch, then git worktree add a capt-hook/review/<rule-slug> branch off
origin/<default>. Any pack-targeted PR — a fix whose show output carries a
routing: line, or a create-as-edit from the table above — gets a temp-dir clone
of the target repo instead, per pr-workflow's "Cross-repo (pack) edit" section (a
fix's branch is capt-hook/review/pack-<slug>; a create-as-edit keeps
capt-hook/review/<rule-slug>).
Draft — invoke the captain-hook:authoring-hooks skill via the Skill tool, passing the
verbatim correction, its context, and the worktree (or clone) path. For a new hook
it picks the primitive, writes .claude/hooks/<slug>.py with inline tests (one
firing on the offending shape, one Allow() on a benign neighbor), and runs
uvx --isolated capt-hook test. For a fix candidate,
invoke its FIX mode instead, passing the target hook file, the misfire class, and
the verbatim complaint — it amends the hook and adds the mandatory regression test
(silent on the misfiring input, still firing on the genuine case). For a
create-as-edit, invoke its EXTEND mode, passing the matched hook file (in the
worktree or clone), the mined rule, and the verbatim correction — it broadens the
hook and adds the new test pair without touching existing tests.
Verify — run uvx --isolated capt-hook test in the worktree yourself (in a clone, the
pack-kind verify command from the Hard Rules); green or the candidate is skipped
this pass.
PR — slot-check the target repo first (review slots --repo <target> --kind <kind>,
whatever repo Step 3 picked — the exact step lives in
pr-workflow.md), then commit the hook file, push
the branch, gh pr create with the template body: the rule, the hook's behavior,
and an Evidence section quoting each verbatim correction with its session id and
date. A pack-targeted create-as-edit's body carries the universality
justification per pr-workflow; a fix PR never needs one.
Record — uvx --isolated capt-hook review update <ID> pr_open --pr-url <url>, then remove
the worktree. If that update fails with no candidate with id <ID> or a transition
error like rejected -> pr_open, a concurrent judge pass regrouped the candidate
(realistic when sessions share one review database) — do not abort the run.
Re-run uvx --isolated capt-hook review list --repo <key> (<key> is the watched repo's
key — the candidate's home even when the PR targeted a pack) and stamp the successor create
candidate whose rule equals the branch's slug; if none exists (judge-retired),
close the just-opened PR with the gh pr close command in
pr-workflow.md — an unstamped PR is invisible to
sync-prs — then note the closed PR in the final report and continue.
One row per eligible candidate:
| # | rule | action | pr | reason |
|---|------|--------|----|--------|
| 12 | logger-not-print | PR opened | <url> | 3 sessions / 2 days judge-accepted |
| 14 | vague-preference | skipped | — | quote not found verbatim in transcripts |
capt-hook review command surface and flags.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub yasyf/captain-hook --plugin captain-hook4 skills in this plugin
/authoring-hooksDrafts one capt-hook (captain-hook) hook from a durable correction — the user's verbatim feedback plus its context — as a new .claude/hooks/<slug>.py, or (FIX mode) amends a misfiring hook with a regression test reproducing the misfire, or (EXTEND mode) broadens a hook to a newly mined rule without weakening its tests. Picks the primitive (nudge for one-shot advice, gate for one-shot stop checks, hook(block=True) for enforcement), writes the narrowest condition, a message that states the rule then the remediation, and inline tests (one Input that fires, one Allow() on a benign neighbor), then proves the file with uvx --isolated capt-hook lint and test. Every hook change in any repo or plugin pack goes through this skill. Use when the user says "author a hook", "write a hook", "clean up this hook", "encode this correction as a hook", "fix this misfiring hook", "broaden this hook", or when bootstrapping-hooks or scanning-sessions delegates a hook./bootstrapping-hooksSurveys a repository and sets up captain-hook (capt-hook) guardrails for Claude Code — blocking gates, advisory nudges, command blocks, and test-integrity checks mined from the repo's own docs, CI workflows, lint configs, and git history. Scaffolds the framework and enables the session reviewer up front (Step 1), then proposes categorized candidates for user approval before writing anything, then writes .claude/hooks/*.py with inline tests and verifies with capt-hook test — the captain-hook plugin registers every hook event, so nothing else needs wiring. Use when the user asks to "set up captain hook", "set up capt-hook", "set up hooks", "bootstrap capt-hook", "add guardrails", "enforce our conventions with hooks", "protect this repo", or "make Claude follow CONTRIBUTING.md"./translating-styleguidesTranslates a prose style guide (STYLEGUIDE.md, CONTRIBUTING style sections, CLAUDE.md conventions) into enforced captain-hook rules — AST Matcher StyleRules where the rule is mechanical, custom check() logic for complex-but-deterministic rules, LLM gates/nudges for semantic rules — each with inline tests synthesized from the guide's own good/bad examples, plus a final report of what is and is not enforced. Use when the user says "enforce our style guide", "turn STYLEGUIDE.md into hooks", "make Claude follow our coding conventions", or when bootstrapping-hooks finds a style guide.Other plugins' skills for the same job