Agents Playbook
Scripts

Reference gate scripts

Drop-in reference implementations for the quality + structural gates the pillars rely on. Adapt to your stack; the contract each gate enforces is more important than the specific code.

Reference gate scripts

Drop-in reference implementations for the quality + structural gates the pillars rely on. Adapt to your stack; the contract each gate enforces is more important than the specific code.

Status

✓ All 12 gate reference impls shipped + orchestrator. Pure Node 22 ESM, zero deps. Adapt the regexes / paths to your codebase.

Verified: every script node --check-clean. Orchestrator smoke-tested, gates exit 0 on a clean codebase (or produce actionable failures on a populated one).

Index

ScriptPillarWhat it enforcesRun when
check-file-size.example.mjsarchitecture / quality.tsx ≤ 300 lines, .ts ≤ 500 (calibrate); shrink-only baseline at .file-size-baseline.jsonpre-commit + CI
check-named-exports.example.mjsarchitectureNo export default outside framework-mandated filesCI
check-no-any.example.mjsarchitectureNo any outside // allow-any: \<reason\>; counts only grow on a sweepCI
check-error-raw.example.mjsarchitectureNo throw new Error(...) in boundary files (methods/, handlers/, api/)CI
check-pr-intent.example.mjsgovernancePR description has well-formed intent block; removes: matches diffCI on PR
check-adr.example.mjsarchitectureADR sequence integrity; status values; superseder back-pointersCI
check-rfc.example.mjsarchitectureRFC index; review window; promotion linkageCI
check-tokens.example.mjsui-uxNo hex/rgb/hsl/oklch literals; no Tailwind arbitrary color classes; no inline color stylesCI
check-native-html.example.mjsui-uxNo native \<button\>, \<input\>, \<select\>, \<dialog\>, \<form\>, \<table\>, \<a href\> in shipped surfacesCI
check-intl.example.mjsui-uxNo JSX string literals or hardcoded aria-label/title/placeholder/altCI
check-secrets.example.mjssecurity / qualityNo high-entropy strings, no PEM blocks, no API-key prefixes outside ALLOW_FILESCI
check-completeness.example.mjsui-ux / qualityNo TODO/FIXME/disabled:true tab/throw new Error('not implemented') in shipped surfacesCI
check-quality-gates.example.mjsqualityOrchestrator; runs the structural gates above in parallellocal + CI
sanity.example.mjsquality / governanceCross-cutting audit; generates docs/audit/sanity-report.mdweekly / on demand

Shape conventions

Every gate script:

  1. Exits 0 on green, non-zero on fail.
  2. Prints actionable messages: file path, line number, the rule, the fix.
  3. Supports --explain to print the rationale and recovery pattern.
  4. Supports --baseline to regenerate the baseline file (only for shrink-only gates).
  5. Reads config from one file at repo root (e.g. .quality-gates.json) — not from scattered package configs.

Wiring

Two integration points:

  1. Pre-commit hook (Husky / lefthook) — runs the fastest subset (file-size, secrets, raw-error, intl spot-check) on the changed files only.
  2. CI — runs pnpm check:quality-gates on every PR; full sweep.

The pre-commit hook should be fast (<3s) so agents do not learn to bypass it. Anything slow runs in CI only.

A pre-push hook that runs:

  • structural gates (this directory),
  • ADR / RFC index integrity,
  • typecheck,
  • build,

— but not lint or the full test suite (those run in CI). The goal of pre-push is to catch structural drift before it hits CI, not to be CI.

See also