Coding Standards & Best Practices
Universal coding standards applicable across all projects.
When to Activate
- Starting a new project or module
- Reviewing code for quality and maintainability
- Refactoring existing code to follow conventions
- Enforcing naming, formatting, or structural consistency
- Setting up linting, formatting, or type-checking rules
- Onboarding new contributors to coding conventions
Code Quality Principles
1. Readability First
- Code is read more than written
- Clear variable and function names
- Self-documenting code preferred over comments
- Consistent formatting
2. KISS (Keep It Simple, Stupid)
- Simplest solution that works
- Avoid over-engineering
- No premature optimization
- Easy to understand > clever code
3. DRY (Don't Repeat Yourself)
- Extract common logic into functions
- Create reusable components
- Share utilities across modules
- Avoid copy-paste programming
4. YAGNI (You Aren't Gonna Need It)
- Don't build features before they're needed
- Avoid speculative generality
- Add complexity only when required
- Start simple, refactor when needed
TypeScript/JavaScript Standards
Variable Naming
Function Naming
Immutability Pattern (CRITICAL)
Error Handling
Async/Await Best Practices
Type Safety
React Best Practices
Component Structure
Custom Hooks
State Management
Conditional Rendering
API Design Standards
REST API Conventions
Response Format
Input Validation
File Organization
Project Structure
File Naming
Comments & Documentation
When to Comment
JSDoc for Public APIs
Performance Best Practices
Memoization
Lazy Loading
Database Queries
Testing Standards
Test Structure (AAA Pattern)
Test Naming
Code Smell Detection
Watch for these anti-patterns:
1. Long Functions
2. Deep Nesting
3. Magic Numbers
Remember: Code quality is not negotiable. Clear, maintainable code enables rapid development and confident refactoring.


