The spellbook for your codebase โ chronicle decisions, lore, and context your AI companions can actually read.
Project description
๐ lore
The spellbook for your codebase โ chronicle decisions, context, and lessons your AI companions can actually read.
Lore is a local AI memory system for software projects. It stores what you know as plain YAML alongside your code โ then publishes that knowledge as instruction files that GitHub Copilot, Claude, Cursor, Codex, and other AI tools read automatically.
No external database. No API keys. No cloud sync. Everything lives in .lore/ next to your code.
How it works
AI coding tools are stateless โ they don't remember why you chose PostgreSQL over SQLite, that the auth layer must never bypass JWT validation, or that the frontend team deprecated the v1 API six months ago. You end up re-explaining the same context in every session.
Lore fixes that. You capture knowledge once; every AI session inherits it automatically.
Your decisions, facts, and lessons
โ lore add / lore relic
.lore/ (plain YAML)
โ lore export
CHRONICLE.md โ full project memory (one source of truth)
โ referenced by lean instruction files:
copilot-instructions.md ยท AGENTS.md ยท CLAUDE.md ยท .cursor/rules/memory.md
โ on-demand:
/lore โ reads CHRONICLE.md into AI context when you ask
โ
Every AI tool reads your repo context โ without you repeating yourself
Core concepts
Spell (memory)
A single piece of knowledge: a decision, a fact, a hard-won lesson. Short, specific, retrievable by semantic search.
lore add decisions "Use PostgreSQL โ we need JSONB and row-level locking"
lore add facts "Auth service is the sole issuer of JWTs โ never bypass it"
lore add preferences "Prefer explicit over clever โ this codebase has many contributors"
Tome (category)
A named collection of spells. Default tomes: decisions, facts, preferences, summaries. You can add your own in .lore/config.yaml.
Tomes are just directory names โ each spell is one YAML file filed under its tome.
Relic
A raw artifact saved as-is for later processing. Use a relic when things are moving fast and you don't have time to curate.
Capture a relic now โ distill spells from it later.
A relic can be anything: a pasted session log, a git diff, a doc excerpt from Confluence, a long Slack thread. It lands in .lore/relics/ untouched. When you have time, you open it with lore relic distill and choose exactly which parts become proper spells.
Export (the chronicle)
lore export writes your spells into the files AI tools pick up automatically, using a two-layer architecture:
CHRONICLE.md โ the single source of truth. Contains every spell grouped by tome. All lean instruction files reference it.
| Lean instruction file | Tool | On by default |
|---|---|---|
CHRONICLE.md |
All tools (full memory) | โ |
.github/copilot-instructions.md |
GitHub Copilot | โ |
AGENTS.md |
OpenAI Codex, agent frameworks | โ |
CLAUDE.md |
Anthropic Claude | โ |
.cursor/rules/memory.md |
Cursor | โ |
.github/prompts/lore.prompt.md |
/lore trigger in Copilot Chat |
โ |
.windsurfrules |
Windsurf / Codeium | opt-in |
GEMINI.md |
Gemini CLI | opt-in |
.clinerules |
Cline | opt-in |
CONVENTIONS.md |
Aider | opt-in |
Lean instruction files are intentionally small โ they contain your project description, security preamble, and a single line telling the AI to read CHRONICLE.md for full context. This keeps per-request token overhead minimal.
To enable opt-in targets, set them in .lore/config.yaml:
export_targets:
cline: true
aider: true
Exports are atomic โ a crash mid-write never leaves a partial file.
Install
pip install lore-book
For local development:
pip install -e .
Requirements: Python 3.10+. Semantic search uses sentence-transformers (downloaded once, ~80 MB). If the model is unavailable, a TF-IDF fallback kicks in automatically โ no configuration needed.
Quick start
lore onboard
The onboarding command explains every concept, walks you through store setup, security policy, your first spell, and publishing โ with an interactive step-by-step flow. It also prompts for a project description (auto-detected from pyproject.toml or README) that appears at the top of every lean instruction file. Start here if you're new.
Spells โ adding and searching memories
# Interactive, step-by-step
lore add
# One-liner (scriptable, CI-friendly)
lore add decisions "Use FastAPI โ async support + automatic OpenAPI docs"
lore add preferences "Always use type hints" --tags style,python
lore add facts "Minimum supported Python is 3.10"
# Semantic search โ finds conceptually related spells, not just keyword matches
lore search "why did we choose FastAPI"
lore search "authentication strategy"
# List all spells
lore list
# List by tome
lore list decisions
# Delete a spell
lore remove <id>
Spell IDs are short UUID prefixes. lore list shows them.
Relics โ capture now, curate later
Use relics when you want to preserve raw information without slowing down to decide what matters.
# Paste session notes interactively (enter . to finish)
lore relic capture
# Pull in a file โ meeting notes, spec doc, wiki export
lore relic capture --file session-notes.md --title "Auth redesign session"
# Snapshot the current working-tree + staged diff
lore relic capture --git-diff --title "Pre-deploy changes"
# Capture the last N commits (messages + diffs)
lore relic capture --git-log 5 --title "Sprint 12 wrap-up"
# Read from clipboard (macOS: pbpaste, Linux: xclip)
lore relic capture --clipboard --title "Slack thread on rate limiting"
# Pipe anything in
git log --oneline -20 | lore relic capture --stdin --title "Recent commit history"
cat confluence-export.txt | lore relic capture --stdin --title "Architecture decision"
# Browse relics (shows preview of content)
lore relic list
# Read one in full
lore relic view a3f1b2c4
# Distill the good parts into spells
lore relic distill a3f1b2c4
# Delete a relic
lore relic remove a3f1b2c4
Distilling
lore relic distill shows you the relic content and walks you through extracting spells one at a time:
โโโ Spell #1 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฆ Inscription the wisdom to enshrine (. to seal the book): We chose CQRS to
separate read and write models after hitting contention on the orders table
โฆ Tome which grimoire? [decisions]:
โ Spell a1b2c3d4 sealed into decisions.
โโโ Spell #2 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
...
Each spell links back to its source relic. The tome selection is sticky โ after you choose decisions for spell #1, it defaults to decisions for spell #2. Enter . to finish.
Exporting AI context files
# Write all AI context files (CHRONICLE.md + all enabled lean files)
lore export
# Write one target only
lore export --format chronicle
lore export --format copilot
lore export --format agents
lore export --format claude
lore export --format cursor
lore export --format prompt # .github/prompts/lore.prompt.md
lore export --format windsurf # requires: windsurf: true in .lore/config.yaml
lore export --format gemini
lore export --format cline
lore export --format aider
If no project_description is set, lore export will remind you to run lore onboard โ lean instruction files are more useful with a one-line project summary at the top.
Exports are regenerated every run and are safe to commit. The git hook can automate this on every commit (see below).
The /lore trigger
The prompt export target writes .github/prompts/lore.prompt.md. In GitHub Copilot Chat, type /lore to invoke it โ the AI will read CHRONICLE.md and surface context relevant to your current task. No setup beyond running lore export.
Git integration
Post-commit hook
lore hook install opens an interactive wizard that installs a .git/hooks/post-commit script:
lore hook install
The wizard asks whether you want:
- Auto-extract โ scan each new commit message for decisions and facts, store them automatically
- Auto-export โ regenerate all AI context files after every commit so they're always current
The generated hook is clearly marked # Installed by lore. Remove it safely with:
lore hook uninstall
Extracting from past commits
# Extract from the last 20 commits
lore extract --last 20
Lore scans commit messages for structured knowledge and adds it to your store.
Security guidelines
lore security configures a security preamble injected at the top of every export. This ensures every AI tool that reads your repo context also receives your security constraints before anything else.
lore security
The preamble can include:
- OWASP Top 10 reference (prevents the classics: injection, broken auth, SSRF, etc.)
- Security policy file link (e.g.
SECURITY.md) - CODEOWNERS notice โ warns that sensitive paths need human review
- Custom rules โ any project-specific edicts ("Never disable SSL verification", "All secrets via env vars", etc.)
This is especially useful in GitHub Enterprise environments where Copilot should always be reminded of your security posture before providing suggestions.
Store layout
.lore/
config.yaml โ store settings, categories, model config, security
decisions/ โ why things were built a certain way
facts/ โ project context, constraints, team conventions
preferences/ โ coding style, tooling choices
summaries/ โ AI session summaries, sprint recaps
relics/ โ raw captured artifacts (sessions, diffs, docs)
embeddings/
index.json โ local semantic search index (no external DB)
Each spell and relic is a plain YAML file. No database engine, no lock files, no proprietary format. You can read, edit, and commit them directly.
.lore/ is automatically added to .gitignore on lore init โ your memories stay local unless you explicitly opt in to committing them.
TUI
lore ui
A retro phosphor-green terminal browser for searching, reading, adding, and exporting memories. Live-reloads whenever .lore/ files change on disk โ open it in a split pane while you work.
Background daemon
# Start watching โ auto-exports on every .lore change
lore awaken
# Run in background
lore awaken --background
# Stop the daemon
lore slumber
The daemon watches .lore/ with filesystem events and regenerates all export files the moment any spell or config changes. Zero-friction โ add a spell, your AI tools get it immediately.
Health check
lore doctor
Reports:
- Whether the
.lore/store exists and is readable - Which semantic search mode is active (embedding model or TF-IDF fallback)
- Whether the configured model endpoint is reachable
- Counts of spells by tome and relics
Corporate proxy / Artifactory
If you're behind a ZScaler proxy or using an internal HuggingFace mirror:
lore config model_endpoint https://artifactory.example.com/artifactory/api/huggingfaceml/huggingface
lore config model_ssl_verify false # only if SSL inspection breaks certificate validation
Run lore doctor to confirm the model downloads and loads from your endpoint.
Command reference
| Command | Args / Flags | What it does |
|---|---|---|
onboard |
Guided setup โ concepts, store, security, first spell, export | |
init |
[path] |
Create a .lore/ store in a directory |
add |
[category] [content] |
Store a spell (interactive if no args) |
list |
[category] |
List spells, optionally filtered by tome |
search |
<query> |
Semantic search across all spells |
remove |
<id> |
Delete a spell |
extract |
[--last N] |
Pull spells from git commit messages |
export |
[--format F] |
Write AI context files (chronicle, agents, copilot, cursor, claude, prompt, windsurf, gemini, cline, aider, all) |
config |
<key> <value> |
Set a config value |
security |
Configure the security preamble for exports | |
doctor |
Store + model health report | |
hook install |
Install git post-commit hook (wizard) | |
hook uninstall |
Safely remove the lore-managed git hook | |
index rebuild |
Rebuild the semantic search index from scratch | |
ui |
Open the interactive terminal browser | |
awaken |
[--background] |
Watch .lore/ and auto-export on change |
slumber |
Stop the background daemon | |
relic capture |
[--file F] [--git-diff] [--git-log N] [--clipboard] [--stdin] [--title T] [--tags T] |
Capture a raw artifact |
relic list |
List relics with content preview | |
relic distill |
<id> |
Extract spells from a relic interactively |
relic view |
<id> |
View full relic content |
relic remove |
<id> |
Permanently delete a relic |
Run lore <command> --help for detailed options on any command.
Dependencies
| Package | Purpose |
|---|---|
sentence-transformers |
Local semantic embeddings via all-MiniLM-L6-v2 |
gitpython |
Git history extraction |
typer + rich |
CLI and terminal output |
textual |
Interactive TUI |
watchdog |
Live reload in TUI + background daemon |
pyyaml + numpy |
YAML storage and vector math |
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 lore_book-1.1.7.tar.gz.
File metadata
- Download URL: lore_book-1.1.7.tar.gz
- Upload date:
- Size: 49.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83ff3a81a2bf24c2d0a4a3018df368751d0608858a69fb705b95f9d19f103f3d
|
|
| MD5 |
3d1a24e2c98557f08678d85787c437b9
|
|
| BLAKE2b-256 |
64486b8540128d4f0fb68958bf03de9d268fcbf9474c3d2538ea36979dd741e2
|
Provenance
The following attestation bundles were made for lore_book-1.1.7.tar.gz:
Publisher:
publish.yml on CptPlastic/lore-book
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lore_book-1.1.7.tar.gz -
Subject digest:
83ff3a81a2bf24c2d0a4a3018df368751d0608858a69fb705b95f9d19f103f3d - Sigstore transparency entry: 1138198528
- Sigstore integration time:
-
Permalink:
CptPlastic/lore-book@d86d72dbb1b6cf4863e7bf022b66d1fdb736fad9 -
Branch / Tag:
refs/tags/v1.1.7 - Owner: https://github.com/CptPlastic
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d86d72dbb1b6cf4863e7bf022b66d1fdb736fad9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file lore_book-1.1.7-py3-none-any.whl.
File metadata
- Download URL: lore_book-1.1.7-py3-none-any.whl
- Upload date:
- Size: 51.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32d85d742912e3554a6195d355d23decf510330c398b419604bcbd3fbe6a3931
|
|
| MD5 |
978edcc9bf1a92fcb1973779d160c77c
|
|
| BLAKE2b-256 |
30ef5779a28023fbb9b31a501f73fae92a600facdc87a2dddfdcea7b08faa467
|
Provenance
The following attestation bundles were made for lore_book-1.1.7-py3-none-any.whl:
Publisher:
publish.yml on CptPlastic/lore-book
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lore_book-1.1.7-py3-none-any.whl -
Subject digest:
32d85d742912e3554a6195d355d23decf510330c398b419604bcbd3fbe6a3931 - Sigstore transparency entry: 1138198593
- Sigstore integration time:
-
Permalink:
CptPlastic/lore-book@d86d72dbb1b6cf4863e7bf022b66d1fdb736fad9 -
Branch / Tag:
refs/tags/v1.1.7 - Owner: https://github.com/CptPlastic
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d86d72dbb1b6cf4863e7bf022b66d1fdb736fad9 -
Trigger Event:
release
-
Statement type: