Harness Branch Buster
Sync a branch from its base with interactive conflict resolution, run the
project's exact CI gate set locally, delegate review to harness-code-review,
then classify every finding by origin — introduced by this branch, or
pre-existing on the base — into a dated report, and auto-fix only the in-scope
ones after a single approval.
When to Use
- Manually, when a feature branch is ready for a thorough pre-merge audit: after
a long development period, before opening a PR, or after a large merge from the
base branch.
- When a branch has drifted far enough from its base that the integration itself
is the risk, not just the diff.
- When you need to know which problems a branch introduced versus which it
merely inherited — that separation is this skill's reason to exist.
- NOT as a continuous linter or a pre-commit hook. This is a deliberate,
on-demand audit.
- NOT as a replacement for CI. It mirrors CI locally to predict it, never to
bypass it.
- NOT for reviewing a diff alone — that is
harness-code-review, which this
skill calls rather than duplicates. If you do not need the sync, the CI-exact
gate run, or the origin split, use harness-code-review directly.
Iron Law
Review and Fix are separate phases. No edit is applied while findings are
still being gathered, and the report is frozen before any code changes. Review
integrity comes first; the auto-fix follows it.
What this skill owns, and what it delegates
This skill exists alongside harness-code-review, and the boundary is
deliberate. Two copies of review logic in one toolchain drift apart, and the
copy that drifts is the one nobody is looking at.
| Concern |
Owner |
| Generic review lenses (bugs, security, architecture) |
harness-code-review — delegated to |
| Adversarial refutation of high-severity findings |
harness-code-review — delegated to |
| Syncing the branch and resolving conflicts |
This skill |
| Running the project's CI-exact gate set |
This skill |
| Classifying findings by origin |
This skill — its novel contribution |
| Project-specific lenses |
This skill, from configuration |
| The single approved fix pass |
This skill |
Never re-implement a generic lens here. If the generic roster is missing
something, that is a change to harness-code-review, not a second roster.
Configuration
The skill hardcodes no project's commands, packages, or conventions. Everything
project-specific lives in harness.config.json under skills.branchBuster:
{
"skills": {
"branchBuster": {
"baselineEnv": "TURBO_SCM_BASE",
"runDir": "docs/branch-buster",
"reportLintCommand": "npx markdownlint-cli2 --no-globs {report}",
"quarantinePath": "quarantine.json",
"learningsPath": ".harness/branch-buster-learnings.md",
"gates": [
{ "id": "format", "cmd": "npm run format:check", "parse": "prettier", "blocking": true },
{ "id": "build", "cmd": "npm run build", "parse": "passfail", "blocking": true },
{ "id": "typescript", "cmd": "npm run typecheck", "parse": "passfail", "blocking": true },
{ "id": "test", "cmd": "npm test", "parse": "passfail", "blocking": true },
{
"id": "codegen-drift",
"cmd": "DRIFT",
"parse": "drift",
"blocking": true,
"drift": {
"regenerate": ["npm run codegen"],
"paths": ["src/generated"],
"remedy": "re-run `npm run codegen`"
}
}
],
"lenses": [
{
"id": "design-system",
"prompt": "Check for hardcoded colors, off-grid spacing, and bypassed design tokens.",
"paths": ["packages/ui/**"]
}
]
}
}
}
| Key |
Meaning |
If absent |
gates[] |
The project's blocking gate set, in CI order. |
Phase 2 abstains — see the Gates section. |
baselineEnv |
Env var pinning an incremental build tool to the merge base. |
No baseline is set; gates run unscoped. |
lenses[] |
Project-specific review lenses, added alongside the delegated generic roster. |
Only the generic roster runs. |
runDir |
Where dated run directories are written. |
docs/branch-buster. |
reportLintCommand |
Command to lint the rendered report. {report} is substituted. |
The report is not linted; say so rather than implying it was. |
quarantinePath |
Known-flaky test ledger, checked before calling a failure a regression. |
Every failure is treated as real. |
learningsPath |
Where pushed-back findings are recorded and suppressed from. |
No learnings filter is applied. |
Process
0 INTAKE -> 1 SYNC -> 2 MECHANICAL -> 3 SCOPE+CALIBRATE -> 4 FAN-OUT (delegated)
|
v
8 VERIFY+FINALIZE <- 7 FIX <- 6 CLASSIFY+REPORT <- 5 VALIDATE+DEDUP
Phase 0: INTAKE
- Resolve identity: if a PR exists (
gh pr view --json number,title), derive
a slug from its title; otherwise use the branch name.
- Resolve the base ref (default
origin/main), the flags, and the run
directory {runDir}/{slug}_{YYYY-MM-DD}/.
- Resume check: if the run directory holds a
state.json from an interrupted
run, offer to resume from the last completed phase rather than restart.
- Dirty-tree guard: run
git status --porcelain. If the tree is dirty, ask
once in plain text in your reply whether to commit or stash before SYNC,
and wait for the answer. Stashes are restored in Phase 8.
Every ask in this skill is plain text in your own reply, never an
emit_interaction question or confirmation. That call renders and records a
prompt but does not show it to the human — the client
collapses it to "Called harness" and the text returns only to the model, so the
human sits looking at nothing while the agent waits on an answer they were
never shown. Plain text is the only channel that reaches the human on every
platform this skill ships to. AskUserQuestion is Claude-Code-only.
Phase 1: SYNC
git fetch origin.
- Pre-merge preview via
scripts/sync-branch.mjs: show git log --oneline HEAD..{base} and which of the branch's files those commits touch, so the scope
of the integration is visible before conflicts start.
git merge {base}. Never --no-verify; no auto-commit on conflict.
- Interactive conflict resolution: for every conflicted file, present both
sides with surrounding context and a proposed resolution in plain text in
your reply, one at a time, and take an explicit decision — even when the
resolution looks obvious.
git add each resolved file.
- Complete the merge with a conventional message.
- Post-merge semantic smoke: run the project's typecheck and lint gates on
affected packages to catch semantic breakage a textually-clean merge hides.
Tag conflict-resolved hunks for first-priority review in Phase 4 as candidate
merge-artifact findings.
- Escape hatch: any failure or user abort triggers
git merge --abort and a
clean stop.
Phase 2: MECHANICAL
Runs scripts/run-gates.mjs, which executes the configured gate set in
order and captures structured findings. This is the deterministic backbone and
the source of the exclusion set — review agents in Phase 4 must not re-report
what a tool already caught.
- Load
skills.branchBuster.gates. If none are configured, Phase 2 abstains:
record verdict: abstained and carry it into the report. Do not render an
empty gate run as a pass — a gate set that ran nothing verified nothing.
- Set
baselineEnv to the merge base so local verdicts match CI's scoping.
- Run each gate. A failing blocking gate produces a
critical finding
tagged with that gate; non-blocking gates produce suggestion findings.
- Flaky awareness: cross-check a test failure against
quarantinePath
before reporting it as a blocker. If no ledger is configured, treat every
failure as real and say that is what you did.
- Diff-smell sub-pass: deterministic greps over the diff for high-signal
regressions — functional code replaced by a comment, stray
console.log or
debugger, committed .only/.skip, newly added any/@ts-ignore/
eslint-disable, new TODO/FIXME.
- Skipped entirely with
--no-mechanical, which must be recorded in the report
as reduced coverage.
Phase 3: SCOPE and CALIBRATE
Runs scripts/compute-diff.mjs and scripts/pick-hotspots.mjs.
- Compute the diff as
{base}...HEAD (three-dot, post-merge) for stats, per-file
change type, and blast radius via import tracing.
- Classify change type (feature/bugfix/refactor/docs) from commit prefixes and
diff heuristics, to shape review focus.
- Calibrate depth from diff size plus risk keywords: Quick, Standard, or
Deep. A large, wide branch calibrates to Deep.
- Assemble read-only context bundles per lens: changed files, dependencies,
convention files, corresponding tests.
- Bound the sweep, and log the bound. Mechanical detectors run repo-wide;
expensive review lenses run on the diff plus dependents plus the top-N riskiest
files by churn × complexity. Record what was excluded so the report never
implies more coverage than was performed.
Phase 4: FAN-OUT REVIEW — delegated
- Invoke
harness-code-review for the generic roster, passing the computed
diff scope, the depth tier, and the mechanical exclusion set. It owns the
generic lenses and the adversarial refutation pass; consume its Finding[].
- Dispatch only the project's configured
lenses[] (via Task), each with
crafted, domain-scoped, read-only context — never the orchestrator's session
history. Each returns Finding[].
- Conflict-resolved hunks from Phase 1 are reviewed first, whichever lens covers
them.
- Diff-coverage / test-gap runs here: new logic in the diff with no test
coverage is emitted as
test-type findings.
If lenses[] is empty, the delegated generic roster is the whole review. That is
a valid configuration, not a degraded one — say so plainly rather than implying
project-specific coverage that does not exist.
Phase 5: VALIDATE and DEDUP
- Mechanical exclusion — discard agent findings already flagged in Phase 2.
- Reachability check — verify claimed dependency and impact paths; downgrade
or discard unreachable claims.
- Adversarial verification — delegated to
harness-code-review for the
findings it produced. For findings from project lenses, dispatch a second agent
prompted to refute each critical/important one. Refuted findings, and any
below confidence 25, are suppressed.
- Learnings filter — suppress findings matching the Noise section of
learningsPath, when configured.
- Dedup and merge — group by file plus overlapping line range, keep the
highest severity, combine evidence, merge type tags.
Phase 6: CLASSIFY and REPORT
Runs scripts/render-report.mjs.
Classify every surviving finding on three axes. Origin is the axis this
skill contributes and the one the fix phase keys off:
pr-scoped — the finding is inside the branch's own diff. This branch
introduced it.
underlying — the finding is in code the branch did not touch. It exists on
the base too, and the branch merely revealed it.
Getting this wrong in either direction is costly: a pre-existing problem
labelled pr-scoped blocks a branch for something it did not cause, and an
introduced problem labelled underlying ships a regression as someone else's
pre-existing debt. Classify by whether the file and line range appear in the
three-dot diff, not by intuition about the cause.
Write the report to the dated run directory, with an adjacent .gitignore:
*
!.gitignore
!report.md
An allowlist on purpose: report.md is the only output a run is meant to
track. A denylist only excludes the artifact shapes that existed when it was
written.
Lint the report with reportLintCommand if configured. If not configured, do
not claim the report was linted.
Present the summary and ask for one approval of the fix plan in plain
text in your reply. The approval is informed: safe-mechanical fixes are
summarized in aggregate; semantic fixes are shown as concrete diffs, so
nothing risky is applied sight-unseen.
Phase 7: FIX
Apply review-receiving discipline throughout: verify before implementing, no
performative agreement, push back with evidence when a finding is wrong on
re-examination, one logical change at a time.
pr-scoped, clear — auto-fix. Safe-mechanical fixes (formatter, linter
--fix, codegen regeneration) applied directly; semantic fixes applied as the
approved diffs.
pr-scoped, entangled or multi-route — emit_interaction question, one at
a time, most-blocking first.
underlying — ask before fixing each cluster. Out-of-scope repair needs
explicit approval to enter this branch.
- Per-batch re-verify — re-run the affected gate after each fix batch.
- Post-fix regression mini-pass — re-review just the fix diff to catch
fix-induced breakage beyond what gates catch.
- Fixes land as grouped conventional commits — reviewable and revertable — never
one mega-commit.
Phase 8: VERIFY and FINALIZE
- Re-run the full configured gate set to prove the branch green. Evidence
before claims; if Phase 2 abstained, Phase 8 abstains too and says so.
- Update the report's applied / deferred / pushed-back sections and the
merge-blockers banner.
- Restore any stash from Phase 0.
- Lean handoff: offer to push, open or update the PR, and — for deferred
underlying work — hand the report to
harness-planning.
Finding schema
interface Finding {
id: string;
file: string;
lineRange: [number, number];
origin: 'pr-scoped' | 'underlying'; // axis (a) — this skill's contribution
type:
| 'bug'
| 'logic'
| 'drift'
| 'dead-code'
| 'lint'
| 'type'
| 'test'
| 'security'
| 'architecture'
| 'a11y'
| 'i18n'
| 'perf'
| 'docs'
| 'merge-artifact'; // axis (b)
severity: 'critical' | 'important' | 'suggestion'; // axis (c)
confidence: 25 | 50 | 75 | 100; // below 25 is suppressed
title: string;
rationale: string;
evidence: string[]; // each cites file:line
validatedBy: 'mechanical' | 'graph' | 'heuristic' | 'agent' | 'adversarial';
gate?: string;
fixRisk?: 'safe-mechanical' | 'semantic';
proposedSolutions: { summary: string; approach: string; tradeoffs?: string }[];
entangled?: boolean;
disposition: 'auto-fix' | 'ask' | 'defer' | 'fixed' | 'pushed-back';
}
Severity anchoring: any finding failing a blocking gate is critical. Confidence
follows the anchored rubric — 100 mechanical, 75 constructible scenario, 50
judgment, 25 speculative (suppressed).
Report format
Written to {runDir}/{slug}_{YYYY-MM-DD}/report.md; a new directory per run,
never overwriting a prior one. Sections in order:
- Merge-blockers banner — what will fail CI, plus the preview of what came
in from the base. If Phase 2 abstained, this banner says so instead of
claiming the branch is clean.
- Run header — branch, base SHA, merge result, depth tier, gate table with
its denominator (how many gates ran, how many were skipped).
- Branch-introduced issues (
pr-scoped) — grouped by severity then type.
- Pre-existing issues (
underlying) — same structure, marked "ask before
fixing".
- Merge-conflict resolutions — what was decided for each conflict.
- Open questions / entangled — items needing a decision.
- Fixes applied / deferred / pushed-back — filled in after Phase 7.
Resumable run-state
state.json in the run directory records phase (last fully completed, 0–8),
accumulated findings, conflictDecisions, fixDispositions, runDir, and the
flags in effect. On re-invocation against the same run directory the skill
offers to resume. This matters because a Deep run on a large branch is long and
may be interrupted by a context limit, a crash, or a deliberate stop.
Flags
| Flag |
Effect |
--report-only |
Review and report; skip the Fix phase entirely |
--no-sync |
Skip the merge; review the current branch state |
--scope diff|touched|repo |
Override the out-of-scope boundary (default repo) |
--depth quick|standard|deep |
Override depth calibration |
--fast / --thorough |
Reduce or maximize rigor |
--no-mechanical |
Skip gate runs when CI already ran them |
--comment |
Also post findings as a PR review via gh |
base=<ref> |
Override the base ref (default origin/main) |
Examples
Example A: a report-only pre-merge audit
$ harness skill run harness-branch-buster --report-only
Phase 0 INTAKE — branch feat/checkout-rewrite, base origin/main, depth: deep
Phase 1 SYNC — 14 commits incoming; 3 conflicts, resolved interactively
Phase 2 MECHANICAL — 6 gates configured, 6 ran, 1 failed (typescript)
Phase 3 SCOPE — 84 files changed; swept diff + dependents + top-40 hotspots
(excluded: 612 files — logged in the report)
Phase 4 FAN-OUT — harness-code-review: 22 findings
project lenses (design-system): 4 findings
Phase 5 VALIDATE — 9 suppressed (6 refuted, 3 below confidence)
Phase 6 REPORT — docs/branch-buster/checkout-rewrite_2026-09-08/report.md
Branch-introduced (pr-scoped): 11 ← this branch caused these
Pre-existing (underlying): 6 ← inherited from main
--report-only stops here: the frozen report is the deliverable, with a
merge-blockers banner naming the failing typescript gate.
Example B: a project with no gates configured
$ harness skill run harness-branch-buster
Phase 2 MECHANICAL — ABSTAINED
No gates are configured (skills.branchBuster.gates in harness.config.json).
Nothing was mechanically verified — this is an abstention, not a pass.
⚠ Merge-blockers banner will read "not mechanically verified", NOT "clean".
Want help authoring a gate block from .github/workflows/? [y/N]
The abstention propagates into the report rather than being smoothed over. A
branch that was never gate-checked must not read as a branch that passed.
Harness Integration
harness skill run harness-branch-buster — Run the audit.
harness skill validate harness-branch-buster — Validate before shipping
changes.
harness-code-review — Declared in depends_on. Phase 4 delegates the
generic review roster and adversarial refutation to it. This skill adds only
the project's configured lenses.
harness-planning — Offered in Phase 8 as the handoff for deferred
underlying work that is too large to repair in-branch.
Capability roles
- Service Definition — the
Finding schema plus the skills.branchBuster
configuration contract (gates, lenses). Both are stated independently of any
project's commands.
- Providers —
scripts/run-gates.mjs provides gate execution against a
configured gate set; harness-code-review provides the generic review roster;
configured lenses[] provide project-specific review.
- Consumers — Phases 5–7 of this skill consume
Finding[] without knowing
which provider produced it, which is what lets a project add a lens or a gate
without touching this skill.
Success Criteria
- Every phase runs in order; SYNC prompts on every conflict; the post-merge smoke
runs.
- Phase 2 reproduces CI's verdict using the project's configured gates — or
explicitly abstains when none are configured.
- The report states its denominators: gates run, gates skipped, files swept,
files excluded.
- Every reported finding carries
file:line evidence and all three axes.
origin is derived from the three-dot diff, and the report separates
branch-introduced from pre-existing findings.
- The generic review roster came from
harness-code-review, not from a second
roster defined here.
- High-severity findings were adversarially refuted; refuted ones are suppressed.
- After one approval,
pr-scoped clear issues are fixed; entangled and
underlying issues are surfaced as questions.
- Phase 8 proves the branch green — or names the remaining blockers.
- An interrupted run resumes from
state.json rather than restarting.
Gates
- No fix while findings are still being gathered. Review, then report, then
fix. Violating this destroys review integrity.
- Zero configured gates is an abstention, not a pass. If
skills.branchBuster.gates is empty, Phase 2 reports abstained and the
merge-blockers banner says the branch was not mechanically verified. Rendering
"0 gates failed" as green is the exact false-green this skill exists to catch.
- No
--no-verify, ever. Fix the underlying failure instead.
- No finding without
file:line evidence. An unlocatable finding is a
rumour.
- No fix marked done without re-running the gate it addresses.
- No overwriting a prior run's report directory.
- No silent coverage loss. Whatever the bounded sweep did not cover is logged
in the report.
- No second generic review roster. If a generic lens is missing, change
harness-code-review.
Escalation
- Merge abort: any Phase 1 failure or user abort triggers
git merge --abort
and a clean stop. Never proceed to Phase 2 with a partially-merged tree.
- No gates configured: stop and report the abstention, and offer to help
author a
skills.branchBuster.gates block from the project's CI workflow. Do
not invent a gate set by guessing at the toolchain.
- Protected or policy-blocked files: if the only correct fix requires editing
a file a hook blocks, stop, describe the needed change, and ask the user to
apply it. Never fight the hook.
- Repeated pushback on a finding type: record it in the Noise section of
learningsPath and suppress it on future runs. After three pushbacks on the
same class, raise one emit_interaction question to confirm a permanent
suppression or recalibrate the lens.
- Underlying scope creep: if repairing
underlying findings would touch more
than a handful of files outside the diff, stop and offer harness-planning
with those findings as input instead of attempting in-branch repair.
- Run directory collision: if the dated directory exists with no
state.json,
ask before overwriting. With a state.json, offer the resume instead.
Rationalizations to Reject
| Rationalization |
Reality |
| "No gates are configured, so there is nothing failing." |
Nothing failing and nothing checked are different states. An empty gate set verified nothing; report the abstention rather than a clean bill of health. |
| "The merge was clean, so nothing broke." |
Textual merges hide semantic breakage. Run the post-merge smoke and review resolved hunks first. |
| "This finding is in a file the branch touched, so it's ours." |
Touching a file is not introducing a line. Origin is decided by whether the finding's line range is in the three-dot diff — otherwise the branch inherits someone's debt. |
| "It's pre-existing, so it doesn't matter." |
underlying changes who decides and when, not whether it is real. It goes in the report and gets asked about; it is not discarded. |
| "It's a known-flaky test, ignore it." |
Confirm against the configured quarantine ledger first. With no ledger, the failure is real by default. A regression hiding behind "probably flaky" is the failure mode. |
| "This finding is obviously real, skip verification." |
High-severity findings are adversarially refuted before reaching the report. Obvious-but-wrong is exactly the mode adversarial refutation catches. |
| "The fix is trivial, apply it without showing it." |
Semantic fixes are shown as diffs inside the approval. Trivial-looking logic fixes are where silent regressions hide. |
| "I'll add a bug-detection lens here since the generic one missed it." |
That is a change to harness-code-review. A second generic roster in this skill drifts from the first, and the drifted one is the one nobody audits. |
Skill Test Scenarios
Scenario 1: Gate — zero configured gates
Input: A project with no skills.branchBuster.gates. Phase 2 runs and produces
an empty result set.
Expected: The agent reports verdict: abstained, the merge-blockers banner
states the branch was not mechanically verified, and the agent does NOT say the
gates passed. It offers to help author a gate block.
Scenario 2: Rationalization — "this finding is in a file we touched, so it's ours"
Input: A review lens reports a bug at src/legacy/parse.ts:40. The branch edited
src/legacy/parse.ts but only lines 100–120.
Expected: The agent checks the three-dot diff, finds line 40 outside it,
classifies the finding underlying, and asks before fixing rather than
auto-fixing it as branch-scoped.
Scenario 3: Gate — no second generic roster
Input: The delegated harness-code-review roster misses a race condition, and
the agent is tempted to add a concurrency lens to this skill's lenses[].
Expected: The agent rejects it per the Rationalizations table and the Gates
section, and proposes the change to harness-code-review instead.
Scenario 4: Iron Law — fixing during review
Input: While Phase 4 lenses are still returning findings, a trivially fixable
formatting error appears.
Expected: The agent does NOT fix it. It records the finding, completes review,
freezes the report, and applies the fix in Phase 7 after approval.
Scenario 5: Escalation — merge conflict abort
Input: During Phase 1 the user aborts on an ambiguous conflict.
Expected: The agent runs git merge --abort, stops cleanly, and does not proceed
to Phase 2 with a partially-merged tree.
1---2name: harness-branch-buster3description: Harness Branch Buster4metadata:5 source: https://skillmd.com/skills/intense-visions/harness-branch-buster6---7# Harness Branch Buster89> Sync a branch from its base with interactive conflict resolution, run the10> project's exact CI gate set locally, delegate review to `harness-code-review`,11> then classify every finding by **origin** — introduced by this branch, or12> pre-existing on the base — into a dated report, and auto-fix only the in-scope13> ones after a single approval.1415## When to Use1617- Manually, when a feature branch is ready for a thorough pre-merge audit: after18 a long development period, before opening a PR, or after a large merge from the19 base branch.20- When a branch has drifted far enough from its base that the integration itself21 is the risk, not just the diff.22- When you need to know **which** problems a branch introduced versus which it23 merely inherited — that separation is this skill's reason to exist.24- NOT as a continuous linter or a pre-commit hook. This is a deliberate,25 on-demand audit.26- NOT as a replacement for CI. It mirrors CI locally to _predict_ it, never to27 bypass it.28- NOT for reviewing a diff alone — that is `harness-code-review`, which this29 skill calls rather than duplicates. If you do not need the sync, the CI-exact30 gate run, or the origin split, use `harness-code-review` directly.3132## Iron Law3334**Review and Fix are separate phases.** No edit is applied while findings are35still being gathered, and the report is frozen before any code changes. Review36integrity comes first; the auto-fix follows it.3738## What this skill owns, and what it delegates3940This skill exists alongside `harness-code-review`, and the boundary is41deliberate. Two copies of review logic in one toolchain drift apart, and the42copy that drifts is the one nobody is looking at.4344| Concern | Owner |45| ---------------------------------------------------- | ---------------------------------------- |46| Generic review lenses (bugs, security, architecture) | **`harness-code-review`** — delegated to |47| Adversarial refutation of high-severity findings | **`harness-code-review`** — delegated to |48| Syncing the branch and resolving conflicts | This skill |49| Running the project's CI-exact gate set | This skill |50| Classifying findings by **origin** | This skill — its novel contribution |51| Project-specific lenses | This skill, from configuration |52| The single approved fix pass | This skill |5354**Never re-implement a generic lens here.** If the generic roster is missing55something, that is a change to `harness-code-review`, not a second roster.5657## Configuration5859The skill hardcodes no project's commands, packages, or conventions. Everything60project-specific lives in `harness.config.json` under `skills.branchBuster`:6162```json63{64 "skills": {65 "branchBuster": {66 "baselineEnv": "TURBO_SCM_BASE",67 "runDir": "docs/branch-buster",68 "reportLintCommand": "npx markdownlint-cli2 --no-globs {report}",69 "quarantinePath": "quarantine.json",70 "learningsPath": ".harness/branch-buster-learnings.md",71 "gates": [72 { "id": "format", "cmd": "npm run format:check", "parse": "prettier", "blocking": true },73 { "id": "build", "cmd": "npm run build", "parse": "passfail", "blocking": true },74 { "id": "typescript", "cmd": "npm run typecheck", "parse": "passfail", "blocking": true },75 { "id": "test", "cmd": "npm test", "parse": "passfail", "blocking": true },76 {77 "id": "codegen-drift",78 "cmd": "DRIFT",79 "parse": "drift",80 "blocking": true,81 "drift": {82 "regenerate": ["npm run codegen"],83 "paths": ["src/generated"],84 "remedy": "re-run `npm run codegen`"85 }86 }87 ],88 "lenses": [89 {90 "id": "design-system",91 "prompt": "Check for hardcoded colors, off-grid spacing, and bypassed design tokens.",92 "paths": ["packages/ui/**"]93 }94 ]95 }96 }97}98```99100| Key | Meaning | If absent |101| ------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- |102| `gates[]` | The project's blocking gate set, in CI order. | **Phase 2 abstains** — see the Gates section. |103| `baselineEnv` | Env var pinning an incremental build tool to the merge base. | No baseline is set; gates run unscoped. |104| `lenses[]` | Project-specific review lenses, added _alongside_ the delegated generic roster. | Only the generic roster runs. |105| `runDir` | Where dated run directories are written. | `docs/branch-buster`. |106| `reportLintCommand` | Command to lint the rendered report. `{report}` is substituted. | The report is not linted; say so rather than implying it was. |107| `quarantinePath` | Known-flaky test ledger, checked before calling a failure a regression. | Every failure is treated as real. |108| `learningsPath` | Where pushed-back findings are recorded and suppressed from. | No learnings filter is applied. |109110## Process111112```text1130 INTAKE -> 1 SYNC -> 2 MECHANICAL -> 3 SCOPE+CALIBRATE -> 4 FAN-OUT (delegated)114 |115 v1168 VERIFY+FINALIZE <- 7 FIX <- 6 CLASSIFY+REPORT <- 5 VALIDATE+DEDUP117```118119### Phase 0: INTAKE1201211. Resolve **identity**: if a PR exists (`gh pr view --json number,title`), derive122 a slug from its title; otherwise use the branch name.1232. Resolve the **base ref** (default `origin/main`), the **flags**, and the **run124 directory** `{runDir}/{slug}_{YYYY-MM-DD}/`.1253. **Resume check:** if the run directory holds a `state.json` from an interrupted126 run, offer to resume from the last completed phase rather than restart.1274. **Dirty-tree guard:** run `git status --porcelain`. If the tree is dirty, ask128 once **in plain text in your reply** whether to commit or stash before SYNC,129 and wait for the answer. Stashes are restored in Phase 8.130131> **Every ask in this skill is plain text in your own reply, never an132> `emit_interaction` question or confirmation.** That call renders and records a133> prompt but does not show it to the human — the client134> collapses it to "Called harness" and the text returns only to the model, so the135> human sits looking at nothing while the agent waits on an answer they were136> never shown. Plain text is the only channel that reaches the human on every137> platform this skill ships to. `AskUserQuestion` is Claude-Code-only.138139### Phase 1: SYNC1401411. `git fetch origin`.1422. **Pre-merge preview** via `scripts/sync-branch.mjs`: show `git log --oneline143HEAD..{base}` and which of the branch's files those commits touch, so the scope144 of the integration is visible before conflicts start.1453. `git merge {base}`. Never `--no-verify`; no auto-commit on conflict.1464. **Interactive conflict resolution:** for every conflicted file, present both147 sides with surrounding context and a proposed resolution **in plain text in148 your reply**, one at a time, and take an explicit decision — **even when the149 resolution looks obvious**. `git add` each resolved file.1505. Complete the merge with a conventional message.1516. **Post-merge semantic smoke:** run the project's typecheck and lint gates on152 affected packages to catch semantic breakage a textually-clean merge hides.153 Tag conflict-resolved hunks for first-priority review in Phase 4 as candidate154 `merge-artifact` findings.1557. **Escape hatch:** any failure or user abort triggers `git merge --abort` and a156 clean stop.157158### Phase 2: MECHANICAL159160Runs `scripts/run-gates.mjs`, which executes the **configured** gate set in161order and captures structured findings. This is the deterministic backbone and162the source of the **exclusion set** — review agents in Phase 4 must not re-report163what a tool already caught.1641651. Load `skills.branchBuster.gates`. **If none are configured, Phase 2 abstains:166 record `verdict: abstained` and carry it into the report.** Do not render an167 empty gate run as a pass — a gate set that ran nothing verified nothing.1682. Set `baselineEnv` to the merge base so local verdicts match CI's scoping.1693. Run each gate. A failing **blocking** gate produces a `critical` finding170 tagged with that gate; non-blocking gates produce `suggestion` findings.1714. **Flaky awareness:** cross-check a test failure against `quarantinePath`172 before reporting it as a blocker. If no ledger is configured, treat every173 failure as real and say that is what you did.1745. **Diff-smell sub-pass:** deterministic greps over the diff for high-signal175 regressions — functional code replaced by a comment, stray `console.log` or176 `debugger`, committed `.only`/`.skip`, newly added `any`/`@ts-ignore`/177 `eslint-disable`, new `TODO`/`FIXME`.1786. Skipped entirely with `--no-mechanical`, which must be recorded in the report179 as reduced coverage.180181### Phase 3: SCOPE and CALIBRATE182183Runs `scripts/compute-diff.mjs` and `scripts/pick-hotspots.mjs`.1841851. Compute the diff as `{base}...HEAD` (three-dot, post-merge) for stats, per-file186 change type, and blast radius via import tracing.1872. Classify change type (feature/bugfix/refactor/docs) from commit prefixes and188 diff heuristics, to shape review focus.1893. **Calibrate depth** from diff size plus risk keywords: Quick, Standard, or190 Deep. A large, wide branch calibrates to Deep.1914. Assemble read-only context bundles per lens: changed files, dependencies,192 convention files, corresponding tests.1935. **Bound the sweep, and log the bound.** Mechanical detectors run repo-wide;194 expensive review lenses run on the diff plus dependents plus the top-N riskiest195 files by churn × complexity. Record what was excluded so the report never196 implies more coverage than was performed.197198### Phase 4: FAN-OUT REVIEW — delegated1992001. **Invoke `harness-code-review`** for the generic roster, passing the computed201 diff scope, the depth tier, and the mechanical exclusion set. It owns the202 generic lenses and the adversarial refutation pass; consume its `Finding[]`.2032. **Dispatch only the project's configured `lenses[]`** (via `Task`), each with204 crafted, domain-scoped, read-only context — never the orchestrator's session205 history. Each returns `Finding[]`.2063. Conflict-resolved hunks from Phase 1 are reviewed first, whichever lens covers207 them.2084. **Diff-coverage / test-gap** runs here: new logic in the diff with no test209 coverage is emitted as `test`-type findings.210211If `lenses[]` is empty, the delegated generic roster is the whole review. That is212a valid configuration, not a degraded one — say so plainly rather than implying213project-specific coverage that does not exist.214215### Phase 5: VALIDATE and DEDUP2162171. **Mechanical exclusion** — discard agent findings already flagged in Phase 2.2182. **Reachability check** — verify claimed dependency and impact paths; downgrade219 or discard unreachable claims.2203. **Adversarial verification** — delegated to `harness-code-review` for the221 findings it produced. For findings from project lenses, dispatch a second agent222 prompted to refute each `critical`/`important` one. Refuted findings, and any223 below confidence 25, are suppressed.2244. **Learnings filter** — suppress findings matching the Noise section of225 `learningsPath`, when configured.2265. **Dedup and merge** — group by file plus overlapping line range, keep the227 highest severity, combine evidence, merge type tags.228229### Phase 6: CLASSIFY and REPORT230231Runs `scripts/render-report.mjs`.2322331. Classify every surviving finding on three axes. **Origin is the axis this234 skill contributes** and the one the fix phase keys off:235 - `pr-scoped` — the finding is inside the branch's own diff. This branch236 introduced it.237 - `underlying` — the finding is in code the branch did not touch. It exists on238 the base too, and the branch merely revealed it.239240 Getting this wrong in either direction is costly: a pre-existing problem241 labelled `pr-scoped` blocks a branch for something it did not cause, and an242 introduced problem labelled `underlying` ships a regression as someone else's243 pre-existing debt. Classify by whether the file and line range appear in the244 three-dot diff, not by intuition about the cause.2452462. Write the report to the dated run directory, with an adjacent `.gitignore`:247248 ```text249 *250 !.gitignore251 !report.md252 ```253254 An allowlist on purpose: `report.md` is the only output a run is meant to255 track. A denylist only excludes the artifact shapes that existed when it was256 written.2572583. Lint the report with `reportLintCommand` if configured. If not configured, do259 not claim the report was linted.2604. Present the summary and ask for **one** approval of the fix plan **in plain261 text in your reply**. The approval is informed: safe-mechanical fixes are262 summarized in aggregate; semantic fixes are shown as concrete diffs, so263 nothing risky is applied sight-unseen.264265### Phase 7: FIX266267Apply review-receiving discipline throughout: verify before implementing, no268performative agreement, push back with evidence when a finding is wrong on269re-examination, one logical change at a time.2702711. **`pr-scoped`, clear** — auto-fix. Safe-mechanical fixes (formatter, linter272 `--fix`, codegen regeneration) applied directly; semantic fixes applied as the273 approved diffs.2742. **`pr-scoped`, entangled or multi-route** — `emit_interaction` question, one at275 a time, most-blocking first.2763. **`underlying`** — ask before fixing each cluster. Out-of-scope repair needs277 explicit approval to enter this branch.2784. **Per-batch re-verify** — re-run the affected gate after each fix batch.2795. **Post-fix regression mini-pass** — re-review just the fix diff to catch280 fix-induced breakage beyond what gates catch.2816. Fixes land as grouped conventional commits — reviewable and revertable — never282 one mega-commit.283284### Phase 8: VERIFY and FINALIZE2852861. Re-run the **full** configured gate set to prove the branch green. Evidence287 before claims; if Phase 2 abstained, Phase 8 abstains too and says so.2882. Update the report's applied / deferred / pushed-back sections and the289 merge-blockers banner.2903. Restore any stash from Phase 0.2914. **Lean handoff:** offer to push, open or update the PR, and — for deferred292 underlying work — hand the report to `harness-planning`.293294## Finding schema295296```ts297interface Finding {298 id: string;299 file: string;300 lineRange: [number, number];301 origin: 'pr-scoped' | 'underlying'; // axis (a) — this skill's contribution302 type:303 | 'bug'304 | 'logic'305 | 'drift'306 | 'dead-code'307 | 'lint'308 | 'type'309 | 'test'310 | 'security'311 | 'architecture'312 | 'a11y'313 | 'i18n'314 | 'perf'315 | 'docs'316 | 'merge-artifact'; // axis (b)317 severity: 'critical' | 'important' | 'suggestion'; // axis (c)318 confidence: 25 | 50 | 75 | 100; // below 25 is suppressed319 title: string;320 rationale: string;321 evidence: string[]; // each cites file:line322 validatedBy: 'mechanical' | 'graph' | 'heuristic' | 'agent' | 'adversarial';323 gate?: string;324 fixRisk?: 'safe-mechanical' | 'semantic';325 proposedSolutions: { summary: string; approach: string; tradeoffs?: string }[];326 entangled?: boolean;327 disposition: 'auto-fix' | 'ask' | 'defer' | 'fixed' | 'pushed-back';328}329```330331Severity anchoring: any finding failing a blocking gate is `critical`. Confidence332follows the anchored rubric — 100 mechanical, 75 constructible scenario, 50333judgment, 25 speculative (suppressed).334335## Report format336337Written to `{runDir}/{slug}_{YYYY-MM-DD}/report.md`; a new directory per run,338never overwriting a prior one. Sections in order:3393401. **Merge-blockers banner** — what will fail CI, plus the preview of what came341 in from the base. If Phase 2 abstained, this banner says so instead of342 claiming the branch is clean.3432. **Run header** — branch, base SHA, merge result, depth tier, gate table with344 its denominator (how many gates ran, how many were skipped).3453. **Branch-introduced issues** (`pr-scoped`) — grouped by severity then type.3464. **Pre-existing issues** (`underlying`) — same structure, marked "ask before347 fixing".3485. **Merge-conflict resolutions** — what was decided for each conflict.3496. **Open questions / entangled** — items needing a decision.3507. **Fixes applied / deferred / pushed-back** — filled in after Phase 7.351352## Resumable run-state353354`state.json` in the run directory records `phase` (last fully completed, 0–8),355accumulated `findings`, `conflictDecisions`, `fixDispositions`, `runDir`, and the356`flags` in effect. On re-invocation against the same run directory the skill357offers to resume. This matters because a Deep run on a large branch is long and358may be interrupted by a context limit, a crash, or a deliberate stop.359360## Flags361362| Flag | Effect |363| ------------------------------- | --------------------------------------------------- |364| `--report-only` | Review and report; skip the Fix phase entirely |365| `--no-sync` | Skip the merge; review the current branch state |366| `--scope diff\|touched\|repo` | Override the out-of-scope boundary (default `repo`) |367| `--depth quick\|standard\|deep` | Override depth calibration |368| `--fast` / `--thorough` | Reduce or maximize rigor |369| `--no-mechanical` | Skip gate runs when CI already ran them |370| `--comment` | Also post findings as a PR review via `gh` |371| `base=<ref>` | Override the base ref (default `origin/main`) |372373## Examples374375### Example A: a report-only pre-merge audit376377```bash378$ harness skill run harness-branch-buster --report-only379Phase 0 INTAKE — branch feat/checkout-rewrite, base origin/main, depth: deep380Phase 1 SYNC — 14 commits incoming; 3 conflicts, resolved interactively381Phase 2 MECHANICAL — 6 gates configured, 6 ran, 1 failed (typescript)382Phase 3 SCOPE — 84 files changed; swept diff + dependents + top-40 hotspots383 (excluded: 612 files — logged in the report)384Phase 4 FAN-OUT — harness-code-review: 22 findings385 project lenses (design-system): 4 findings386Phase 5 VALIDATE — 9 suppressed (6 refuted, 3 below confidence)387Phase 6 REPORT — docs/branch-buster/checkout-rewrite_2026-09-08/report.md388389 Branch-introduced (pr-scoped): 11 ← this branch caused these390 Pre-existing (underlying): 6 ← inherited from main391```392393`--report-only` stops here: the frozen report is the deliverable, with a394merge-blockers banner naming the failing typescript gate.395396### Example B: a project with no gates configured397398```bash399$ harness skill run harness-branch-buster400Phase 2 MECHANICAL — ABSTAINED401 No gates are configured (skills.branchBuster.gates in harness.config.json).402 Nothing was mechanically verified — this is an abstention, not a pass.403404⚠ Merge-blockers banner will read "not mechanically verified", NOT "clean".405 Want help authoring a gate block from .github/workflows/? [y/N]406```407408The abstention propagates into the report rather than being smoothed over. A409branch that was never gate-checked must not read as a branch that passed.410411## Harness Integration412413- **`harness skill run harness-branch-buster`** — Run the audit.414- **`harness skill validate harness-branch-buster`** — Validate before shipping415 changes.416- **`harness-code-review`** — Declared in `depends_on`. Phase 4 delegates the417 generic review roster and adversarial refutation to it. This skill adds only418 the project's configured lenses.419- **`harness-planning`** — Offered in Phase 8 as the handoff for deferred420 `underlying` work that is too large to repair in-branch.421422### Capability roles423424- **Service Definition** — the `Finding` schema plus the `skills.branchBuster`425 configuration contract (gates, lenses). Both are stated independently of any426 project's commands.427- **Providers** — `scripts/run-gates.mjs` provides gate execution against a428 configured gate set; `harness-code-review` provides the generic review roster;429 configured `lenses[]` provide project-specific review.430- **Consumers** — Phases 5–7 of this skill consume `Finding[]` without knowing431 which provider produced it, which is what lets a project add a lens or a gate432 without touching this skill.433434## Success Criteria435436- Every phase runs in order; SYNC prompts on every conflict; the post-merge smoke437 runs.438- Phase 2 reproduces CI's verdict using the project's configured gates — or439 explicitly abstains when none are configured.440- The report states its denominators: gates run, gates skipped, files swept,441 files excluded.442- Every reported finding carries `file:line` evidence and all three axes.443- `origin` is derived from the three-dot diff, and the report separates444 branch-introduced from pre-existing findings.445- The generic review roster came from `harness-code-review`, not from a second446 roster defined here.447- High-severity findings were adversarially refuted; refuted ones are suppressed.448- After one approval, `pr-scoped` clear issues are fixed; entangled and449 `underlying` issues are surfaced as questions.450- Phase 8 proves the branch green — or names the remaining blockers.451- An interrupted run resumes from `state.json` rather than restarting.452453## Gates454455- **No fix while findings are still being gathered.** Review, then report, then456 fix. Violating this destroys review integrity.457- **Zero configured gates is an abstention, not a pass.** If458 `skills.branchBuster.gates` is empty, Phase 2 reports `abstained` and the459 merge-blockers banner says the branch was not mechanically verified. Rendering460 "0 gates failed" as green is the exact false-green this skill exists to catch.461- **No `--no-verify`, ever.** Fix the underlying failure instead.462- **No finding without `file:line` evidence.** An unlocatable finding is a463 rumour.464- **No fix marked done without re-running the gate it addresses.**465- **No overwriting a prior run's report directory.**466- **No silent coverage loss.** Whatever the bounded sweep did not cover is logged467 in the report.468- **No second generic review roster.** If a generic lens is missing, change469 `harness-code-review`.470471## Escalation472473- **Merge abort:** any Phase 1 failure or user abort triggers `git merge --abort`474 and a clean stop. Never proceed to Phase 2 with a partially-merged tree.475- **No gates configured:** stop and report the abstention, and offer to help476 author a `skills.branchBuster.gates` block from the project's CI workflow. Do477 not invent a gate set by guessing at the toolchain.478- **Protected or policy-blocked files:** if the only correct fix requires editing479 a file a hook blocks, stop, describe the needed change, and ask the user to480 apply it. Never fight the hook.481- **Repeated pushback on a finding type:** record it in the Noise section of482 `learningsPath` and suppress it on future runs. After three pushbacks on the483 same class, raise one `emit_interaction` question to confirm a permanent484 suppression or recalibrate the lens.485- **Underlying scope creep:** if repairing `underlying` findings would touch more486 than a handful of files outside the diff, stop and offer `harness-planning`487 with those findings as input instead of attempting in-branch repair.488- **Run directory collision:** if the dated directory exists with no `state.json`,489 ask before overwriting. With a `state.json`, offer the resume instead.490491## Rationalizations to Reject492493| Rationalization | Reality |494| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |495| "No gates are configured, so there is nothing failing." | Nothing failing and nothing checked are different states. An empty gate set verified nothing; report the abstention rather than a clean bill of health. |496| "The merge was clean, so nothing broke." | Textual merges hide semantic breakage. Run the post-merge smoke and review resolved hunks first. |497| "This finding is in a file the branch touched, so it's ours." | Touching a file is not introducing a line. Origin is decided by whether the finding's line range is in the three-dot diff — otherwise the branch inherits someone's debt. |498| "It's pre-existing, so it doesn't matter." | `underlying` changes who decides and when, not whether it is real. It goes in the report and gets asked about; it is not discarded. |499| "It's a known-flaky test, ignore it." | Confirm against the configured quarantine ledger first. With no ledger, the failure is real by default. A regression hiding behind "probably flaky" is the failure mode. |500| "This finding is obviously real, skip verification." | High-severity findings are adversarially refuted before reaching the report. Obvious-but-wrong is exactly the mode adversarial refutation catches. |501| "The fix is trivial, apply it without showing it." | Semantic fixes are shown as diffs inside the approval. Trivial-looking logic fixes are where silent regressions hide. |502| "I'll add a bug-detection lens here since the generic one missed it." | That is a change to `harness-code-review`. A second generic roster in this skill drifts from the first, and the drifted one is the one nobody audits. |503504## Skill Test Scenarios505506### Scenario 1: Gate — zero configured gates507508Input: A project with no `skills.branchBuster.gates`. Phase 2 runs and produces509an empty result set.510Expected: The agent reports `verdict: abstained`, the merge-blockers banner511states the branch was not mechanically verified, and the agent does NOT say the512gates passed. It offers to help author a gate block.513514### Scenario 2: Rationalization — "this finding is in a file we touched, so it's ours"515516Input: A review lens reports a bug at `src/legacy/parse.ts:40`. The branch edited517`src/legacy/parse.ts` but only lines 100–120.518Expected: The agent checks the three-dot diff, finds line 40 outside it,519classifies the finding `underlying`, and asks before fixing rather than520auto-fixing it as branch-scoped.521522### Scenario 3: Gate — no second generic roster523524Input: The delegated `harness-code-review` roster misses a race condition, and525the agent is tempted to add a concurrency lens to this skill's `lenses[]`.526Expected: The agent rejects it per the Rationalizations table and the Gates527section, and proposes the change to `harness-code-review` instead.528529### Scenario 4: Iron Law — fixing during review530531Input: While Phase 4 lenses are still returning findings, a trivially fixable532formatting error appears.533Expected: The agent does NOT fix it. It records the finding, completes review,534freezes the report, and applies the fix in Phase 7 after approval.535536### Scenario 5: Escalation — merge conflict abort537538Input: During Phase 1 the user aborts on an ambiguous conflict.539Expected: The agent runs `git merge --abort`, stops cleanly, and does not proceed540to Phase 2 with a partially-merged tree.