pre-commit
БесплатноБез исполняемых скриптовНе проверенWhen setting up automated code quality checks on git commit. When project has .pre-commit-config.yaml. When implementing git hooks for formatting, linting, or…
от BbgnsurfTech★ 30 звёзд на GitHubОб этом скилле
Pre-commit Framework
Configure and implement git hooks using pre-commit or prek for automated code quality checks, formatting, linting, and commit message processing across multi-language projects.
Alternative: prek
prek is a Rust-based reimplementation of pre-commit that offers:
- Faster execution (Rust vs Python)
- No Python dependency required
- Drop-in replacement: Uses same
.pre-commit-config.yamlfile - Identical CLI interface: All commands work the same way
Installation:
# Using uv (recommended)
uv tool install prek
# Using pip
pip install prek
# Using cargo
cargo install prek
Detection: To determine which tool is installed in a repository, read .git/hooks/pre-commit (second line):
- Contains "pre-commit.com" → pre-commit is installed
- Contains "github.com/j178/prek" → prek is installed
Throughout this skill: Commands shown with pre-commit work identically with prek. Simply replace pre-commit with prek in any command.
When to Use This Skill
Use this skill when:
- Setting up git hooks for code quality automation
- Implementing commit message validation or rewriting workflows
- Configuring pre-commit hooks for formatting tools (black, prettier, etc.)
- Creating custom hooks for project-specific quality checks
- Installing hooks for prepare-commit-msg stage (message modification)
- Troubleshooting hook installation or execution issues
- Designing hook definitions for distribution in tool repositories
- Managing hook stages and execution order
Core Concepts
Hook Stages
Pre-commit supports multiple git hook stages matching git hook names directly:
| Stage | Purpose | Common Use Cases |
|---|---|---|
pre-commit |
Before commit creation | Code formatting, linting, tests |
prepare-commit-msg |
Before message editor opens | Commit message rewriting |
commit-msg |
After message written | Message validation only |
pre-push |
Before push to remote | Integration tests, security scans |
pre-merge-commit |
Before merge commit | Merge validation |
post-checkout |
After checkout | Environment setup |
post-commit |
After commit created | Notifications, logging |
post-merge |
After merge completes | Dependency updates |
manual |
Explicit invocation only | On-demand tasks |
Critical Distinction: prepare-commit-msg vs commit-msg
| Feature | prepare-commit-msg | commit-msg |
|---|---|---|
| Can modify message | Yes | No (validation only) |
| When it runs | Before editor opens | After message written |
| Environment variables | PRE_COMMIT_COMMIT_MSG_SOURCE, PRE_COMMIT_COMMIT_OBJECT_NAME |
None |
| Use for | Rewriting, formatting | Validation, rejection |
For commit message rewriting: Use prepare-commit-msg stage.
For commit message validation: Use commit-msg stage with tools like commitlint.
Activate the commitlint skill for commit message validation patterns:
Skill(command: "commitlint")
Activate the conventional-commits skill for commit message format standards:
Skill(command: "conventional-commits")
Installation
Install pre-commit or prek Tool
pre-commit (Python-based):
# Using uv (recommended)
uv tool install pre-commit
# Using pip
pip install pre-commit
# Verify installation
pre-commit --version
prek (Rust-based alternative):
# Using uv (recommended)
uv tool install prek
# Using pip
pip install prek
# Using cargo
cargo install prek
# Verify installation
prek --version
Install Hooks in Repository
# Using pre-commit:
# Install default hook type (pre-commit stage only)
pre-commit install
# Install specific hook type (required for prepare-commit-msg)
pre-commit install --hook-type prepare-commit-msg
# Install multiple hook types
pre-commit install --hook-type pre-commit --hook-type prepare-commit-msg
# Install and setup environments immediately
pre-commit install --install-hooks
# Overwrite existing hooks
pre-commit install --overwrite
# Using prek (same commands, just replace 'pre-commit' with 'prek'):
prek install
prek install --hook-type prepare-commit-msg
# ... etc
Configure Default Hook Types
To install prepare-commit-msg automatically with pre-commit install
Установить pre-commit в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл pre-commit?
When setting up automated code quality checks on git commit. When project has .pre-commit-config.yaml. When implementing git hooks for formatting, linting, or validation. When creating prepare-commit-msg hooks to modify commit messages. When distributing a tool as a pre-commit hook.
Как установить скилл pre-commit?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pre-commit запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic