agentleFS
assisjpassisjp/specflow/skills/engineering/repo-hardening/SKILL.md

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

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. gabrieldabbah/genesis★ 4same name
    2. 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.

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
  1. Distinctive:

    Ensure a deterministic verification layer exists in the repository, and that it is recorded where agents read.

    line 9
  2. Distinctive:

    Never overwrite existing config.

    line 17
  3. Distinctive:

    Never install a second hook manager.

    line 18
  4. Distinctive:

    Never change an existing CI rule.

    line 19
  5. Distinctive:

    Never make a bulk change without confirmation.

    line 20
  6. Distinctive:

    Stop and ask whenever a choice is irreversible or opinionated.

    line 23
  7. Distinctive:

    Write nothing in this phase.

    line 27
  8. Distinctive:

    test runner and where tests live

    line 48
  9. Distinctive:

    Wait for confirmation: If the user wants only part, do only that part.

    line 66
  10. Distinctive:

    Only what the inventory found missing, in this order:

    line 70
  11. Distinctive:

    Tests: if the suite is slow or flaky, record it as a known problem rather than masking it.

    line 89
  12. Distinctive:

    Never disable a rule to make a check pass.

    line 91
  13. Distinctive:

    If AGENTS.md exists, write the block there — it is the cross-harness standard.

    line 97
  14. Distinctive:

    If the block already exists, compare it against reality and update only what diverged.

    line 129
  15. Distinctive:

    Run the "All" command and confirm it passes.

    line 135
  16. Distinctive:

    Test commit: did the hook fire?

    line 136
  17. Distinctive:

    Do CI and the hook run the same commands?

    line 137

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Never overwrite existing config. If it exists, adopt it and record it.
  2. Never install a second hook manager. A repo has at most one.
  3. Never change an existing CI rule. Only add, and only with authorisation.
  4. Never make a bulk change without confirmation.
  5. Never write outside your own markers in the agent-context file (AGENTS.md/CLAUDE.md).
  6. Never create or edit CONTEXT.md, ADRs, or domain docs. Those have another owner (domain-modeling).
  7. Stop and ask whenever a choice is irreversible or opinionated.

Phase 1 — Inventory

Write nothing in this phase.

Ecosystem — detect from the manifest:

FileEcosystem
package.jsonNode/TS
pyproject.toml, requirements.txt, setup.pyPython
go.modGo
Cargo.tomlRust
mix.exsElixir
GemfileRuby
composer.jsonPHP
pom.xml, build.gradleJVM

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/serve script, 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 a repo-hardening block 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:

  1. Formatter — the ecosystem's default config, zero customisation.
  2. 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.

  3. Type checker — where the language supports it (tsc, mypy, …).
  4. Hooks — if a manager exists, add a step to it; otherwise install the ecosystem default (husky for Node, the pre-commit framework for Python, …). pre-commit hook = formatter + lint + types on staged files. pre-push = the test suite.
  5. 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 tsc has 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:

  1. If AGENTS.md exists, write the block there — it is the cross-harness standard.
  2. Else if CLAUDE.md exists (e.g. a Claude Code repo), write the block there.
  3. Else create AGENTS.md.
  4. If you wrote to AGENTS.md but CLAUDE.md also exists, add a one-line pointer inside CLAUDE.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

  1. Run the "All" command and confirm it passes.
  2. Test commit: did the hook fire?
  3. Do CI and the hook run the same commands? Divergence is the classic source of "passes local, breaks in the PR".
  4. If Run is not n/a, execute it — confirm the app actually comes up, then tear it down. The Run line is the evidence gate's contract, and an untested run command breaks that gate in spec-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.
  5. 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-spec and to-tickets commit theirs for the same reason). Leave it uncommitted and the next spec-execution run 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, and code-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 blanket git add -A swallows 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.
  6. Report what was installed, what was kept, and what is still pending.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.