Overview
gitcap is a command-line tool that writes Conventional Commit messages from your staged diff. Instead of asking for yet another API key, it hands the diff to the coding agent you are already logged in to (Claude Code, Codex, Gemini CLI, Grok CLI and several others), and falls back to a local model or Groq's free API when none is available.
I built and released it as a Python package on PyPI, with a review loop in the terminal (commit, edit, regenerate, quit), automatic fallback between agents, a self-updating command and a small project website on GitHub Pages.
The challenge
AI commit message tools usually want their own API key and billing, even though most developers already pay for a coding agent. Those agents also hit limits: a plan expires, credits run out, or a rate limit kicks in halfway through a working day.
Large diffs add a second problem. Every backend has a different context limit, and a prompt that is too big either fails or silently loses the instructions at the start.
The goal
Make a commit message tool that needs no new accounts and keeps working when one provider does not.
- 01Detect the coding agents already installed and logged in, without reading their tokens.
- 02Fall back to the next agent, a local model or Groq when one fails, and pause agents that keep failing.
- 03Trim large diffs to fit each backend and retry smaller when a prompt is rejected.
- 04Keep the human in charge with a short review step before anything is committed.
The commit flow
Running gitcap commit reads the staged diff, adds recent commit subjects so the message matches the repo's style, and shows the generated message in a panel. A single keypress commits it, edits it, regenerates it or quits. Flags cover dry runs, skipping review, extra context and choosing one agent or model for a single run.
Every message shows which agent and model wrote it, how long it took, and the token counts and cost the agent reported.
Agent detection and fallback
gitcap looks at what is already on the machine: agent programs on the PATH, their login files and how recently their session logs changed. It tries a default agent first, then the others by most recent use, then a local model server, then Groq.
- 01An account failure (expired plan, no credits, logged out) pauses that agent for 6 hours.
- 02A rate limit pauses it for 15 minutes, and two other failures in a row pause it for 30 minutes.
- 03gitcap agents lists every agent, the order they are tried in and why any are paused.
Fitting big diffs into small windows
The diff is read once and trimmed per backend: about 100k characters for agents that read stdin, 60k for agents that take the prompt as an argument, 16k for Groq's free tier, and a size derived from the real context window for local models. Trimming keeps the stat summary and every file header and shares the remaining space between files, smallest first.
If a backend still says the prompt is too large, gitcap shrinks it and retries, using the exact limit from the error where one is given.
Shipping it
The package has two small dependencies and no AI SDKs. Releases are automated with release-please, CI runs lint, tests on Linux and macOS across Python 3.11 to 3.13 and a clean-environment install check. The tests use fake agent CLIs, a fake HTTP server for Groq, Ollama, LM Studio and PyPI, and a temporary HOME, so real credentials are never touched. gitcap upgrade and gitcap uninstall handle updates and clean removal.
The outcome
gitcap is published on PyPI, documented with a changelog and a project website, and covered by a test suite that runs without network access or real agents. It shows a CLI taken from idea to a released, self-updating package, with careful handling of provider failures and context limits.


