be-code-style

Fix C++ code formatting in BE and Cloud modules using clang-format v16.

15.8k|3.9k|Updated Aug 10, 2017
One-click install
npx skills add https://github.com/apache/doris --skill be-code-style
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: be-code-style
Source: https://github.com/apache/doris/tree/main/.claude/skills/be-code-style
Command: npx skills add https://github.com/apache/doris --skill be-code-style

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

C++ code in the Apache Doris BE and Cloud modules must conform to the project's clang-format rules, and CI fails when formatting deviates. This Skill automates detecting and fixing those formatting violations with the correct clang-format version.

Core Features & Use Cases

  • Auto-fix formatting: Runs build-support/clang-format.sh to reformat all C++ files under be/src, be/test, cloud/src, and cloud/test in place.
  • Check-only mode: Runs build-support/check-format.sh to output a diff of violations without modifying files, exiting non-zero on failures.
  • Version enforcement: Ensures clang-format major version 16 is used, locating the correct binary via .vscode/settings.json, PATH, or custom_env.sh.
  • Use Case: Before committing BE C++ changes, run the formatting script, review the diff with git diff, and commit only formatting-consistent code that passes CI.

Quick Start

Fix the C++ formatting in my BE and Cloud code changes using the project's clang-format script before I commit.

Frequently Asked Questions about be-code-style

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

FAQPage Schema
How do I fix clang-format failures in Apache Doris CI?

Run build-support/clang-format.sh from the repository root to auto-fix all C++ files under be/src, be/test, cloud/src, and cloud/test. Then review changes with git diff and commit the formatting fixes.

How to check C++ code formatting without modifying files?

Run build-support/check-format.sh, which outputs a diff of any formatting violations and exits with a non-zero status if violations exist. This is useful for verifying style compliance before pushing changes.

Which clang-format version does Apache Doris require?

Apache Doris requires clang-format major version 16. The formatting script checks the version and exits with an error if a different version is found, since other versions produce inconsistent formatting.

Why does clang-format report version is not 16 error?

This error occurs when the default clang-format binary is not version 16. Install clang-format v16 (on macOS use brew install llvm@16), set the CLANG_FORMAT_BINARY environment variable, or configure clang-format.executable in .vscode/settings.json.

Which files are excluded from clang-format in Doris?

The .clang-format-ignore file excludes third-party and generated code, including be/src/apache-orc, be/src/clucene, be/src/gutil, be/src/glibc-compatibility, vendored files like mustache and sse2neon, and cloud/src/common/defer.h.