- Tech Stack: [Node.js 22 or higher, TypeScript 5.x, Next.js 15, Tailwind]
- Architecture: [Clean Architecture / Modular Monolith]
- Environment: Production
Implement the requested change with:
- Minimum code changes
- Maximum correctness
- Maximum reuse of existing code
- Minimum token consumption
- Zero architectural degradation
When tradeoffs exist, follow this order:
- Correctness
- Existing Architecture
- Existing Conventions
- Simplicity
- Token Efficiency
- New Abstractions
Never sacrifice higher priorities for lower ones.
Before writing code:
- Identify the exact files that require modification.
- Trace the execution flow affected by the request.
- Determine the smallest possible implementation.
- Reuse existing services, utilities, hooks, repositories, and components whenever possible.
- Do not introduce abstractions unless duplication already exists or is clearly imminent.
- Modify only files directly involved in the request.
- Show only changed sections whenever possible.
- Preserve untouched code.
- Avoid repeating existing code for context.
- Avoid verbose explanations.
- Rewriting entire files unnecessarily.
- Reformatting unrelated code.
- Renaming symbols without necessity.
- Moving files without necessity.
- Generating large code blocks for small changes.
- Bypassing service layers.
- Bypassing repositories.
- Duplicating business logic.
- Introducing hidden side effects.
- Mixing infrastructure concerns with domain logic.
- Respect existing architectural boundaries.
- Keep dependency direction unchanged.
- Maintain separation of concerns.
- Strict typing.
- No implicit any.
- Explicit return types for public APIs.
- Exhaustive handling of discriminated unions.
- Proper null/undefined handling.
- any
- @ts-ignore
- @ts-expect-error without justification
- Unsafe type assertions
Before adding a dependency:
- Verify the feature cannot be implemented with existing dependencies.
- Verify the runtime benefit outweighs maintenance cost.
- Prefer platform-native APIs.
Never introduce a package that duplicates existing functionality.
If test infrastructure exists:
- Run impacted tests.
- Run type checking.
- Run linting when available.
Suggested order:
npm run test
npm run typecheck
npm run lintIf failures occur:
- Analyze root cause.
- Fix code.
- Re-run validations.
Never modify tests merely to make failures disappear unless the request explicitly requires updating test behavior.
A task is complete only when:
- Requested behavior is implemented.
- Existing behavior remains unchanged.
- Type checks pass.
- Relevant tests pass.
- No architectural rules were violated.
- No dead code remains.
- No unnecessary dependencies were introduced.
Unless explicitly requested otherwise:
- Return only the necessary code changes.
- Do not provide tutorials.
- Do not explain obvious code.
- Do not generate implementation alternatives.
- Do not include marketing-style commentary.
Be concise, precise, and implementation-focused.