Automatically records every AI prompt you send and appends them to your git commit messages — so your commit history always reflects the AI assistance that shaped the code.
- Claude Code saves every prompt to
.prompts/as a timestamped file, named after the model that answered it (via aUserPromptSubmithook in.claude/settings.json, which runs.claude/hooks/record-prompt.py). Only prompts you actually wrote are recorded — the turns Claude Code injects on its own, such as background-task notifications, are skipped. Other models can also be instructed to record prompts. - On
git commit, theprepare-commit-msghook reads all pending prompts and appends them to the commit message under anAI Prompts:section. - After the commit, the
post-commithook moves the used prompts to.prompts/committed/, tagged with the commit hash, so they are archived but not reused.
Fix login redirect bug
AI Prompts:
claude-sonnet-4-6: why does the redirect fail after OAuth callback?
claude-sonnet-4-6: rewrite the session middleware to preserve the return URL
- git
- pre-commit (
pip install pre-commit) - Python 3.10+
Add the following to your repository's .pre-commit-config.yaml (create it if it doesn't exist):
default_install_hook_types: [pre-commit, prepare-commit-msg, post-commit]
repos:
- repo: https://github.com/pycalendar/ai-prompt-auto-commit
rev: v0.0.10
hooks:
- id: prepare-ai-repository
- id: unstage-ai-prompts
- id: append-ai-prompts
- id: archive-ai-promptsThis needs to be run for every clone:
pre-commit installThis installs all three git hooks (pre-commit, prepare-commit-msg, post-commit) in one step.
This needs to be run once for each repository:
pre-commit run --hook-stage manual prepare-ai-repositoryThis runs the one-time setup (using the manual stage) and will:
- Create a
.prompts/directory with a.gitignorethat prevents prompt files from being committed - Install the prompt-recording script as
.claude/hooks/record-prompt.py - Install the Claude Code
UserPromptSubmithook into.claude/settings.jsonso prompts are recorded automatically (merges safely with existing settings)
To update the hooks:
pre-commit autoupdate
git add .pre-commit-config.yaml
pre-commit run --hook-stage manual prepare-ai-repositorypre-commit refuses to run while .pre-commit-config.yaml has unstaged
changes, hence the git add between the two.
.github/assistant-guidelines.md tells AI models how to record each of your prompts.
We welcome your contribution!
This pre-commit supports the following AI models:
| Model | ID in commit message |
|---|---|
| Any Claude model | recorded automatically, e.g. claude-opus-5 or claude-sonnet-4-6 |
| GitHub Copilot | manual prompt recording |
Claude model IDs are taken verbatim from the session transcript, so new models need no change here.
The recording is done automatically through the hooks. The model name is read
from the session transcript, which records a model only once it has answered.
The name is therefore the model that answered the previous turn: after a
/model switch, the first prompt you send is still attributed to the model
you switched away from, and only the ones after that are right. A prompt sent
before the assistant has answered even once — the first prompt of a session —
is recorded as unknown, because at that point nothing has stated which model
is answering.
If no files are created in .prompts:
- Restart the editor or session.
- Or open /hooks in Claude Code (the UI menu) to reload config.
After that, the hook will fire on every prompt.
Prompt the AI:
Save all prompts according to the assistant guidelines
You can record prompts manually or instruct the AI to use the script.
record-ai-prompt --prompt "<your prompt>" --model "<model used>"Or pipe text into it:
printf "%s" "<your prompt>" | record-ai-prompt.claude/
settings.json ← calls the hook below on each prompt
hooks/
record-prompt.py ← installed by prepare-ai-repository
.prompts/
2026-04-12T20-35-51_claude-sonnet-4-6.txt ← pending (not yet committed)
committed/
2026-04-12T20-10-00_claude-sonnet-4-6_a2e1ca7....txt ← archived after commit
.claude/hooks/record-prompt.py is rewritten every time prepare-ai-repository
runs, so edit the copy in this project rather than the one in your repository.
You can view the versions in the change log.
To release a new version:
./release 0.0.5- cairn - Tool-free convention that keeps, beside your code, a living spec of what the system does now plus a dated log of how it got there, readable by any agent, human or AI.