Pre-Commit Checks

VerifiedSafe

Runs Ruff linting and formatting with auto-fix, then performs Mypy type checking on Python files. Use this skill before every git commit to catch errors early and meet CI requirements. It stages auto-fixed files if needed and reports pass/fail results.

Sby Skills Guide Bot
DevelopmentBeginner
706/2/2026
Claude CodeCursorWindsurfCopilotCodex
#pre-commit#code-quality#linting#type-checking#python

Recommended for

Our review

Runs all pre-commit checks (lint and typecheck) before every git commit to ensure code quality.

Strengths

  • Automates linting and formatting with Ruff
  • Checks types with Mypy to catch common errors
  • Auto-fixes files and stages them for commit

Limitations

  • Only supports Python projects
  • Mypy options are very permissive (ignores many error codes)
  • Does not include other checks like tests or security
When to use it

Before every commit on a Python project to ensure code meets quality standards.

When not to use it

For non-Python projects or when you need stricter type checking (since Mypy is configured leniently).

Security analysis

Safe
Quality score90/100

Commands run local linting (ruff) and type checking (mypy) on project files. No network access, file deletion, or secret exfiltration. The `--fix` flag modifies source files locally, which is expected. No obfuscation or disabling of safety mechanisms.

No concerns found

Examples

Run pre-commit checks
Run pre-commit checks on my Python project (lint with Ruff and typecheck with Mypy) before I commit.
Fix and check code
Run all pre-commit checks and auto-fix any lint issues, then stage the changes.
Full pre-commit run
Execute the pre-commit skill: lint with Ruff (auto-fix and format), then typecheck with Mypy, and report pass/fail.

name: precommit description: Run all pre-commit checks (lint + typecheck). Use before every git commit to ensure code quality.

Pre-Commit Checks

Run all required checks before committing.

Commands

# 1. Ruff lint check (auto-fix and format)
git ls-files "*.py" | xargs python -m ruff check --fix
git ls-files "*.py" | xargs python -m ruff format

# 2. Mypy type check
python -m mypy src/ --ignore-missing-imports --disable-error-code=union-attr --disable-error-code=no-redef --disable-error-code=no-any-return --disable-error-code=attr-defined --disable-error-code=assignment --disable-error-code=arg-type --disable-error-code=index --disable-error-code=misc

Instructions

  1. Run lint check with auto-fix
  2. Run format
  3. Run mypy type check
  4. Report results:
    • PASS if both succeed
    • FAIL with details if either fails
  5. Stage any auto-fixed files if requested

Checklist

  • [ ] Ruff lint passes
  • [ ] Ruff format applied
  • [ ] Mypy type check passes

Notes

  • NEVER commit without passing ALL checks
  • CI will reject PRs with lint/type errors
  • Run this skill before every commit
Related skills