agentleFS
alex-voloshin-devalex-voloshin-dev/ai-skills/.agents/skills/pre-commit/SKILL.md

pre-commit

Skill2 starsChanged 6 months agoMITView on GitHub

Pre-commit quality gate — lint, format, test, validate before committing. Runs automated checks and fixes issues. Use before git commit to ensure code quality.

12 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 11 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 11

    Distinctive

    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:

    Read AGENTS.md and project config files to determine:

    line 12
  2. Distinctive:

    Stop and inform the user.

    line 34
  3. Distinctive:

    Run the project's linter on staged files:

    line 38
  4. Distinctive:

    Completion: If exit code 0 after auto-fix → proceed.

    line 47
  5. Distinctive:

    Run the project's formatter:

    line 56
  6. Distinctive:

    Completion: If exit code 0 → proceed. If type errors → report and STOP.

    line 79
  7. Distinctive:

    Run the project's test suite (unit tests at minimum):

    line 83
  8. Distinctive:

    If still failing — report and STOP

    line 96
  9. Distinctive:

    Completion: All tests pass → proceed. Any failure after auto-fix attempt → STOP.

    line 98
  10. Distinctive:

    If all checks pass, suggest the commit command:

    line 124
  11. Distinctive:

    Follow Conventional Commits format.

    line 129

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “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

Pre-Commit

Automated quality gate before committing code. Runs linting, formatting, tests, and validation checks. Fixes auto-fixable issues and reports blockers.

1. Detect Project Stack

Read AGENTS.md and project config files to determine:

  • Language(s): TypeScript, Java, Python, Go, etc.
  • Package manager: npm/pnpm/yarn, maven/gradle, pip/poetry, go mod
  • Linter: ESLint, Checkstyle, ruff/flake8, golangci-lint
  • Formatter: Prettier, google-java-format, black/ruff, gofmt
  • Test runner: Vitest/Jest, JUnit/Maven, pytest, go test

2. Check Staged Changes

// turbo
git status --short

Identify which files are staged. If no files are staged:

⚠️ No staged changes found. Stage your changes first:
  git add <files>

Stop and inform the user.

3. Run Linter

Run the project's linter on staged files:

StackCommand
TypeScript/JSnpx eslint --fix <files>
Pythonruff check --fix <files> or flake8 <files>
Javamvn checkstyle:check or gradle checkstyleMain
Gogolangci-lint run <files>

Completion: If exit code 0 after auto-fix → proceed. If errors remain → report and STOP:

## Lint Issues (must fix)
- [file:line] [rule] description

4. Run Formatter

Run the project's formatter:

StackCommand
TypeScript/JSnpx prettier --write <files>
Pythonruff format <files> or black <files>
Javamvn spotless:apply or google-java-format <files>
Gogofmt -w <files>

Re-stage any auto-formatted files:

git add <formatted-files>

Completion: Files formatted and re-staged → proceed.

5. Run Type Checker (if applicable)

StackCommand
TypeScriptnpx tsc --noEmit
Pythonmypy <files> or pyright <files>

Completion: If exit code 0 → proceed. If type errors → report and STOP.

6. Run Tests

Run the project's test suite (unit tests at minimum):

StackCommand
TypeScript/JSnpx vitest run or npx jest
Pythonpytest -x -q
Javamvn test -q or gradle test
Gogo test ./...

If tests fail:

  1. Analyze the failure
  2. Attempt auto-fix if the fix is obvious and safe
  3. Re-run tests to verify
  4. If still failing — report and STOP

Completion: All tests pass → proceed. Any failure after auto-fix attempt → STOP.

7. Validate Build (if applicable)

StackCommand
TypeScript/JSnpm run build or npx tsc --noEmit
Javamvn compile -q
Gogo build ./...

8. Summary

## Pre-Commit Results

| Check      | Status | Details |
|------------|--------|---------|
| Lint       | ✅/❌  | [issues found/fixed] |
| Format     | ✅/❌  | [files formatted] |
| Type check | ✅/❌/⏭️ | [errors or N/A] |
| Tests      | ✅/❌  | [passed/failed count] |
| Build      | ✅/❌/⏭️ | [success or N/A] |

Ready to commit: [YES / NO — fix issues above first]

If all checks pass, suggest the commit command:

git commit -m "<type>(<scope>): <description>"

Follow Conventional Commits format.

Integration

  • Called by: feature-dev skill, bugfix skill (before commit)
  • Calls: run-tests skill
  • Followed by: create-pr skill

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.