Prerequisites
Before you start developing, ensure you have:- Python 3.12+ - Lerim requires Python 3.12 or higher
- Docker (optional) - For building and testing the Docker image
- uv (recommended) - Fast Python package installer and virtual environment manager
Lerim uses
uv for dependency management. While you can use pip, uv is significantly faster and is the recommended approach.Clone and set up the repository
Installing optional dependencies
Lerim has several optional dependency groups you can install based on what you’re working on:The embeddings extra includes
lancedb, pyarrow, torch, and transformers for vector search functionality.Running Lerim locally
Once installed, you can run Lerim commands directly:Initialize Lerim
~/.lerim/ and detects your coding agents.Alternative: Run as a service
Alternative: Run as a service
You can also run Lerim as an HTTP server:This starts the API server on
http://localhost:8765 and runs sync/maintain in the background.Building the Docker image
Lerim ships as a Docker image for production use. To build it locally:- Uses
python:3.12-slimas the base image - Installs
curlandripgrep - Installs Lerim from local source
- Exposes port 8765
- Runs
lerim serveas the entrypoint
Project structure overview
Understanding the codebase layout will help you navigate and contribute effectively:Key code locations
Adding adapters
Platform adapters live in
src/lerim/adapters/. See the dedicated guide for details.Memory schemas
Memory primitives (decisions, learnings, summaries) are defined in
src/lerim/memory/schemas.py.CLI commands
CLI entry points and command routing live in
src/lerim/app/cli.py.Agent logic
The PydanticAI lead agent orchestration is in
src/lerim/runtime/agent.py.Configuration layers
Lerim uses a layered TOML configuration system (low to high priority):src/lerim/config/default.toml- Shipped defaults~/.lerim/config.toml- User global overrides<repo>/.lerim/config.toml- Project-specific overridesLERIM_CONFIGenvironment variable - Explicit override path (used in CI/tests)
Coding style guidelines
Lerim follows strict coding conventions. The short version:- Minimal code - Prefer fewer functions, fewer layers, fewer lines
- Strict schemas - Use Pydantic models and enums for inputs and outputs
- Fail fast - No
try/exceptfallbacks for missing packages. If something is required, let it raise - Docstrings everywhere - Every file gets a top-level docstring. Every function gets a docstring
- Real tests - Prefer real-path tests over mocked tests
- No dead code - When you replace logic, remove the old path
- Config from TOML, keys from env - Runtime config comes from TOML layers. Only API keys use environment variables
Full coding rules are documented in
docs/simple-coding-rules.md in the repository.Linting before you commit
Always run the linter before submitting a PR:Next steps
Running tests
Learn how to run the test suite and write new tests
Adding adapters
Step-by-step guide for adding support for new coding agents