CLAUDE.md#
This file provides guidance to coding agents when working with code in this repository.
Build & Development Commands#
# Install dependencies
poetry install
# Run unit tests
make test-unit
# Or directly:
poetry run pytest tests/
# Run a single test file
poetry run pytest tests/path_to_my_test_file.py
# Run tests with print output
poetry run pytest -s tests/
# Run tests in watch mode
poetry run ptw . -v tests/path/to/test.py
# Run integration tests (requires Docker)
make test-integration
# Or if services are running locally:
poetry run pytest tests/integration
# Linting (runs pre-commit on changed files)
make lint
# Manual formatting/linting
poetry run ruff check .
poetry run black .
# Type checking
poetry run mypy <module>
# Update snapshot tests
make test-update-snapshots
Docker Development#
# Build and start all services
make all-up
# Lightweight agent development (less resource-intensive)
make agent-up
# Interactive shell in dev container
make ipython # or: make bash
# Start specific services
make public-api-up
make search-up
Architecture Overview#
This is a Python backend monolith for Dosu, an AI assistant that monitors GitHub, Slack, Linear, and other platforms to help with knowledge management and thread intelligence.
Core Directories#
| Directory | Purpose |
|---|---|
| core/ | Shared infrastructure - database clients, AI/LLM integration, external service integrations (GitHub, Slack, Notion, etc.), utilities |
| agent/ | Agent system - workflows, tasks, tools, retrieval logic |
| workflows/ | DBOS durable workflows for agent orchestration |
| api/ | Internal API - GitHub/Slack event handling, publishing responses |
| public_api/ | Public REST API - chat, docs, answers, OAuth, webhooks |
| internal/ | Internal-only APIs - DBOS workflow endpoints, event handlers |
| cloudfunctions/ | Webhook handlers (GitHub, Linear, Billing, Slack) |
| data_syncing/ | Background data sync (GitHub, Confluence, Notion, Slack, etc.) |
| search/ | Search service (FastAPI) with semantic and full-text search |
Application Entry Points#
- Internal API:
api/main.py- Main FastAPI app for event handling - Public API:
public_api/main.py- Public-facing REST endpoints - Internal API:
internal/main.py- DBOS workflows and internal endpoints - Search:
search/main.py- Standalone search service
Key Patterns#
Event Flow: External webhook -> CloudFunction -> DBOS Queue -> Pub/Sub -> Agent Router -> Workflow -> Publish response
Workflow Composition: Workflows use pipe operator composition:
PreliminaryChecks() | Ack() | OrchestrateWorkflow()
Database: Supabase PostgreSQL with Row-Level Security (RLS). Use Engine.begin_as_user() for user-scoped queries.
Vector Search: LanceDB for semantic search over documents.
Module Dependencies: Enforced via tach.toml. Key allowed dependencies:
agentdepends oncore,workflowsworkflowsdepends oncore,api,search,data_syncingpublic_apidepends oncore,agent,workflows,data_syncing
Test Organization#
tests/- Unit tests (run by default with pytest)tests/integration/- Integration tests (excluded by default, run explicitly)tests/e2e/- End-to-end tests (excluded by default)
Integration and E2E tests require explicit paths: poetry run pytest tests/integration
Configuration#
Environment files loaded in order: .env -> .env.development -> .env.development.local
Key config in core/config.py and core/base_config.py.