format

- clang-format: ../../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang-format

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "format" with this command: npx skills add openharmonyinsight/openharmony-skills/openharmonyinsight-openharmony-skills-format

Tool Locations

  • clang-format: ../../../prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang-format

  • clang-format-diff.py: ../../../prebuilts/clang/ohos/linux-x86_64/llvm/share/clang/clang-format-diff.py

Approach

Use clang-format-diff.py which is designed specifically for this use case - it reads a diff from stdin and only applies formatting to lines that were changed.

Working Command

Navigate to repo root and run:

git diff HEAD -- 'graphic_2d//*.cpp' 'graphic_2d//*.h' 2>/dev/null |
python3 prebuilts/clang/ohos/linux-x86_64/llvm/share/clang/clang-format-diff.py
-p1 -binary prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang-format -i

Why This Works

  • git diff HEAD

  • Shows all unstaged changes relative to HEAD

  • -- 'graphic_2d//*.cpp' 'graphic_2d//*.h'

  • Filters to C++ source files

  • clang-format-diff.py

  • Reads the diff and only formats changed lines

  • -p1

  • Strips one path component (graphic_2d/ ) from diff paths

  • -binary ...

  • Specifies the clang-format executable to use

  • -i

  • Applies edits directly to files

Important Notes

  • Must run from repo root of OpenHarmony so file paths in the diff match actual file locations

  • The tool only applies formatting if changed lines violate style rules

  • If changed lines are already properly formatted, no changes are made

  • This avoids the problem of formatting thousands of unchanged lines in a file

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

openharmony-cpp

No summary provided by upstream source.

Repository SourceNeeds Review
General

oh-ut-generator

No summary provided by upstream source.

Repository SourceNeeds Review
General

cpp-core-guidelines-review

No summary provided by upstream source.

Repository SourceNeeds Review