skills/targeted-vuln-analysis/SKILL.md
Use this skill when performing the actual vulnerability analysis AFTER a threat model has been established (see threat-model skill). Triggers when the user asks to find vulnerabilities, audit code for security, hunt for bugs, or perform security review of source code AND a threat model already exists or the codebase context is clear. This skill enforces depth-first, exploitability-proven analysis — it actively prevents the breadth-first pattern-matching that produces lists of theoretical vulnerabilities. Do NOT use without a threat model; use threat-model skill first. Do NOT use for general code quality review.
npx skillsauth add kylejryan/better-code targeted-vuln-analysisInstall 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.
The default behavior when asked to "find vulnerabilities in this code" is breadth-first hallucination: scan every file, pattern-match against known CWE classes, and produce a long list of theoretical possibilities. This fails for two reasons:
Broad prompts invite broad answers. The model pattern-matches common bug classes even when they are not possible in the code's actual context. You end up reviewing theoretical vulnerabilities in code paths no attacker could reach.
Without depth, nothing is proven. A finding that says "this function concatenates user input into SQL" is a pattern match. A finding that traces the exact path from HTTP request → parameter extraction → string concatenation → query execution, demonstrates that no sanitizer exists on that path, and shows the concrete payload that exploits it — that is a vulnerability. The first is noise. The second is actionable.
This skill enforces depth-first analysis: pick a specific attack surface from the threat model, go deep on it, prove or disprove exploitability, and only then move to the next surface. Never scan broadly.
Every finding must be PROVEN exploitable through an actual traced code path, or explicitly marked as unconfirmed/theoretical. "This pattern looks vulnerable" is never acceptable as a finding. Either trace the full path and prove it, or don't report it.
A threat model must exist before this skill runs. The threat model provides:
If no threat model exists, stop and build one first using the threat-model skill. Analyzing code without a threat model is the root cause of the noise problem.
| Phase | Action | Priority | Prefix |
|-------|--------|----------|--------|
| 1 | Select Target Surface | CRITICAL | target |
| 2 | Map the Concrete Code Path | CRITICAL | trace |
| 3 | Identify Controls Along the Path | HIGH | control |
| 4 | Prove or Disprove Exploitability | CRITICAL | exploit |
| 5 | Anti-Pattern Suppression | HIGH | antipattern |
| 6 | Document and Report | HIGH | report |
The cycle: Select target → Map path → Identify controls → Prove exploitability → Document → Next target. Never revert to breadth-first scanning. If you have time to analyze 3 surfaces deeply, that is infinitely more valuable than shallowly scanning 30.
Work through phases sequentially for each attack surface. Read reference files for detailed guidance:
references/target-scoping-from-threat-model.md — How to select and scope targetsreferences/target-well-scoped-examples.md — Examples of good vs bad target scopingreferences/trace-data-flow-mapping.md — Source-to-sink path tracing techniquesreferences/trace-framework-specific.md — Framework-specific tracing patternsreferences/control-bypass-evaluation.md — Evaluating and bypassing security controlsreferences/control-common-patterns.md — Common control patterns and their limitsreferences/exploit-payload-construction.md — Constructing proof-of-concept payloadsreferences/exploit-static-analysis-limits.md — What static analysis can and cannot provereferences/antipattern-breadth-first.md — Recognizing and suppressing breadth-first hallucinationreferences/antipattern-cwe-dumping.md — Avoiding CWE database dump reportsreferences/report-finding-template.md — Detailed finding documentation formatreferences/report-confidence-calibration.md — Confidence levels and honest scopingStructure the final report as:
# Security Analysis: [System Name]
## Threat Model Reference: [link or section reference]
## Scope: [what was analyzed and to what depth]
## Confirmed Findings
[Full finding documentation per finding template]
## Likely Exploitable (Pending Verification)
[Findings with traced paths but unverifiable conditions]
## Investigated and Not Vulnerable
[Paths analyzed and found protected — proves thoroughness]
## Unconfirmed (Requires Further Analysis)
[Pattern matches that could not be fully traced — honest about limits]
## Surfaces Not Yet Analyzed
[Remaining items from threat model priority list — shows what's left]
The "Investigated and Not Vulnerable" section proves depth. The "Surfaces Not Yet Analyzed" section is honest scoping — it tells the user what was covered and what wasn't.
Before finalizing any analysis, verify:
development
Staff+ engineering patterns for maximum leverage per line of code. Use this skill when designing abstractions, building reusable primitives, creating shared libraries, reducing code through architecture, reviewing code for leverage and reuse potential, choosing between building vs configuring, or establishing conventions and patterns across a codebase.
development
Use this skill when designing test strategies, writing tests beyond basic unit tests, verifying software for production readiness, or improving test coverage and reliability. Triggers when the user asks about testing strategy, integration tests, end-to-end tests, contract tests, property-based tests, load tests, chaos testing, test architecture, flaky tests, test confidence, 'how do I test this,' 'how do I know this is safe to deploy,' 'my tests are flaky,' 'what should I test,' 'test coverage,' CI/CD test pipelines, or any question about software verification and validation. Also triggers when the user is shipping a change and wants confidence it won't break production. Primarily targets TypeScript and Go but principles apply universally. Do NOT use for writing basic unit tests for simple functions — this skill is for the harder testing questions.
development
Use this skill when debugging software issues, performing root cause analysis, triaging errors from logs or alerts, or investigating why code isn't working as expected. Triggers when the user shares an error message, stack trace, log output, failing test, unexpected behavior, crash report, performance degradation, or says things like 'this isn't working,' 'I'm getting an error,' 'help me debug,' 'why is this failing,' 'something broke,' or 'I can't figure out what's wrong.' Also use when the user has been going back and forth trying fixes that aren't working — this is the signal to stop guessing and start systematically diagnosing. Do NOT use for writing new code from scratch, general code review, or feature development unless a bug is involved.
development
Principal-engineer / architect review loop driven by desired state and invariants rather than feature lists. Use this skill when scoping a new initiative, kicking off a feature or refactor, reviewing a design doc or PR for over-scope, cutting work that isn't paying for itself, deciding what to defer, or reviewing whether a system actually reaches the state it claims. Triggers on phrases like "what should we cut," "is this the right scope," "what are the invariants here," "are we over-engineering," "design review," "principal review," "architect review," "what must be true when this is done," or whenever the team is choosing between building more vs. building right.