agentleFS
gg-mogg-mo/repo-hygiene/skills/gating-commits/SKILL.md

gating-commits

Skill3 starsChanged 7 months agoMITView on GitHub

Use when about to commit, merge, or push — runs verification (tests, typecheck, lint), confirms focus, and checks sibling hygiene (docs, tests, docstrings) BEFORE the commit lands, so "user said commit" doesn't bypass quality

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run these BEFORE staging or committing.

    line 22
  2. Very specific:

    Identify the verification commands: Read package.json, pyproject.toml, Makefile, .github/workflows/, or CLAUDE.md.

    line 24
  3. Distinctive:

    Run them: Read the full output. Check exit codes.

    line 28

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

Gating Commits

Overview

"User said commit" is not authorization to skip verification. The honest baseline from agents is: do git triage, draft a message, stage, commit — no test/typecheck/lint in between. This skill changes the default to verify first, commit second.

Core principle: A commit is a promise that what's in it works. Don't ship that promise on faith.

When To Use

  • User says "commit" / "ship" / "land" / "merge" / "push"
  • Just finished a multi-file change
  • About to call git commit for any reason

The Gate

Run these BEFORE staging or committing. Stop at the first failure.

  1. Identify the verification commands. Read package.json, pyproject.toml, Makefile, .github/workflows/, or CLAUDE.md. Typical targets:
    • Tests: npm test, pytest, go test ./..., cargo test
    • Types: tsc --noEmit, mypy, pyright
    • Lint: npm run lint, ruff check, golangci-lint run
  2. Run them. Read the full output. Check exit codes.
  3. If anything fails: Fix or revert. Do NOT commit failing code with intent to fix in the next commit.
  4. Sibling-skill checks:
    • Changed a public API surface? Did repo-hygiene:keeping-docs-fresh run?
    • Added business logic? Did repo-hygiene:testing-new-code run?
    • Added new functions/classes/files? Did repo-hygiene:writing-docstrings apply?
  5. Focus check — git diff --stat HEAD. Are all changes related to the stated commit purpose? If unrelated changes snuck in, split them.
  6. Then stage specific files (no blanket git add .) and commit with a clear message.

What Counts as "Verified"

CheckSufficient evidence
Tests passTest command output: 0 failures, exit 0
Types cleanType-checker output: 0 errors
Lint cleanLinter output: 0 errors (warnings: use judgment)
Build succeedsBuild command exits 0

"Looks fine," "should pass," and "I'm confident" do not count.

What if the Repo Has No Verification Setup?

Tell the user explicitly:

"I don't see test/lint/typecheck commands in this repo. I can commit as-is, or set up a minimal check first. Which do you want?"

Defer to the user. Silent skipping is the failure mode.

Commit Message Hygiene

  • Subject: imperative mood, under 72 chars (Fix foo when bar, not Fixed foo or Fixing foo)
  • Body: explain WHY, not what (the diff shows what)
  • One logical change per commit. Bundling unrelated fixes makes review and bisect harder.

Common Mistakes

MistakeFix
"User said commit" → commitAuthorization ≠ verification
Tests only, not typesLinter ≠ compiler ≠ test runner; check each
git add . blanket stageStage specific files
"Tests failed but they're unrelated"Either fix or split into a separate commit that flags the breakage
Giant diff, multiple unrelated changesSplit. One logical change per commit.
Skipping doc/test sibling checksRe-read the trigger list above
--no-verify to bypass pre-commit hooksInvestigate why the hook is firing; don't bypass

Red Flags — STOP

  • About to type git commit without fresh test/lint/typecheck output in context
  • "User said commit so it's their call" — verification is YOUR job before the commit
  • Diff shows unrelated changes — split first
  • About to use --no-verify
  • "I'll fix the failing test in the next commit" — no; fix or revert now

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.