# pi-commit-lint

> Validate commit messages against Conventional Commits format with configurable rules.

## Installation

```bash
pi install npm:pi-commit-lint
```

## What It Does

pi-commit-lint validates git commit messages against the [Conventional Commits](https://www.conventionalcommits.org/) specification. Unlike `@commitlint/cli` (33M+ downloads), this is a Pi-native extension that integrates directly as a tool and command — no external CLI needed, zero dependencies.

## Tools

### `commit-lint`
Validate a single commit message against Conventional Commits rules. Returns structured errors with fix suggestions.

**Parameters:**
- `message` (string, required) — The commit message to validate

**Example:**
```
Use the commit-lint tool with message="feat(auth): add login endpoint"
```

### `lint-recent-commits`
Audit the last N git commits for Conventional Commits compliance. Returns per-commit pass/fail with details.

**Parameters:**
- `count` (number, optional, default: 10) — Number of recent commits to check

**Example:**
```
Use the lint-recent-commits tool with count=20
```

## Commands

### `/lint-commits [count]`
Check the last N git commits for Conventional Commit compliance. Defaults to 10.

### `/install-hooks`
Install a pre-commit-msg git hook that validates commit messages before they're saved.

## Configuration

Create a `.commitlintrc.json` in your project root:

```json
{
  "types": ["feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", "revert"],
  "maxSubjectLength": 72,
  "maxBodyLength": 100,
  "requireScope": false,
  "allowedScopes": [],
  "requireLowercaseSubject": true,
  "disallowPeriodInSubject": true
}
```

## Rules

| Rule | Default | Description |
|------|---------|-------------|
| `types` | feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert | Allowed commit types |
| `maxSubjectLength` | 72 | Max characters in subject line |
| `maxBodyLength` | 100 | Max characters per body line |
| `requireScope` | false | Whether scope is mandatory |
| `allowedScopes` | [] | Allowed scopes (empty = any) |
| `requireLowercaseSubject` | true | Subject must start lowercase |
| `disallowPeriodInSubject` | true | Subject must not end with period |

## Resources

- [npm](https://www.npmjs.com/package/pi-commit-lint)
- [GitHub](https://github.com/ZachDreamZ/pi-commit-lint)
- [pi.dev](https://pi.dev/packages/pi-commit-lint)

## License

MIT
