Create include-cleaner skill Bug: webrtc:465491622 Change-Id: I277172143a77a6ea88102ae1a9668f476a6a6964 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/460020 Commit-Queue: Evan Shrubsole <eshr@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Auto-Submit: Evan Shrubsole <eshr@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47277}
diff --git a/.agents/skills/include-cleaner/SKILL.md b/.agents/skills/include-cleaner/SKILL.md new file mode 100644 index 0000000..d664a81 --- /dev/null +++ b/.agents/skills/include-cleaner/SKILL.md
@@ -0,0 +1,67 @@ +--- +name: webrtc-include-cleaner +description: Runs the WebRTC include-cleaner tool (IWYU replacement) to fix headers in C++ files. Use when preparing a CL for upload, after modifying .cc or .h files, or when instructed to fix include regressions. +--- + +# WebRTC Include Cleaner + +This skill provides instructions for using +`tools_webrtc/iwyu/apply-include-cleaner`, a tool that automatically manages C++ +`#include` directives in the WebRTC codebase. It ensures that every header used +is explicitly included and that unused headers are removed. + +## When to Use + +- **Pre-upload**: Run this tool before uploading a CL to ensure clean includes. +- **After refactoring**: When moving code or changing dependencies, use this to + update `#include` blocks. +- **Fixing regressions**: Use this if a presubmit or bot identifies + include-related issues. + +## Basic Usage + +To run the include cleaner on specific files: + +```bash +tools_webrtc/iwyu/apply-include-cleaner path/to/file.cc path/to/file.h +``` + +To run it on all modified files relative to the upstream branch (ideal for CL +preparation): + +```bash +tools_webrtc/iwyu/apply-include-cleaner +``` + +Note: This is as expensive as a build for each file, so use it sparingly. + +## Options + +- `-p`, `--print`: Don't modify the files, just print the proposed changes. +- `-w WORK_DIR`, `--work-dir WORK_DIR`: Specify the GN work directory (default: + `out/Default`). + +## Post-Execution Steps + +After running the include cleaner, it is recommended to perform the following +steps to ensure build and style consistency: + +1. **Check for build errors**: The tool might occasionally make mistakes. Run a + build to verify. +1. **Fix GN dependencies**: Use `tools_webrtc/gn_check_autofix.py` to fix any + `deps` issues caused by include changes. + ```bash + tools_webrtc/gn_check_autofix.py -C out/Default + ``` +1. **Format code**: Run `git cl format` to fix any formatting issues in the + `#include` blocks. + ```bash + git cl format + ``` + +## Prerequisites + +- The tool automatically generates `compile_commands.json` in the output + directory if `out/Default` exists. +- `clangd` must be checked out in your `.gclient` file + (`"checkout_clangd": True`).