plugin/skills/pre-commit/SKILL.md
Use this skill when running a quality gate over staged changes before a git commit to catch lint/format/type/test failures — a pre-commit quality gate that lints, formats, type-checks, tests, and validates before committing. Detects existing pre-commit framework / Husky / Lefthook / lint-staged and routes to it; otherwise runs an inline stack-detected gate. Not the [pre-commit framework](https://pre-commit.com) itself — see Step 0 for framework detection.
npx skillsauth add avav25/ai-assets pre-commitInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Automated quality gate before committing code. Runs linting, formatting, tests, and validation checks. Fixes auto-fixable issues and reports blockers.
Before running any inline gate, check whether the repo already has a pre-commit hook framework configured. If so, route to it; the team's framework choice supersedes anything in this skill.
| Marker file present | Framework | Run command |
|---|---|---|
| .pre-commit-config.yaml (root) | pre-commit framework | pre-commit run --files <staged-files> (or --all-files if staged scope ambiguous) |
| .husky/ directory | Husky | .husky/pre-commit (or git commit triggers it; just continue) |
| lefthook.yml / lefthook.toml (root) | Lefthook | lefthook run pre-commit |
| package.json["lint-staged"] | lint-staged (Node) | npx lint-staged |
| .git/hooks/pre-commit (custom) | Bespoke shell hook | inspect contents; run only if obviously safe |
If a framework is detected:
If multiple markers are present, prefer the most specific (Husky + lint-staged is the common Node combo — let Husky drive).
If no framework is detected, continue to Step 1 below.
Read CLAUDE.md and project config files to determine:
// 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.
Run the project's linter on staged files:
| Stack | Command |
|---|---|
| TypeScript/JS | npx eslint --fix <files> |
| Python | ruff check --fix <files> or flake8 <files> |
| Java | mvn checkstyle:check or gradle checkstyleMain |
| Go | golangci-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
Run the project's formatter:
| Stack | Command |
|---|---|
| TypeScript/JS | npx prettier --write <files> |
| Python | ruff format <files> or black <files> |
| Java | mvn spotless:apply or google-java-format <files> |
| Go | gofmt -w <files> |
Re-stage any auto-formatted files:
git add <formatted-files>
Completion: Files formatted and re-staged → proceed.
| Stack | Command |
|---|---|
| TypeScript | npx tsc --noEmit |
| Python | mypy <files> or pyright <files> |
Completion: If exit code 0 → proceed. If type errors → report and STOP.
Run the project's test suite (unit tests at minimum):
| Stack | Command |
|---|---|
| TypeScript/JS | npx vitest run or npx jest |
| Python | pytest -x -q |
| Java | mvn test -q or gradle test |
| Go | go test ./... |
If tests fail:
Completion: All tests pass → proceed. Any failure after auto-fix attempt → STOP.
| Stack | Command |
|---|---|
| TypeScript/JS | npm run build or npx tsc --noEmit |
| Java | mvn compile -q |
| Go | go build ./... |
## 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.
/feature-dev, /bugfix (before commit)/run-tests/create-prdevelopment
Use this skill when running the recurring (daily) knowledge-base rescan for a repo that already has knowledge/.knowledge-sync.yml — the main-thread dispatcher that reads the config, computes the git delta since last_scanned_sha, maps changed paths to affected doc areas, early-exits cheaply when nothing changed, then fans out one Agent(content-writer) per affected area, applies the propose/direct update policy, advances the baseline only on success, and writes an L4 run log — all with the G1 untrusted-content choke-point, secret-scan, deny-list, and budget controls woven in. For first-time setup use /knowledge-sync-init.
development
Use this skill when bootstrapping scheduled knowledge-base sync for a repo that has no knowledge/.knowledge-sync.yml yet — to run one-time setup that detects the knowledge_root from CLAUDE.md/AGENTS.md, maps doc areas to source globs, records opt-in external sources (Linear/Notion/WebFetch, all disabled by default), captures a baseline last_scanned_sha, sets the per-area update policy, generates or seeds knowledge/CONVENTIONS.md, provisions the L4 memory dir, and offers to register the daily routine. Routes ongoing recurring sync operations to /knowledge-sync.
tools
Use this skill when bootstrapping a target repository to be ai-skills-aware — on the first run of any ai-skills workflow in a fresh repo, when adopting the ai-skills plugin in an existing repo, or after upgrading to a plugin version that adds new memory paths or templates, including when the user does not say "init" but asks to "set up" or "onboard" the repo — to detect codebase type, create CLAUDE.md + AGENTS.md scaffolding, initialize the .ai-skills-memory/ directory tree from L1 templates, and configure .gitignore. Idempotent — safe to re-run. Accepts `--codebase-type <type>` and `--overwrite`. Not for re-initializing only memory — use `/memory-init` instead.
tools
Use this skill when extending, repairing, or improving plugin assets, when ingesting a `/feedback` report as a fix-cycle backlog, or when you do not remember which lower-level command is right for the job — the umbrella workflow for ai-skills plugin-asset authoring and maintenance: creating, auditing, fixing, improving, refactoring, and migrating skills, agents, rules, hooks, prompts, schemas, and rubrics inside the plugin. Auto-classifies the request, loads the right knowledge skills (`@prompt-engineering`, `@context-engineering`, `@team-protocols`), and spawns the right subagents (`prompt-engineer`, `system-architect`, `python-engineer`, `software-engineer`, `qa-engineer`, `eval-judge`) via the `Agent` tool.