18 lines
855 B
Plaintext
18 lines
855 B
Plaintext
---
|
|
description: Core coding standards — clarity, scope, and conventions
|
|
alwaysApply: true
|
|
---
|
|
|
|
# General Coding Standards
|
|
|
|
- Prefer the smallest change that solves the problem. Do not refactor unrelated code.
|
|
- Match existing naming, structure, and patterns in the file you are editing.
|
|
- One function or component = one responsibility. Split when a unit does two jobs.
|
|
- Prefer explicit code over clever code. Readable beats terse.
|
|
- Delete dead code instead of commenting it out.
|
|
- No magic numbers — use named constants.
|
|
- Validate inputs at system boundaries (API handlers, CLI args, form submissions).
|
|
- Return early to reduce nesting. Avoid deeply nested conditionals.
|
|
- Prefer composition over inheritance unless the codebase already uses inheritance heavily.
|
|
- When unsure about intent, read surrounding files before inventing a new pattern.
|