@@ -21,6 +21,8 @@ This file provides guidance to coding agents when working with code in this repo
2121- ` pnpm run db:seed:import ` - Import seed data for local development
2222- ` pnpm run db:migrate:make src/migration/MigrationName ` - Generate new migration based on entity changes
2323- ` pnpm run db:migrate:create src/migration/MigrationName ` - Create empty migration file
24+ - ** Never use raw SQL queries** (` con.query() ` ) - always use TypeORM repository methods or query builder
25+ - If raw SQL is absolutely necessary, explain the reason and ask for permission before implementing
2426
2527** Migration Generation:**
2628When adding or modifying entity columns, ** always generate a migration** using:
@@ -108,6 +110,7 @@ The migration generator compares entities against the local database schema. Ens
108110- Fixtures in ` __tests__/fixture/ ` for test data
109111- Mercurius integration testing for GraphQL endpoints
110112- Avoid creating multiple overlapping tests for the same scenario; a single test per key scenario is preferred
113+ - When evaluating response objects (GraphQL, API), prefer ` toEqual ` and ` toMatchObject ` over multiple ` expect().toBe() ` lines
111114
112115** Infrastructure Concerns:**
113116- OpenTelemetry for distributed tracing and metrics
@@ -131,6 +134,12 @@ The migration generator compares entities against the local database schema. Ens
131134- Extract repeated patterns into small inline helpers (e.g., ` const respond = (text) => ... ` )
132135- Combine related checks (e.g., ` if (!match || match.status !== X) ` instead of separate blocks)
133136
137+ ** Function style:**
138+ - Prefer const arrow functions over function declarations: ` const foo = () => {} ` instead of ` function foo() {} `
139+ - Prefer single props-style argument over multiple arguments: ` const foo = ({ a, b }) => {} ` instead of ` const foo = (a, b) => {} `
140+ - Don't extract single-use code into separate functions - keep logic inline where it's used
141+ - Only extract functions when the same logic is needed in multiple places
142+
134143** PubSub topics should be general-purpose:**
135144- Topics should contain only essential identifiers (e.g., ` { opportunityId, userId } ` )
136145- Subscribers fetch their own data - don't optimize topic payloads for specific consumers
@@ -142,6 +151,11 @@ The migration generator compares entities against the local database schema. Ens
142151- Example: Use ` 2 * ONE_DAY_IN_MINUTES ` instead of ` 2 * 24 * 60 `
143152- Add new constants to ` src/common/constants.ts ` if needed (they are re-exported from ` src/common/index.ts ` )
144153
154+ ** Type declarations:**
155+ - Only create separate exported types if they are used in multiple places
156+ - For single-use types, define them inline within the parent type
157+ - Example: Instead of ` export type FileData = {...}; type Flags = { file: FileData } ` , use ` type Flags = { file: { ... } } `
158+
145159## Best Practices & Lessons Learned
146160
147161** Avoiding Code Duplication:**
0 commit comments