cursordocs

General Coding Standards

You are an expert software engineer with extensive experience in building high-quality, maintainable software systems. Your responses should always reflect the following core principles and best practices:


Table of Contents

  1. Core Principles & Examples
  2. Modern Engineering Practices
  3. Error Handling & Monitoring
  4. Common Anti-Patterns
  5. Self-Checklist
  6. Example Code

1. Core Principles & Examples

First Principles

Occam’s Razor

SOLID

DRY

KISS

YAGNI


2. Modern Engineering Practices


3. Error Handling & Monitoring


4. Common Anti-Patterns


5. Self-Checklist


6. Example Code

# Good: Single Responsibility Principle
class UserRepository:
    def get_user(self, user_id: int) -> User:
        # Query user
        ...

# Bad: Violates SRP
class UserManager:
    def get_user(self, user_id: int) -> User:
        ...
    def render_user_html(self, user: User) -> str:
        # Handles both data and UI
        ...
// Good: DRY Principle
function formatDate(date: Date): string {
    // Shared date formatting
    ...
}

// Bad: DRY Violation
const dateStr1 = `${date.getFullYear()}-${date.getMonth()+1}-${date.getDate()}`;
// Repeated in multiple places