Instruction file imported from shweta-bavishi/forgeflow (
.github/instructions/coding-standards.instructions.md). Copyright stays with the author.
Coding Standards — Source File Instructions
These rules apply when generating, editing, or reviewing source code files.
Code Generation Rules
- Read before write: Always read at least 2-3 existing files in the same layer/directory to understand established patterns before generating new code.
- Match conventions exactly: Follow the project's naming, import style, error handling, and documentation patterns as detected from existing code and
otomate.config.yml. - No stubs or placeholders: Every generated file must be complete and production-ready. Never output
// TODO: implement thisfor core logic. - Full type safety: Include all type definitions, interfaces, and generics. No
anytypes unless justified. - Error handling is mandatory: Every service method must handle errors. Every controller must return proper HTTP status codes for error cases.
- JSDoc on public methods: Every public method and class must have JSDoc documentation with
@param,@returns, and@throwsannotations. - Input validation: Use framework-appropriate validation (class-validator decorators for NestJS, Pydantic for FastAPI, Bean Validation for Spring).
Naming Conventions (from config)
| Element | Convention | Example |
|---|---|---|
| Files | kebab-case | avatar-service.ts, user.entity.ts |
| Directories | kebab-case | src/user-service/, src/auth-guards/ |
| Classes | PascalCase | UserService, AvatarController |
| Functions | camelCase | getUserById, createAvatarUpload |
| Constants | UPPER_SNAKE_CASE | MAX_FILE_SIZE, DEFAULT_TIMEOUT |
| Interfaces | PascalCase | IUserRepository, UserCreateRequest |
| Variables | camelCase | userId, isActive |
Architecture Layer Rules
Dependencies flow downward only:
- Controllers → Services (allowed)
- Services → Repositories (allowed)
- Repositories → Entities (allowed)
- Controllers → Repositories (VIOLATION — always go through services)
- Services → Controllers (VIOLATION — reverse dependency)
Test Generation Rules
- Every new source file MUST have a corresponding test file matching
config.coding_standards.test_pattern. - Tests use Arrange-Act-Assert (AAA) pattern.
- Each test covers ONE behavior.
- Mock external dependencies (databases, APIs, file systems).
- Test naming: descriptive
it('should reject files larger than 5MB'), notit('test1'). - Cover: happy path, error cases, boundary conditions, edge cases.
Forbidden Patterns
console.login production code (use proper logger)debuggerstatements- Hardcoded secrets, tokens, or credentials
anytype without comment explaining why- Empty catch blocks
- Magic numbers without named constants
- Synchronous file I/O in async contexts