بنقرة واحدة
code-quality
Use when writing or reviewing C++ code, running pre-commit checks, or addressing formatting, naming, or static analysis violations.
القائمة
Use when writing or reviewing C++ code, running pre-commit checks, or addressing formatting, naming, or static analysis violations.
| name | code-quality |
| license | MIT |
| description | Use when writing or reviewing C++ code, running pre-commit checks, or addressing formatting, naming, or static analysis violations. |
NO UNFORMATTED OR UNTIDY CODE SHIPS
YOU MUST run clang-format AND clang-tidy BEFORE every commit. CI will reject violations.
No exceptions.
Violating the letter of this rule is violating the spirit of this rule.
Announce at start: "I am using the code-quality skill to [format/lint/review] [description]."
Formatting and naming are automated via .clang-format and .clang-tidy. Never manually format code -- run the tools.
Before every commit, verify:
find src tests -name "*.cpp" -o -name "*.hpp" | xargs clang-format -ifind src tests -name "*.cpp" -o -name "*.hpp" | xargs clang-format --dry-run -Werrorgit diff of every modified C++ file visually inspected -- do not trust silent tool outputcmake --build build./build/tests/ParticleViewerTests[+] All 5 met -> proceed to commit [-] Any unmet -> fix the failing step; do not commit
Note: clang-format is C++ only. Never run it on Markdown, YAML, or documentation files -- it will corrupt them.
See references/CPP_TOOLCHAIN.md for full command reference and optional clang-tidy invocation.
See references/FORMATTING_RULES.md for formatting rule details.
PascalCase classes/enums - camelCase methods - snake_case vars/params - snake_case_ private members - UPPER_CASE constants - snake_case files/namespaces - <PROJECT>_<PATH>_<FILE>_H guards
See references/NAMING_TABLES.md for full naming examples.
Before naming a new enum, struct field, or constant: open docs/CODING_STANDARDS.md and verify the naming convention. Enumerators: UPPER_CASE.
Readability is more important than development speed or execution speed. Time spent on clarity is recovered many times over in maintenance, review, and debugging.
Comments are not intent. Comments can go stale; code cannot. When a comment exists to explain what a value means, that is a signal the code must be rewritten -- not the comment improved.
| Signal | Wrong fix | Right fix |
|---|---|---|
// 0=Fullscreen, 1=AutoCOM... comment above a switch | Add a better comment | Replace magic numbers with a named enum |
magic_value = 42; // timeout in ms | Document the constant | constexpr int kTimeoutMs = 42; |
Function with a bool parameter | Comment at the call site | Replace with an enum or named overloads |
Rule: If a comment is explaining what a value is, the comment is a code smell. Make the code say it directly.
See references/CPP_TOOLCHAIN.md for PV-specific toolchain commands.
Static analysis catches syntax violations. These structural smells require human review on every PR:
int, float, or GLenum? Introduce typed wrappers.See references/CODE_SMELLS.md for the full code smells catalog.
[+] All checked -> no structural smells found
[-] Any flagged -> log [BROKEN WINDOW NOTED] or fix before commit (see cpp-patterns skill)
See references/REVIEW_CHECKLIST.md for the full numbered pre-commit checklist.
[+] All 10 met -> proceed to commit [-] Any unmet -> complete the failing step before committing
| Excuse | Reality |
|---|---|
| "I'll run clang-format once at the end before the PR" | Format after every meaningful change. Catch issues early, not in bulk. |
| "clang-tidy has too many false positives, I'll skip it" | Fix or suppress with justification in code. Suppression without reason is tech debt. |
| "The naming is close enough to the convention" | Exact naming prevents confusion across sessions and contributors. |
| "Formatting is cosmetic, doesn't affect behavior" | Unformatted code gets rejected by CI. It's a hard gate, not a preference. |
| "I'll clean up the style in a follow-up PR" | Style debt compounds. Clean it now while context is fresh. |
| "The auto-formatter will handle it" | Run the auto-formatter explicitly -- it doesn't run itself. |
If you catch yourself thinking any of these, stop and follow the rule:
clang-format -iAll of these mean: Run find src tests -name "*.cpp" -o -name "*.hpp" | xargs clang-format -i and clang-tidy before every commit. No exceptions.
docs/CODING_STANDARDS.mdversioning skilltesting skillreferences/CPP_TOOLCHAIN.md -- formatting settings, clang-tidy, PV workflow patternsreferences/FORMATTING_RULES.md -- human-reviewable formatting patternscpp-patterns skill -- C++ runtime patternsreferences/DESIGN_PRINCIPLES.md -- design heuristicsreferences/CODE_SMELLS.md -- smells, refactoring mapreferences/NAMING_TABLES.md -- naming examplesreferences/REVIEW_CHECKLIST.md -- pre-review checklistreferences/INVOCATION.md -- agent invocation instructionsUse when adding new classes, refactoring code, or reviewing PRs for Particle-Viewer.
Use when a task needs design exploration before any implementation begins. Required for any task with unclear approach, significant architecture impact, or multiple valid solutions.
Use when building, adding dependencies, configuring CMake options, troubleshooting build failures, or managing Flatpak packaging for Particle-Viewer.
Use when writing tests for any interface, abstract base class, or type with multiple implementations.
Use when implementing C++ code for Particle-Viewer, handling GL resources, working with SDL3, or applying DRY/deprecation/docs-commit patterns.
Use when writing or reviewing any C++ class that owns resources, has a destructor, or acquires in a constructor.