Skip to main content

Post-session knowledge crystallizer for AI coding agents

Project description

prism-mem

Every coding session leaves behind artifacts. Prism reads them and turns them into structured, reusable knowledge — automatically.

Prism is a post-session knowledge crystallizer for AI coding agents. It reads Claude Code session transcripts and git history, extracts semantic knowledge as triples, links them into a graph, and auto-regenerates the context files every agent reads at session start (CLAUDE.md, .cursorrules, AGENTS.md).

Quickstart

pip install prism-mem

# Configure your LLM provider (one-time setup)
prism config set provider anthropic
prism config set model claude-haiku-4-5-20251001
prism config set api-key <your-api-key>

# Run once after a coding session to extract knowledge and regenerate context files
prism crystallize --project /path/to/your/project

# Install the git hook so it runs automatically after every commit
prism hook install --project /path/to/your/project

# Add as an MCP server so agents can query the knowledge graph directly
claude mcp add prism -- prism serve --project /path/to/your/project

Configuration

Prism uses ~/.prism/config.toml to store your LLM provider settings. Set it up with:

prism config set provider anthropic        # or: openai, gemini, ollama, groq, mistral, ...
prism config set model claude-haiku-4-5-20251001
prism config set api-key <your-api-key>

prism config show                          # verify (api-key is masked)

The provider is validated against LiteLLM's provider list at set-time. Any provider LiteLLM supports works — Anthropic, OpenAI, Gemini, local Ollama models, etc. The model string is passed as provider/model to LiteLLM.

How it works

[git commit]
     │
     ▼
[1] INGEST
    Read ~/.claude/projects/<id>/<session>.jsonl  +  git diff HEAD~1 HEAD
     │
     ▼
[2] EXTRACT
    kg-gen → NetworkX graph of (subject, predicate, object) triples
     │
     ▼
[3] STORE + LINK
    Embed triples (sentence-transformers, local)
    Store in SQLite at ~/.prism/projects/<hash>/graph.db
    Connect related triples by cosine similarity (numpy)
    Flag contradicted facts as stale
     │
     ▼
[4] GENERATE
    Score triples (recency + confidence)
    Top 30 → LLM (via LiteLLM) → write CLAUDE.md / .cursorrules / AGENTS.md

Commands

Command What it does
prism config set <key> <value> Set provider, model, or api-key
prism config show Show current config (api-key masked)
prism crystallize --project . Full pipeline: ingest → extract → store → generate
prism hook install --project . Write .git/hooks/post-commit to run crystallize after every commit
prism hook uninstall --project . Remove the hook
prism serve --project . Start MCP server in stdio mode
prism ui --project . Open graph UI at http://localhost:7823

MCP tools

When added as an MCP server, Prism exposes three tools to any agent:

Tool What it does
get_context() Returns the current CLAUDE.md for the project
query_knowledge(question) Semantic search over the triple graph, returns top-5 matches
crystallize(session_id?) Triggers the full pipeline in the background

Graph UI

prism ui opens a local browser UI at http://localhost:7823:

  • /constitution — current CLAUDE.md with a Regenerate button
  • /memory — searchable table of all triples (active + stale)
  • /graph — interactive force-directed knowledge graph

Storage

All data is local. Nothing leaves your machine except calls to your configured LLM provider.

~/.prism/
├── config.toml             ← provider, model, api-key
└── projects/
    └── <project-hash>/
        └── graph.db        ← SQLite, one file per project

Requirements

  • Python 3.13+
  • Any LiteLLM-compatible LLM provider (configured via prism config set)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prism_mem-0.1.1.tar.gz (31.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prism_mem-0.1.1-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file prism_mem-0.1.1.tar.gz.

File metadata

  • Download URL: prism_mem-0.1.1.tar.gz
  • Upload date:
  • Size: 31.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for prism_mem-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cd56f95b7363983c5a751f3a1f294360f49ab5be7bfa58a4a5b3c94372c571d4
MD5 274e30ee26c9e73bffd55dc5469b2f0d
BLAKE2b-256 4f2512405d4c57f22278645e69fd992738cd1f61348cbd335998a799bd64fce0

See more details on using hashes here.

File details

Details for the file prism_mem-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: prism_mem-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for prism_mem-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03f0a7a8a7cf37d4b16045b27b785e3aab300e992a5fadbe5e9917bfd7dbc95f
MD5 b9b7c12a75631f7a884d78eb396ee5d6
BLAKE2b-256 b19c6f813c79810dafce7225fd10950b01ca6aa4b0652cfeb6d2ca69f73d3a39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page