iwyu

$npx mdskill add cloudflare/workerd/iwyu

Adapted from [include-what-you-use](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md). Small targets with accurate deps mean a change rebuilds and retests fewer targets.

SKILL.md

.github/skills/iwyuView on GitHub ↗
---
name: iwyu
description: Follow IWYU guidelines to improve build caching. This entails adding/removing C++
includes as well as Bazel deps and implementation_deps when appropriate. Load when making non-
trivial changes to C++ includes or Bazel target declarations.
---

## IWYU FOR C++ TARGETS

Adapted from [include-what-you-use](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md).
Small targets with accurate deps mean a change rebuilds and retests fewer targets.

- Don't add `#include`s a file doesn't use or `deps` a target doesn't use. When a change removes
  the last use of a header, delete its `#include`, then the dep if it's now unused.
- Put deps whose headers are included only from `.c++` files in `implementation_deps`, so they
  don't propagate to dependents.
- Prefer direct includes and deps over relying on transitive ones, but don't add a long list just
  to spell out what you already get transitively. For instance, most workerd C++ sources depend on
  KJ but we don't declare this dependency for each target separately, or include kj/common.h,
  kj/string.h and so on each time. Direct includes that are already present and being used should
  generally stay in place.
- Give each `.h`/`.c++` pair its own `wd_cc_library`, named after the file (e.g.
  `:tracked-wasm-instance`). A header without a `.c++` gets its own target too, with the deps it
  needs to compile on its own.
- Keep each header in exactly one target, together with its `.c++` if it has one. Exposing a
  header from a target that doesn't build its `.c++` lets code call its functions without
  depending on their definitions, which shows up later as undefined-symbol link errors.
- If splitting a pair out would create a dependency cycle, leave it in its combined target (e.g.
  `//src/workerd/io`) instead of separating the header from its `.c++`. Don't add new files to
  such targets if they can have their own.

More from cloudflare/workerd

SkillDescription
bazel-test-hygieneMandatory rules for running bazel tests during development. Load this skill before running any bazel test command, especially when validating fixes or verifying regression tests. Prevents false confidence from cached results, filter flags that silently match nothing, and partial test runs that miss breakage.
commit-categoriesCommit categorization rules for changelogs and "what's new" summaries. MUST be loaded before categorizing commits in changelog or whats-new commands. Provides the canonical path-based category table used to group commits by area.
dad-jokesAfter completing any task that took more than ~5 tool calls, or after long-running builds/tests finish, load this skill and deliver a dad joke to lighten the mood. Also load before any user-requested joke, pun, or limerick. Never improvise jokes without loading this skill first.
find-and-run-testsHow to find, build, and run tests in workerd. Covers wd-test, kj_test target naming, bazel query patterns, and common flags. Also covers parent project integration tests if workerd is used as a submodule. Load this skill when you need to locate or run a test and aren't sure of the exact target name or invocation.
identify-reviewerIdentifies the local user's GitHub account and git identity before performing code reviews. Load this skill at the start of any PR review, code review, or commit log analysis so findings can be framed relative to the user's own prior comments, commits, and approval status.
investigation-notesStructured scratch tracking document for investigation state during bug hunts - prevents re-reading code, losing context, and rabbit holes; maintains external memory so you don't re-derive conclusions
kj-styleKJ/workerd C++ style guidelines for code review. Covers naming, type usage, memory management, error handling, inheritance, constness, and formatting conventions. Load this skill when reviewing or writing C++ code in the workerd codebase.
markdown-draftsUse markdown formatting when drafting content intended for external systems (GitHub issues/PRs, Jira tickets, wiki pages, design docs, etc.) so formatting is preserved when the user copies it. Load this skill before producing any draft the user will paste elsewhere.
parent-project-skillsBootstrap skill for discovering additional skills and context from a parent project when workerd is used as a submodule. Load this skill when tasks span project boundaries (e.g., Sentry/production investigation, integration testing, cross-repo debugging).
pr-review-guideGuidelines for posting pull request review comments via GitHub CLI, including suggested edits format, handling unresolved comments, etiquette, and report/issue tracking. Load this skill when reviewing a PR via GitHub and posting inline comments.