.claude/skills/quality-gate/SKILL.md
Run the quality gate — parallel agent review, fix cycle, test, report. Composable — called by /iteration-complete and /phase-complete.
npx skillsauth add the-agency-ai/the-agency .claude/skills/quality-gateInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Run the full quality gate protocol: parallel agent review → consolidate → bug-exposing tests → fix → coverage tests → confirm clean → present QGR.
This skill is composable — it runs the QG and returns the report. It does NOT commit, update the plan, or update the handoff. The caller (/iteration-complete, /phase-complete, /plan-complete) handles those steps.
The full QGR format and commit message structure are injected automatically via the ref-injector hook when this skill is invoked — refer to that injected content for the authoritative format.
The gate applies to any artifact type — code, commands, config, documentation. Adapt the review to the artifact: code gets correctness/security/performance review plus tests; commands and config get design review, spec compliance, and edge case analysis; documentation gets accuracy and completeness review. Report sections that don't apply are marked "N/A" with a brief explanation, never omitted.
$ARGUMENTS: Description of what was completed (e.g., "Iteration 1.2: parser edge cases" or "Phase 1: types and parser"). Required — if empty, stop and ask the caller what was completed.--base <ref>: Baseline ref for the diff hash chain. Optional. If omitted, defaults to origin/main. Callers pass:
/iteration-complete → --base {prior-iteration-commit}/phase-complete → --base {phase-start-tag}/pr-prep / /plan-complete → --base origin/mainParse --base <ref> out of $ARGUMENTS at the start of Step 0. The remainder is the description. If no --base is present, set BASE_REF=origin/main.
$ARGUMENTS (after stripping --base) is empty, stop and ask what was completed before proceeding../claude/tools/skill-verify --quiet. If it fails, report the missing/invalid skills and stop — the framework is incomplete.git diff --stat HEAD and git status. If no changed files, report "Nothing to gate — no changes since last commit" and stop../claude/tools/diff-hash --base "$BASE_REF" --json and capture the full SHA-256 from the JSON output. Record as HASH_A. This is the state of the code BEFORE any QG work begins.Launch all four reviewer agents in parallel, plus conduct your own review simultaneously.
Provide each agent with the list of changed files and instruct them to read those files.
reviewer-code (subagent_type: reviewer-code) — Bugs, logic errors, null handling, type mismatches, runtime crashes. Focus on correctness.
reviewer-security (subagent_type: reviewer-security) — OWASP Top 10, injection risks, auth/authz gaps, data exposure, secrets. Focus on security.
reviewer-design (subagent_type: reviewer-design) — Architecture patterns, convention compliance, API design, structural consistency. Focus on design quality.
reviewer-test (subagent_type: reviewer-test) — Test coverage gaps, missing edge cases, stale assertions, test/implementation consistency. Focus on test quality.
Launch all four in a single parallel Agent tool call. Each agent runs independently with read-only tools (Read, Grep, Glob).
While agents run, read the changed files yourself. Look for:
Take ALL findings from the 4 agents + your own review and send them to the reviewer-scorer agent (subagent_type: reviewer-scorer, model: haiku) for confidence scoring.
Provide the scorer with:
The scorer rates each finding 0-100. Filter out findings scored below 50. (The QG fixes real issues — threshold 50 catches anything the scorer considers "likely real." Note: the scorer's output shows both >=80 and >=50 thresholds for informational purposes — the QG uses >=50 as the operative threshold.)
Merge and deduplicate the surviving findings into a single prioritized list. Assign each an ID (1, 2, 3...).
Capture Hash B (raw review findings): write the consolidated findings list (the post-scorer, deduplicated, prioritized list with IDs) to a temp file — e.g., $(mktemp -t qg-findings). Then run ./claude/tools/diff-hash --file <temp-file> --json and capture the full SHA-256 as HASH_B.
After the findings list is finalized (post-scorer, deduplicated, with author triage decisions — what's accepted, what's rejected, what's deferred into a bucket), write the triage summary to a temp file — e.g., $(mktemp -t qg-triage). Include per-finding disposition (accept / reject / defer / bucket) and any rationale. Then run ./claude/tools/diff-hash --file <temp-file> --json and capture the full SHA-256 as HASH_C.
For each code issue in the consolidated list, write a test that exposes the bug.
./claude/tools/test-run if available, or the project's standard test command.Fix each issue. Re-run the exposing test and confirm it now passes (green).
Red → green is the proof the fix works. If you can't demonstrate the red → green cycle, you don't have a valid bug-exposing test.
Do NOT defer findings. Fix everything. "Fix what you find."
Using the reviewer-test findings (from Step 1), decide what additional tests are needed:
If the work has no testable code (pure docs/config), note "N/A" in the report.
Write the additional tests identified in Step 5.
If new tests expose problems, fix them.
Run checks scoped to the changed files. Use the project's quality tooling:
./claude/tools/commit-precheck or the project's format command./claude/tools/test-run or the project's test commandAddress any failures. Re-run until all pass. The Failing row must be 0.
Present the QGR in the exact format from the injected quality-gate.md reference. This includes all sections:
The QGR format in the injected reference is the source of truth — do not use a different format.
In the "Stage 1 — Parallel Review" section, attribute findings to the formal agents:
**Stage 1 — Parallel Review**
- reviewer-code: N issues (bugs, logic errors, correctness)
- reviewer-security: N issues (security, injection, auth)
- reviewer-design: N issues (patterns, conventions, API design)
- reviewer-test: N issues (coverage gaps, stale tests, consistency)
- reviewer-scorer: scored N findings, N passed threshold (>=50)
- Own review: N issues (describe what you looked at)
After presenting the QGR, sign a receipt via ./claude/tools/receipt-sign. Receipts live in claude/workstreams/{W}/qgr/ (or rgr/ for review gates) with full provenance naming and a five-hash chain of trust.
phase-complete / plan-complete / pr-prep): hash the transcript file. Run ./claude/tools/diff-hash --file <transcript-path> --json and capture the full SHA-256 as HASH_D. Record HASH_D_SOURCE="transcript" and HASH_D_TRANSCRIPT=<transcript-path>.iteration-complete): set HASH_D=$HASH_C and HASH_D_SOURCE="auto-approved — no principal 1B1". Omit --hash-d-transcript. (receipt-sign also auto-detects this when hash-d == hash-c.)After Step 8 confirmed everything is clean and all fixes are staged/written to disk, run ./claude/tools/diff-hash --base "$BASE_REF" --json and capture the full SHA-256 as HASH_E. This is the final artifact state — what will be committed.
$ARGUMENTS (first token after any --base is stripped): one of iteration-complete, phase-complete, plan-complete, pr-prep../claude/tools/agency whoami (or glob usr/*/)../claude/tools/agent-identity if available) or from the caller's context. Workstream typically matches the current branch/worktree; project matches the active plan/A&D.--summary string derived from the description in $ARGUMENTS (the text after the boundary token)../claude/tools/receipt-sign \
--type qgr \
--boundary <iteration-complete|phase-complete|plan-complete|pr-prep> \
--org the-agency \
--principal <principal> \
--agent <agent> \
--workstream <workstream> \
--project <project> \
--hash-a "$HASH_A" \
--hash-b "$HASH_B" \
--hash-c "$HASH_C" \
--hash-d "$HASH_D" \
--hash-e "$HASH_E" \
--hash-d-source "$HASH_D_SOURCE" \
[--hash-d-transcript "$HASH_D_TRANSCRIPT"] \
--diff-base "$BASE_REF" \
--summary "<short summary>"
Capture the receipt path printed by receipt-sign (it writes to claude/workstreams/{W}/qgr/ with the naming convention {org}-{principal}-{agent}-{ws}-{proj}-qgr-{boundary}-{YYYYMMDD-HHMM}-{hash_e_short}.md).
Report: "Receipt signed: claude/workstreams/{W}/qgr/{filename}"
Do NOT write the old usr/{principal}/{project}/qgr-*.md stage-hash receipt — that path is retired. During transition, receipt-verify still recognizes old-format receipts at usr/**/qgr-*.md (per Plan Iteration 1.4) so in-flight PRs aren't broken, but new QG runs MUST emit receipts only via receipt-sign. The sunset condition: backward compat is removed when no old-format receipts remain in the repo.
After signing the receipt, the skill is complete. The caller handles:
Return control to the caller.
business
Sync worktree with master — merge, copy settings, run sandbox-sync, report changes
tools
List all git worktrees with status info (branch, clean/dirty, deps)
tools
Remove a git worktree and optionally delete its branch
development
Create a new git worktree with dedicated branch and bootstrapped dev environment