Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Use when reducing header bloat and compilation cascades with Include What You Use, interpreting IWYU reports, mapping files, forward declarations, or CMake integration.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
설치 방법 보기설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
IWYU finds #include directives a file does not need and ones it implicitly relies on. Grounded against IWYU 0.26.
| Field | Bound contract |
|---|---|
| Trigger | The task reduces C/C++ header bloat or compilation cascades, runs or interprets IWYU, writes mapping files, decides between forward declarations and full includes, or wires IWYU into a build. |
| Authority | Reversible local: writes only source files (through fix_include), .imp mapping files, and build configuration; rollback is version control. No remote mutation. |
| Side effect | fix_include edits source files in place; IWYU analysis runs the compiler front end on each translation unit. |
| Done | The IWYU report is produced, applied or triaged, and the project still builds and passes its tests. |
compile_commands.json from CMake, Bear, or compiledb.iwyu/include-what-you-use plus iwyu_tool.py and fix_include from the same package..imp files.compile_commands.json covers the files to analyze.cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# or for Make-based trees: bear -- make
# Single file
iwyu -Xiwyu --error main.cpp 2>&1
# Whole project through the compilation database
iwyu_tool.py -p build/ 2>&1 | tee iwyu.log
find_program(IWYU_PROGRAM NAMES include-what-you-use iwyu)
if(IWYU_PROGRAM)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
${IWYU_PROGRAM}
-Xiwyu --mapping_file=${CMAKE_SOURCE_DIR}/iwyu.imp
-Xiwyu --no_comments
)
endif()
should add names headers that provide symbols the file uses but does not include. should remove names headers whose symbols the file does not use directly. The full include-list is the suggested final state. Done when: each add and remove line is classified as correct, wrong, or needing a mapping.main.cpp should add these lines:
#include <string> // for std::string
#include "mylib/widget.h" // for Widget
main.cpp should remove these lines:
- #include <vector> // lines 5-5
The full include-list for main.cpp:
#include <string> // for std::string
#include "mylib/widget.h" // for Widget
---
fix_include, then rebuild and test before accepting. Done when: the tree builds and tests pass after the edits.fix_include --dry_run < iwyu.log # preview only
fix_include < iwyu.log # apply
fix_include --nosafe_headers < iwyu.log # also remove "safe" system headers
fix_include --comments < iwyu.log # keep the // for-symbol comments
fix_include --only_re='src/.*\.cpp' < iwyu.log # limit to matching files
// Forward declaration suffices for:
class Widget;
void process(Widget *w); // pointer or reference parameters
Widget *make(); // pointer return types
// Full include is required for:
class Mine : public Widget {}; // inheritance
void f() { Widget w; w.size(); } // instances, member access, sizeof
std::vector<Widget> items; // template instantiation
// IWYU-friendly header: the .cpp pays the include cost, consumers do not
#pragma once
class Widget;
class Container {
Widget *head_;
public:
void add(Widget *w);
Widget *get(int idx);
};
.imp files are JSON-like and allow # comments and trailing commas. Done when: IWYU stops suggesting private or internal headers.# iwyu.imp
[
# Map an internal header to its public entry point
{ "include": ["<bits/types.h>", "private", "<sys/types.h>", "public"] },
{ "include": ["<bits/socket.h>", "private", "<sys/socket.h>", "public"] },
# Map a symbol to the header that must provide it
{ "symbol": ["std::string", "private", "<string>", "public"] },
]
iwyu -Xiwyu --mapping_file=iwyu.imp main.cpp
# IWYU ships mappings for STL, Boost, and libc++; check the package's
# share directory, e.g. /usr/share/include-what-you-use/
# Measure the cascade a header causes before removing it
grep -rl '#include "expensive.h"' src/ | wc -l
fix_include: revert the file and add a mapping or a // IWYU pragma: keep comment on the include that must stay.include mapping from the private path to the public one.// IWYU pragma: keep; macro provenance is a known blind spot.iwyu_tool.py finds no files: the compilation database is missing or empty; regenerate it with CMAKE_EXPORT_COMPILE_COMMANDS=ON.--only_re or run per-directory; fix the most-included headers first, they dominate the cascade.An IWYU report triaged into applied fixes and documented rejections, a tree that still builds and tests clean, and where useful a project .imp mapping file that stops recurring bad advice.
아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.
Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Use when configuring ADC sampling time, DMA-driven ADC, calibration, or DAC channel setup on bare-metal MCUs. Not for the DMA stream itself: use dma-baremetal.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Use when creating AF_XDP sockets, configuring UMEM and XSK rings, writing an XDP redirect program, or choosing copy versus zero-copy mode. Not for full kernel bypass: use dpdk.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Use when a completed session needs an agent-environment retrospective. Not for an engineering retrospective from telemetry: use engineering-retrospective.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Use when a redacted, trimmed agent transcript must be appended to a GitHub PR or issue body, with human approval and preview. Not for automated or model-initiated insertion.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Use when a repo needs agent setup, AGENTS.md added or made lean, CLAUDE.md audited, or agent instructions scored or pruned. Not for remote, credential, publish, deploy, or irreversible changes.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.