SKILL.md--- name: backend-dev-guidelines description: Comprehensive backend development guide for Node.js/Express/TypeScript microservices. Use when creating routes, controllers, services, repositories, middleware, or working with Express APIs, Prisma database access, Sentry error tracking, Zod validation, unifiedConfig, dependency injection, or async patterns. Covers layered architecture (routes → controllers → services → repositories), BaseController pattern, error handling, performance monitoring, testing strategies, and migration from legacy patterns. --- # Backend Development Guidelines ## Purpose Establish consistency and best practices across backend services using modern Node.js/Express/TypeScript patterns. Written for Node.js/Express/TypeScript with Prisma and Sentry. Different stack? Adapt the architectural principles - see CLAUDE_INTEGRATION_GUIDE.md in the repo root. ## When to Use This Skill Automatically activates when working on: - Creating or modifying routes, endpoints, APIs - Building controllers, services, repositories - Implementing middleware (auth, validation, error handling) - Database operations with Prisma - Error tracking with Sentry - Input validation with Zod - Configuration management - Backend testing and refactoring --- ## Quick Start ### New Backend Feature Checklist - [ ] **Route**: Clean definition, delegate to controller - [ ] **Controller**: Extend BaseController - [ ] **Service**: Business logic with DI - [ ] **Repository**: Database access (if complex) - [ ] **Validation**: Zod schema - [ ] **Sentry**: Error tracking - [ ] **Tests**: Unit + integration tests - [ ] **Config**: Use unifiedConfig ### New Microservice Checklist - [ ] Directory structure (see [architecture-overview.md](architecture-overview.md)) - [ ] instrument.ts for Sentry - [ ] unifiedConfig setup - [ ] BaseController class - [ ] Middleware stack - [ ] Error boundary - [ ] Testing framework --- ## Architecture Overview ### Layered Architecture ``` HTTP Request ↓ Routes (routing only) ↓ Controllers (request handling) ↓ Services (business logic) ↓ Repositories (data access) ↓ Database (Prisma) ``` **Key Principle:** Each layer has ONE responsibility. See [architecture-overview.md](architecture-overview.md) for complete details. --- ## Directory Structure ``` service/src/ ├── config/ # UnifiedConfig ├── controllers/ # Request handlers ├── services/ # Business logic ├── repositories/ # Data access ├── routes/ # Route definitions ├── middleware/ # Express middleware ├── types/ # TypeScript types ├── validators/ # Zod schemas ├── utils/ # Utilities ├── tests/ # Tests ├── instrument.ts # Sentry (FIRST IMPORT) ├── app.ts # Express setup └── server.ts # HTTP server ``` **Naming Conventions:** - Controllers: `PascalCase` - `UserController.ts` - Services: `camelCase` - `userService.ts` - Routes: `camelCase + Routes` - `userRoutes.ts` - Repositories: `PascalCase +