cpp-formatting

Format modified lines in C/C++ files with clang-format.

14|Updated May 28, 2026
One-click install
npx skills add https://github.com/Redtropig/harness-anchor --skill cpp-formatting
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-formatting
Source: https://github.com/Redtropig/harness-anchor/tree/main/skills/cpp-formatting
Command: npx skills add https://github.com/Redtropig/harness-anchor --skill cpp-formatting

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Maintains consistent C/C++ code formatting while minimizing diff noise by formatting only changed lines, reducing review overhead.

Core Features & Use Cases

  • Changed-lines formatting: formats only lines that have changed, preserving stable code.
  • Project-wide style adherence: respects a root-level or LLVM-based .clang-format configuration to enforce a consistent style.
  • Targeted application: can be used during development sessions or before committing changes to ensure clean diffs.

Quick Start

Format the currently edited C/C++ files using clang-format, applying changes only to the modified lines.

Frequently Asked Questions about cpp-formatting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I format only changed lines in C++ to keep diffs clean?

Format C++ code by running clang-format exclusively on modified lines, which preserves stable code and minimizes diff noise during code review.

What is changed-lines formatting and how does it work with clang-format?

Changed-lines formatting applies clang-format strictly to modified code segments, leaving stable code untouched. It uses your root .clang-format configuration to enforce style while keeping diffs minimal.

Do I need a .clang-format configuration file to format C++ code?

Yes, formatting requires clang-format installed and a valid .clang-format configuration at the project root to ensure the applied style matches your project's style guide.

Can I use this C++ formatting approach in pre-commit workflows?

Yes, you can invoke changed-lines formatting during development sessions or pre-commit workflows to ensure clean diffs by applying clang-format only to modified lines before committing code.

What's the best way to maintain consistent C++ style without reformatting entire files?

Apply clang-format only to modified lines to maintain consistent C++ style without reformatting entire files, enforcing project-wide style adherence while keeping stable code untouched.

Why does clang-format create large diffs and how do I limit it to changed lines?

Clang-format creates large diffs by reformatting entire files. Limit formatting to changed lines by applying clang-format selectively to modified segments, reducing review overhead and preserving stable code.