xp-gate / githooks
AGENTS.md4 starsChanged 6 months agoMITView on GitHub
Generated: 2026-11-04 Commit: eb2097b0 Branch: sprint/2026-11-03-02 Version: 0.37.0.0 The README/docs/CA
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- plugins/AGENTS.mdAGENTS.md
- skills/delphi-review/AGENTS.mdAGENTS.md
- skills/sprint-flow/AGENTS.mdAGENTS.md
- skills/test-specification-alignment/AGENTS.mdAGENTS.md
- admin-template-guidelinesSkill
- batch-grill-meSkill
- delphi-reviewSkill
- domain-modelingSkill
- grillingSkill
- grill-with-docsSkill
- improve-codebase-architectureSkill
- ralph-loopSkill
- sprint-flowSkill
- test-driven-developmentSkill
- test-specification-alignmentSkill
- to-issuesSkill
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 90
Code-walkthrough scope: no hard file-count or LOC threshold.
- Very specific: line 102
Do NOT use --no-verify to bypass any gate.
- Distinctive: line 103
Do NOT use change size as authorization to bypass code-walkthrough.
- Very specific: line 104
Do NOT hardcode tool paths in an adapter — use the routing in adapter-common.sh.
- Very specific: line 105
Do NOT delete or rename .code-walkthrough-result.json before push.
- Distinctive: line 106
Do NOT add a new gate without adding both a script-level Gate N row AND updating root AGENTS.md + README.md.
- Very specific: line 107
Do NOT edit adapters here without resyncing src/npm-package/adapters/.
- Very specific: line 113
JSON journal: every pre-push writes .xp-gate/reports/pre-push/*.json for audit / xp-gate audit --tail.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GITHOOKS KNOWLEDGE BASE
Generated: 2026-11-04 Commit: eb2097b0 Branch: sprint/2026-11-03-02 Version: 0.37.0.0
OVERVIEW
Git quality gates: pre-commit runs 12 numbered gates (Gate 0–11) plus Gate 12 (File Hygiene, warning-only) via 13 language adapters; pre-push runs 8 gates: Gate 10 (Build Integrity), Gate M (TS mutation), Gate M-Python, M-Go, M-Java, M-Kotlin (multi-lang mutation), Gate M2 (Mock Density, WARNING-only), Gate ML (Mock Layering), Gate UI (UI Sprint Gates), Gate MW (Code Walkthrough), and Gate S (Sprint Flow). Zero-tolerance policy per QUALITY-GATES-CODE-OF-CONDUCT.md — --no-verify strictly prohibited.
STRUCTURE
githooks/
├── pre-commit # ~2084 lines: Gate 0 (Version) + Gates 1–9
├── pre-push # ~607 lines: Gate M / M2 / M3 + Delphi walkthrough validator
├── adapter-common.sh # detect_project_lang(), route_to_adapter(), 3-tier resolution
├── adapters/ # 13 language adapters + plugins/
│ ├── typescript.sh, python.sh, go.sh, java.sh, kotlin.sh
│ ├── cpp.sh, swift.sh, objectivec.sh, shell.sh, powershell.sh
│ ├── dart.sh, flutter.sh, iac.sh
│ │ # NOTE: no standalone c.sh (cpp.sh handles both C and C++)
│ └── plugins/ # 5 third-party extensions
│ ├── p3c-java/ # Alibaba P3C Java guidelines
│ ├── whalecloud-java/ # Whalecloud Java rules
│ ├── book299-20132-python/ # Python style rules
│ ├── book299-4081-c/ # C style rules
│ └── book299-4083-javascriptes5/ # ES5 JavaScript rules
├── QUALITY-GATES-CODE-OF-CONDUCT.md # --no-verify strictly prohibited
├── TOOL-INSTALLATION-GUIDE.md
├── install.sh, verify.sh # Project-local install + verification
└── __tests__/ # BATS testsWHERE TO LOOK
| Task | Location | Notes |
| Pre-commit gates | pre-commit | Gate 0 + 1..9 (see GATES section below) |
| Language routing | adapter-common.sh | 3-tier: global ~/.config/xp-gate/adapters → project githooks/adapters/ → script dir |
| Adapters | adapters/ | 13 languages (no standalone C — cpp.sh handles both) |
| Plugin adapters | adapters/plugins/ | 5 third-party extensions |
| Pre-push gates | pre-push | Gate M (mutation), M2 (mock density), M3 (mock policy), + Delphi walkthrough |
| Code of Conduct | QUALITY-GATES-CODE-OF-CONDUCT.md | Zero-tolerance — --no-verify prohibited |
| Local install | install.sh | Per-project install of hooks + adapter infrastructure |
| Verify install | verify.sh | Sanity check installation |
| Tests | tests/ | BATS tests for gate routing + adapters |
GATES
Pre-commit (12 numbered gates)
| Gate | Name | Tool / Source | Block on |
| 0 | Version Consistency | ../src/architecture/version-parser.ts + repo VERSION | VERSION ≠ any package.json |
| 1 | Code Quality | Adapter lint (ESLint / Ruff / govet / clang-tidy / ...) | Any lint error |
| 2 | Duplicate Code | jscpd (jscpd.conf.json) | >5% similarity |
| 3 | Cyclomatic Complexity | lizard | CCN >5 warn, >10 block |
| 4 | Principles | ../src/principles/index.ts (14 rules × 9 langs) | Any error/warning per .principlesrc |
| 5 | Tests + Coverage | Adapter test + coverage | Test fail; coverage <80% |
| 6 | Architecture + Boy Scout | .archlint.yaml + ../src/principles/boy-scout.ts | New warnings on modified files |
| 7 | IaC Security | checkov / hadolint / kube-score / tflint | High-severity finding |
| 8 | Secret Scanning | gitleaks (.gitleaks.toml) | Any leaked secret |
| 9 | Build Integrity | tsc + npm pack + import check | Build/compilation failure |
| 10 | SAST Security | semgrep ruleset | High-severity finding |
| 11 | Sprint Flow | sprint-gate.sh | Sprint compliance violation |
| 12 | File Hygiene | gate-12-file-hygiene.sh | WARNING-only (conflict markers, YAML/JSON syntax block) |
The README/docs/CAPABILITIES.md "6 Gates" framing is a conceptual grouping (CodeQ, Complexity, Principles, Tests, Architecture, Security) over these 10 script-level gates. See root
AGENTS.md→ "Known Drift" #1.
Pre-push (8 gates)
| Gate | Name | Source | Block on |
| 10 | Build Integrity | tsc + npm pack | Build/compilation failure |
| M | Incremental Mutation (TS) | ../src/mutation/gate-m.ts (Stryker, stryker.prepush.conf.json) | Mutation score < threshold |
| M-Python | Incremental Mutation (Python) | inline in pre-push | Mutation score < threshold |
| M-Go | Incremental Mutation (Go) | inline in pre-push | Mutation score < threshold |
| M-Java | Incremental Mutation (Java) | inline in pre-push | Mutation score < threshold |
| M-Kotlin | Incremental Mutation (Kotlin) | inline in pre-push | Mutation score < threshold |
| M2 | Mock Density | inline in pre-push (keyword scan: vi.mock, jest.mock, etc.) | WARNING only (>30% mock density without @mock-justified) |
| ML | Mock Layering Policy | ../src/mock-policy/gate-m3.ts | Per-layer mock policy violation when severity=error |
| UI | UI Sprint Quality Gates | inline in pre-push | UI regression or missing UI review |
| MW | Code-walkthrough validator | reads .code-walkthrough-result.json | File missing, OR commit hash stale vs HEAD |
| S | Sprint Flow Enforcement | sprint-gate.sh | specification.yaml compliance |
Code-walkthrough has no hard file-count or LOC threshold. Large diffs must be reviewed completely or split by user choice; size-based bypass is not permitted. Code-walkthrough is skipped on main/master pushes by design. All pre-push runs write a JSON journal under .xp-gate/reports/pre-push/<UTC-timestamp>.json.
CONVENTIONS
- 3-tier adapter resolution:
~/.config/xp-gate/adapters/<lang>.sh(global) →<project>/githooks/adapters/<lang>.sh(project) → script dir (fallback). - Tool unavailable → SKIP, not BLOCK — except Gate 8: since #499 secret scanning is fail-closed — gitleaks missing or exiting non-0/1 BLOCKs the commit (a security gate that cannot run must not report success). CI installs gitleaks for the first-commit job accordingly. Adapter degrades other gates to SKIP when the underlying tool isn't installed; block fires only when the tool exists and the check fails.
- Code-walkthrough scope: no hard file-count or LOC threshold; large diffs require complete review or user-directed splitting, never a size-based bypass.
- Code-walkthrough skipped on main/master. Gate M, M2, M3 still run.
- Boy Scout Rule (Gate 6): new files zero-tolerance; modified files cannot increase warnings; untouched files unchecked.
- Adapter plugins under
adapters/plugins/extend the base language adapters (P3C/whalecloud for Java, book299 for Python/C/ES5 JS). Opt-in per project. - Project-level coverage exclusions: a project may ship
.xp-gate-powershell-coverage-ignore(one glob per line,#comments allowed) to exclude scripts that cannot be exercised by Pester (e.g. bootstrap scripts whoseMainends inexit); the PowerShell adapter drops matching files from coverage accounting instead of counting them as 0%. Python coverage thresholds come frompyproject.toml [tool.coverage.report] fail_under— the adapter never hardcodes a threshold. - Gate 10 SAST verdict comes from semgrep's JSON, not its exit code (#518): without
--error, semgrep exits 0 even with ERROR-severity findings, and its own severity scale (ERROR/WARNING/INFO) never intersects the old CRITICAL/HIGH red-flag vocabulary — the gate used to print PASS on a textbook command-injection finding. The verdict is now parsed fromresults[].extra.severitywith a union vocabulary: blocking = everything OUTSIDE the warnings-only list (WARNING|INFO|MEDIUM|LOW) — i.e. ERROR/CRITICAL/HIGH and any unknown or missing tier fail closed to BLOCK; warnings-only = WARNING|INFO|MEDIUM|LOW. stdout/stderr are captured separately (the old2>&1merge poisoned the JSON).--errormust NOT be added: its exit-code mapping has drifted across semgrep versions/platforms and the JSON verdict needs nothing from it — keeping it off also leaves failure exit codes unambiguous for the #475 diagnostics path. node is a hard dependency of the verdict and is checked BEFORE the semgrep run (missing node = SKIP with an install hint, not a silent net-loss). Unparseable output, missing verdict fields, or a zero-results run with scan errors/nonzero exit all fail closed to SKIP (never PASS). The same semantics are implemented in the TS CLI gate (src/gates/gate-9.ts, dispatched asxp-gate gate sast); the legacygate-9*.shfallback copies are tracked in a follow-up issue. Pinned by__tests__/gate-10-verdict.test.batsandsrc/gates/__tests__/gate-9.test.ts. - Python mypy scope is repo-declared (#513, generalizing #501):
adapters/python.shuses.xp-gate-mypy-scopeat the repo root when present (one directory per line,#comments allowed — full-line or inline); otherwise existence-guardedsrc/+scripts/. Every target (declared or default) must exist AND contain at least one.pyfile — targets failing the guard are WARNed and skipped, so a typo'd or .py-less declaration degrades to SKIP instead of false-BLOCKing. An empty or fully-unusable declaration also SKIPs (with a distinct WARNING), never a silent pass-through. A repo declaring no type surface SKIPs with a notice pointing to the declaration file instead of false-BLOCKing every.pycommit. mypy is invoked per target (matching the CI type job's per-directory runs — a mergedmypy src scriptscall reports "Duplicate module" for same-named modules and false-BLOCKs). Never a baremypy .. Pinned by__tests__/adapter-mypy-pester-scope.test.bats. - PROJECT_SUBDIR derivation is root-aware (#515, R2 delphi-walkthrough): nested project markers only locate a subdir when the repo ROOT itself declares no project. The root short-circuit marker set is the FULL
_detect_subdirset (10 markers: tsconfig.json / package.json / pyproject.toml / setup.py / go.mod / pubspec.yaml / pom.xml / build.gradle / build.gradle.kts / CMakeLists.txt) — the two lists must not drift. One exception, checked FIRST (a root tsconfig.json often coexists with it): a rootpackage.jsoncarrying a"workspaces":key is a JS monorepo, not a single project, so derivation keeps running there. Known limitation (#527, pinned in tests): Gradle multi-module, CMake subdirectory layouts and pnpm (pnpm-workspace.yaml) / Lerna (lerna.json) workspaces are not disambiguated from single projects — the root marker wins. With a root marker present, a nested marker that is merely a module file must not hijack the cwd — Gates 1-9 would run in the wrong directory and false-BLOCK on root-relative paths. Pinned by__tests__/subdir-root-shortcircuit.test.bats. - No CLI invocation in pre-push hook for Delphi. The hook is a validator only — it reads
.code-walkthrough-result.json; the actual review must run via the skill before push. - Adapters are duplicated into
src/npm-package/adapters/. Source of truth = here; resync via build scripts.
ANTI-PATTERNS (THIS PROJECT)
- Do NOT use
--no-verifyto bypass any gate. Process violation perQUALITY-GATES-CODE-OF-CONDUCT.md. - Do NOT use change size as authorization to bypass code-walkthrough; review large diffs completely or split them before review.
- Do NOT hardcode tool paths in an adapter — use the routing in
adapter-common.sh. - Do NOT delete or rename
.code-walkthrough-result.jsonbefore push; the validator will block. - Do NOT add a new gate without adding both a script-level Gate N row AND updating root
AGENTS.md+README.md. - Do NOT edit adapters here without resyncing
src/npm-package/adapters/. Source-of-truth is this directory.
UNIQUE STYLES
- Monolithic pre-commit (~2084 lines) intentionally — single bash file keeps the trust boundary auditable.
- Pre-push is a thin validator — heavy lifting (mutation, mock policy, Delphi) lives in
src/modules invoked vianpx tsx. - Graceful adapter degradation: SKIP semantics keep the hook useful in mixed-language repos.
- JSON journal: every pre-push writes
.xp-gate/reports/pre-push/*.jsonfor audit /xp-gate audit --tail.
COMMANDS
# Install per-project hooks + adapter infrastructure
bash githooks/install.sh
# Verify installation integrity
bash githooks/verify.sh
# Run BATS tests
cd githooks/__tests__ && bats *.bats
# Check / repair drift between this directory and the INSTALLED hooks
xp-gate doctor # reports hook drift + which copy is in charge
xp-gate doctor --sync-hooks # copy githooks/* over the installed copyEFFECTIVE HOOKS — READ THIS BEFORE EDITING A HOOK
This directory is the source of truth in version control, but it is not
necessarily what executes. When core.hooksPath is set (global install), git
runs the copy under ~/.config/xp-gate/hooks/ instead:
$ git config --get core.hooksPath
C:/Users/think/.config/xp-gate/hooksEditing a hook here therefore has no local effect until you sync. This was the whole of issue #451, and it is easy to misread as "my edit does nothing".
xp-gate doctor # shows "Effective hooks:", the drift, and its direction
xp-gate doctor --sync-hooks # make this directory effective, then commit as normalxp-gate doctor reports drift only when the current project actually carries
hook files here (i.e. this repo, or a fork). Consumer projects get only
githooks/adapters/ from xp-gate init, which is not a hook source of truth.
NOTES
- See repo root
AGENTS.md→ "Known Drift" for the canonical list of doc-vs-reality gaps (gate count, C-adapter claim, etc). - Pre-push reads
.code-walkthrough-result.jsonand comparescommit_hashtogit rev-parse HEAD. - Main-branch push: Gate M / M2 / M3 still execute; only the walkthrough validator is skipped.
- Mutation testing CI:
.github/workflows/mutation-test.ymlnarrows--mutateto the files changed in the PR (full-suite runs exceed the 45-min budget).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

