include-what-you-use

Analyzes and optimizes C/C++ header includes using IWYU-compatible recommendations.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/awfixers-stuff/opencode-config --skill include-what-you-use-awfixers-stuff
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: include-what-you-use
Source: https://github.com/awfixers-stuff/opencode-config/tree/main/skills/include-what-you-use
Command: npx skills add https://github.com/awfixers-stuff/opencode-config --skill include-what-you-use-awfixers-stuff

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Large C and C++ codebases often suffer from excessive and unnecessary header includes that increase compile times, cause wide compilation cascades, and make dependency reasoning difficult; this Skill helps identify and remove unused includes while adding any missing direct includes to ensure correctness and faster builds.

Core Features & Use Cases

  • Interpret include-what-you-use (IWYU) output to determine which headers should be added or removed and explain the rationale.
  • Recommend forward declarations versus full includes to minimize downstream compile costs and provide guidance on when each is appropriate.
  • Integrate IWYU into build systems and CI by using compile_commands.json, mapping files, and CMake integration patterns to automate detection and remediation of header bloat.
  • Use mapping files to resolve indirect or platform-specific header relationships and to teach IWYU about third-party or STL mappings.

Quick Start

Run IWYU against your project's build (using iwyu or iwyu_tool.py), pipe the report to fix_include to apply suggested changes, then rebuild and run tests to validate.

Frequently Asked Questions about include-what-you-use

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

FAQPage Schema
How do I remove unused C++ headers to speed up compilation?▼

Use include-what-you-use to analyze and remove unused C++ headers while adding missing direct includes. This reduces compilation cascades and speeds up build times in large codebases by ensuring correct dependencies.

When should I use forward declarations instead of full header includes in C++?▼

Use forward declarations instead of full header includes when you only need to reference a type without accessing its members. This minimizes downstream compile costs and reduces header bloat, while full includes are necessary when you use the type's full definition.

How do I integrate include-what-you-use with CMake and CI workflows?▼

Integrate include-what-you-use with CMake and CI by using compile_commands.json to automate detection. Run the IWYU tool against your build, pipe the report to fix_include to apply changes, then rebuild and validate tests in your pipeline.

What are mapping files and how do they work with IWYU?▼

Mapping files teach IWYU about indirect or platform-specific header relationships, resolving complex dependencies like third-party or STL mappings. They ensure accurate analysis when standard include paths cannot fully trace header relationships.

Can I run header optimization across a whole C++ project or just single files?▼

You can run header optimization on both single files and whole C++ projects. For whole project analysis, use compile_commands.json to process all translation units and identify unused includes across the entire codebase simultaneously.

Why do unnecessary header includes cause slow C++ build times?▼

Unnecessary header includes cause slow C++ build times by creating wide compilation cascades where changes to one header trigger recompilation of many dependent files. Removing unused includes and using forward declarations minimizes this cascading effect.