cpp-modules

A guide to C++20 modules, a way to organise and share code using imports instead of relying only on copied header files.

In plain words
What is it for?
Use it when creating or importing named modules, module partitions, or header units, configuring CMake or Clang, and moving an older header-based project to modules.
Why use it?
It helps explain module types, compiler settings, build-system integration, and errors involving compiled module information.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/mohitmishra786/low-level-dev-skills/cpp-modules
Any agent
npx skills add mohitmishra786/low-level-dev-skills --skill cpp-modules
Clone the repo
git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills

Made for: Claude Code, Codex.

Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,605 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00076 $0.01605
Opus 5 $0.00038 $0.00803
Sonnet 5 $0.00015 $0.00321
Haiku 4.5 $0.00008 $0.00161

Measured 3d ago against content hash fbbb5ea5d334, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cpp-modules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/compilers/cpp-modules/SKILL.md · 203 lines

How it starts

The opening of the file, as written. The whole thing — 203 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

// math.cppm — module interface unit
export module math;          // declares the module name

export int add(int a, int b) { return a + b; }
export double pi = 3.14159;

// Non-exported (module-private)
int internal_helper() { return 42; }
// main.cpp — consumer
import math;                 // import the module
#include <iostream>          // legacy header (still works)

int main() {
    std::cout << add(2, 3) << "\n";  // 5
    std::cout << pi << "\n";
}

3. Module partitions

// math-core.cppm — partition
export module math:core;     // partition 'core' of module 'math'

export int add(int a, int b) { return a + b; }
// math.cppm — primary module interface
export module math;
export import :core;         // re-export the partition
// math-impl.cpp — implementation unit (no export)
module math;                 // belongs to 'math' module, not a partition
// has access to all math declarations, but exports nothing

Read the full file on GitHub · 203 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 203 lines · 76 tokens per session scan A fbbb5ea5d334

Subscribe to this mod's changes

cpp-modules is a skill published in the GitHub repository mohitmishra786/low-level-dev-skills (192 stars, last pushed 2mo ago), licensed MIT. It adds 76 tokens to every session and 1,605 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

spanify-buffers

Find and fix unsafe buffer operations in a C++ file by removing UNSAFETODO markers and replacing unsafe raw pointers/C-style functions with base::span and standard safe containers. Use when the user asks to fix unsafe buffer warnings or -Wunsafe-buffer-usage errors. Don't use for other types of memory safety bugs like…

chromium/chromium · 86 tokens

jni-type-conversion

How to use @JniType annotations for ergonomic JNI. Relevant for Java files that use @NativeMethods or @CalledByNative.

chromium/chromium · 32 tokens

cpp-pro

Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques. Use when building or refactoring C++ code requiring concepts, ranges, coroutines, SIMD optimization, or careful memory management — or when addressing performance…

Jeffallan/claude-skills · 79 tokens

qt-cpp-docs

Generates standalone Markdown reference documentation for any Qt/C++ source files — Qt Widgets classes, Qt Quick backends, Qt/C++ modules, plain C++ utilities, structs, free-function headers, and entry points like main.cpp. Use this skill to document any .h or .cpp file: Qt classes, plain C++ code, utility helpers, or…

mavlink/qgroundcontrol · 155 tokens

cpu-kernels

Provides guidance for writing, optimizing, and benchmarking C++ CPU kernels with SIMD intrinsics (AVX2/AVX512) for the Hugging Face kernels ecosystem. Includes a two-phase workflow: Phase 1 correctness (generic → AVX2) and Phase 2 performance exploration (AVX512 with branching trial loop), runtime CPU dispatch, OpenMP…

huggingface/kernels · 89 tokens

implementing-jsc-classes-cpp

Implements JavaScript classes in C++ using JavaScriptCore. Use when creating new JS classes with C++ bindings, prototypes, or constructors.

oven-sh/bun · 38 tokens