clang-format
Review C and C++ formatting from the unified diff and the repository's committed .clang-format policy. This skill is an LLM review lens, not a formatter execution workflow.
Boundaries
- Formatting review covers layout and clang-format behavior only. Do not report correctness, safety, security, API, or architecture findings unless the user separately asks for semantic review.
- Read the changed file and the repository's
.clang-format before judging style. The project configuration is authoritative over bundled templates.
- Do not replace an existing project configuration with a template unless explicitly requested.
- Do not run tools or claim that a formatter was executed. Review only changed lines and the context needed to establish the rule violation.
- Preserve generated, vendored, excluded, or intentionally unformatted code. Check
.clang-format-ignore and local project guidance.
- Treat bundled templates and integrations as reference material, not evidence that a changed line is invalid.
Route the request
- Existing configuration analysis or formatting-only review:
- Read the authoritative config and the changed diff.
- Match the changed line to a rule in the Rule index below.
- Report only violations that can be proven from the diff and rule text.
- New configuration:
- Confirm no authoritative project config already exists.
- Select the closest file under
assets/configs/, then make minimal overrides.
- Validate the proposed config change by reasoning through representative changed constructs. Do not claim execution.
- Configuration change:
- Read the current config and identify the smallest option change.
- Check version compatibility in
references/complete/clang-format-style-options.md.
- Compare the changed construct with the configured rule. Do not propose repository-wide reformatting.
- Troubleshooting:
- State that runtime confirmation is outside this skill. Use the configured option and changed code as evidence.
- Consult
references/cli-usage.md and the relevant option guide only for interpretation.
- Editor or git integration:
- Review examples under
assets/integrations/.
- Adapt them to the repository instead of installing or copying them blindly.
Option navigation
- Alignment:
references/01-alignment.md
- Line breaking and wrapping:
references/02-breaking.md
- Braces:
references/03-braces.md
- Indentation:
references/04-indentation.md
- Spacing:
references/05-spacing.md
- Include handling:
references/06-includes.md
- Language-specific behavior:
references/07-languages.md
- Comments:
references/08-comments.md
- Penalties and advanced options:
references/09-advanced.md
- Working examples:
references/quick-reference.md
- CLI details:
references/cli-usage.md
- Complete CLI reference:
references/complete/clang-format-cli.md
- Complete style-options reference:
references/complete/clang-format-style-options.md
Repository-specific review guidance
- The repository's
.clang-format is authoritative for reviewed C and C++ files. Inspect it rather than substituting assets/configs/linux-kernel.clang-format or another generic template.
- For macro-heavy C, include representative headers and source files with
ForEachMacros, IfMacros, AttributeMacros, and WhitespaceSensitiveMacros behavior when validating configuration changes.
- Respect
// clang-format off and // clang-format on regions. Do not remove markers or treat intentionally preserved layout inside them as a formatting defect.
- Validate a focused change on representative files and inspect the diff for macro damage, preprocessor movement, include changes, and excessive churn.
- In Qodo review, report formatting findings only when they are in scope and supported by the authoritative config. Route semantic C concerns to the appropriate semantic review skill instead of attaching them to clang-format findings.
Finding contract
Every finding must include all of these fields:
Rule ID: the stable ID from the Rule index, such as CF-001.
Rule text: the exact configuration line or rule text quoted below.
Evidence: changed file path and changed line. Never invent a line number.
Reason: why the changed text violates that rule.
Fix: the smallest source change that restores compliance.
If no Rule ID and exact Rule text can be established, do not report a clang-format rule violation.
Rule index for the repository configuration
These IDs are a local review adaptation because the source .clang-format has no rule IDs.
The quoted text is the source rule text and must be preserved in findings.
- CF-001:
BreakBeforeBraces: Linux
- CF-001 semantics: function, type, and namespace opening braces go on the next line. Control-statement braces stay on the same line. Never report an attached
if, for, while, or switch brace as a CF-001 violation.
- CF-002:
ColumnLimit: 100
- CF-003:
ContinuationIndentWidth: 8
- CF-004:
IndentCaseLabels: false
- CF-005:
IndentGotoLabels: false
- CF-006:
IndentWidth: 8
- CF-007:
InsertNewlineAtEOF: true
- CF-008:
SpaceBeforeParens: ControlStatementsExceptControlMacros
- CF-009:
SortIncludes: Never
- CF-010:
UseTab: ForContinuationAndIndentation
- CF-011:
ForEachMacros includes the project macro being reviewed.
- CF-012:
IfMacros includes CHECKIF.
- CF-013:
WhitespaceSensitiveMacros includes COND_CODE_0, COND_CODE_1, IF_DISABLED, IF_ENABLED, LISTIFY, STRINGIFY, Z_STRINGIFY, and DT_FOREACH_PROP_ELEM_SEP.
Do not infer a formatting violation solely from a generic preference. Cite one of these IDs and its exact text.
Review scope
Review only changed C/C++ lines and necessary context. Respect clang-format off/on, generated or vendored paths, and macro-sensitive constructs. Do not claim that a candidate is confirmed when the diff does not show the relevant formatting.
Bundled resources
Seven configuration examples are under assets/configs/:
assets/configs/google-cpp-modified.clang-format
assets/configs/linux-kernel.clang-format
assets/configs/microsoft-visual-studio.clang-format
assets/configs/modern-cpp17-20.clang-format
assets/configs/compact-dense.clang-format
assets/configs/readable-spacious.clang-format
assets/configs/multi-language.clang-format
Integration examples are:
assets/integrations/pre-commit
assets/integrations/vimrc-clang-format.vim
assets/integrations/emacs-clang-format.el
Reporting
State the authoritative config, changed file and line, Rule ID, exact Rule text, evidence, and fix. Use the Maintainability category for formatting-only findings. Do not claim that clang-format or another CLI ran. Separate formatting findings from semantic review.
1---2name: clang-format3description: Use when a PR changes C or C++ formatting governed by clang-format or .clang-format, including indentation, braces, spacing, alignment, include ordering, line breaking, macro-sensitive layout, or formatting-only review.4---56# clang-format78Review C and C++ formatting from the unified diff and the repository's committed `.clang-format` policy. This skill is an LLM review lens, not a formatter execution workflow.910## Boundaries1112- Formatting review covers layout and clang-format behavior only. Do not report correctness, safety, security, API, or architecture findings unless the user separately asks for semantic review.13- Read the changed file and the repository's `.clang-format` before judging style. The project configuration is authoritative over bundled templates.14- Do not replace an existing project configuration with a template unless explicitly requested.15- Do not run tools or claim that a formatter was executed. Review only changed lines and the context needed to establish the rule violation.16- Preserve generated, vendored, excluded, or intentionally unformatted code. Check `.clang-format-ignore` and local project guidance.17- Treat bundled templates and integrations as reference material, not evidence that a changed line is invalid.1819## Route the request20211. Existing configuration analysis or formatting-only review:22 - Read the authoritative config and the changed diff.23 - Match the changed line to a rule in the **Rule index** below.24 - Report only violations that can be proven from the diff and rule text.252. New configuration:26 - Confirm no authoritative project config already exists.27 - Select the closest file under `assets/configs/`, then make minimal overrides.28 - Validate the proposed config change by reasoning through representative changed constructs. Do not claim execution.293. Configuration change:30 - Read the current config and identify the smallest option change.31 - Check version compatibility in `references/complete/clang-format-style-options.md`.32 - Compare the changed construct with the configured rule. Do not propose repository-wide reformatting.334. Troubleshooting:34 - State that runtime confirmation is outside this skill. Use the configured option and changed code as evidence.35 - Consult `references/cli-usage.md` and the relevant option guide only for interpretation.365. Editor or git integration:37 - Review examples under `assets/integrations/`.38 - Adapt them to the repository instead of installing or copying them blindly.3940## Option navigation4142- Alignment: `references/01-alignment.md`43- Line breaking and wrapping: `references/02-breaking.md`44- Braces: `references/03-braces.md`45- Indentation: `references/04-indentation.md`46- Spacing: `references/05-spacing.md`47- Include handling: `references/06-includes.md`48- Language-specific behavior: `references/07-languages.md`49- Comments: `references/08-comments.md`50- Penalties and advanced options: `references/09-advanced.md`51- Working examples: `references/quick-reference.md`52- CLI details: `references/cli-usage.md`53- Complete CLI reference: `references/complete/clang-format-cli.md`54- Complete style-options reference: `references/complete/clang-format-style-options.md`5556## Repository-specific review guidance5758- The repository's `.clang-format` is authoritative for reviewed C and C++ files. Inspect it rather than substituting `assets/configs/linux-kernel.clang-format` or another generic template.59- For macro-heavy C, include representative headers and source files with `ForEachMacros`, `IfMacros`, `AttributeMacros`, and `WhitespaceSensitiveMacros` behavior when validating configuration changes.60- Respect `// clang-format off` and `// clang-format on` regions. Do not remove markers or treat intentionally preserved layout inside them as a formatting defect.61- Validate a focused change on representative files and inspect the diff for macro damage, preprocessor movement, include changes, and excessive churn.62- In Qodo review, report formatting findings only when they are in scope and supported by the authoritative config. Route semantic C concerns to the appropriate semantic review skill instead of attaching them to clang-format findings.6364## Finding contract6566Every finding must include all of these fields:6768- `Rule ID`: the stable ID from the Rule index, such as `CF-001`.69- `Rule text`: the exact configuration line or rule text quoted below.70- `Evidence`: changed file path and changed line. Never invent a line number.71- `Reason`: why the changed text violates that rule.72- `Fix`: the smallest source change that restores compliance.7374If no Rule ID and exact Rule text can be established, do not report a clang-format rule violation.7576## Rule index for the repository configuration7778These IDs are a local review adaptation because the source `.clang-format` has no rule IDs.79The quoted text is the source rule text and must be preserved in findings.8081- **CF-001**: `BreakBeforeBraces: Linux`82- **CF-001 semantics**: function, type, and namespace opening braces go on the next line. Control-statement braces stay on the same line. Never report an attached `if`, `for`, `while`, or `switch` brace as a CF-001 violation.83- **CF-002**: `ColumnLimit: 100`84- **CF-003**: `ContinuationIndentWidth: 8`85- **CF-004**: `IndentCaseLabels: false`86- **CF-005**: `IndentGotoLabels: false`87- **CF-006**: `IndentWidth: 8`88- **CF-007**: `InsertNewlineAtEOF: true`89- **CF-008**: `SpaceBeforeParens: ControlStatementsExceptControlMacros`90- **CF-009**: `SortIncludes: Never`91- **CF-010**: `UseTab: ForContinuationAndIndentation`92- **CF-011**: `ForEachMacros` includes the project macro being reviewed.93- **CF-012**: `IfMacros` includes `CHECKIF`.94- **CF-013**: `WhitespaceSensitiveMacros` includes `COND_CODE_0`, `COND_CODE_1`, `IF_DISABLED`, `IF_ENABLED`, `LISTIFY`, `STRINGIFY`, `Z_STRINGIFY`, and `DT_FOREACH_PROP_ELEM_SEP`.9596Do not infer a formatting violation solely from a generic preference. Cite one of these IDs and its exact text.9798## Review scope99100Review only changed C/C++ lines and necessary context. Respect `clang-format off/on`, generated or vendored paths, and macro-sensitive constructs. Do not claim that a candidate is confirmed when the diff does not show the relevant formatting.101102## Bundled resources103104Seven configuration examples are under `assets/configs/`:105106- `assets/configs/google-cpp-modified.clang-format`107- `assets/configs/linux-kernel.clang-format`108- `assets/configs/microsoft-visual-studio.clang-format`109- `assets/configs/modern-cpp17-20.clang-format`110- `assets/configs/compact-dense.clang-format`111- `assets/configs/readable-spacious.clang-format`112- `assets/configs/multi-language.clang-format`113114Integration examples are:115116- `assets/integrations/pre-commit`117- `assets/integrations/vimrc-clang-format.vim`118- `assets/integrations/emacs-clang-format.el`119120## Reporting121122State the authoritative config, changed file and line, Rule ID, exact Rule text, evidence, and fix. Use the Maintainability category for formatting-only findings. Do not claim that clang-format or another CLI ran. Separate formatting findings from semantic review.