Pre merge qa gate

From CarlosCaPe/octorato · View interactive version

Pre merge qa gate is an AI agent skill from the GitHub repository CarlosCaPe/octorato. Before merging a PR that touches production code, dispatch a QA specialist agent against an explicit test/user-case spec for the diff, then merge directly, pinned to the commit it reviewed. Build-passes ≠ correct. The merge is the mechanism, not the gate.

How to use this skill

Skill file

Pre-Merge QA Gate

What

A discipline for AI-driven dev: no PR lands without an agent-validated QA pass against an explicit test/user-case spec. A direct SQUASH merge pinned to the reviewed commit (--match-head-commit) is the merge mechanism; the gate that precedes it is the QA agent verdict.

Build pipelines (astro check, tsc --noEmit, unit tests) tell you the code compiles. They do not tell you:

Those failures are the kind that ship to production looking green and break operators silently. The pattern below catches them BEFORE the merge.

When

Activate this discipline for any PR that:

Skip (TRIVIAL): typo fixes, comment-only changes, README updates, dependency bumps with no API surface change. For those, a 2-line manual review note in the PR body suffices.

Escalate (LARGE): 10+ files, security-relevant, multi-domain (frontend + backend + a11y). Use multiple specialist agents in parallel.

How

Four steps before the pinned SQUASH merge:

1. Build locally first

npx astro build (or the project's equivalent). Must pass. This eliminates the trivial "broken code" class so the agent's time goes to behavioral verification.

2. Compose the test/user case spec for the diff

Either:

The spec is the contract the QA agent validates against. Without it, the agent has nothing to compare to and you get "looks fine" hand-waving.

3. Dispatch the gate — `/bug-hunter --pr` is the default

The DEFAULT gate is now /bug-hunter --pr (the bug-hunter brain skill — adversarial 3-agent pipeline: Hunter → Skeptic → Referee). Single-shot reviewers (Reality Checker alone) have a documented false-approve rate on schema, contract, and framework-reactivity bugs (see "Why this upgrade" below).

Invocation:

/bug-hunter --pr current --scan-only

--scan-only keeps it in review mode (no auto-fixes; the operator owns the merge). Output: .bug-hunter/referee.json with verdict per finding + severity. Merge gate: only merge when no finding has severity >= HIGH.

The 3-agent flow:

  1. Hunter searches the diff for bugs. Has shell/Read/Grep access — can grep migrations/ to verify column names, npx tsc --noEmit for type errors, wrangler d1 PRAGMA table_info(...) for schema sanity.
  2. Skeptic tries to disprove each Hunter finding. Penalty for missing a real bug ≫ penalty for over-skepticism → less false-approve.
  3. Referee delivers the verdict, surviving findings only.
When to layer additional specialist agents

bug-hunter is general-purpose. Layer a specialist agent IN PARALLEL when the diff touches a narrow domain it doesn't deeply model:

| Diff touches | Layer also |

|---|---|

| ARIA / keyboard / SR | Accessibility Auditor |

| CSP / security headers | Security Engineer + Frontend Developer |

| Cryptography / auth tokens | Security Engineer |

| Visual rendering / animation jank | Frontend Developer + Evidence Collector |

| Stripe / payment-flow | Stripe specialist (per arm) |

| SDD-LARGE-score (≥6, 10+ files, multi-module) | /ocr:review (open-code-review) as third reviewer with feature.md |

Reality Checker is now a specialist for "acceptance criteria / spec compliance" — invoke when the PR has an explicit feature.md or plan.md to verify against. It's good at that. It is NOT the default gate anymore.

Brief any agent with:

4. Only after agent verdict, merge the commit that was reviewed

The reviewer's final report ends with three lines, which the SubagentStop hook records as the receipt:

QA-VERDICT: PASS
QA-SCOPE: PR #<N>
QA-HEAD: <the 40-digit commit it reviewed>

If ✅ VERIFIED → merge directly, pinned to that commit: gh pr merge <N> --squash --delete-branch --match-head-commit <sha>. GitHub refuses the merge when the head moved after the review. --auto is refused by qa-merge-gate, because whether GitHub re-checks the pin when an auto-merge fires is not established. A push after the review needs a new QA pass on the new commit; the newest verdict for a commit decides.

When the head moved only because master was merged into the branch, /requa <pr> (commands/requa.md) is that new pass: a verifier proves against the remote master that the patch is the one that passed and records the receipt for the new head, and any content difference sends the PR back to a full QA.

If ⚠️ PARTIAL → decide whether to ship with caveats (document the unknown in the PR body) or wait for more evidence.

If 🚨 NEEDS WORK / BROKEN → fix the issues, rebuild, re-validate. Do not merge.

Post-deploy live verification (cache-bust curl + agent-browser screenshot) is still recommended, but no longer the primary gate. The agent gate runs against the build, the live check confirms the deploy applied cleanly.

Anti-patterns to refuse

Exception: documented bypass with operator nod

If the operator explicitly says "hazlo directo" / "ship it now" for a TRIVIAL-but-urgent fix (incident response, hotfix to recover from a previous deploy), the gate can be bypassed with an explicit note in the PR body: QA-gate-bypass: operator-authorized hotfix for <incident-id>. The bypass is loggable; the rule still applies for everything else.

Paired / continuous milestone QA (coworking)

Operator directive (2026-06-01): for any non-trivial developer-agent task, pair it with a QA counterpart that reviews each milestone as it lands, not only the final diff — shift-left, continuous review ("its QA counterpart monitoring/reading it as it works"). Grounded in market practice: pair programming (driver/navigator), shift-left QA, continuous/adversarial review. Proven the same session: milestone QA caught a 160+ agent-count regression that the developer agent and the orchestrator both missed, before it shipped.

Honest realization in this harness. Sub-agents don't stream intermediate work to a live watcher — they run to completion and return. So "QA watches the developer live" is realized as milestone-gated review; the closer the milestones, the closer to continuous:

Scale to task size (don't double cost on trivial work): TRIVIAL → no milestone QA; MEDIUM → QA the final diff (the gate below); LARGE / risky / visual / correctness-critical → QA each milestone (this section). This is the continuous-review front-half; the pre-merge gate below is the final-half — same discipline, applied earlier and more often.

Why this exists

A session 2026-05-21 shipped multiple PRs through gh pr merge --auto --squash after npx astro build passed. Two HIGH-severity bugs only surfaced when specialist agents were finally dispatched after operator complaints:

Both would have been caught by a pre-merge agent dispatch against the test/user case spec. After the incident, the operator set the rule explicitly: "regla número 1 en los deploys: no puede haber deploy si el QA no lo aprobó."

This skill captures the rule.

Why this upgrade (2026-05-22)

Reality Checker (single-shot single-agent) passed the following bugs that hit production:

Common pattern: Reality Checker reads source files and cites file:line. It does NOT run npx tsc, does NOT grep migrations/ to verify column names, does NOT send a mock request to verify server↔client contracts, does NOT inspect framework reactive graphs.

/bug-hunter (Hunter + Skeptic + Referee) fixes the structural gap:

Reality Checker stays in the toolbox as a specialist for SDD acceptance-criteria verification, where its strength (close reading + citation) shines.

Related

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.