repo-hardening
Skill17 starsChanged 4 months agoMITView on GitHub
Prepare a repository for agent work — install the deterministic verification layer (formatter, linter, types, tests, git hooks, CI) without breaking what already exists, and record the canonical commands and prohibitions in the repo's agent-context file (AGENTS.md or CLAUDE.md). Use whenever the user wants to set up a linter, pre-commit, pre-push or CI, "get the repo ready for agents", standardise checks. Run it before `spec-execution` — that skill refuses to build without the verification block this installs. Works on a fresh repo and on an old one with partial config. Idempotent — re-run any time to re-verify.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- gabrieldabbah/genesistheir own version, first seen Jul 28, 2026
- forjd/agent-skillstheir own version, first seen May 21, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- gabrieldabbah/genesis★ 4same name
- forjd/agent-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- code-reviewSkill
- domain-modelingSkill
- spec-executionSkill
- tddSkill
- to-specSkill
- to-ticketsSkill
- grillSkill
- guideSkill
- session-handoffSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 17 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Ensure a deterministic verification layer exists in the repository, and that it is recorded where agents read.
- Distinctive: line 17
Never overwrite existing config.
- Distinctive: line 18
Never install a second hook manager.
- Distinctive: line 19
Never change an existing CI rule.
- Distinctive: line 20
Never make a bulk change without confirmation.
- Distinctive: line 23
Stop and ask whenever a choice is irreversible or opinionated.
- Distinctive: line 27
Write nothing in this phase.
- Distinctive: line 48
test runner and where tests live
- Distinctive: line 66
Wait for confirmation: If the user wants only part, do only that part.
- Distinctive: line 70
Only what the inventory found missing, in this order:
- Distinctive: line 89
Tests: if the suite is slow or flaky, record it as a known problem rather than masking it.
- Distinctive: line 91
Never disable a rule to make a check pass.
- Distinctive: line 97
If AGENTS.md exists, write the block there — it is the cross-harness standard.
- Distinctive: line 129
If the block already exists, compare it against reality and update only what diverged.
- Distinctive: line 135
Run the "All" command and confirm it passes.
- Distinctive: line 136
Test commit: did the hook fire?
- Distinctive: line 137
Do CI and the hook run the same commands?
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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
Repo Hardening
Ensure a deterministic verification layer exists in the repository, and that it is recorded where agents read.
Principle: an error a machine can catch, a model should never have to. Every check here is an agent cycle and a human review saved.
Idempotent. Re-running re-verifies and corrects drift — it never duplicates.
Inviolable rules
- Never overwrite existing config. If it exists, adopt it and record it.
- Never install a second hook manager. A repo has at most one.
- Never change an existing CI rule. Only add, and only with authorisation.
- Never make a bulk change without confirmation.
- Never write outside your own markers in the agent-context file (
AGENTS.md/CLAUDE.md). - Never create or edit
CONTEXT.md, ADRs, or domain docs. Those have another owner (domain-modeling). - Stop and ask whenever a choice is irreversible or opinionated.
Phase 1 — Inventory
Write nothing in this phase.
Ecosystem — detect from the manifest:
| File | Ecosystem |
package.json | Node/TS |
pyproject.toml, requirements.txt, setup.py | Python |
go.mod | Go |
Cargo.toml | Rust |
mix.exs | Elixir |
Gemfile | Ruby |
composer.json | PHP |
pom.xml, build.gradle | JVM |
Multiple manifests or a monorepo: list them all and ask which is in scope.
What already exists:
- hook manager:
.husky/,lefthook.yml,.pre-commit-config.yaml,.githooks/,core.hooksPath, a.git/hooks/with real content - formatter, linter, type-checker config
- test runner and where tests live
- CI:
.github/workflows/,.gitlab-ci.yml - scripts in the manifest, Makefile, justfile
- run/dev command for the evidence gate — a
dev/start/servescript, a documented run command, or none (a library with no runnable surface) AGENTS.md,CLAUDE.md,CONTRIBUTING.md— which one the harness auto-loads, and whether arepo-hardeningblock is already inside
Health of what exists — run the checks you found and count the failures. A linter configured but unrun for two years is not a verification layer, it is a liability.
Phase 2 — Report and decide
Present, briefly:
- ecosystem detected
- what exists and is healthy → kept
- what exists and is failing → how many failures, and a proposal
- what is missing → a proposal
- whether any bulk change is involved
Wait for confirmation. If the user wants only part, do only that part.
Phase 3 — Install what is missing
Only what the inventory found missing, in this order:
- Formatter — the ecosystem's default config, zero customisation.
Linter — the recommended default ruleset. Do not invent custom rules now.
Formatter and linter may be one tool or two — do not force two. Node splits them (prettier + eslint); modern Python is a single tool (
ruff format+ruff check), as is Biome for JS/TS. Install or adopt whatever the ecosystem's default is; if one tool covers both roles, that is one install with two commands, not a gap to fill with a second tool.- Type checker — where the language supports it (
tsc,mypy, …). - Hooks — if a manager exists, add a step to it; otherwise install the ecosystem default (husky for Node, the
pre-commitframework for Python, …).pre-commithook = formatter + lint + types on staged files.pre-push= the test suite. - CI — a job running exactly the same commands. If a workflow exists, add a new job rather than editing existing ones.
The hook is bypassable; CI is the real gate. Both must exist.
Phase 4 — Existing repo: don't break everything
Turning on strict mode in an old repo spews thousands of errors and the user quits on day one.
- Formatter: apply across the whole repo in one isolated commit, mixed with nothing. Confirm first.
- Linter and types: use the tool's own baseline/suppression mechanism if it has one (eslint does; many linters do), otherwise restrict scope to the folders where work will happen. A type-checker like
tschas no baseline — do not reach for one that does not exist; its only honest options are scope-restrict (include just the folders under work) or fix the errors in one isolated commit. Record that scope is partial either way. - Tests: if the suite is slow or flaky, record it as a known problem rather than masking it. A slow suite is the second-largest cost leak in agent work.
Never disable a rule to make a check pass. Either it enters the baseline, or it becomes a task.
Phase 5 — Write to the agent-context file
The block must land in the file the harness auto-loads into every session, or the prohibitions do not hold. That file is not the same everywhere: Claude Code loads CLAUDE.md; many other agent harnesses load AGENTS.md; some load both. Pick the target this way:
- If
AGENTS.mdexists, write the block there — it is the cross-harness standard. - Else if
CLAUDE.mdexists (e.g. a Claude Code repo), write the block there. - Else create
AGENTS.md. - If you wrote to
AGENTS.mdbutCLAUDE.mdalso exists, add a one-line pointer insideCLAUDE.md, between your markers, so the block is discoverable from whichever file the harness loads:<!-- repo-hardening:start --> See the Verification block in AGENTS.md. <!-- repo-hardening:end -->.
In the target file: create it if missing; if it exists, edit only between the markers below; if there are no markers, append the block at the end without touching anything else.
This block enters context in every session in the repo. Keep it lean — only what must hold even with no skill invoked. Procedure does not go here.
<!-- repo-hardening:start -->
## Verification
- Format: <command>
- Lint: <command>
- Types: <command>
- Tests: <command>
- Run: <dev server / run command, for the evidence gate — or "n/a" if the project has no runnable surface>
- All: <single command chaining format+lint+types+tests>
Lint/type scope: <full | folders X, Y>
Work is only done when every check is green.
Do not disable a lint rule, or add ignore/noqa/any, to make a check pass.
Do not use `--no-verify`.
Do not change an existing test to accommodate a change.
If the same check fails three times, stop and report the obstacle.
<!-- repo-hardening:end -->The Run line is what the evidence gate depends on — spec-execution brings the app up with it to capture real evidence, instead of guessing a command. Detect it in Phase 1 (a dev/start/serve script, a documented run command); if there genuinely is no runnable surface, record n/a so the gate knows to fall back to test output.
If the block already exists, compare it against reality and update only what diverged.
Then run the repo's formatter — whether you installed it or adopted an existing one — over the file you just wrote (and any config files you added). Any formatter will reflow an aligned block or a hand-written config, so this bites just as hard in a repo that already had one as in a fresh install — if you skip it, the Phase 6 check fails on the very files this skill created. The skill's own output must pass the skill's own gate.
Phase 6 — Verify
- Run the "All" command and confirm it passes.
- Test commit: did the hook fire?
- Do CI and the hook run the same commands? Divergence is the classic source of "passes local, breaks in the PR".
- If
Runis notn/a, execute it — confirm the app actually comes up, then tear it down. TheRunline is the evidence gate's contract, and an untested run command breaks that gate inspec-execution's evidence step, at the worst possible time (the work is already done, and the gate fails on infrastructure, not quality). This is the same rule as the rest of Phase 6: don't trust what you just wrote — run it. - Commit the hardening — one isolated commit, mixed with no feature work. This layer is durable repo state, exactly like a spec or a ticket (
to-specandto-ticketscommit theirs for the same reason). Leave it uncommitted and the nextspec-executionrun inherits a dirty tree: config, hooks, CI and the agent-context file land inside a feature PR, breaking its closed scope (§3) and its one-diff-one-concern rule (§8) by construction, andcode-review's Standards axis reviews your config as if it were the feature. If a formatter pass reflowed pre-existing code, that is a second isolated commit (see Working on an old repo) — never folded into this one. Stage by path — only the files you installed or edited. Phase 1 told you whether the tree was already dirty; if it was, a blanketgit add -Aswallows the user's uncommitted work into "your" commit and the isolation is gone without anyone noticing. Leave what is not yours untouched and say in the report that you found it dirty. - Report what was installed, what was kept, and what is still pending.
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.

