Skip to content

mohitmishra786/low-level-dev-skills / skills/build-systems/static-analysis

static-analysis

Verified

Static analysis skill for C/C++ codebases. Use when hardening code quality, triaging noisy builds, running clang-tidy, cppcheck, or scan-build, interpreting check categories, suppressing false positives, or integrating static analysis into CI. Activates on queries about clang-tidy checks, cppcheck, scan-build, compile_commands.json, code hardening, or static analysis warnings.

FileKindSize
SKILL.mdskill md5.7 KB
references/clang-tidy-checks.mdmarkdown3.1 KB

references/clang-tidy-checks.md

View on GitHub
# 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

```yaml
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

```cpp
// 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 |
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall