Skip to main content

Write a clean conventional-commit message from your staged diff — an AI git commit helper you run as a hook or CLI.

Project description

stagepen

Writes a clean conventional-commit message from your staged diff. Run it as a CLI or wire it into a git hook so you never stare at a blank commit prompt again.

CI Python 3.9+ License: MIT

I write a lot of commits, and I noticed I either dashed off a lazy "fix stuff" message or wasted a minute crafting the perfect conventional-commit line. Pasting every diff into a chat window each time isn't it either. So I built stagepen: it reads what you've staged and proposes a proper message, right there in the terminal.

$ git add .
$ stagepen

✍  Proposed commit message:

  feat(auth): add refresh-token rotation

  - rotate the refresh token on every use
  - revoke the prior token family when reuse is detected

The point isn't "ask an AI to write a commit." It's that this lives in your flow — one command, or a hook that fires on every commit — so you don't context-switch at all.

Why it's a tool and not just ChatGPT

Because you'd never paste every diff into a chat window. The value is that it runs where you already are:

  • one command in the repo, no copy-paste
  • can auto-create the commit (-c)
  • works offline with --provider mock or a local model, so nothing has to leave your machine
  • reads only your staged diff, and redacts secrets before sending anything

Install

git clone https://github.com/jay-tank/stagepen.git
cd stagepen
pip install .
# for the Claude / OpenAI providers:
pip install '.[claude]'   # or '.[openai]'

Using it

# stage something, then:
stagepen                     # prints the proposed message
stagepen -c                  # prints it, asks, then commits
stagepen -c -y               # commit without the confirmation prompt
stagepen --provider mock     # offline demo, no key
stagepen --provider ollama   # local model, no key

If you like it, drop it in a git hook so it runs on its own — see docs/USAGE.md.

Providers

Defaults to Claude, but it's provider-agnostic: claude, openai, ollama (local, no key), or mock (offline). Details in docs/PROVIDERS.md.

A note on your secrets

Diffs sometimes contain a stray key or password. stagepen redacts common secret patterns before the diff is ever sent to a model, and it only ever reads your staged changes.

Limitations

  • It writes the message from the diff, so a huge diff gets truncated to keep the prompt sane. For sprawling commits the message is a strong starting point, not gospel.
  • Quality tracks the diff quality: tiny, focused commits get the best messages (which is how you should be committing anyway).

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stagepen-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stagepen-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file stagepen-0.1.0.tar.gz.

File metadata

  • Download URL: stagepen-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for stagepen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ed91d108d2a36e6eb1c9f0c983b8fe237fcecf84a62af4d3957762f1bd1c4bb7
MD5 d1b006387c0ec59ddf83a8c64a5659bf
BLAKE2b-256 ca1b835cac8428d25a20ece91df03e72c9e6b1ad4912730fd98d7a238d45f7fa

See more details on using hashes here.

File details

Details for the file stagepen-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: stagepen-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for stagepen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bb4e8a76c27eb8b1b27246c885e0c3b123905a59ca3daf61c06e22ba02142ca
MD5 77aadfa03294e01c72791420acd27cc1
BLAKE2b-256 0efb79c6424eb413d7447ea2f82333d6a24c0103bd8cdada99f4a6baa719ebeb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page