Awesome-claude-code pre-commit

Run all checks before committing

install
source · Clone the upstream repo
git clone https://github.com/m-ret/awesome-claude-code
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/m-ret/awesome-claude-code "$T" && mkdir -p ~/.claude/skills && cp -r "$T/templates/nodejs/.claude/skills/pre-commit" ~/.claude/skills/m-ret-awesome-claude-code-pre-commit && rm -rf "$T"
manifest: templates/nodejs/.claude/skills/pre-commit/SKILL.md
source content

Pre-Commit Checks Skill

Comprehensive validation before committing code.

When to Use

  • Before any git commit
  • When user runs /pre-commit
  • As part of quick-commit workflow

Steps

  1. Check for unstaged changes

    git status --short
    

    Warn if there are unstaged changes that won't be committed.

  2. Type Check (TypeScript)

    npx tsc --noEmit
    

    STOP if type errors found.

  3. Lint Check

    npm run lint
    

    STOP if lint errors found (warnings OK).

  4. Format Check

    npx prettier --check .
    

    Offer to fix if formatting issues found.

  5. Run Tests

    npm test
    

    STOP if tests fail.

  6. Check for Sensitive Files Scan staged files for:

    • .env files (should be .env.example only)
    • Credentials, API keys, secrets
    • Large binary files WARN if found.
  7. Verify Git Identity

    git config user.email
    

    Confirm correct email for this project.

Output

All Checks Pass

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PRE-COMMIT CHECK

[OK] TypeScript: No errors
[OK] ESLint: Passed
[OK] Prettier: Formatted
[OK] Tests: All passing
[OK] No sensitive files
[OK] Git identity: your.email@example.com

Ready to commit!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Checks Failed

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PRE-COMMIT CHECK

[OK] TypeScript: No errors
[FAIL] ESLint: 3 errors found
  - src/index.ts:15 - Unexpected any
  - src/utils.ts:8 - Missing return type
  - src/utils.ts:12 - Unused variable
[--] Prettier: Skipped (lint failed)
[--] Tests: Skipped (lint failed)

Fix errors before committing.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Auto-Fix Mode

When invoked with "fix" argument:

  1. Run lint:fix
  2. Run prettier --write
  3. Re-run all checks
  4. Report final status