Skip to main content

MemForge ⚒

License: MIT Python 3.11+

Local external memory for LLM agents. Turns your AI coding sessions into a structured, versioned, human-readable knowledge base in plain markdown.

Philosophy: no hidden magic, no auto-saves, no timers. Every change to your knowledge base is the result of an explicit command you ran. Human-in-the-loop at every step.


Agent support

Agent Status
Claude Code Fully supported and verified
Cursor Not yet verified — may work, treat as experimental
ChatGPT (export) Not yet verified — may work, treat as experimental

All other agents and sources are currently unverified. Contributions and test reports are welcome.


Quick start

# Install
pip install memforge           # or: pipx install memforge

# Initialise global knowledge base
mem init --global

# After a productive Claude Code session:
mem save                       # extract drafts → inbox/
mem review                     # open drafts in $EDITOR (optional)
mem commit --all               # promote drafts → daily log + git commit

# Weekly: merge daily logs into permanent knowledge
mem compile

# Load your knowledge into Claude's context (run inside Claude Code with !)
! mem context                            # pinned articles + full index
! mem context "authentication flow"     # search + relevant snippets
! mem context "auth" --full             # search + full article bodies

# Search and inspect from terminal
mem recall "how did we handle rate limiting"
mem load rate-limiting-pattern          # print article to stdout

# Launch the web UI
mem ui --open

Installation

Requirements: Python 3.11+

pip install memforge

# Option A: API key (paid, any Claude model)
export ANTHROPIC_API_KEY=sk-ant-...

# Option B: Claude Code CLI subscription (free if you have Claude Code)
# Just make sure `claude` is in your PATH — MemForge detects it automatically

mem init --global              # creates ~/.memforge/ with git repo
mem init                       # creates .memforge/ in current project (optional)
mem doctor                     # verify everything is set up correctly

The knowledge flow

Claude Code session
        ↓  mem save
    inbox/draft-<uuid>.md       ← preview, edit, or discard
        ↓  mem commit
    daily/YYYY-MM-DD.md         ← git commit
        ↓  mem compile
    knowledge/<type>/<slug>.md  ← git commit
        ↓
    index.md                    ← BM25 retrieval
        ↓  mem context / mem recall / mem load
    LLM context

All files are plain markdown with YAML front-matter. No database, no binary formats, no cloud.


Loading memory into Claude

The key command is mem context. Run it with ! inside Claude Code to inject knowledge directly into the conversation:

# In Claude Code chat:
! mem context                          # everything: pinned + index
! mem context "rate limiting"          # targeted: search + snippets
! mem context "rate limiting" --full   # targeted: search + full bodies
! mem context --no-index               # pinned articles only

The output is clean markdown — no ANSI codes — ready to be read by the model.

You can also pin the most important articles so they always appear first:

mem pin my-architecture-decision
mem pin api-contract-v2

Commands

Core workflow

Command Description
mem init [--global] [--no-git] Initialise store. Creates directory structure and a git repo.
mem save [--source auto|claude|cursor|chatgpt|stdin|file] [--file PATH] [--note "…"] [--type TYPE] Extract knowledge from latest session → inbox/. Nothing is committed to daily yet.
mem review Open inbox drafts in $EDITOR.
mem commit [DRAFT_ID…] [--all] [-m MESSAGE] Promote drafts from inbox → daily/YYYY-MM-DD.md. Makes a git commit.
mem discard <DRAFT_ID> Delete a draft without saving.
mem compile [--since DATE] [--dry-run] Merge daily logs → knowledge/. Rebuilds index.md. Makes a git commit.

Context injection

Command Description
mem context [QUERY] [--top N] [--full] [--no-pinned] [--no-index] Dump knowledge to stdout for LLM context. Run with ! in Claude Code.
mem recall "<query>" [--top N] [--type TYPE] BM25 search — shows titles and snippets in the terminal.
mem load <slug> Print a single article to stdout.

Knowledge management

Command Description
mem pin <slug> / mem unpin <slug> Mark articles as always-load in pinned.md.
mem forget <slug> Soft-delete: moves article to archive/, git commit.
mem restore <slug> Restore from archive.
mem revert <git-sha> Revert a knowledge-base commit via git revert.
mem diff [--since DATE] Show git diff of knowledge/ since a date.
mem export --to obsidian [--out PATH] Export to Obsidian vault (wiki-links, YAML properties, tag syntax).

Diagnostics

Command Description
mem stats [--days N] Terminal dashboard: article counts, drift, LLM cost summary.
mem lint Check integrity: unparseable files, empty bodies.
mem doctor Check API key / CLI, git, dependencies.
mem ui [--port 7777] [--open] [--token TOKEN] Launch local web UI.

