This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
For comprehensive coding standards and patterns, see @AGENTS.md which contains detailed instructions for AI agents working in this codebase.
Tambo Cloud is a monorepo for the Tambo platform, an AI-powered agent system. The repository uses Turborepo for build orchestration and includes both frontend (Next.js) and backend (NestJS) applications, with shared packages for database access, utilities, and LLM integration.
npm run dev # Run API and web in dev mode (ports 3001/3000)
npm run build # Build all apps and packages
npm run lint # Lint all workspaces
npm run lint:fix # Lint with auto-fix
npm run check-types # TypeScript type checking across workspace
npm run format # Format code with Prettier
npm run prettier-check # Check formatting without changes
npm test # Run tests across all packagesnpm run db:generate # Generate migrations from schema changes
npm run db:migrate # Apply pending migrations
npm run db:check # Check migration status
npm run db:studio # Open Drizzle Studio for DB visualizationnpm run build:api # Build only the API app
npm run hydra-api:start # Start API in production mode# In apps/api
cd apps/api && npm test
# In packages/core
cd packages/core && npm test
# Run specific test file
cd apps/api && npm test -- threads.service.test.ts./scripts/tambo-setup.sh # Initial Docker setup
./scripts/tambo-start.sh # Start Docker stack
./scripts/init-database.sh # Initialize databaseDocker runs on alternate ports to avoid conflicts:
- Web: http://localhost:3210 (vs local:3000)
- API: http://localhost:3211 (vs local:3001)
- PostgreSQL: localhost:5433 (vs local:5432)
The repository follows a standard Turborepo pattern with apps and packages:
Applications (apps/)
apps/api- NestJS backend API server with OpenAPI/Swagger documentationapps/web- Next.js frontend with App Router, tRPC, and Shadcn UIapps/mcp-proxy- MCP (Model Context Protocol) proxy serviceapps/docs-mcp- Documentation MCP serverapps/test-mcp-server- Testing MCP server
Shared Packages (packages/)
packages/db- Drizzle ORM schema, migrations, and database operationspackages/core- Pure utilities with no database dependencies (validation, JSON, crypto, threading)packages/backend- LLM/agent-side helpers and streaming utilitiespackages/testing- Shared testing utilitiespackages/eslint-config- ESLint configurationspackages/typescript-config- TypeScript configurations
Frontend (apps/web)
- Next.js 15 (App Router)
- React 18
- tRPC for type-safe API calls
- Tailwind CSS + Shadcn UI components
- Next-Auth for authentication
- React Query for data fetching
- Geist fonts (Sans, Mono) and Sentient for headings
Backend (apps/api)
- NestJS with modular architecture
- OpenAPI/Swagger documentation at
/api - Class-validator for DTOs
- OpenTelemetry and Sentry for observability
- Helmet for security headers
Database
- PostgreSQL
- Drizzle ORM with TypeScript schema
- Schema source of truth:
packages/db/src/schema.ts
Observability
- Sentry for error tracking
- Langfuse for LLM observability
- OpenTelemetry for distributed tracing
The API follows NestJS modular patterns:
- Modules: Each domain has its own module (threads, projects, users, etc.)
- Controllers: Handle HTTP routing and validation
- Services: Contain business logic
- DTOs: Use class-validator for input validation
- Guards: Handle authentication and authorization
Key modules:
ai/- LLM integration and agent orchestrationthreads/- Message threads and conversation managementprojects/- Project/workspace managementusers/- User management and authenticationcommon/- Shared utilities, filters, guards, and interceptors
Entry point: apps/api/src/main.ts initializes Sentry, OpenTelemetry, Swagger, and global pipes/filters.
Next.js App Router structure:
app/- Route definitions with App Router conventions(authed)/- Protected routes requiring authentication(marketing)/- Public marketing pagesapi/- API route handlers (avoid creating new ones, use tRPC instead)
components/- Reusable React components (Shadcn UI)lib/- Client-side utilities and configurationshooks/- Custom React hooksproviders/- React context providerstrpc/- tRPC client and router setupstyles/- Global styles and Tailwind configuration
Important Patterns:
- Use tRPC for API calls, not REST endpoints
- Follow loading state patterns from devdocs/LOADING_STATES.md
- Follow naming conventions from devdocs/NAMING_CONVENTIONS.md
- Prefer named exports over default exports
- Use Skeleton components during loading states
- Schema:
src/schema.tsis the single source of truth - Migrations: Generated via
npm run db:generate, never hand-edited - Operations:
src/operations/contains reusable database queries - Type-safe: Full TypeScript types generated from schema
Pure utilities with no external dependencies:
async-queue.ts- Async queue implementationjson.ts- JSON utilitiesencrypt.ts- Encryption helpersemail.ts- Email validationllm-config-types.ts- LLM configuration types
Rule: This package must NOT depend on database or framework-specific code.
LLM and agent integration:
tambo-backend.ts- Main backend orchestrationservices/- LLM service implementationsprompt/- Prompt templates and utilitiesutil/- Backend-specific utilities
Required environment files:
apps/api/.env- API server configurationapps/web/.env.local- Web app configuration (use.env.exampleas template)packages/db/.env- Database connection stringdocker.env- Docker environment variables (created by setup script)
Key environment variables (see turbo.json for full list):
DATABASE_URL- PostgreSQL connection stringOPENAI_API_KEY- OpenAI API key for LLMNEXT_PUBLIC_TAMBO_API_KEY- API key for frontendNEXTAUTH_SECRET- NextAuth secret for sessionsLANGFUSE_*- Langfuse observability keysSENTRY_DSN- Sentry error tracking
- Read relevant code first (see AGENTS.md)
- Follow existing patterns and naming conventions
- Run type checks:
npm run check-types - Run linting:
npm run lint:fix - Run tests:
npm test - Test locally before committing
- Modify
packages/db/src/schema.ts - Generate migration:
npm run db:generate - Review generated SQL in
packages/db/migrations/ - Apply migration:
npm run db:migrate - Never manually edit generated migration files
- Create/update module in
apps/api/src/ - Define DTOs with class-validator
- Add controller method with Swagger decorators
- Implement service logic
- Update OpenAPI spec (auto-generated)
- Create components in
apps/web/components/ - Use tRPC for API calls (not REST endpoints)
- Follow loading state patterns (see devdocs/LOADING_STATES.md)
- Use Shadcn UI components
- Prefer server components when possible
All PRs must follow Conventional Commits:
<type>(scope): <description>
Examples:
feat(api): add transcript export endpointfix(web): prevent duplicate project creationchore(db): reorganize migration files
Types: feat, fix, perf, deps, revert, docs, style, chore, refactor, test, build, ci
Common scopes: api, web, core, db, deps, ci, config
Visual changes: Must include a short video demo (30-90s)
Before requesting review:
npm run lintpassesnpm run check-typespassesnpm testpasses- Tests added for new functionality
- Dependencies: Do not add/upgrade/remove dependencies or modify tool configs unless explicitly requested
- No Secrets: Never commit API keys, tokens, or credentials
- Database: Always use Drizzle migrations, never hand-edit SQL
- API Changes: TypeScript SDK is auto-generated by Stainless from OpenAPI spec
- Frontend API: Use tRPC, not new API route handlers in apps/web
- Testing: Add tests for public functions and new features
- Start dev servers:
npm run dev - Visit http://localhost:3000/dashboard
- Login and create a project
- Generate API key
- Add to
apps/web/.env.local:NEXT_PUBLIC_TAMBO_API_KEY=your_generated_key_here - Verify at http://localhost:3000/internal/smoketest
- AGENTS.md - Comprehensive coding guidelines
- CONTRIBUTING.md - PR process and requirements
- GETTING_STARTED.md - Setup instructions
- RELEASING.md - Release process
- devdocs/LOADING_STATES.md - Loading state patterns
- devdocs/NAMING_CONVENTIONS.md - React naming conventions
- DOCKER_README.md - Docker deployment guide
- Docs site: https://docs.tambo.co
- React SDK: https://github.com/tambo-ai/tambo
- Issue tracker: https://github.com/tambo-ai/tambo-cloud/issues