
Static Analysis
- 781 installs
- 155 repo stars
- Updated June 27, 2026
- mohitmishra786/low-level-dev-skills
Static Analysis is a C++ agent skill that configures clang-tidy checks—including bugprone, security, and modernization rules—to surface defects in low-level code before merge or deployment.
About
Static Analysis is a mohitmishra786/low-level-dev-skills module centered on clang-tidy for C and C++ codebases. It documents high-value check groups, prominently the bugprone-* family that catches use-after-move, suspicious memset on pointers, narrowing conversions, identical if/else branches, and macro parenthesis errors. Developers reach for Static Analysis when hardening systems code, preparing PR reviews, or enabling modernization passes without manually curating hundreds of LLVM check names. The skill maps each check to concrete failure modes—integer division assigned to float, signed char as array index, and brittle string constructors—so agents recommend targeted .clang-tidy configs. Outputs include prioritized check lists, suggested NOLINT exceptions, and CI-ready clang-tidy invocation patterns for repositories using CMake or compile_commands.json.
- Enables the full bugprone-* group that catches 9 critical issues including use-after-move, integer-division pitfalls, an
- Activates deep clang-analyzer-* checks covering null dereferences, malloc/free errors, and insecure API usage
- Applies modernize-* rules to upgrade code to modern C++ standards such as nullptr, override, and auto
- Runs as a static analysis checker that produces severity-classified findings for review
- Hard gate: review all HIGH severity issues before commit
Static Analysis by the numbers
- 781 all-time installs (skills.sh)
- +40 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #181 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill static-analysisAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 781 |
|---|---|
| repo stars | ★ 155 |
| Security audit | 3 / 3 scanners passed |
| Last updated | June 27, 2026 |
| Repository | mohitmishra786/low-level-dev-skills ↗ |
Which clang-tidy checks catch C++ bugs?
Automatically surface bugs, security issues, and modernization opportunities in C++ code before merging or deploying.
Who is it for?
C++ systems engineers enabling clang-tidy gates on performance-critical or security-sensitive code before merge.
Skip if: Pure JavaScript or Python repos with no clang-tidy toolchain or compile_commands.json available.
When should I use this skill?
A developer asks to run static analysis on C++, configure clang-tidy, or find bugprone checks before merging C++ changes.
What you get
.clang-tidy configuration, prioritized check enablement list, and CI review findings for C++ sources.
- .clang-tidy config
- CI check list
- Annotated defect findings
By the numbers
- Documents 9+ bugprone-* checks including use-after-move, integer-division, and branch-clone
- bugprone-* check group marked as always enable for C++ review
Files
Static Analysis
Purpose
Guide agents through selecting, running, and triaging static analysis tools for C/C++ — clang-tidy, cppcheck, and scan-build — including suppression strategies and CI integration.
Triggers
- "How do I run clang-tidy on my project?"
- "What clang-tidy checks should I enable?"
- "cppcheck is reporting false positives — how do I suppress them?"
- "How do I set up scan-build for deeper analysis?"
- "My build is noisy with static analysis warnings"
- "How do I generate compile_commands.json for clang-tidy?"
Workflow
1. Generate compile_commands.json
clang-tidy requires a compilation database:
# CMake (preferred)
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ln -s build/compile_commands.json .
# Bear (for Make-based projects)
bear -- make
# compiledb (alternative for Make)
pip install compiledb
compiledb make2. Run clang-tidy
# Single file
clang-tidy src/foo.c -- -std=c11 -I include/
# Whole project via compile_commands.json
run-clang-tidy -p build/ -j$(nproc)
# With specific checks enabled
clang-tidy -checks='bugprone-*,modernize-*,performance-*' src/foo.cpp
# Apply auto-fixes
clang-tidy -checks='modernize-use-nullptr' -fix src/foo.cpp3. Check category decision tree
Goal?
├── Find real bugs → bugprone-*, clang-analyzer-*
├── Modernise C++ code → modernize-*
├── Follow core guidelines → cppcoreguidelines-*
├── Catch performance issues → performance-*
├── Security hardening → cert-*, hicpp-*
└── Readability / style → readability-*, llvm-*| Category | Key checks | What it catches |
|---|---|---|
bugprone-* | use-after-move, integer-division, suspicious-memset-usage | Likely bugs |
modernize-* | use-nullptr, use-override, use-auto | C++11/14/17 idioms |
cppcoreguidelines-* | avoid-goto, pro-bounds-*, no-malloc | C++ Core Guidelines |
performance-* | unnecessary-copy-initialization, avoid-endl | Performance regressions |
clang-analyzer-* | core.*, unix.*, security.* | Path-sensitive bugs |
cert-* | err34-c, str51-cpp | CERT coding standard |
4. .clang-tidy configuration file
# .clang-tidy — place at project root
Checks: >
bugprone-*,
modernize-*,
performance-*,
-modernize-use-trailing-return-type,
-bugprone-easily-swappable-parameters
WarningsAsErrors: 'bugprone-*,clang-analyzer-*'
HeaderFilterRegex: '^(src|include)/.*'
CheckOptions:
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: readability-identifier-naming.VariableCase
value: camelCase5. Suppress false positives
// Suppress a single line
int result = riskyOp(); // NOLINT(bugprone-signed-char-misuse)
// Suppress a block
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
constexpr int BUFFER_SIZE = 4096;
// Suppress whole function
[[clang::suppress("bugprone-*")]]
void legacy_code() { /* ... */ }Or in .clang-tidy:
# Exclude third-party directories
HeaderFilterRegex: '^(src|include)/.*'
# Disable specific checks
Checks: '-bugprone-easily-swappable-parameters'6. Run cppcheck
# Basic run
cppcheck --enable=all --std=c11 src/
# With compile_commands.json
cppcheck --project=build/compile_commands.json
# Include specific checks and suppress noise
cppcheck --enable=warning,performance,portability \
--suppress=missingIncludeSystem \
--suppress=unmatchedSuppression \
--error-exitcode=1 \
src/
# Generate XML report for CI
cppcheck --xml --xml-version=2 src/ 2> cppcheck-report.xml--enable= value | What it checks |
|---|---|
warning | Undefined behaviour, bad practices |
performance | Redundant operations, inefficient patterns |
portability | Non-portable constructs |
information | Configuration and usage notes |
all | Everything above |
7. Path-sensitive analysis with scan-build
# Intercept a Make build
scan-build make
# Intercept CMake build
scan-build cmake --build build/
# Show HTML report
scan-view /tmp/scan-build-*/
# With specific checkers
scan-build -enable-checker security.insecureAPI.gets \
-enable-checker alpha.unix.cstring.BufferOverlap \
makescan-build finds deeper bugs than clang-tidy: use-after-free across functions, dead stores from logic errors, null dereferences on complex paths.
8. CI integration
# GitHub Actions
- name: Static analysis
run: |
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
run-clang-tidy -p build -j$(nproc) -warnings-as-errors '*'
- name: cppcheck
run: |
cppcheck --enable=warning,performance \
--suppress=missingIncludeSystem \
--error-exitcode=1 \
src/For clang-tidy check details, see references/clang-tidy-checks.md.
Related skills
- Use
skills/compilers/clangfor Clang toolchain and diagnostic flags - Use
skills/compilers/gccfor GCC warnings as complementary analysis - Use
skills/runtimes/sanitizersfor runtime bug detection alongside static analysis - Use
skills/build-systems/cmakeforCMAKE_EXPORT_COMPILE_COMMANDSsetup
clang-tidy Check Reference
High-Value Check Groups
bugprone-* (always enable)
| Check | What it catches |
|---|---|
bugprone-use-after-move | Using a C++ moved-from object |
bugprone-integer-division | Integer division assigned to float |
bugprone-suspicious-memset-usage | memset(p, 0, sizeof(p)) on pointer |
bugprone-macro-parentheses | Unparenthesised macro arguments |
bugprone-signed-char-misuse | Signed char used as array index |
bugprone-string-constructor | std::string(0) instead of "" |
bugprone-narrowing-conversions | Narrowing int → smaller type |
bugprone-branch-clone | Identical if/else branches |
bugprone-infinite-loop | Loop with no exit condition |
clang-analyzer-* (deep path analysis)
| Check | What it catches |
|---|---|
clang-analyzer-core.NullDereference | Null pointer deref |
clang-analyzer-core.UndefinedBinaryOperatorResult | Uninit value in expr |
clang-analyzer-unix.Malloc | malloc/free misuse |
clang-analyzer-unix.API | POSIX API misuse |
clang-analyzer-security.insecureAPI.* | gets, strcpy, rand |
clang-analyzer-cplusplus.NewDelete | new/delete mismatches |
modernize-* (C++11/14/17 upgrades)
| Check | Migration |
|---|---|
modernize-use-nullptr | NULL → nullptr |
modernize-use-override | Add override to virtual |
modernize-use-auto | Deduce obvious types |
modernize-use-emplace | push_back(T(...)) → emplace_back |
modernize-loop-convert | for index loops → range-for |
modernize-use-default-member-init | In-class member init |
modernize-use-nodiscard | Add [[nodiscard]] |
performance-*
| Check | What it catches |
|---|---|
performance-unnecessary-copy-initialization | Copy when const ref suffices |
performance-avoid-endl | std::endl flushes; use '\n' |
performance-for-range-copy | Range-for copies when ref suffices |
performance-move-const-arg | std::move on const has no effect |
Recommended Starter Configuration
Checks: >
bugprone-*,
clang-analyzer-core.*,
clang-analyzer-unix.*,
clang-analyzer-security.*,
modernize-use-nullptr,
modernize-use-override,
performance-*,
-modernize-use-trailing-return-type,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result
WarningsAsErrors: 'bugprone-*,clang-analyzer-*'
HeaderFilterRegex: '^(src|include)/.*'Suppressions Reference
// Per-line
foo(); // NOLINT
foo(); // NOLINT(check-name)
// Per-next-line
// NOLINTNEXTLINE(check-name)
foo();
// Per-block
// NOLINTBEGIN(check-name)
...
// NOLINTEND(check-name)Common False Positive Patterns
| False positive | Suppression strategy |
|---|---|
| Third-party headers | HeaderFilterRegex to exclude |
| Platform-specific compat code | NOLINT at call site |
| Legacy C-style casts in C code | -modernize-use-* for C projects |
bugprone-easily-swappable-parameters on intentional API | Disable globally |
Related skills
How it compares
Pick Static Analysis for curated clang-tidy enablement; use compiler warnings alone when the team only needs -Wall without LLVM check catalogs.
FAQ
Which clang-tidy group does Static Analysis prioritize?
Static Analysis prioritizes the bugprone-* check group for always-on C++ review. Documented checks include use-after-move, integer-division, suspicious-memset-usage, narrowing-conversions, and branch-clone among others.
When should developers run Static Analysis?
Developers should run Static Analysis before merging or deploying C++ changes when automated defect detection is required. The skill fits PR review setup and CI integration with clang-tidy and compile_commands.json.
Is Static Analysis safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.