|
1 | 1 | # Getting Started |
2 | 2 |
|
3 | | -Welcome to commit-check! This guide will help you integrate commit-check into your workflow quickly and efficiently. |
| 3 | +Welcome to commit-check! This guide walks you from zero to enforcing commit |
| 4 | +standards in your project — no prior configuration needed. |
4 | 5 |
|
5 | 6 | <!-- markdownlint-disable MD033 --> |
6 | 7 |
|
7 | | -Select the method that best fits your development workflow: |
| 8 | +--- |
8 | 9 |
|
9 | | -<div class="grid cards" markdown> |
| 10 | +## 1. Install |
10 | 11 |
|
11 | | -- :material-github: **GitHub Actions** |
| 12 | +Choose the installation method that fits your stack: |
12 | 13 |
|
13 | | - --- |
| 14 | +=== "pip (recommended)" |
14 | 15 |
|
15 | | - GitHub Action for automated commit-check in your workflows |
| 16 | + ```bash |
| 17 | + pip install commit-check |
| 18 | + ``` |
16 | 19 |
|
17 | | - **Perfect for:** CI/CD pipelines, automated PRs, team collaboration |
| 20 | + Requires Python 3.10+. Works on Linux, macOS, and Windows. |
18 | 21 |
|
19 | | - [Get started with GitHub Actions →](https://github.com/commit-check/commit-check-action){ .md-button .md-button--primary } |
| 22 | + Verify the installation: |
20 | 23 |
|
21 | | -- :material-git: **Pre-commit Hooks** |
| 24 | + ```bash |
| 25 | + commit-check --version |
| 26 | + # or its shorter alias |
| 27 | + cchk --version |
| 28 | + ``` |
22 | 29 |
|
23 | | - --- |
| 30 | +=== "Homebrew (macOS)" |
24 | 31 |
|
25 | | - Pre-commit hooks for automated commit-check in your local development |
| 32 | + ```bash |
| 33 | + brew install commit-check |
| 34 | + ``` |
26 | 35 |
|
27 | | - **Perfect for:** Local development, enforcing commit standards before commits |
| 36 | +=== "pre-commit" |
28 | 37 |
|
29 | | - [Get started with pre-commit →](https://commit-check.github.io/commit-check/example.html#running-as-pre-commit-hook){ .md-button .md-button--primary } |
| 38 | + No direct install needed — add to your `.pre-commit-config.yaml`: |
30 | 39 |
|
31 | | -- :fontawesome-brands-python: **Command Line Interface (CLI)** |
| 40 | + ```yaml |
| 41 | + repos: |
| 42 | + - repo: https://github.com/commit-check/commit-check |
| 43 | + rev: v2.11.1 |
| 44 | + hooks: |
| 45 | + - id: check-message |
| 46 | + - id: check-branch |
| 47 | + ``` |
32 | 48 |
|
33 | | - --- |
| 49 | + pre-commit will install commit-check automatically when you run |
| 50 | + `pre-commit install --hook-type commit-msg`. |
34 | 51 |
|
35 | | - The core Python package powering commit-check-action behind the scenes |
| 52 | +=== "MCP Server (AI agents)" |
36 | 53 |
|
37 | | - **Perfect for:** Custom scripts, advanced workflows, and integration across different environments |
| 54 | + AI coding agents (Claude Code, Cursor, Copilot) can use commit-check |
| 55 | + without a direct Python install, via the MCP server: |
38 | 56 |
|
39 | | - [Get started with CLI →](https://commit-check.github.io/commit-check/){ .md-button .md-button--primary } |
| 57 | + ```bash |
| 58 | + # Run with uvx — no install needed |
| 59 | + uvx commit-check-mcp |
| 60 | + ``` |
40 | 61 |
|
41 | | -- :material-robot: **MCP Server** |
| 62 | + See the [MCP Server docs](https://github.com/commit-check/commit-check-mcp) |
| 63 | + for client-specific configuration instructions. |
42 | 64 |
|
43 | | - --- |
| 65 | +--- |
44 | 66 |
|
45 | | - MCP server exposing commit-check validations as structured tools for AI coding agents |
| 67 | +## 2. Run Your First Check |
46 | 68 |
|
47 | | - **Perfect for:** Claude Code, Cursor, Copilot & any MCP-compatible AI agent |
| 69 | +Commit-check works **out of the box with zero configuration**. The default |
| 70 | +rules enforce: |
48 | 71 |
|
49 | | - [Get started with MCP →](https://github.com/commit-check/commit-check-mcp){ .md-button .md-button--primary } |
| 72 | +- [Conventional Commits](https://www.conventionalcommits.org/) for commit messages |
| 73 | +- [Conventional Branch](https://conventionalbranch.org/) for branch names |
50 | 74 |
|
51 | | -</div> |
| 75 | +### Validate a commit message |
| 76 | + |
| 77 | +```bash |
| 78 | +# Pass a message via stdin |
| 79 | +echo "feat: add user authentication" | commit-check --message |
| 80 | +# Exit code: 0 (pass) |
| 81 | + |
| 82 | +echo "bad commit message" | commit-check --message |
| 83 | +# Exit code: 1 (fail) — shows error details and suggestion |
| 84 | +``` |
| 85 | + |
| 86 | +### Validate from a file |
| 87 | + |
| 88 | +```bash |
| 89 | +# Pre-commit hooks pass the commit message file automatically |
| 90 | +commit-check --message .git/COMMIT_EDITMSG |
| 91 | +``` |
| 92 | + |
| 93 | +### Validate the current branch |
| 94 | + |
| 95 | +```bash |
| 96 | +commit-check --branch |
| 97 | +``` |
| 98 | + |
| 99 | +### Validate everything at once |
| 100 | + |
| 101 | +```bash |
| 102 | +commit-check --message --branch --author-name --author-email |
| 103 | +``` |
| 104 | + |
| 105 | +### Quiet output for CI |
| 106 | + |
| 107 | +```bash |
| 108 | +# Compact mode: one [FAIL] line per failure, no ASCII art |
| 109 | +echo "bad message" | commit-check --message --compact |
| 110 | +# Output: [FAIL] message: bad message |
| 111 | + |
| 112 | +# Machine-readable JSON (great for automation and AI agents) |
| 113 | +echo "feat: add feature" | commit-check --message --format json |
| 114 | +``` |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +## 3. Add a Configuration File |
| 119 | + |
| 120 | +To customize the rules for your project, create a `cchk.toml` in your |
| 121 | +repository root: |
| 122 | + |
| 123 | +```toml |
| 124 | +[commit] |
| 125 | +# Require imperative mood in subject lines |
| 126 | +subject_imperative = true |
| 127 | + |
| 128 | +# Enforce a 72-character subject limit |
| 129 | +subject_max_length = 72 |
| 130 | + |
| 131 | +# Restrict allowed commit types |
| 132 | +allow_commit_types = ["feat", "fix", "docs", "refactor", "test", "chore"] |
| 133 | + |
| 134 | +# Bypass checks for bot authors |
| 135 | +ignore_authors = ["dependabot[bot]", "renovate[bot]"] |
| 136 | + |
| 137 | +# AI attribution policy: "ignore" (default) or "forbid" |
| 138 | +# "forbid" rejects commits co-authored by known AI coding agents |
| 139 | +ai_attribution = "forbid" |
| 140 | + |
| 141 | +[branch] |
| 142 | +# Require rebase onto main |
| 143 | +require_rebase_target = "main" |
| 144 | +``` |
| 145 | + |
| 146 | +Run checks again — commit-check automatically discovers the config file: |
| 147 | + |
| 148 | +```bash |
| 149 | +commit-check --message --branch |
| 150 | +``` |
| 151 | + |
| 152 | +> **Tip:** commit-check's TOML schema is published on |
| 153 | +> [SchemaStore](https://www.schemastore.org/), so editors like VS Code |
| 154 | +> (via the Even Better TOML extension) provide autocompletion and validation |
| 155 | +> for `cchk.toml` out of the box. |
| 156 | +
|
| 157 | +### Configuration priority |
| 158 | + |
| 159 | +``` |
| 160 | +CLI arguments (highest priority) |
| 161 | + ↑ |
| 162 | +Environment variables (CCHK_*) |
| 163 | + ↑ |
| 164 | +cchk.toml / commit-check.toml |
| 165 | + ↑ |
| 166 | +Built-in defaults (lowest priority) |
| 167 | +``` |
| 168 | + |
| 169 | +See the [configuration reference](https://commit-check.github.io/commit-check/configuration.html) |
| 170 | +for a complete list of all options. |
| 171 | + |
| 172 | +### Organization-wide config |
| 173 | + |
| 174 | +Share a base policy across all repos in your organization: |
| 175 | + |
| 176 | +```toml |
| 177 | +# .github/cchk.toml |
| 178 | +inherit_from = "github:my-org/.github:cchk.toml" |
| 179 | + |
| 180 | +[commit] |
| 181 | +subject_max_length = 72 # Override inherited value |
| 182 | +``` |
| 183 | + |
| 184 | +--- |
| 185 | + |
| 186 | +## 4. Set Up Pre-commit Hooks |
| 187 | + |
| 188 | +Commit-check provides five pre-commit hooks: |
| 189 | + |
| 190 | +| Hook ID | Stage | What it checks | |
| 191 | +|---------|-------|---------------| |
| 192 | +| `check-message` | `commit-msg` | Commit message follows Conventional Commits | |
| 193 | +| `check-branch` | `pre-commit` | Branch name follows Conventional Branch | |
| 194 | +| `check-author-name` | `pre-commit` | Author name format | |
| 195 | +| `check-author-email` | `pre-commit` | Author email format | |
| 196 | +| `check-no-force-push` | `pre-push` | Prevents force pushes | |
| 197 | + |
| 198 | +Add them to your `.pre-commit-config.yaml`: |
| 199 | + |
| 200 | +```yaml |
| 201 | +repos: |
| 202 | + - repo: https://github.com/commit-check/commit-check |
| 203 | + rev: v2.11.1 |
| 204 | + hooks: |
| 205 | + - id: check-message |
| 206 | + - id: check-branch |
| 207 | + - id: check-author-name |
| 208 | + - id: check-author-email |
| 209 | + |
| 210 | + # Force push protection runs on pre-push (not pre-commit) |
| 211 | + - repo: https://github.com/commit-check/commit-check |
| 212 | + rev: v2.11.1 |
| 213 | + hooks: |
| 214 | + - id: check-no-force-push |
| 215 | + stages: [pre-push] |
| 216 | +``` |
| 217 | +
|
| 218 | +Install the hooks: |
| 219 | +
|
| 220 | +```bash |
| 221 | +pre-commit install --hook-type commit-msg --hook-type pre-commit --hook-type pre-push |
| 222 | +``` |
| 223 | + |
| 224 | +Now every commit, branch creation, and push is validated automatically. |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +## 5. Set Up CI/CD |
| 229 | + |
| 230 | +### GitHub Actions |
| 231 | + |
| 232 | +Add the [commit-check-action](https://github.com/commit-check/commit-check-action) |
| 233 | +to your workflow: |
| 234 | + |
| 235 | +```yaml |
| 236 | +name: Commit Check |
| 237 | +on: [push, pull_request] |
| 238 | +jobs: |
| 239 | + commit-check: |
| 240 | + runs-on: ubuntu-latest |
| 241 | + permissions: |
| 242 | + contents: read |
| 243 | + pull-requests: write # Required for PR comments |
| 244 | + steps: |
| 245 | + - uses: actions/checkout@v5 |
| 246 | + with: |
| 247 | + fetch-depth: 0 # Required for merge-base checks |
| 248 | + - uses: commit-check/commit-check-action@v2 |
| 249 | + with: |
| 250 | + message: true |
| 251 | + branch: true |
| 252 | + author-name: true |
| 253 | + author-email: true |
| 254 | + job-summary: true |
| 255 | + pr-comments: ${{ github.event_name == 'pull_request' }} |
| 256 | +``` |
| 257 | +
|
| 258 | +### GitLab CI |
| 259 | +
|
| 260 | +```yaml |
| 261 | +include: |
| 262 | + - remote: https://raw.githubusercontent.com/commit-check/commit-check/main/examples/gitlab-ci.yml |
| 263 | +``` |
| 264 | +
|
| 265 | +### Other CI platforms |
| 266 | +
|
| 267 | +commit-check is a standard Python CLI tool — it works anywhere Python runs. |
| 268 | +Set environment variables (`CCHK_*`) or check in a config file, then run |
| 269 | +`commit-check --message --branch` in your pipeline step. |
| 270 | + |
| 271 | +--- |
| 272 | + |
| 273 | +## 6. Set Up for AI Coding Agents (MCP) |
| 274 | + |
| 275 | +If your team uses AI coding agents (Claude Code, Cursor, Copilot, etc.), |
| 276 | +commit-check helps enforce commit standards even on AI-generated commits. |
| 277 | + |
| 278 | +### Claude Desktop |
| 279 | + |
| 280 | +```json |
| 281 | +{ |
| 282 | + "mcpServers": { |
| 283 | + "commit-check": { |
| 284 | + "command": "uvx", |
| 285 | + "args": ["commit-check-mcp"] |
| 286 | + } |
| 287 | + } |
| 288 | +} |
| 289 | +``` |
| 290 | + |
| 291 | +### Claude Code CLI |
| 292 | + |
| 293 | +Add to your project's `.claude/settings.local.json`: |
| 294 | + |
| 295 | +```json |
| 296 | +{ |
| 297 | + "mcpServers": { |
| 298 | + "commit-check": { |
| 299 | + "command": "uvx", |
| 300 | + "args": ["commit-check-mcp"] |
| 301 | + } |
| 302 | + } |
| 303 | +} |
| 304 | +``` |
| 305 | + |
| 306 | +### AI Attribution Policy |
| 307 | + |
| 308 | +Use the `ai_attribution` config option to control AI-assisted commits: |
| 309 | + |
| 310 | +```toml |
| 311 | +[commit] |
| 312 | +# "ignore" (default) — AI co-authored commits are allowed |
| 313 | +# "forbid" — rejects commits with known AI tool signatures |
| 314 | +ai_attribution = "forbid" |
| 315 | +``` |
| 316 | + |
| 317 | +When set to `forbid`, commit-check detects signatures from 10+ AI coding |
| 318 | +tools (Claude Code, GitHub Copilot, Cursor, Codex, and more) and rejects |
| 319 | +commits that carry them. |
| 320 | + |
| 321 | +See the [MCP Server README](https://github.com/commit-check/commit-check-mcp) |
| 322 | +for all supported clients and configuration options. |
| 323 | + |
| 324 | +--- |
| 325 | + |
| 326 | +## Next Steps |
| 327 | + |
| 328 | +| Topic | Where to go | |
| 329 | +|-------|-------------| |
| 330 | +| Complete configuration reference | [Configuration docs](https://commit-check.github.io/commit-check/configuration.html) | |
| 331 | +| In-depth examples | [Examples page](https://commit-check.github.io/commit-check/example.html) | |
| 332 | +| Python API (for automation) | [API reference](commit_check.api) in the Python package | |
| 333 | +| Migrate from v1 (YAML) to v2 (TOML) | [Migration guide](https://commit-check.github.io/commit-check/migration.html) | |
| 334 | +| GitHub Action details | [commit-check-action](https://github.com/commit-check/commit-check-action) | |
| 335 | +| AI agent integration | [commit-check-mcp](https://github.com/commit-check/commit-check-mcp) | |
| 336 | +| Report a bug or request a feature | [GitHub Issues](https://github.com/commit-check/commit-check/issues) | |
0 commit comments