Git-native project memory for AI coding assistants
Membase is a simple, git-friendly project memory system that helps AI coding assistants (like Claude Code) maintain context across sessions. It stores decisions, implementation details, and gotchas in plain text files that version naturally with your code.
When working with AI coding assistants across multiple sessions, important context gets lost:
- 🤔 "Why did we choose PostgreSQL over MySQL?"
- 🔄 "We already decided on JWT auth, but the AI doesn't remember"
- 🐛 "This bug was fixed before, but the solution isn't documented"
- 🎨 "What naming conventions did we establish?"
Without persistent memory, you waste time:
- Re-explaining decisions
- Re-solving problems
- Making inconsistent choices
- Searching through git history
Membase provides persistent, queryable memory that:
✅ Lives in git - No databases, no sync issues, just text files ✅ Merges cleanly - JSONL format prevents merge conflicts ✅ Tags intelligently - Multi-dimensional organization (topic × phase) ✅ Queries fast - Find relevant context in milliseconds ✅ Stays simple - Single Python script, zero dependencies
Traditional approaches use SQLite or large JSON files that create merge conflicts. Membase uses:
- JSONL format - One memory per line, independent changes merge cleanly
- UUID sorting - Changes spread across file, reducing conflicts
- Separate schema - Dimension changes don't conflict with data changes
- No gitignore - Everything is committed, no hidden state
Organize memories by topic (what area) and phase (what stage):
topic=authentication phase=decision → "Why JWT?"
topic=authentication phase=implementation → "Where's the code?"
topic=authentication phase=troubleshooting → "Known issues?"
Query precisely: "Show me all database decisions" or "Find API troubleshooting notes"
Membase helps AI assistants:
- Query before implementing - Check existing decisions
- Store after deciding - Remember for next time
- Maintain consistency - Follow established patterns
- Learn from gotchas - Don't repeat mistakes
No installation needed! Just copy the script:
# Clone this repo or copy scripts/mb to your project
curl -o scripts/mb https://raw.githubusercontent.com/gingertom/Membase/main/scripts/mb
chmod +x scripts/mbRequirements: Python 3.7+ (uses only standard library)
scripts/mb initCreates .membase/ directory with:
schema.json- Dimension definitionsmemories.jsonl- Memory storage
Define areas relevant to your project:
scripts/mb dims add topic authentication
scripts/mb dims add topic database
scripts/mb dims add topic apiscripts/mb add \
-s "Using JWT for authentication" \
-c "Chose JWT over sessions for stateless API. 24h expiry, refresh tokens for 7 days. Stored in HTTP-only cookies." \
topic=authentication phase=decision# What did we decide about authentication?
scripts/mb query --topic authentication --phase decision
# Search for specific details
scripts/mb query --search "JWT"
# See everything
scripts/mb query --allgit add .membase/
git commit -m "Document authentication decision"
git pushTeam members automatically get the context when they pull!
# By dimension
scripts/mb query --topic database --phase decision
# Full-text search
scripts/mb query --search "PostgreSQL"
# By ID prefix
scripts/mb query --id abc123
# JSON output for scripting
scripts/mb query --all --json- ≤5 results → Shows full details automatically
- >5 results → Shows brief summaries (ID + tags + summary)
- Override with
--fullor--brief
$ scripts/mb add -s "Test" -c "..." topik=api phase=decision
✗ Unknown dimension 'topik'. Did you mean: topic?
$ scripts/mb add -s "Test" -c "..." topic=api phase=decission
✗ Unknown value 'decission' for dimension 'phase'. Did you mean: decision?Default dimensions:
- topic - Project-specific areas (you define: authentication, database, api, etc.)
- phase - Workflow stage (pre-populated):
decision- Architectural/design decisionsbackend-implementation- Backend code detailsfrontend-implementation- Frontend code detailstroubleshooting- Known issues and solutionsplanning,requirements,testing,documentation,deployment
Custom dimensions:
scripts/mb dims add-dim priority "Task priority"
scripts/mb dims add priority high
scripts/mb dims add priority critical$ scripts/mb stats
Total memories: 12
phase:
decision: 5
backend-implementation: 4
troubleshooting: 3
topic:
authentication: 4
database: 5
api: 3Session start:
scripts/mb query --all --limit 5 # What was I working on?
scripts/mb query --topic <area> # Context for today's workDuring development:
scripts/mb query --topic <area> --phase decision # Check decisions
scripts/mb add -s "..." -c "..." <tags> # Store new contextCode review:
scripts/mb query --topic <pr-area> # Check if decision is documentedMembase includes a skill file (SKILL.md) that teaches Claude Code to:
- Query proactively - Check for existing decisions before implementing
- Store automatically - Suggest storing decisions after they're made
- Maintain consistency - Reference stored context when relevant
- Update when needed - Keep memories current as projects evolve
See SKILL.md for Claude Code integration details.
scripts/mb add \
-s "Microservices architecture with event bus" \
-c "Moving to microservices. Services communicate via RabbitMQ event bus. Each service has its own database (no shared DB). API gateway handles routing and auth. Chose this for independent scaling and deployment." \
topic=architecture phase=decisionscripts/mb add \
-s "User service in services/user/" \
-c "User service handles: registration, login, profile updates. Database: PostgreSQL. API: REST on port 8001. Auth: JWT validation via shared secret. Dockerfile for containerization." \
topic=backend phase=backend-implementationscripts/mb add \
-s "Fix: Database connection pool exhaustion" \
-c "Issue: App crashed under load due to connection pool exhaustion. Solution: Increased pool size from 10 to 50, added connection timeout of 30s. Monitor with pg_stat_activity. File: src/database.py:15" \
topic=database phase=troubleshootingscripts/mb add \
-s "API rate limiting: 100 req/min per user" \
-c "Product requirement: Rate limit API to 100 requests per minute per authenticated user. Return 429 with Retry-After header. Admin users exempt from limits." \
topic=api phase=requirementsyour-project/
├── .membase/
│ ├── schema.json # Dimensions and allowed values
│ └── memories.jsonl # One memory per line, sorted by UUID
└── scripts/
└── mb # The membase CLI tool
scripts/mb init # Initialize .membase/
scripts/mb add -s "summary" -c "content" <tags> # Add memory
scripts/mb query [--topic X] [--phase Y] # Query memories
scripts/mb query --search "keyword" # Full-text search
scripts/mb stats # Show statisticsscripts/mb dims # List dimensions
scripts/mb dims add <dimension> <value> # Add value to dimension
scripts/mb edit <id> -s "new summary" # Edit memory
scripts/mb delete <id> # Delete memorySee REFERENCE.md for complete command reference and advanced usage.
- SKILL.md - Concise guide for Claude Code integration
- REFERENCE.md - Comprehensive reference with examples and advanced usage
# Make changes and store context
scripts/mb add -s "..." -c "..." <tags>
# Commit together with code
git add .membase/ src/
git commit -m "Add authentication + document decision"
git push# Pull changes from team
git pull # Automatically merges memories
# If conflicts, accept both (different memories)
# File auto-sorts, so merge both changes
# Review team's decisions
scripts/mb query --all --limit 10Memories stay with the code:
git checkout -b feature/payments
scripts/mb add -s "Stripe integration" -c "..." topic=payments phase=decision
git commit -am "Add payments feature + decision"
git push
# PR reviewers see both code AND context
# When merged, memory comes with the feature- No database - Just text files
- No dependencies - Pure Python standard library
- No configuration - Sensible defaults
- No network - Everything is local and in git
- Commit everything -
.membase/is part of the project - Merge-friendly - JSONL format handles concurrent changes
- Version control - Full history in git
- Team-ready - Shared context across all contributors
- Queryable - Fast, precise context retrieval
- Taggable - Multi-dimensional organization
- Discoverable - Search finds relevant context
- Maintainable - Edit and delete outdated info
Q: Why not just use git commit messages? A: Commit messages are chronological and hard to query. "Show me all database decisions" is instant with membase, impossible with git log.
Q: Why not use a wiki or Notion? A: External tools require syncing and don't version with code. Membase lives in the repo and merges naturally.
Q: Why not SQLite? A: SQLite binaries don't merge. Two developers can't add memories concurrently without conflicts. JSONL merges cleanly.
Q: How big can it get? A: Suitable for hundreds to thousands of memories. For very large projects, archive old memories to a separate file.
Q: Does it work with other AI assistants? A: Yes! The CLI works with any AI. The SKILL.md file is Claude Code-specific, but the concept applies to any assistant.
Q: Can I use it without AI? A: Absolutely! It's useful for personal knowledge management and team documentation.
See REFERENCE.md for detailed examples including:
- API design decisions
- Database schema documentation
- Troubleshooting discoveries
- Frontend patterns
- Deployment configurations
- Team workflows
- Scripting with membase
This is a personal project, but suggestions and improvements are welcome! File an issue or submit a PR.
MIT License - use freely in your projects.
Created to solve the "context loss" problem when working with AI coding assistants across multiple sessions.
Remember: Store decisions, query before implementing, keep context alive across sessions.