Every AI-assisted commit has a backstory. Never lose it again.
Project description
Backstory
Git shows what changed. Backstory shows why.
Ever opened an AI-generated commit and wondered:
- Why was this approach chosen?
- What did the agent try before this?
- What assumptions are hidden in this code?
What is Backstory?
Backstory is a local-first AI memory layer for Git repositories. It captures session context from AI coding tools, extracts the durable reasoning (decisions, risks, alternatives), stores it as Google's OKF markdown, and links it to Git commits so you can retrieve the why later.
Why not just write good commit messages? Commit messages describe what changed. They rarely capture the rejected alternatives, the risks you accepted, or the reasoning trail across a multi-step AI session. Backstory fills that gap.
Quick Install
pip install backstory-cli
Then initialize in your repo:
backstory init
backstory status
See a full worked example with before/after code and stored session.
Features
- Commit-level reasoning --
backstory why HEADshows why a commit was made, not just what changed - Code-aware retrieval -- Query by file (
backstory file <path>), line (backstory line <path>:<line>), or range (backstory range <path>:start-end) - Contradiction detection -- Warns when new changes reverse earlier recorded decisions
- Local-first -- Everything stays in your repo. No cloud, no telemetry.
- Human-readable storage -- Google's OKF markdown that agents, tools, and humans can read
- Privacy by default -- Extracts decisions and risks, not raw chat logs. Built-in redaction for API keys and secrets.
How It Works
- Capture -- A tool-native hook or exporter hands the AI session to Backstory.
- Ingest -- Backstory extracts the durable decisions, risks, and changed files. The raw conversation is discarded.
- Link -- The session is attached to the relevant Git commit via
backstory attach HEAD. - Retrieve -- Query reasoning by commit, file, line, range, or diff.
Git stays the linkage layer. Backstory stores the reasoning.
Commands
| Command | Status | What it does |
|---|---|---|
backstory init |
✅ Stable | Set up Backstory in the current repo |
backstory dump |
✅ Stable | Ingest an AI session into OKF markdown |
backstory attach HEAD |
✅ Stable | Link a session to a commit |
backstory why HEAD |
✅ Stable | Explain why a commit happened |
backstory status |
✅ Stable | Show Backstory state in this repo |
backstory search <query> |
✅ Stable | Search past sessions and decisions |
backstory show <session> |
🧪 Experimental | View a stored session |
backstory file <path> |
🧪 Experimental | Show AI context relevant to a file |
backstory line <path>:<line> |
🧪 Experimental | Show the decision behind a specific line |
backstory range <path>:start-end |
🧪 Experimental | Show context for a range of lines |
backstory code <path>:start-end |
🧪 Experimental | Show why a code block exists |
backstory diff |
🧪 Experimental | Explain the reasoning behind the current diff |
backstory redact |
✅ Stable | Re-scan and redact sensitive data |
backstory hooks |
✅ Stable | Manage Git hook installation |
Integration
Works with Claude Code today. Cursor and Codex support planned.
Backstory is designed for tool-native capture. The preferred path is a tool-specific hook, callback, or transcript exporter that hands the session to Backstory automatically.
See the integration guide for step-by-step setup.
Contradiction Detection
Backstory watches for new changes that appear to reverse earlier recorded decisions.
⚠ This change may contradict a decision from commit 8f21c9a:
"payment.failed should mark subscription as pending, not cancelled"
That turns the tool from an archive into a guardrail.
Storage
.backstory/
config.json
knowledge/
index.md
sessions/
index.md
latest.md
sha256-<session>.md
redactions/
tombstones.log
Session memory is stored as Google's OKF-style markdown -- human-readable, Git-friendly, and agent-friendly.
Privacy
Backstory is local-first by design. No cloud service or telemetry is required. Raw transcripts are never persisted -- only extracted decisions, risks, follow-ups, and Git context are kept. Built-in redaction scans for and removes API keys and secrets during ingestion.
Documentation
- Integration guide -- Set up with Claude Code and other tools
- Engineering walkthrough
- Product spec
- Retrieval model
If you find this useful, starring the repo helps others discover it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file backstory_cli-0.5.1.tar.gz.
File metadata
- Download URL: backstory_cli-0.5.1.tar.gz
- Upload date:
- Size: 52.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a180a2ade3848c0e8337eb0224874c130b6f8ef85c11e580cd5e6f44df307c28
|
|
| MD5 |
3e1920ae445bc18ab56ae41b31b33f08
|
|
| BLAKE2b-256 |
5e6f0d2aca64f5e4bdc1dff0ca061ea668f712c8efc3f1c1ec01a33e3af32ec9
|
Provenance
The following attestation bundles were made for backstory_cli-0.5.1.tar.gz:
Publisher:
publish.yml on arpitkath/backstory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
backstory_cli-0.5.1.tar.gz -
Subject digest:
a180a2ade3848c0e8337eb0224874c130b6f8ef85c11e580cd5e6f44df307c28 - Sigstore transparency entry: 2087347099
- Sigstore integration time:
-
Permalink:
arpitkath/backstory@fc08a4493ac3de3efd0906d66365bbb2251f1a97 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/arpitkath
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fc08a4493ac3de3efd0906d66365bbb2251f1a97 -
Trigger Event:
release
-
Statement type:
File details
Details for the file backstory_cli-0.5.1-py3-none-any.whl.
File metadata
- Download URL: backstory_cli-0.5.1-py3-none-any.whl
- Upload date:
- Size: 40.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86fdd35b0d074ff215a9dc5b3e855db823473d9d905a601a677ffe7bfea58a7d
|
|
| MD5 |
43cd9131e3e035f28210c08e93f473be
|
|
| BLAKE2b-256 |
125db30ff1fc0ae7f80036ee2fce550bea1053ab19c21f9a7f81300e12b86c35
|
Provenance
The following attestation bundles were made for backstory_cli-0.5.1-py3-none-any.whl:
Publisher:
publish.yml on arpitkath/backstory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
backstory_cli-0.5.1-py3-none-any.whl -
Subject digest:
86fdd35b0d074ff215a9dc5b3e855db823473d9d905a601a677ffe7bfea58a7d - Sigstore transparency entry: 2087347219
- Sigstore integration time:
-
Permalink:
arpitkath/backstory@fc08a4493ac3de3efd0906d66365bbb2251f1a97 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/arpitkath
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fc08a4493ac3de3efd0906d66365bbb2251f1a97 -
Trigger Event:
release
-
Statement type: