Code Style and Standards
Python Version and Syntax
Memori requires Python 3.10+ and uses modern Python features:Formatting with Ruff
We use Ruff for formatting and linting: Configuration (inpyproject.toml):
Line Length
Maximum line length: 88 characters (Black-compatible)Import Organization
Ruff automatically organizes imports:Type Hints
All public APIs must have type hints:Docstrings
Public APIs require docstrings:Comments
Minimize comments - prefer self-documenting code:Testing Guidelines
Test Coverage Requirements
- New features: >80% coverage
- Bug fixes: Add test reproducing the bug
- Critical paths (memory recall, LLM integration): >95% coverage
Unit Tests
Fast tests using mocks, no external dependencies:Integration Tests
Tests with real databases and LLM APIs:Test Organization
Pytest Markers
Pull Request Guidelines
PR Title Format
Use Conventional Commits format:feat:- New featurefix:- Bug fixdocs:- Documentation changesperf:- Performance improvementsrefactor:- Code refactoring (no behavior change)test:- Add or update testschore:- Maintenance tasksci:- CI/CD changes
PR Description Template
PR Size Guidelines
Keep PRs focused and manageable
Keep PRs focused and manageable
Ideal PR sizes:
- Small (under 100 lines): Bug fixes, documentation updates
- Medium (100-500 lines): New features, refactoring
- Large (500-1000 lines): Major features (consider breaking up)
- Extra Large (over 1000 lines): Avoid if possible - break into smaller PRs
- Break into smaller, logical PRs
- Submit infrastructure changes first
- Add features incrementally
- Keep refactoring separate from new features
Review Process
CI checks
Automated checks must pass:
- Tests (unit and integration)
- Linting (Ruff)
- Type checking
- Security scans (Bandit, pip-audit)
CHANGELOG Updates
Add an entry toCHANGELOG.md under the “Unreleased” section:
Added- New featuresChanged- Changes to existing functionalityDeprecated- Soon-to-be removed featuresRemoved- Removed featuresFixed- Bug fixesSecurity- Security improvements
Commit Guidelines
Commit Message Format
- Header:
<type>: <short description>(max 72 chars) - Body: Detailed explanation (optional)
- Footer: Issue references, breaking changes
Atomic Commits
Keep commits focused and atomic:Breaking Changes
Identifying Breaking Changes
A breaking change is any modification that requires users to change their code:- Removing or renaming public APIs
- Changing function signatures
- Modifying default behavior
- Updating minimum version requirements
Documenting Breaking Changes
-
Update documentation:
- Mark as deprecated in docstrings
- Provide migration guide
- Maintain for at least one major version
- Remove in next major version
Security Guidelines
Handling Sensitive Data
API Keys and Secrets
Dependency Security
Documentation Guidelines
Code Examples
Provide complete, runnable examples:README Updates
When adding new features:- Update feature list
- Add example usage
- Update installation instructions (if needed)
- Add to table of contents
API Documentation
Document all public APIs:Benchmarking Changes
Best Practices Checklist
Before submitting your PR:- Code follows PEP 8 and project style guidelines
- All functions have type hints
- Public APIs have docstrings
- Code is self-documenting (minimal comments)
- Unit tests added for new functionality
- Integration tests added (if applicable)
- All tests pass locally
- Test coverage >80% for new code
- CHANGELOG.md updated
- Documentation updated (if needed)
- Pre-commit hooks pass
- Security scans pass (Bandit, pip-audit)
- No hardcoded secrets or sensitive data
- Breaking changes documented with migration guide
- Commits are atomic and well-described
- PR description is clear and complete
Getting Help
Need clarification on guidelines?Discord
Ask questions in the #contributors channel
GitHub Discussions
Start a discussion for design questions
Code Review
Tag maintainers in your PR for feedback
Contact the team directly
Next Steps
Development Setup
Set up your development environment
Overview
Back to contributing overview
Submit PR
Create a pull request
View Issues
Find issues to work on
Thank you for contributing to Memori! Your efforts help make AI memory accessible to everyone. 🚀