Review all changed or newly added code in this repository for code style and quality issues. Check both staged and unstaged changes.
Rules
Naming & Structure
- Meaningful, consistent names. Use the same name for the same concept everywhere. Make a variable name pronounceable and searchable.
- Single Responsibility. Give each module and function one reason to change.
- Depend on abstractions. Use DI tags and interfaces, not concrete implementations.
Code Quality
- No duplicated code. Extract similar code that runs in the same calling context.
- Avoid deep nesting. Keep conditional nesting to three levels. Refactor with an early return or an extraction.
- Short parameter lists. More than three or four parameters asks for an options object.
- Self-documenting code. Express intent through a name or a structure before you write a comment.
Comments
When a comment may exist:
- Write a comment only for what the code cannot show: a constraint, an invariant, a reason, an upstream or browser bug, a non-obvious order of operations.
- Do not narrate the next line. Do not restate a name that the code already carries.
- Do not record process history, for example "previously" or "per review feedback". Git history owns that. A regression test may state the bug it pins, in one sentence.
- Write one concrete action in a
TODO. Add the issue number when one exists: TODO(#2463).
/// is the public API reference. builddocs publishes it into docs/api. Keep every fact in it accurate.
How a comment reads (adapted from ASD-STE100, Simplified Technical English):
- Give one idea to one sentence. Keep a sentence to 25 words or fewer.
- Use the active voice and the present tense. Use the imperative for an instruction.
- Do not use an em dash. Use a period, a colon, or a comma.
- Do not use the first person: "we", "our", "let's".
- Use parentheses only for a reference or an example. Move a condition into its own sentence.
- Use a list when a sentence carries more than three items.
- Use one word for one meaning. Do not switch synonyms for the same concept.
- Wrap at 80 columns, to match
printWidth in .oxfmtrc.json.
- Write in English only.
Cleanup
- No dead code. Remove an unused variable, function, or import. Remove a commented-out code block.
- Fix typos in a name, a comment, and a string.
SOLID Principles
- Single Responsibility: One responsibility to one actor
- Open/Closed: Open for extension, closed for modification
- Liskov Substitution: Subtypes must be substitutable
- Interface Segregation: No forced implementation of unused methods
- Dependency Inversion: Depend on abstractions, not concretions
Design Patterns (GoF)
- Creational Patterns: Factory, Abstract Factory, Builder, Prototype, Singleton
- Structural Patterns: Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
- Behavioral Patterns: Observer, Strategy, Command, State, Template Method, Chain of Responsibility
Output Format
For each issue found, output:
- File: path and line number
- Rule: which rule is violated
- Problem: what the code does wrong
- Fix: how to correct it
If no issues are found, confirm the code is clean.
1---2name: review-code-style3description: Review all changed or newly added code in this repository for code style and quality issues. Check both staged and unstaged changes.4---56Review all changed or newly added code in this repository for code style and quality issues. Check both staged and unstaged changes.78## Rules910### Naming & Structure1112- **Meaningful, consistent names**. Use the same name for the same concept everywhere. Make a variable name pronounceable and searchable.13- **Single Responsibility**. Give each module and function one reason to change.14- **Depend on abstractions**. Use DI tags and interfaces, not concrete implementations.1516### Code Quality1718- **No duplicated code**. Extract similar code that runs in the same calling context.19- **Avoid deep nesting**. Keep conditional nesting to three levels. Refactor with an early return or an extraction.20- **Short parameter lists**. More than three or four parameters asks for an options object.21- **Self-documenting code**. Express intent through a name or a structure before you write a comment.2223### Comments2425When a comment may exist:2627- Write a comment only for what the code cannot show: a constraint, an invariant, a reason, an upstream or browser bug, a non-obvious order of operations.28- Do not narrate the next line. Do not restate a name that the code already carries.29- Do not record process history, for example "previously" or "per review feedback". Git history owns that. A regression test may state the bug it pins, in one sentence.30- Write one concrete action in a `TODO`. Add the issue number when one exists: `TODO(#2463)`.31- `///` is the public API reference. `builddocs` publishes it into `docs/api`. Keep every fact in it accurate.3233How a comment reads (adapted from ASD-STE100, Simplified Technical English):3435- Give one idea to one sentence. Keep a sentence to 25 words or fewer.36- Use the active voice and the present tense. Use the imperative for an instruction.37- Do not use an em dash. Use a period, a colon, or a comma.38- Do not use the first person: "we", "our", "let's".39- Use parentheses only for a reference or an example. Move a condition into its own sentence.40- Use a list when a sentence carries more than three items.41- Use one word for one meaning. Do not switch synonyms for the same concept.42- Wrap at 80 columns, to match `printWidth` in `.oxfmtrc.json`.43- Write in English only.4445### Cleanup4647- **No dead code**. Remove an unused variable, function, or import. Remove a commented-out code block.48- **Fix typos** in a name, a comment, and a string.4950### SOLID Principles5152- Single Responsibility: One responsibility to one actor53- Open/Closed: Open for extension, closed for modification54- Liskov Substitution: Subtypes must be substitutable55- Interface Segregation: No forced implementation of unused methods56- Dependency Inversion: Depend on abstractions, not concretions5758### Design Patterns (GoF)5960- Creational Patterns: Factory, Abstract Factory, Builder, Prototype, Singleton61- Structural Patterns: Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy62- Behavioral Patterns: Observer, Strategy, Command, State, Template Method, Chain of Responsibility6364## Output Format6566For each issue found, output:6768- **File**: path and line number69- **Rule**: which rule is violated70- **Problem**: what the code does wrong71- **Fix**: how to correct it7273If no issues are found, confirm the code is clean.