Sources

mem save --source auto tries sources in order: Claude Code → Cursor → ChatGPT → stdin.

Source What it reads Status
claude ~/.claude/projects/<hash>/*.jsonl — latest Claude Code session Verified
cursor %APPDATA%/Cursor/User/workspaceStorage/*/state.vscdb — Cursor chat SQLite Not yet verified
chatgpt ~/Downloads/conversations.json — ChatGPT export Not yet verified
stdin Pipe or --file PATH — any markdown/plain text Verified

Record types

Type When to use
decision An architectural or design choice with rationale and trade-offs
pattern A reusable solution approach
gotcha A trap, unexpected behaviour, or lesson learned the hard way
contract An API, DB schema, or event contract
glossary Domain term definition
todo An open question or pending investigation

Store structure

~/.memforge/                   # global (personal)
├── config.yaml
├── memory/
│   ├── inbox/                 # drafts awaiting review
│   ├── daily/                 # YYYY-MM-DD.md logs
│   ├── knowledge/             # permanent articles
│   │   ├── index.md
│   │   ├── decisions/
│   │   ├── concepts/
│   │   ├── gotchas/
│   │   ├── contracts/
│   │   ├── glossary/
│   │   └── todo-knowledge/
│   ├── archive/               # soft-deleted
│   └── pinned.md
└── logs/
    ├── memforge.log
    └── llm.jsonl              # per-call cost tracking

<repo>/.memforge/              # project overlay (same structure)

Configuration

~/.memforge/config.yaml is merged with <repo>/.memforge/config.yaml (project wins on conflict). Edit via mem ui → Settings or directly:

extractor:
  model: claude-sonnet-4-6     # model used for extraction + compilation
  backend: auto                # auto | api | cli
  language: en                 # language for extracted text (en, ru, …)
  max_units_per_save: 10

scrubber:
  regex: default               # default | strict | off
  detect_secrets: false        # optional deep scan (pip install memforge[optional])
  corporate_email_domains: []

index:
  max_tokens: 4000             # index.md size cap

git:
  auto_commit: true            # commit on every write

Web UI

mem ui --open                  # opens http://127.0.0.1:7777

Pages: Dashboard · Inbox (Accept/Discard drafts) · Knowledge (search, filter) · Daily (timeline) · Stats (LLM cost, drift) · Settings (config editor)

The UI is read/write — you can accept drafts, edit articles, pin/forget, all with git commits happening automatically.


Secret scrubbing

Every draft passes through the scrubber before hitting disk:

  • Default mode: AWS/GCP/Azure keys, GitHub/GitLab PATs, private keys, JWTs, generic secret=… patterns.
  • Strict mode (scrubber.regex: strict): also redacts emails, private IPs, phone numbers.
  • detect-secrets (optional): pip install memforge[optional] enables a deeper scan as a second pass.

Redacted values become [REDACTED:<kind>]. Drafts that were modified are flagged quarantine: true and excluded from git commits by default.


Development

git clone <repo>
cd mem_forge
pip install -e ".[dev]"
pytest                         # 57 tests
ruff check .

License

MIT — see LICENSE.

Metadata

Release files for memforge 0.1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memforge 0.1.5.1
File Size Uploaded Provenance Actions
memforge-0.1.5.1.tar.gz 58.2 kB With provenance Details for memforge-0.1.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for memforge 0.1.5.1
File Interpreter ABI Platform Actions
memforge-0.1.5.1-py3-none-any.whl Python 3 none any Details for memforge-0.1.5.1-py3-none-any.whl

Total release size: 130.0 kB

Release files / memforge-0.1.5.1.tar.gz

Download URL memforge-0.1.5.1.tar.gz
Size 58.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4a82f49cbddc1fd2b7b1b88fb84cf8be0294118ee0cc0cd7de7c5a8de44adc5a
BLAKE2b-256 checksum
How to use checksums
6c0af58f3f61f3a453dc0ecfab167079ac68e510c396a99e14b63b4a3f87fd8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2026.

Transparency log

Release files / memforge-0.1.5.1-py3-none-any.whl

Download URL memforge-0.1.5.1-py3-none-any.whl
Size 71.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14057ebfda1716a41dcf9b7e4c3d83805395c17484d589804147c3b278585264
BLAKE2b-256 checksum
How to use checksums
4732d25cfec32957b70189ed67a1a73666696306ebe7277d82a772d9b45c8a6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2026.

Transparency log

Security for memforge 0.1.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for memforge-0.1.5.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page