Code Quality & Validation Requirements¶
MANDATORY Validation Process¶
After making ANY code changes, ALWAYS run comprehensive validation on the entire codebase: npm run check.
Validation Scope¶
- Comprehensive Validation: Testing only modified areas is insufficient.
- Ripple Effects: Changes can have ripple effects across the codebase that must be caught before completion.
- Full Codebase Check: Always validate the entire codebase, not just changed files.
Repository State¶
- Treat existing uncommitted changes as intentional; never revert or overwrite them unless the user explicitly requests it.
- If unexpected differences appear while working, stop immediately and ask the user how to proceed.
- Document any assumptions made when working alongside pre-existing changes.
Build Failures¶
Acceptable Build Failures¶
- Build failures due to missing environment variables (like
AUTH_SECRETorDATABASE_URL) are acceptable during development when infrastructure hasn't been configured yet. - These failures should be documented and resolved before deployment.
Unacceptable Build Failures¶
- TypeScript errors are NEVER acceptable.
- Linting errors are NEVER acceptable.
- Import errors are NEVER acceptable.
- Missing dependencies are NEVER acceptable.
Code Quality Standards¶
TypeScript Quality¶
- Zero
anytypes allowed. - All types must be explicit and properly defined.
- No implicit
anytypes. - Proper null/undefined handling.
Code Style¶
- Follow ESLint rules configured in the project.
- Use Prettier for consistent formatting.
- Consistent naming conventions.
- Proper code organization.
Performance¶
- No unnecessary re-renders.
- Proper memoization where needed.
- Efficient data structures and algorithms.
- Optimized bundle size.
Continuous Integration¶
- All validation steps should pass in CI/CD pipeline.
- No skipping of validation steps.
- Fast feedback on code quality issues.
- Automated quality checks on every commit.
Quality Metrics¶
Code Metrics to Monitor¶
- Test coverage percentage (minimum 80%).
- TypeScript strict mode compliance.
- Linting error count (should be zero).
- Build success rate (should be 100%).
- Bundle size (monitor for increases).
Quality Gates¶
- Code must pass all quality gates before merge.
- No exceptions for "quick fixes" or "temporary code".
- Technical debt should be tracked and addressed.
Error Handling in Validation¶
- Validation errors should be clear and actionable.
- Provide context for why validation failed.
- Suggest fixes when possible.
- Document known issues and workarounds.