# Pre-commit hooks for fastmcp-template
# Install with: uv run pre-commit install
# Run manually: uv run pre-commit run --all-files
repos:
# Ruff - Fast Python linter and formatter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
# Basic file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-added-large-files
args: [--maxkb=1000]
- id: check-merge-conflict
- id: detect-private-key
- id: no-commit-to-branch
args: [--branch, main]
# Security checks
- repo: https://github.com/PyCQA/bandit
rev: 1.7.8
hooks:
- id: bandit
args: [-c, pyproject.toml]
additional_dependencies: ["bandit[toml]"]
files: ^app/
# Dependency vulnerability scanning (pip-audit works with UV projects)
- repo: https://github.com/pypa/pip-audit
rev: v2.10.0
hooks:
- id: pip-audit
# --local: scan installed packages in .venv
# --skip-editable: skip local package (not on PyPI)
args: [--local, --skip-editable]
pass_filenames: false
# CI configuration
ci:
autofix_commit_msg: "style: auto-fix by pre-commit hooks"
autofix_prs: true
autoupdate_commit_msg: "chore: update pre-commit hooks"
autoupdate_schedule: weekly