CLAUDE.md - Development Guidelines
๐ Core development standards and autonomous working principles for this monorepo
๐ฏ Autonomous Working Principles
Work boldly and confidently without hesitation. Institute best practices immediately. Act decisively on:
- Refactoring: Convert to async/await, eliminate dead code, modernize patterns
- Architecture: Apply clean architecture, DDD, and dependency injection
- Security: Strengthen validation, enforce strict TypeScript, implement safeguards
- Testing: Add/refactor tests with modern frameworks (Vitest/Jest)
- Quality: Auto-fix linting, use modern abstractions, prefer clear code over TODOs
โ Finishing Rules
- No TODOs: Resolve or remove them entirely
- Pass all checks: Ensure linting, type-checking, and tests pass
- Self-documenting code: Prioritize clarity over verbose documentation
๐๏ธ Repository Structure
NX Monorepo with two main directories:
- apps/ - Backend services (datastream, orderbook, relayer, sequencer, etc.)
- libs/ - Shared libraries (commons-ts, connections-ts, tools, risk, etc.)
๐ง Core Tools & Standards
Package Manager
Yarn โฅ4.0.0 (never npm/pnpm)
Code Style
- TypeScript with ESM modules (
"type": "module"
) - 2 spaces, 120 char width, double quotes
- Biome + Prettier for formatting
- Zod schemas for validation
- Service architecture with dependency injection
Key Principles
- Early returns over nested conditions
- Descriptive names (prefix handlers with "handle")
- Functional/immutable style when possible
- Minimal changes - only modify what's needed
๐ ๏ธ Essential Commands
NX Workspace
nx show projects # List all projects
nx build <project> # Build specific project
nx test <project> # Test specific project
nx affected -t build # Build affected projects
Common Operations
yarn nx:build # Build all
yarn nx:lint # Lint all
yarn nx:test # Test all
yarn validate # Full validation
Docker Testing
๐ Naming Conventions
- PascalCase: Interfaces (
IService
), Types (UserType
) - camelCase: Variables, functions, methods
- kebab-case: Files (
base.service.ts
) - Tests:
.spec.ts
(unit),.test.ts
(integration)
๐ Security Standards
- Never commit secrets - use environment variables
- Validate all inputs with proper type checking
- Follow least privilege for service accounts
- Use encrypted storage for sensitive state
๐งช Testing Approach
- Vitest for modern testing
- Tenderly for blockchain testing (not Anvil)
- Mock services using
vi.fn()
patterns - Comprehensive coverage for new/modified code
๐ฆ Publishing (GitHub Packages)
yarn publish:commons # Patch version
yarn publish:commons:minor # Minor version
yarn publish:commons:major # Major version
๐ Development Workflow
- Understand the architecture before making changes
- Follow conventions from existing codebase
- Use available libraries - don't reinvent
- Test thoroughly with proper mocks
- Validate with linting and type checking
- Document complex logic only when necessary
๐ง Build System
Standardized targets across all projects:
- build: Main build target
- typecheck: Strict type checking
- validate: Full validation (lint + test + build)
- build:retry: For flaky builds
For flaky builds: nx run [project]:build:retry
๐ฏ File Creation Policy
- Prefer editing existing files over creating new ones
- Never create documentation files unless explicitly requested
- Clean up temporary files after use
- Focus changes only on task-related sections
๐ก Detailed documentation: See CLAUDE.local.md for comprehensive guides on infrastructure, troubleshooting, and advanced configurations.