skills/debugging/static-bug-detector/SKILL.md
Identifies bugs through static code analysis (null dereferences, type mismatches, control flow issues) without executing the program. Use when scanning code for defects before running tests, when the user asks for static analysis, or when integrating with CI for defect detection.
npx skillsauth add santosomar/general-secure-coding-agent-skills static-bug-detectorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Find bugs that are syntactically provable without running the code. This is the fast, shallow pass: it won't catch design bugs, but everything it catches is real (or should be — see FP suppression below).
| Defect class | What to look for | False-positive trap |
| ----------------------- | ------------------------------------------------------------- | ------------------------------------------------ |
| Null/undefined deref | Path where x could be null and is dereferenced | Framework guarantees non-null (Spring @Autowired, DI) |
| Uninitialized read | Variable read before any assignment on some path | Language zero-initializes (Go, Java fields) |
| Dead store | Assignment never read before reassign/return/scope-end | Intentional — value used by debugger/reflection |
| Unreachable code | Statements after unconditional return/throw/break | Intentional dead-switch-default for exhaustiveness |
| Resource leak | open/acquire with no close/release on all exit paths | Ownership transferred to caller (factory pattern) |
| Unchecked return | err/Result/error-returning API call ignored | Intentionally best-effort (_ = file.Close()) |
| Always-true/false cond | Condition provably constant via value-range or type | Defensive belt-and-suspenders after earlier guard |
| Identical branches | if/else bodies are syntactically identical | Copy-paste placeholder during dev — rarely intentional |
| Self-assignment / no-op | x = x, list.remove(x); list.add(x) with no side effect | Rarely intentional; near-always a bug |
| Format string mismatch | printf/format arg count or type mismatch | Almost never a false positive |
| Integer over/underflow | Arithmetic that provably exceeds type range | Intentional wraparound (hash, checksum) |
Sort findings by severity × confidence × reachability:
Before reporting, check each finding against the FP-trap column above. Then:
// NOSONAR, # noqa, // SAFETY:). If someone already justified it, lower confidence to 0.strictNullChecks), you're fighting the compiler.Code:
public String getDisplayName(User u) {
if (u.getNickname() != null) {
return u.getNickname();
}
return u.getFullName().toUpperCase(); // line 12
}
Finding:
src/User.java:12 NULL_DEREFERENCE severity=high confidence=0.7
`u.getFullName()` may return null (no @NonNull annotation, and UserBuilder
permits `fullName` to be unset), and `.toUpperCase()` would NPE.
Callers checked: 3/3 pass non-null `u`, so the outer `u` is safe.
But no caller guarantees `u.fullName` is set.
Suggested fix:
return Optional.ofNullable(u.getFullName()).map(String::toUpperCase).orElse("");
*.pb.go or *_generated.ts. Report the generator config instead if the pattern is dangerous.xOrNull, maybe_x, Optional[X] in docstrings) and flow-sensitive narrowing. Accept the lower confidence.confidence=low and note why.if DEBUG: or #ifdef blocks as bugs. It's conditional, not dead.node_modules/.Emit SARIF if the consumer is CI. Otherwise:
<file>:<line> <RULE_ID> severity=<low|med|high> confidence=<0.0-1.0>
<one-line explanation of why this is a bug>
<one-line suggested fix, or "manual review required">
development
Extracts human-readable pseudocode from a verified formal artifact (Dafny, Lean, TLA+) while preserving the verified properties as annotations, so the proof-carrying logic can be reimplemented in a production language. Use when porting verified code to an unverified target, when documenting what a formal spec actually does, or when handing a verified algorithm to an implementer.
development
Translates natural-language or pseudocode descriptions of concurrent and distributed systems into TLA+ specifications ready for the TLC model checker. Identifies state variables, actions, type invariants, safety properties, and liveness properties from the description. Use when formalizing a protocol, when the user describes a distributed algorithm to verify, when designing a consensus or locking scheme, or when starting formal verification of a concurrent system.
testing
Reduces a TLA+ model so TLC can actually check it — shrinks constants, adds state constraints, abstracts data, or applies symmetry — when the state space is too large to enumerate. Use when TLC runs out of memory, when checking takes hours, or when a spec works at N=2 and you need confidence at larger scale.
development
TLA+-specific instance of model-guided repair — reads a TLC error trace, identifies the enabling condition that should have been false, strengthens the corresponding action, and maps the fix to source code. Use when TLC reports an invariant violation or deadlock and you have the code-to-TLA+ mapping from extraction.