Thank you for your interest in contributing to Cortex! This guide will help you get started.
- Go 1.24 or later
- CGO enabled (required for SQLite)
- Git
# Clone the repository
git clone https://github.com/petal-labs/cortex.git
cd cortex
# Install dependencies
go mod download
# Build
go build -o cortex ./cmd/cortex
# Run tests
go test ./...cortex/
├── cmd/cortex/ # CLI entrypoint
├── internal/
│ ├── cmd/ # CLI commands
│ ├── config/ # Configuration loading
│ ├── context/ # Workflow context engine
│ ├── conversation/ # Conversation memory engine
│ ├── dashboard/ # Web dashboard
│ ├── embedding/ # Embedding providers
│ ├── entity/ # Entity memory engine
│ ├── gc/ # Garbage collection
│ ├── knowledge/ # Knowledge store engine
│ ├── observability/ # Metrics and logging
│ ├── server/ # MCP server
│ ├── storage/ # Storage backends (SQLite, pgvector)
│ ├── summarization/ # Conversation summarization
│ └── tui/ # Terminal UI
└── pkg/types/ # Shared types
- Search existing issues to avoid duplicates
- Use the bug report template
- Include version, OS, CPU architecture, and relevant logs
- Provide steps to reproduce the issue
- Search existing issues and discussions first
- Use the feature request template
- Explain the problem you're trying to solve
- Describe your proposed solution
- Fork the repository
- Create a feature branch from
main - Make your changes
- Add or update tests as needed
- Ensure all tests pass
- Submit a pull request
- Follow standard Go conventions and idioms
- Run
gofmtandgoimportsbefore committing - Use meaningful variable and function names
- Keep functions focused and reasonably sized
# Format code
gofmt -w .
goimports -w .
# Run linter
golangci-lint run- Write unit tests for new functionality
- Maintain or improve code coverage
- Tests should be deterministic and fast
# Run all tests
go test ./...
# Run tests with coverage
go test -race -coverprofile=coverage.out ./...
# View coverage report
go tool cover -html=coverage.outFollow Conventional Commits:
type(scope): description
[optional body]
[optional footer]
Types:
feat- New featurefix- Bug fixdocs- Documentation onlystyle- Formatting, no code changerefactor- Code restructuringperf- Performance improvementtest- Adding or updating testsci- CI/CD changeschore- Maintenance tasks
Examples:
feat(knowledge): add semantic chunking strategy
fix(storage): handle nil pointer in pgvector query
docs: update installation instructions
- Fill out the PR template completely
- Link related issues using "Fixes #123" or "Relates to #123"
- Ensure CI checks pass (tests, lint, security scan)
- Request review from maintainers
- Address review feedback
- Squash commits if requested
feature/description- New featuresfix/description- Bug fixesdocs/description- Documentation updatesrefactor/description- Code refactoring
Cortex supports two storage backends:
- SQLite + sqlite-vec - Default, zero-configuration, suitable for single-node
- PostgreSQL + pgvector - Production-scale, requires external database
When adding storage features, implement for both backends.
The four memory primitives share common patterns:
- Each has an engine in
internal/{primitive}/ - Storage operations go through
internal/storage/ - MCP tools are registered in
internal/server/mcp.go - CLI commands are in
internal/cmd/
# SQLite (default)
go test ./...
# PostgreSQL (requires running instance)
DATABASE_URL=postgres://localhost:5432/cortex_test go test ./...- Check the README for usage documentation
- Search existing issues
- Open a new issue for bugs or feature requests
By contributing, you agree that your contributions will be licensed under the MIT License.