Thank you for your interest in contributing to mainloop! This document provides guidelines for contributing to the project.
-
Fork the repository and clone it locally
-
Set up your environment:
cp .env.example .env # Edit .env with your configuration make dev # Start local development environment
Authenticate the current Claude integration with
make setup-claude-credsonly when exercising live-agent paths.
-
Create a new branch for your changes:
git checkout -b feature/your-feature-name
-
Make your changes following the project conventions (see Code Style below)
-
Test your changes locally:
make dev # Ensure everything works -
Commit your changes with clear, descriptive commit messages
-
Push to your fork and create a Pull Request
- Use Python 3.13+ features and type hints
- Use
uvfor dependency management (uv add <package>) - Never manually edit
pyproject.tomldependencies - Follow existing patterns in the codebase
- Use Pydantic models for all data validation
- Import shared models from the
models/package
- Use Svelte 5 runes:
$state,$derived,$effect,$props - Follow mobile-first responsive design patterns
- Use the shared theme from
@mainloop/ui/theme.css - Use
$lib/api.tsfor API calls - never hardcode endpoints - Type everything with TypeScript
- Mobile-first: Design for mobile, enhance for desktop
- Delete old code: Don't keep unused code for backward compatibility
- Avoid over-engineering: Keep solutions simple and focused
- Use Makefile targets: Always run
makecommands from repo root
mainloop/
├── backend/ # Python FastAPI + DBOS workflows
├── frontend/ # SvelteKit + Tailwind v4
├── models/ # Shared Pydantic models
├── packages/ui/ # Design tokens + theme
└── k8s/ # Kubernetes manifests
# Start all services with hot reload
make dev
# Backend development
cd backend
uv run mainloop # Run server
uv add <package> # Add dependency
# Frontend development
cd frontend
pnpm dev # Dev server
pnpm check # Type check
- Use Pydantic models from
models/package for data validation - Use DBOS workflows for durable task execution (see
docs/DBOS.md) - Import shared models:
from models import Conversation, Message
- Import theme:
@import '@mainloop/ui/theme.css'in app.css - Use stores in
$lib/stores/for state management - API calls go through
$lib/api.ts
When modifying DBOS workflows:
- Bump
WORKFLOW_VERSIONindbos_config.pywhen changing workflow logic - DBOS replays workflows from checkpoints - changing step order/logic breaks running workflows
- Current version tracked in workflow config
Use these commands for the project's CI checks. The capped backend command has
passed on a Linux amd64 development host; gVisor/arm64 workspace qualification of
make test-backend is pending.
# Backend dependency sync (bounded, locked)
make install-backend
# Offline backend and disposable PostgreSQL (60 seconds/test, 9 minutes/suite)
dev-postgres run make test-backend
# Frontend dependency install
pnpm --version
make install-frontend
# Frontend type/diagnostic check
pnpm check
# Frontend unit tests (lib)
make test-frontend
# Lint
make lintAfter dependency setup, dev-postgres run make check runs the complete offline
check set inside dev-postgres's command budget (515 seconds with an image that
predates deadline export), plus up to 30 seconds for cleanup. See the
foreground deadline table for
per-command caps, network retry limits and timeout diagnostics.
- Keep PRs focused: One feature or fix per PR
- Write clear descriptions: Explain what and why
- Update documentation: If you change behavior, update docs
- Test thoroughly: Ensure local dev environment works
- Follow existing patterns: Match the style of surrounding code
- Check existing issues and discussions
- Read the documentation in
docs/ - See
AGENTS.mdfor repository-wide development guidance
By contributing, you agree that your contributions will be licensed under the same Sustainable Use License as the project.