header-optimization

Reduce C++ header include dependencies and relocate implementations to speed up builds.

31|6|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill header-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: header-optimization
Source: https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/header-optimization
Command: npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill header-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill reduces C++ header compile time by cutting unnecessary dependencies, converting heavy includes into forward declarations, and moving non-trivial inline implementations into cpp files while preserving business logic.

Core Features & Use Cases

  • Inline implementation extraction: moves method bodies longer than 3 lines from headers to cpp to reduce parsing workload.
  • Header dependency reduction: removes unused includes and replaces remaining includes with forward declarations where safe.
  • Advanced refactoring options: applies header splitting for constants/enums and uses PIMPL or template explicit instantiation when beneficial.

Quick Start

Use the header-optimization skill to optimize a target header for compilation efficiency.

Frequently Asked Questions about header-optimization

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

FAQPage Schema
How do I reduce C++ header file dependencies to speed up build performance?

Reduce C++ header dependencies by removing unused includes and replacing them with forward declarations where safe. This cuts parsing workload and speeds up compilation, especially in large codebases like ace_engine or OpenHarmony workflows.

What's the best way to move inline implementations out of C++ header files?

Move inline implementations out of C++ headers by extracting method bodies longer than three lines into cpp files. This preserves business logic while reducing header parsing overhead and improving build performance across ace_engine development.

When do I need forward declarations instead of includes in C++ headers?

Use forward declarations instead of includes in C++ headers when you only reference a type by pointer or reference and do not need its full definition. This dependency reduction technique significantly reduces compile time.

Can I safely refactor C++ headers for OpenHarmony and ace_engine workflows?

You can safely refactor C++ headers for OpenHarmony and ace_engine workflows using structural-only changes such as header splitting, forward-declaration conversion, and PIMPL. The process preserves business logic and stages modifications with git add.

How do I verify C++ header refactoring doesn't break compilation?

Verify C++ header refactoring through compile-analysis, which supports standalone compilation verification. This ensures dependency reduction and inline extraction changes remain structurally safe without altering business logic.

Does header splitting help with C++ build performance for constants and enums?

Header splitting helps C++ build performance by isolating constants and enums into separate files, reducing unnecessary parsing in dependent translation units. This advanced refactoring option complements dependency reduction and PIMPL techniques.