/odin-native:cpp-templatesfrom ODIN Native
Decodes C++ template errors, replaces SFINAE with concepts/requires-clauses, and profiles slow template instantiation.
Ships in ODIN Native. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Field | Bound contract |
|---|---|
| Trigger | The user shows a long template error, asks how to constrain a template, asks SFINAE versus concepts, or reports that template-heavy translation units compile slowly. |
| Authority | Read-only. The skill emits readings, constraint rewrites, and profiling commands to chat; the user edits the code. Rollback is not needed. No remote mutation. |
| Side effect | Chat output. Profiling commands write trace files where the user runs them. |
| Done | The failing instantiation is named with the substitution that failed, the proposed constraint compiles on the user's standard, and any compile-time claim carries a measurement command. |
-std=: required. Concepts need C++20; C++23 is the current standard and C++20 the floor.compile_commands.json or a single reproducing TU: required for profiling.Read the error from the bottom up. The first error: line names the user's call; the required from here (GCC) or in instantiation of (Clang) notes trace the chain; the last note names the type whose substitution failed. Shorten the chain with -ftemplate-backtrace-limit=N (GCC and Clang); with GCC add -fconcepts-diagnostics-depth=N for concept failures; with Clang add -fno-elide-type to print full types and -fdiagnostics-show-template-tree for a tree diff of the mismatch. Done when: the failing substitution and the call site are named.
Write the constraint with concepts when the standard is C++20 or later:
template <typename T> concept Arithmetic = std::is_arithmetic_v<T>;
template <typename T> concept Container = requires(T c) {
c.begin(); c.end(); c.size(); typename T::value_type;
};
template <Arithmetic T> T square(T x) { return x * x; }
auto square(Arithmetic auto x) { return x * x; }
template <typename T> requires Arithmetic<T> && (sizeof(T) >= 4)
T big_square(T x) { return x * x; }
Requires-expression forms: expr; checks validity, { expr } -> std::same_as<U>; checks the result type, { expr } -> std::convertible_to<U>; checks convertibility, requires Other<T>; nests a constraint. Done when: the constraint expresses the operations the body uses and nothing more.
Recognize SFINAE in existing code and map it to a concept: std::enable_if_t<cond, int> = 0 on a parameter, -> std::enable_if_t<cond, R> on a return type, and the std::void_t<decltype(...)> detection idiom. Replace enable_if with a constraint and void_t detectors with a requires expression. Keep SFINAE only when the standard is below C++20. Done when: each SFINAE site has its concept equivalent or a reason to keep it.
Explain the trade-off when asked. Concepts give a named constraint failure at the call site, participate in overload ranking by subsumption, and read directly; SFINAE gives a wall of candidate notes and ranks by hand-built priority. Compile-time differences depend on the code; measure before claiming one. Done when: the comparison is stated without unmeasured speed claims.
Profile instantiation cost. Clang: -ftime-trace writes <object>.json per TU; aggregate a whole build with ClangBuildAnalyzer --start <dir>, build, ClangBuildAnalyzer --stop <dir> capture.bin, ClangBuildAnalyzer --analyze capture.bin, which lists the templates and template sets that took longest to instantiate. Templight, a Clang-based drop-in, traces every instantiation: templight++ -Xtemplight -profiler -Xtemplight -memory -Xtemplight -ignore-system -c src.cpp writes src.o.trace.pbf; it must be built from source with Clang. Done when: a measurement names the top instantiations.
Reduce the measured cost with the pattern that fits: explicit instantiation (extern template int f<int>(int); in the header, template int f<int>(int); in one TU); if constexpr in place of specialization; a constraint that rejects early instead of a deep substitution failure; splitting heavy template implementations into a header included only where needed. Done when: each proposed change is tied to an instantiation the profile named.
Confirm the rewrite compiles on the user's compiler and standard with a scratch TU before reporting. Done when: the scratch build passes.
| Failure class | Behavior |
|---|---|
| Standard below C++20 | Concepts unavailable; keep SFINAE and shorten diagnostics with the backtrace flags. |
| Diagnostic truncated by the user | Ask for the full output or reproduce it; do not guess the failing type. |
| ClangBuildAnalyzer or Templight absent | Fall back to per-TU -ftime-trace and read the JSON with a trace viewer. |
| Slowness is not instantiation | If the profile names headers or codegen, redirect: caching and PCH belong to build-acceleration. |
| Coroutine template question | C++20 coroutines: use cpp-coroutines. |
A chat report naming the failing instantiation and its cause, the constraint rewrite that compiled on a scratch TU, and, when compile time was the complaint, the measurement command and the instantiations it named with the matching reduction.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub outlinedriven/odin-claude-plugin --plugin odin-native138 skills in this plugin
/abi-and-calling-conventionsUse 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./adc-dac-baremetalUse 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./af-xdpUse 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./apple-siliconUse when tuning or profiling native code on Apple M-series Macs: unified memory, 16 KiB pages, Accelerate and Metal for matrix work, xctrace and leaks, Rosetta 2, or sysctl hardware queries./arm-sveUse when writing or porting AArch64 SIMD to SVE or SVE2: arm_sve.h intrinsics, predicates, vector-length-agnostic loops, auto-vectorization, or SVE registers in GDB. Not for NEON: use simd-intrinsics./assembly-armUse when reading or writing AArch64 or AArch32 Thumb assembly, inline asm in C, AAPCS64 register roles, or NEON and SVE vector code. Not for ABI detail across ISAs: use abi-and-calling-conventions.Other plugins' skills for the same job