I built rewind — a CLI that reads your git repo and tells you in plain english where you left off. But the interesting part isn't what it does, it's how it actually works under the hood.
The core problem with context
The naive approach would be to just dump your entire git history into an LLM and ask it to summarize. That works but it's wasteful and noisy. A repo with 500 commits would burn through tokens on irrelevant history.
So rewind only collects what's actually relevant right now:
Current branch name
Last 10 commits with messages and timestamps
Full staged diff
Full unstaged diff
List of untracked files
That's it. Everything else is noise.
Structuring the prompt
The context gets assembled into a structured prompt that tells the LLM exactly what role it's playing and what output format is expected. The key insight here is that you don't want a summary — you want a briefing. Those are different things. A summary recaps what happened. A briefing tells you what matters right now and what's unfinished.
Handling token limits
Bigger repos with lots of changes can generate massive diffs. rewind handles this with a .rewindignore file — same syntax as .gitignore — so you can exclude lockfiles, generated assets, compiled output. Keeps the context clean and the LLM output focused.
There's also a rewind estimate command that shows you token count before making any API call.
Multi-provider support
Rather than locking into one LLM provider, rewind supports Groq, Gemini, OpenAI, and Ollama. The priority order is Groq → Gemini → OpenAI to keep costs low by default. Ollama support means you can run it fully local with zero data leaving your machine.
The rewind commit subcommand
Once I had the git context pipeline working, adding commit message generation was straightforward — same context, different prompt, output formatted as a conventional commit message.
What I learned
The hardest part wasn't the LLM integration. It was figuring out exactly which git data to collect and how to structure it so the output is consistently useful and not just a generic summary. Prompt structure matters way more than model choice for this kind of focused task.
cargo install git-rewind
Top comments (0)