Prerequisites
Python 3.12+
Basic Memory requires Python 3.12 or later
uv (recommended)
Fast Python package manager and project tool
just (optional)
Modern command runner for development tasks
Docker (optional)
Required for PostgreSQL integration tests
Installation
Development Commands
Basic Memory usesjust as a command runner. View all available commands:
Code Quality
Testing
- Quick Tests
- PostgreSQL Tests
- Selective Tests
- Coverage
Fast Development Loop
just fix- Auto-fix linting issuesjust format- Format code with ruffjust typecheck- Type check with pyrightjust testmon- Test only changed filesjust test-smoke- Fast MCP integration test
Database Migrations
Create a new database migration:src/basic_memory/alembic/versions/.
Migrations run automatically on startup:
Testing Architecture
Test Structure
Basic Memory has two test directories:- tests/ (Unit)
- test-int/ (Integration)
Unit tests - Fast, isolated, mockedCharacteristics:
- Test individual functions/classes
- Use mocks for dependencies
- Fast execution (< 1 second per test)
- Run with:
just test-unit-sqlite
Dual Backend Testing
All tests run against both SQLite and PostgreSQL:PostgreSQL tests use testcontainers to automatically spin up a PostgreSQL container. Docker must be running.
Test Markers
Tests use pytest markers for selective execution:Code Style Guidelines
Python Version
Python Version
Python 3.12+ required for:
- Type parameter syntax (
def func[T](...)) - Type aliases (
type MyType = str | int)
Formatting
Formatting
- Line length: 100 characters max
- Tool: ruff (replaces black, isort, flake8)
- Import order: standard lib → third-party → local
Naming Conventions
Naming Conventions
- Functions/variables:
snake_case - Classes:
PascalCase - Constants:
UPPER_SNAKE_CASE - Private members:
_leading_underscore
Type Annotations
Type Annotations
- Required for all public functions
- Use modern syntax:
list[str]notList[str] - Use
| NonenotOptional[T] - Document complex types with type aliases
Async Patterns
Async Patterns
- Prefer async/await throughout
- Use SQLAlchemy 2.0 async ORM
- Use
aiofilesfor file I/O - Use
asyncpgfor PostgreSQL
Debugging
Logging
Basic Memory uses Loguru for logging:MCP Inspector
Test MCP tools interactively:Doctor Command
Check file ↔ database consistency:Continuous Integration
CI runs on GitHub Actions:- ✅ All tests pass (SQLite and Postgres)
- ✅ Linting passes (
just lint) - ✅ Type checking passes (
just typecheck) - ✅ Code coverage ≥ target threshold
Contributing Workflow
Release Process
Basic Memory uses automatic versioning withuv-dynamic-versioning:
- Development Builds
- Beta Releases
- Stable Releases
Published automatically on every commit to
main:Resources
Architecture
Learn about the system architecture
Contributing Guide
Full contributing guidelines
GitHub Repository
View source code and issues
Discord Community
Get help and discuss development