Skip to content
Back to skills

Clang Format

ASecurity

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.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 5, 2026
code-qualitygoc++gitapisecurity

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned November 5, 2026

npx -y skills add gvago/unofficial-qodo-review-skills --skill clang-format --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clang Format?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clang Format
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gvago-clang-format/badge)](https://www.skillsdirectory.com/skills/gvago-clang-format)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: clang-format
description: 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.
---

# 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

1. 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.
2. 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.
3. 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.
4. 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.
5. 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.

Files in this skill

  • SKILL.md7 KB
  • assets/configs/compact-dense.clang-format960 B
  • assets/configs/google-cpp-modified.clang-format983 B
  • assets/configs/linux-kernel.clang-format886 B
  • assets/configs/microsoft-visual-studio.clang-format963 B
  • assets/configs/modern-cpp17-20.clang-format1.2 KB
  • assets/configs/multi-language.clang-format699 B
  • assets/configs/readable-spacious.clang-format1.1 KB
  • assets/integrations/emacs-clang-format.el134 B
  • assets/integrations/pre-commit119 B
  • assets/integrations/vimrc-clang-format.vim530 B
  • evals/evals.json1.6 KB
  • references/01-alignment.md9.3 KB
  • references/02-breaking.md13.6 KB
  • references/03-braces.md10.7 KB
  • references/04-indentation.md9.2 KB
  • references/05-spacing.md12.5 KB
  • references/06-includes.md7.6 KB
  • references/07-languages.md8.2 KB
  • references/08-comments.md13.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.