Skip to main content

Sync AI coding context from Git AI to Redis Agent Memory Server for semantic search and recall.

Project description

DevMemory ๐Ÿš€๐Ÿง 

CI PyPI License: MIT

TL;DR: DevMemory is a longโ€‘term memory for your AI coding agents.
It remembers why code was written, how it changed, and what your team learned โ€” then feeds that back into your agents. No more โ€œreinvent the bugโ€ speedruns. ๐Ÿ›๐Ÿ”ฅ

Built on Git AI for silent capture and Redis Agent Memory Server for semantic search and recall.


๐Ÿ’ก What DevMemory Does (in human terms)

  • ๐Ÿช Hooks into your git workflow via Git AI notes
  • ๐Ÿงฌ Extracts rich memories:
    • Commit summaries (who, what, why, which agent/model, how much AI)
    • Perโ€‘file code snippets
    • Promptโ€‘level context with acceptance metrics
  • ๐Ÿง  Stores everything in Redis AMS as semantic vectors
  • ๐Ÿ” Lets you ask:
    โ€œHow do we handle auth?โ€ โ†’ it searches, then LLMโ€‘synthesizes an actual answer with sources
  • ๐Ÿงพ Ships a knowledge protocol: .devmemory/knowledge/*.md + CLI + Cursor rules so humans and agents keep the docs alive together

If Entire saves how agents worked and Git AI tracks who wrote which line, DevMemory is the part that answers โ€œOkay, but what did we actually learn?โ€.


๐Ÿงฎ How It Works

Developer commits code
        โ”‚
        โ–ผ
Git AI captures AI attribution, prompts, agent/model info
        โ”‚
        โ–ผ
DevMemory syncs enriched memories to Redis AMS (automatic via post-commit hook)
        โ”‚
        โ”œโ”€โ–บ Semantic search via CLI (with LLM-synthesized answers)
        โ”œโ”€โ–บ MCP recall in Cursor IDE (agents search memory before coding)
        โ””โ”€โ–บ Context briefing auto-generated on branch switch

The knowledge loop:

  1. Capture โ€“ Git AI silently records AI code attribution, prompts, and agent/model info on every commit
  2. Enrich โ€“ DevMemory extracts three layers per commit: enriched summary, perโ€‘file code snapshots, and promptโ€‘level context with acceptance metrics
  3. Search โ€“ Semantic vector search with LLMโ€‘powered answer synthesis (RAG over your git history)
  4. Recall โ€“ Cursor agents read memory via MCP before writing code, and persist new decisions after
  5. Learn โ€“ Humanโ€‘curated knowledge files (.devmemory/knowledge/*.md) feed the same store, capturing architecture decisions and gotchas

๐Ÿงต Think of it as git log + โ€œwhat we should have written in the ADRโ€ + your AI agents actually reading it.


๐ŸŽฅ Demo (what it feels like)

Imagine:

devmemory status                    # โœ… Stack + hooks look good
git commit -am "feat: add user auth"   # You used an AI agent heavily

# Normally the post-commit hook runs this for you in the background:
#   (sleep 2 && devmemory sync --latest 2>/dev/null) &
# but you can also trigger it manually:
devmemory sync --latest
devmemory search "how do we handle auth in this service?"

You get:

  • A concise answer synthesized by the LLM (RAG), describing:
    • Which files implement auth
    • Which agent/model was used
    • Key decisions (e.g., why JWT vs sessions)
  • A Sources table listing:
    • Commit summaries
    • Relevant perโ€‘file code snippets
    • The original prompts that drove the changes

Sample search result:

$ devmemory search "why we use redis memory server instead of other databases?"

Searching for: why we use redis memory server instead of other databases?
Synthesizing answer...

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Answer โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                                                                                                     โ”‚
โ”‚  Short answer: because Redis Agent Memory Server (AMS) already provides the exact semantic-memory features we need (embeddings,     โ”‚
โ”‚  topic extraction, NER, deduplication) while being battleโ€‘tested infra, so it reduces operational complexity and keeps the CLI      โ”‚
โ”‚  lightweight.                                                                                                                       โ”‚
โ”‚                                                                                                                                     โ”‚
โ”‚  Details / evidence from the repo:                                                                                                  โ”‚
โ”‚                                                                                                                                     โ”‚
โ”‚   โ€ข AMS handles embeddings, topic extraction and NER internally and provides builtโ€‘in memory deduplication (see                     โ”‚
โ”‚     .devmemory/knowledge/architecture.md, commit b0abbb04ad13).                                                                     โ”‚
โ”‚   โ€ข The same AMS image serves both REST (port 8000) and MCP (port 9050) endpoints used by the CLI (see docker-compose.yml and       โ”‚
โ”‚     ams_client.py; feature enable commit f025d01e107c).                                                                             โ”‚
โ”‚   โ€ข README and ams_client.py show we store semantic vectors in Redis AMS and call its /v1/long-term-memory APIs, avoiding the need  โ”‚
โ”‚     to run a separate vector DB (README.md commit 2b7602a5318a and devmemory/core/ams_client.py).                                   โ”‚
โ”‚                                                                                                                                     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Sources (10 relevant, 20 filtered out)

 #    Score    Type        Source                                                                      
 1    0.302    semantic    Why Redis Agent Memory Server                                               
 2    0.614    semantic    Memory Types and Their Purpose                                              
 3    0.613    semantic    feat: enable devmemory CLI with redis AMS and git-ai (f025d01e107c)         
 4    0.641    semantic    feat: add more metadata from the session to the memory (4ccf7529bd4e)       
 5    0.671    semantic    fix: use the --quite to show the one line update (139d559bdaa0)             
 6    0.677    semantic    Fix: terminal hang issue and the correct saved memories coun (daf56666f1f1) 
 7    0.512    episodic    .devmemory/knowledge/architecture.md (b0abbb04ad13)                         
 8    0.550    episodic    devmemory/core/ams_client.py (f025d01e107c)                                 
 9    0.588    episodic    README.md (2b7602a5318a)                                                    
 10   0.561    episodic    docker-compose.yml (f025d01e107c)                    

Auto-sync example:

auto-sync.gif


๐Ÿš€ Quick Start

Prerequisites

  • Git
  • Docker + Docker Compose
  • Python 3.10+
  • OpenAI API key (for embeddings and answer synthesis)
  • Git AI (for AI code attribution capture)

Oneโ€‘Line Setup

bash scripts/install.sh

This script:

  • Checks Docker / Python / Git AI and verifies the Docker daemon is running
  • Installs uv if not present, then installs the devmemory CLI via uv tool install
  • Sets up .env from .env.example
  • Starts Redis + AMS + MCP via Docker
  • Configures git hooks + Cursor MCP + agent rules in the current repo

Manual Setup

git clone https://github.com/devmemory/devmemory
cd devmemory

# Set up environment
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY

# Start the stack
make up

# Install the CLI (requires uv: https://docs.astral.sh/uv/)
uv tool install --editable .

# Set up hooks, MCP config, and Cursor rules in your project
cd /path/to/your/project
devmemory install

# Check everything works
devmemory status

โŒจ๏ธ CLI Commands

Core workflow ๐Ÿง 

devmemory sync                       # Sync unsynced Git AI commits to Redis
devmemory sync --latest              # Sync only the latest commit
devmemory sync --all                 # Re-sync all commits
devmemory sync --dry-run             # Preview what would be synced
devmemory search "how do we auth"    # Semantic search with LLM-synthesized answer
devmemory search "auth" -n 5         # Limit results
devmemory search "auth" --raw        # Raw results without LLM synthesis
devmemory status                     # Show system health, sync state, hooks

Code archaeology ๐Ÿ”

devmemory why src/auth.py            # Explain why a file exists and how it evolved
devmemory why src/auth.py login      # Focus on a specific function or class
devmemory why src/auth.py --raw      # Show raw memories and git history without synthesis

Knowledge management ๐Ÿ“š

devmemory add "We chose Redis over Postgres for vector search because..." --topic architecture
devmemory add --interactive          # Interactive mode with prompts
devmemory learn                      # Sync .devmemory/knowledge/*.md into memory store
devmemory learn --dry-run            # Preview what would be synced
devmemory context                    # Generate .devmemory/CONTEXT.md from git state + memory

Setup and config โš™๏ธ

devmemory install                    # Set up git hooks + Cursor MCP + agent rules
devmemory install --skip-hook        # Skip hook installation
devmemory install --skip-rule        # Skip Cursor agent rules
devmemory config show                # Show current config
devmemory config set endpoint URL    # Change AMS endpoint
devmemory config reset               # Reset to defaults

๐Ÿ“š Knowledge Files

DevMemory supports humanโ€‘curated knowledge in .devmemory/knowledge/*.md.
Each markdown section (## heading) becomes a separate searchable memory.

.devmemory/
โ”œโ”€โ”€ CONTEXT.md              # Auto-generated context briefing (gitignored)
โ””โ”€โ”€ knowledge/
    โ”œโ”€โ”€ architecture.md     # Architecture decisions and rationale
    โ”œโ”€โ”€ gotchas.md          # Known issues and workarounds
    โ””โ”€โ”€ conventions.md      # Coding patterns and project rules

Knowledge files use frontmatter for metadata:

---
topics: [architecture, decisions]
entities: [Redis, AMS]
---

## Why We Chose Redis

We chose Redis with vector search over dedicated vector DBs
because it's already part of our stack and reduces complexity.

Run devmemory learn to sync knowledge files into the memory store.
Both automated capture (Git AI) and human knowledge feed the same searchable store.

๐Ÿง  Pro tip: Treat .devmemory/knowledge/ like living ADRs. Small, focused, and updated often.


๐Ÿค Cursor Agent Integration

devmemory install sets up three things for Cursor:

  1. MCP server config (~/.cursor/mcp.json) โ€“ Agents can search and write to the memory store via MCP tools (search_long_term_memory, create_long_term_memories, etc.)
  2. Agent behavior rules (.cursor/rules/devmemory.mdc) โ€“ Instructs agents to search memory before coding, persist decisions after significant work, and maintain knowledge files
  3. Context rule (.cursor/rules/devmemory-context.mdc) โ€“ Agents read .devmemory/CONTEXT.md at task start for a preโ€‘built briefing

The result is a compounding loop: each agent session makes the next one smarter.
Your AI stops acting like a goldfish and starts acting like a teammate. ๐Ÿ โžก๏ธ๐Ÿง‘โ€๐Ÿ’ป


๐Ÿช Git Hooks

DevMemory installs two git hooks:

Hook What it does
post-commit Runs devmemory sync --latest in background (autoโ€‘syncs after every commit)
post-checkout Runs devmemory context --quiet (refreshes context briefing on branch switch)

๐Ÿ— Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Developer Machine         โ”‚     โ”‚  Docker Stack     โ”‚     โ”‚  Cursor IDE     โ”‚
โ”‚                             โ”‚     โ”‚                   โ”‚     โ”‚                 โ”‚
โ”‚  Git AI (git hooks)         โ”‚     โ”‚  Redis Stack      โ”‚     โ”‚  MCP Client     โ”‚
โ”‚         โ”‚                   โ”‚     โ”‚    โ–ฒ              โ”‚     โ”‚       โ”‚         โ”‚
โ”‚         โ–ผ                   โ”‚     โ”‚    โ”‚              โ”‚     โ”‚       โ–ผ         โ”‚
โ”‚  Git Notes (refs/ai)        โ”‚     โ”‚  AMS API (:8000)  โ”‚     โ”‚  MCP Server     โ”‚
โ”‚         โ”‚                   โ”‚     โ”‚    โ–ฒ              โ”‚     โ”‚  (:9050)        โ”‚
โ”‚         โ–ผ                   โ”‚     โ”‚    โ”‚              โ”‚     โ”‚                 โ”‚
โ”‚  devmemory sync โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”˜              โ”‚     โ”‚                 โ”‚
โ”‚                             โ”‚     โ”‚                   โ”‚     โ”‚                 โ”‚
โ”‚  devmemory search โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ–บ AMS Search โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ–บ LLM synth    โ”‚
โ”‚                             โ”‚     โ”‚                   โ”‚     โ”‚                 โ”‚
โ”‚  .devmemory/knowledge/*.md  โ”‚     โ”‚                   โ”‚     โ”‚  Agent rules    โ”‚
โ”‚         โ”‚                   โ”‚     โ”‚                   โ”‚     โ”‚  (.cursor/rules)โ”‚
โ”‚  devmemory learn โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”˜              โ”‚     โ”‚                 โ”‚
โ”‚                             โ”‚     โ”‚                   โ”‚     โ”‚                 โ”‚
โ”‚  devmemory context โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ–บ .devmemory/CONTEXT.md              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿงพ What Gets Captured

DevMemory extracts three memory layers from each Git AI commit:

Layer Type What it contains Answers
Commit summary semantic Agent/model, prompts used, AI contribution stats, acceptance metrics, technologies, files โ€œWhich agent was used?โ€, โ€œHow much AI code?โ€
Per-file code episodic Code snippets from diffs with key lines (imports, class/function defs) โ€œHow do we call the API?โ€, โ€œWhat client for Redis?โ€
Prompt context semantic Actual prompt text, acceptance rate, affected files โ€œWhat prompts were used?โ€, โ€œWhat was the developer asking?โ€

Unique data points captured via Git AI and surfaced by DevMemory:

  • AI vs human lines per commit
  • Acceptance rate (lines accepted unchanged vs overridden)
  • Time waiting for AI per commit
  • Agent and model used (Cursor, Copilot, Claude Code, etc.)

๐Ÿณ Docker Stack

The docker-compose.yml runs:

Service Port Description
redis 6379 Redis Stack (vector search, JSON, streams)
api 8000 Agent Memory Server REST API
mcp 9050 MCP server for Cursor IDE (SSE mode)
redis-insight 16381 RedisInsight UI (debug profile only)
make up       # Start stack
make down     # Stop stack
make logs     # View logs
make debug    # Start with RedisInsight
make clean    # Stop and remove volumes
make verify   # Run verification checks

๐ŸŒ How DevMemory Fits the Ecosystem

Tool What it does Data store
Git AI Captures AI code attribution and prompts Git Notes + SQLite
Entire Captures agent sessions/checkpoints Git branch
DevMemory Turns captured data into searchable, evolving team knowledge Redis AMS

Git AI and Entire are capture tools.
DevMemory is a memory and knowledge tool โ€” it makes captured data searchable via semantic vector search, synthesizes answers with LLM, and feeds context back to AI agents automatically.


โš™๏ธ Configuration

Config is stored in ~/.devmemory/config.json:

{
  "ams_endpoint": "http://localhost:8000",
  "mcp_endpoint": "http://localhost:9050",
  "namespace": "default",
  "user_id": ""
}

Environment variables (in .env):

Variable Default Description
OPENAI_API_KEY (required) Used for embeddings and answer synthesis
GENERATION_MODEL gpt-5-mini Model for LLM answer synthesis
EMBEDDING_MODEL text-embedding-3-small Model for vector embeddings

๐Ÿง‘โ€๐Ÿ’ป Contributing

Contributions, bug reports, and wild feature ideas are very welcome. ๐Ÿ’Œ
See CONTRIBUTING.md for details on running the stack, tests, and linting.

If you build something cool with DevMemory, please open an issue or PR and show it off. โœจ


โญ๏ธ Supporting the Project

If DevMemory helps you or your team:

  • Star the repo on GitHub โญ
  • Tell your AIโ€‘obsessed friends
  • Open issues with realโ€‘world workflows youโ€™d like memory support for

Happy shipping โ€” and may your agents never forget another architecture decision again. ๐Ÿง ๐Ÿ“ฆ๐Ÿš€

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

devmemory-0.1.5.tar.gz (9.6 MB view details)

Uploaded Source

Built Distribution

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

devmemory-0.1.5-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

Details for the file devmemory-0.1.5.tar.gz.

File metadata

  • Download URL: devmemory-0.1.5.tar.gz
  • Upload date:
  • Size: 9.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for devmemory-0.1.5.tar.gz
Algorithm Hash digest
SHA256 fe28a4352f01f15b1db709f7d6faa14f2173707593d7c645b055fafb99dee357
MD5 8ca4fddd824da81c61610f24abfaf8ad
BLAKE2b-256 f688a00c9a00f9312ac7cf9a0297c6dd7941cdb529e6b6e9bd67761e234b4057

See more details on using hashes here.

File details

Details for the file devmemory-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: devmemory-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 49.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for devmemory-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4fb127d601dc6fd2891c0a5af9fb441d7f2bd4c275fe1da0ecd82d70ccd9bc36
MD5 2a7a2d4102fb036ed9431560b804dccf
BLAKE2b-256 fa0bb9d7f389c07a904909eb0a3907f96a6ab7ab7437c6a1324ff59cf6268a54

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