Persistent memory for AI agents — cross-session context that actually sticks
Project description
Forgemem
Persistent long-term memory for AI agents — cross-session context that actually sticks.
Forgemem mines your git history, session traces, and project notes to extract what actually happened — failures, successes, plans, and hard-won lessons. It stores them locally in SQLite and exposes them to AI agents via MCP so they start every session informed instead of blind.
The Problem
Every new agent session starts from zero. It doesn't know you already tried the Zod 4 schema approach and it broke. It doesn't know that wildcard CORS killed auth in production last quarter. It doesn't know which approach you abandoned and why.
Without Forgemem, agents repeat your mistakes. With it, they skip straight to what works.
Installation
pip install forgemem
forgemem init
forgemem init now requires a real TTY on first run so the user must choose an inference provider interactively. Agents cannot bypass that step with --yes or a piped session. After init completes, it auto-starts the MCP server; then restart your AI agent (Claude Code, Gemini CLI, or Codex) to pick up the new MCP connection.
How It Works
- Mine — scans git repos and session notes, extracts failure/success/plan traces, saves them with an impact score
- Store — all traces and distilled principles live locally at
~/.forgemem/forgemem_memory.db - Serve — an MCP server exposes the database to agents via the Model Context Protocol
Agents call retrieve_memories before starting any task. That one call surfaces the top matching failures and principles from your history — so they don't burn tokens re-learning what you already know.
Quick Start
# Install
pip install forgemem
# Initialize (interactive on first run)
forgemem init
# Optionally: also schedule background mining every hour
forgemem start --mine
# Restart your agent, then verify
forgemem status
Agent Support
| Agent | Auto-detected | Skill file written |
|---|---|---|
| Claude Code | ✓ | ~/.claude/skills/forgemem.md |
| Gemini CLI | ✓ | ~/.gemini/forgemem-skill.md |
| OpenAI Codex | ✓ | ~/.codex/forgemem-skill.json |
forgemem init detects which agents are installed and writes the appropriate skill file automatically. Agents use retrieve_memories and save_trace via MCP — no extra configuration needed.
MCP Tools
| Tool | Description |
|---|---|
retrieve_memories |
Search principles and traces by keyword before starting a task |
save_trace |
Save a failure, success, plan, or note during or after a session |
mine_session |
Agent-driven mining — no API key required, the agent is the LLM |
distill_session |
Condense raw traces into durable principles |
forgemem_stats |
Summary of DB contents and server health |
CLI Reference
forgemem init # Initialize DB, choose provider, register MCP, write skill files
forgemem start # Start MCP server (background daemon on macOS)
forgemem start --mine # Also install a scheduled mining agent (hourly)
forgemem stop # Stop the daemon
forgemem status # Show DB stats, server health, skill status
forgemem store "<text>" # Save a memory trace manually
forgemem search "<query>" # Search stored memories
forgemem mine # Scan repos and session files for new learnings
forgemem distill # Condense undistilled traces into principles
forgemem config # Set inference provider (anthropic / ollama / gemini / …)
forgemem auth login # Authenticate for managed inference (no BYOK needed)
Inference Providers
Forgemem uses an LLM for mining and distillation. Three options:
| Provider | Setup | Cost |
|---|---|---|
| Forgemem managed | choose it in forgemem init, then run forgemem auth login |
Free tier + paid plans |
| Ollama (local) | choose it in forgemem init |
Free, fully private |
| BYOK (Anthropic / OpenAI / Gemini) | forgemem config <provider> --key <key> |
Your API costs |
forgemem init now requires the user to choose a provider interactively on first run. The mine_session and distill_session MCP tools still work with any subscription — no separate key needed since the agent itself is the LLM.
Platform Support
| Platform | Daemon | Auto-start |
|---|---|---|
| macOS | LaunchAgent (launchctl) |
On login |
| Linux | systemd user service (instructions printed) | Manual |
| Windows | Task Scheduler (command printed) | Manual |
Licensing
Forgemem is Apache-2.0 for community use.
- Community — Apache-2.0, permissive, local-first, commercial-friendly
- Enterprise — hosted terms with SLA, SSO/SAML, audit logs, priority support, and private hosting
- Contributing — all contributors must sign the CLA by adding their name to CONTRIBUTORS.md in their first PR
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 forgememo-0.1.14.tar.gz.
File metadata
- Download URL: forgememo-0.1.14.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7c92e2135eb7abc6a3e7ef172b3e21c008a05638ca9b7171b234e11e248c812
|
|
| MD5 |
6f2522dfb38138acbee1c643366dc69e
|
|
| BLAKE2b-256 |
6ff9fb6ae4a60a01e8189ab22ae7e568ab19ae136f59610f9010c12b5452f909
|
File details
Details for the file forgememo-0.1.14-py3-none-any.whl.
File metadata
- Download URL: forgememo-0.1.14-py3-none-any.whl
- Upload date:
- Size: 58.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5815d095e84f702a99598979ed19434f2205a7f746868dad8554cacaf2b002a6
|
|
| MD5 |
be78d08f2e919bd8f3e5f5d34e6e7bd5
|
|
| BLAKE2b-256 |
b795e96a22bcc24bd2fa3617f121580217b9783807121ba8f348ba340add7135
|