Documentation

Everything you need to know about using CommitPolice.

1. Installation

CommitPolice requires Node.js 18 or higher. Install it globally using npm:

npm install -g commitpolice

Or using yarn:

yarn global add commitpolice

Verify the installation:

commitpolice --version

2. Quick Start

Using CommitPolice is as simple as three steps:

01

Stage your changes

git add .
02

Run CommitPolice

git commitp
03

Review and confirm

Press Y to commit or n to cancel.

3. Commands & Options

CommitPolice can be invoked as git commitp or commitpolice.

OptionDescription
-y, --yesSkip confirmation prompt and commit automatically
-d, --dry-runGenerate message without creating a commit
--api-url <url>Use a custom API endpoint
-V, --versionShow version number
-h, --helpShow help information

4. Examples

Basic usage

git add .
git commitp

Auto-confirm (skip prompt)

git commitp -y

Preview without committing

git commitp --dry-run

Full workflow example

$ git add src/auth.js
$ git commitp

  Analyzing 45 lines of changes...

  Generated commit message:
  feat(auth): add password reset functionality

  Commit with this message? (Y/n) Y

  Committed successfully!

  Commit: a1b2c3d
  Branch: main
  Stats:  1 file(s), +42, -3

5. Conventional Commits

CommitPolice generates messages following the Conventional Commits specification. This provides a standardized format that makes commit history more readable.

Format

type(scope): description

Common Types

TypeDescription
featA new feature
fixA bug fix
docsDocumentation changes
styleCode style changes (formatting, semicolons, etc.)
refactorCode refactoring without feature changes
perfPerformance improvements
testAdding or updating tests
choreMaintenance tasks, dependency updates
ciCI/CD configuration changes
buildBuild system changes

6. Troubleshooting

"No staged changes found"

You need to stage files before running CommitPolice.

git add <files>   # Stage specific files git add .         # Stage all changes

"Not a git repository"

Make sure you're in a directory with an initialized git repository.

git init   # Initialize a new repo

"Could not connect to API"

Check your internet connection. If the issue persists, the service might be temporarily unavailable. You can check status at our GitHub issues page.

7. FAQ

Is it really free?

Yes! CommitPolice is 100% free. We cover the AI costs so you don't have to bring your own API key. If you find it useful, consider buying us a coffee!

Is my code sent to a server?

Only your git diff (the changes you've staged) is sent to our API for analysis. Your full codebase is never uploaded. The diff is processed and immediately discarded.

What AI model is used?

CommitPolice uses Claude 3 Haiku by Anthropic - a fast, efficient model optimized for quick responses.

Can I use this in CI/CD?

Yes! Use the -y flag to skip confirmation prompts in automated environments.

What if I don't like the generated message?

Just press n when prompted to cancel, then write your own commit message manually.

Need Help?

Found a bug or have a feature request? Open an issue on GitHub.