Skip to content

C++20 modules guide covering named modules, partitions, header units, CMake FILE_SET setup, and Clang/GCC build flags.

CCM score
64 of 100
skills.sh installs
669
GitHub stars
303
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers named module interface units, module partitions, header units, and migrating legacy headers to C++20 modules
  • Includes Clang --precompile and -fmodule-file= workflows, GCC -fmodules-ts builds, and a CMake 3.28 FILE_SET CXX_MODULES example
  • Tabulates common errors such as module not found, macros unavailable after import, and stale BMI caches, with fixes
  • Designed for C++ projects adopting modules from headers, including wrapping C libraries through the Global Module Fragment

Install

$ npx -y skills add mohitmishra786/low-level-dev-skills --skill cpp-modules -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

C++20 Modules

Purpose

Guide agents through authoring, building, and debugging C++20 modules: named modules vs header units, module partitions, CMake integration, compiler-specific flags, and interoperability with legacy headers.

Triggers

  • "How do I write a C++20 module?"
  • "How do I import a module in CMake?"
  • "What's the difference between a named module and a header unit?"
  • "My module gives 'cannot find module' errors"
  • "How do I use C++20 modules with Clang?"
  • "How do I migrate from headers to modules?"

Workflow

1. Module concepts overview

C++20 module kinds:
├── Named module interface unit  (.cppm / .ixx)  — exports declarations
├── Module implementation unit   (.cpp)           — defines module members
├── Module partition             (.cppm)          — internal module subdivision
└── Header unit                  (any header)     — import a legacy header as module

Named modules are the primary target. Header units are a bridge for legacy code. Avoid Global Module Fragment unless required for macro access.

2. Named module — minimal example

Details

Repository
github.com/mohitmishra786/low-level-dev-skills
First seen
Jun 3, 2026

Questions

What does the cpp-modules skill help with?

The cpp-modules skill guides agents through writing, building, and debugging C++20 modules, including named modules, module partitions, and header units. It also covers CMake MODULE_SOURCES setup, Clang -fmodules-ts flags, and BMI caching issues. It is aimed at developers migrating legacy headers to modules.

How do I install the cpp-modules skill?

Run npx -y skills add mohitmishra786/low-level-dev-skills --skill cpp-modules -y in your project. After installing, the agent can write named module interface units and partitions for you. It can also set up CMake FILE_SET CXX_MODULES targets and debug module import errors.

What is the difference between a named module and a header unit in C++20?

A named module is the primary target, declared with export module and imported with import. A header unit lets you import a legacy header such as iostream with import, but it does not pass macros to importers. The skill explains both and when to use the Global Module Fragment for macro access.

Why does my C++ module give a 'cannot find module' error?

That error usually means the BMI file is not in the search path, so the interface unit must be compiled first. The skill checks -fmodule-file= flags and the build order. It also covers stale BMI caches in .pcm and .gcm files.

More from mohitmishra786/low-level-dev-skills

All 54

Similar to Cpp Modules