| name | manage-precommit |
| description | Initializes and manages pre-commit hooks for monorepos. Use when setting up pre-commit hooks, adding linting/formatting to git workflow, or managing .pre-commit-config.yaml. |
| tags | ["repo-workflow"] |
| argument-hint | ["init|update|add-project|status"] |
| supplementary-files | ["hook-templates.md"] |
Pre-commit Management
Initialize, update, and manage pre-commit hooks for this multi-project monorepo.
Arguments
$ARGUMENTS - Command to run:
init - Initialize pre-commit (install hooks if missing, generate config)
update - Update config based on current project structure
add-project <name> - Add hooks for a specific project
status - Show current pre-commit status and project detection
- (empty) - Default to
init
Instructions
Step 1: Check Pre-commit Installation
which pre-commit || echo "NOT_INSTALLED"
ls -la .pre-commit-config.yaml 2>/dev/null || echo "NO_CONFIG"
ls -la .git/hooks/pre-commit 2>/dev/null || echo "NO_HOOKS"
If pre-commit is not installed, inform the user:
Pre-commit is not installed. Install with:
brew install pre-commit # macOS
pip install pre-commit # or via pip
uv tool install pre-commit # or via uv
Step 2: Detect Projects in Monorepo
Scan the repository root for projects by looking for:
| Indicator | Project Type |
|---|
pyproject.toml | Python (uv) |
pyproject.toml + app/ folder | Python FastAPI |
package.json + next.config.* | Next.js |
package.json + vite.config.* | Vite |
Package.swift | Swift |
build.gradle* or settings.gradle* | Android/Kotlin |
Dockerfile* | Docker |
*.yaml in k8s/ or kubernetes/ | Kubernetes |
mix.exs | Elixir/Phoenix |
Cargo.toml | Rust |
go.mod | Go |
Build a list of detected projects with their paths and types.
Step 3: Generate Pre-commit Configuration
Create .pre-commit-config.yaml with sections based on detected projects. Use this structure:
default_install_hook_types:
- pre-commit
- pre-push
- commit-msg
default_language_version:
python: python3.12
repos:
[Include general hooks section]
Configuration Templates
For detailed YAML hook templates (General, Python, Frontend, Markdown, Codespell, YAML, Shell, Commit Message, Pre-push), see hook-templates.md in this skill folder.
Step 4: Install Hooks
After generating the config:
pre-commit install --install-hooks
pre-commit install --hook-type commit-msg
pre-commit install --hook-type pre-push
Step 5: Validate Configuration
pre-commit run --all-files --show-diff-on-failure
If validation fails, show the errors and offer to fix common issues.
Commands
init (default)
- Check if pre-commit is installed
- Detect all projects in the monorepo
- Generate
.pre-commit-config.yaml based on detected projects
- Install hooks
- Run validation
update
- Re-detect projects (may have added/removed projects)
- Update
.pre-commit-config.yaml preserving any custom modifications (look for # CUSTOM: comments)
- Reinstall hooks
add-project <name>
- Detect the type of project at
<name>/
- Add hooks for that specific project to the config
- Reinstall hooks
status
- Show pre-commit installation status
- List detected projects and their types
- Show which hooks are currently configured
Output
After completing any command, provide a summary:
Pre-commit Configuration Summary
================================
Status: [Initialized/Updated/Error]
Config: .pre-commit-config.yaml
Detected Projects:
- project-a (Python/uv)
- project-b/backend (Python FastAPI)
- project-b/frontend (Next.js)
Hooks Installed:
- pre-commit
- commit-msg
- pre-push
Run 'pre-commit run --all-files' to validate all files.
Notes
- The configuration prioritizes per-project isolation - each project has its own hook entries
- Python projects use
uv run to execute tools in the project's virtual environment
- Frontend projects assume npm scripts are available
- If a project has both
backend/ and frontend/ subdirectories, it's treated as full-stack
- Custom hooks can be preserved by adding
# CUSTOM: comment before them