From code-analysis-cpp
C++/C language strategy for code-analysis. Returns 2-phase analysis strategy, file classification, auto-exclusions, framework detection rules, and post-preprocessing commands. v2: declares hard-require static_tools for phase 1 (ca-pair-headers, ca-metrics) and phase 2 (clang-tidy, cppcheck, iwyu, ca-metrics).
How this skill is triggered — by the user, by Claude, or both
Slash command
/code-analysis-cpp:strategyhaikuThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
C/C++ separates declarations (headers) from implementations (source files), so **2-Phase analysis** is used.
C/C++ separates declarations (headers) from implementations (source files), so 2-Phase analysis is used.
| Phase | Target | Focus | Condition |
|---|---|---|---|
| 1 — Structure | .h, .hpp, .hxx, .hh, .inl, .ipp | Class design, API surface, inheritance, dependencies | Always |
| 2 — Implementation | .cpp, .cc, .cxx, .c | Complexity, bug patterns, resource management, logic defects | User selects subsystem scope |
header field, or files with extensions .h/.hpp/.hxx/.hh/.inl/.ippanalyze-file skill (file_role: "declaration")After Phase 1 report, present to user:
Structure analysis complete. Select subsystems for deep-dive:
# Subsystem Files Hotspots Key Issues 1 Combat (Attack, Enemy, Weapon) 45 cpp 3 God function 2 Stat (Stat, SpecialStat, Buff) 32 cpp 5 Extension explosion 3 UI (Widget, UIHandler) 88 cpp 1 — Specify by number, glob pattern, or "all".
Subsystem classification is auto-generated from dependency clusters and naming patterns found in Phase 1.
.cpp files in the user-selected scope from analysis plan.cpp with analyze-file skill (file_role: "implementation")
.h mirror as read-only context (do not re-analyze)| Extension | file_role | Phase | Note |
|---|---|---|---|
.h, .hpp, .hxx, .hh | declaration | 1 | Class declarations, API, macros |
.inl, .ipp | declaration | 1 | Inline implementations (treated as headers) |
.cpp, .cc, .cxx, .c | implementation | 2 | Function bodies, logic |
.generated.h, *.gen.cpp | skip | — | Code-generator output |
*.generated.h, *.gen.cpp — code generator outputThirdParty/** — third-party libraries**/build/**, **/out/** — build artifactsFramework detection is owned by each framework pack via its own strategy/SKILL.md
framework_detection YAML block. When /analyze init gate loads a language pack, it
subsequently enumerates installed code-analysis-{framework}:strategy skills whose
requires_language equals this language, and applies each pack's signatures.
Framework strategies extend (never replace) this language strategy — static_tools, entry points, and dead-code exclusions from both packs are combined by the orchestrator.
.h) analysisFocus: What role does this file play in the project architecture?
Lightweight mode: Even if function bodies are inlined in headers, defer deep implementation analysis to Phase 2. Report only obvious bugs found inline.
.cpp) analysisFocus: Implementation quality and latent defects
.h mirror first to understand class structure/API.h) and implementation (.cpp)The following YAML block is the authoritative declaration consumed by phase3-trace.
Surrounding notes are clarifying commentary only.
entry_points:
symbols:
- main
- WinMain
- DllMain
include_root_files: true
symbols: canonical runtime entry symbols the language runtime calls directly.include_root_files: true: files with no incoming edges in the import graph are
treated as additional entry points (library exports without callers). Queried via
MATCH (f:File) WHERE NOT ()-[:IMPORTS]->(f) RETURN f.path.Do NOT flag as dead code:
main() function — always an entry pointoperator overloads — called by implicit conversions/expressionsAfter structure-analyzer Step 1.5 snapshots the GitNexus graph, the core CLI automatically runs pair-headers for C++ projects (codeanalyzer pair-headers). This pairs .h/.cpp files by matching base names and updates analysis-plan.json with header/source fields for each compilation unit. Metrics are then computed via codeanalyzer compute-metrics.
This plugin provides the following extension hooks. The core pipeline registers these at init time and invokes them at the corresponding pipeline stages.
| Hook Point | Skill Name | Invocation Context |
|---|---|---|
after-analyze-file | code-analysis-cpp:after-analyze-file | Per-file, after mirror document is written |
after-phase3-trace | code-analysis-cpp:after-phase3-trace | After Phase 3 flow analysis completes |
phase4-docs | code-analysis-cpp:phase4-docs | During Phase 4 documentation generation |
The core orchestrator invokes these via codeanalyzer run-tools --strategy <this-file> --phase <phase>.
All tools are hard-require — missing tools abort /analyze initialization.
static_tools:
phase1:
- name: ca-pair-headers
command: "codeanalyzer pair-headers --scope={scope}"
output_parser: ca-json
- name: ca-metrics
command: "codeanalyzer compute-metrics --file {file} --json"
output_parser: ca-json
phase2:
- name: clang-tidy
command: "clang-tidy {file} --quiet --export-fixes=- --format=json"
output_parser: clang-tidy-json
- name: cppcheck
command: "cppcheck --template='{severity}|{line}|{id}|{message}' --enable=all {file}"
output_parser: cppcheck-pipe
- name: include-what-you-use
command: "include-what-you-use {file}"
output_parser: iwyu-text
- name: ca-metrics
command: "codeanalyzer compute-metrics --file {file} --json"
output_parser: ca-json
phase3: []
phase4: []
Installation (platform hints)
brew install llvm cppcheck include-what-you-useapt install clang-tidy cppcheck iwyuwinget install LLVM.LLVM), cppcheck separately.npx claudepluginhub juyeongyi/jylee_claude_marketplace --plugin code-analysis-cppCreates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.