/code-intelligence:hunting-failing-inputsfrom code-intelligence
Uses Z3 to find inputs that crash parsers, decoders, or WGSL shaders via index-out-of-bounds or overflow. For 'can this crash?' or when fuzzing finds nothing on untrusted byte code.
Ships in code-intelligence. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A trap is an operation with a precondition the input can break: an index in range, a slice end within the length, a non-zero divisor, a sum that must not wrap.
| Situation | Use instead |
|---|---|
| Races, deadlocks, async ordering | race detector or stress test |
| Whole programs, I/O, network, UI | fuzzing plus sanitizers; extract the pure core first |
| Wrong results no precondition expresses | property tests against a reference, or reasoning-semiformally |
| Whether a test can go red | gating |
| Validating or minifying WGSL | compiling-wgsl |
Stop and report a trap as unmodelled (never as safe) when its model needs
more than about 15 unrolled loop iterations, needs heap state that a single
input cannot build, or returns unknown twice.
python3 -m pip install z3-solver tree-sitter-language-pack
SKILL=/mnt/skills/user/hunting-failing-inputs
python3 $SKILL/scripts/selftest.py # optional: SKIP means a missing toolchain, not a pass
List the traps.
python3 $SKILL/scripts/list_traps.py FILE... [--func NAME] prints
file:line:col kind on-failure func source. on-failure is raises,
silent or UB (C, which is silent without sanitizers). Model the silent
and UB traps first. Strike any trap that an earlier guard already makes
safe, and in JS strike object lookups. For Go, use bce_targets.py
instead (see references/go.md).
Read references/<lang>.md for the target's language: python,
javascript, c, wgsl or go. Each one has the failure semantics, the
predicate to model each trap with, the strict harness, and a runnable
example in examples/<lang>/.
Model one pure function. Include the guards its callers enforce as constraints. Without them, Z3 invents inputs the program can never produce.
Write the model from scripts/z3traps.py, copying the nearest
examples/<lang>/model*.py:
import sys; sys.path.insert(0, f'{SKILL}/scripts')
from z3traps import *
n, base = harness(max_len=64)
b0 = byte_at('b0')
base += [n >= 2] # every early return the path got past
solve_traps(base, {'f.py:10 b[k:k+2]': slice_truncates(k, k + 2, n)}, show=(n, b0))
widen exactly where
the source converts. Python ints never wrap. C narrows on a store or a
cast, JS |0 truncates to 32 bits, and WGSL u32 and Go uint8 wrap.cap. Python wraps silently only for -len <= i < 0.in_order=True when the traps are on one straight-line path, and
leave it off when they are on different branches.L = 1, 2, … with symbolic bytes, and
stop at the first sat.< and >= on bit-vectors are signed. For unsigned values,
widen first or use ULT/UGE.Replay each sat inside the strict harness. literal(bytes, lang)
renders the input for a test. Use the harness for the language:
| language | strict harness |
|---|---|
| Python | parse(strict(data)), scripts/strict.py |
| JS / TS | decode(strict(u8)), scripts/strict.mjs |
| C | -fsanitize=address,undefined -fno-sanitize-recover=all, input in an exact-size malloc |
| WGSL | scripts/wgsl_guard.py counts bad indexes in an extra _oob buffer |
| Go | d = d[:len(d):len(d)] |
Then read the result:
| Z3 | replay | meaning |
|---|---|---|
sat | fails at the trap's line | A bug. Report it with the reproducer. |
sat | fails at an earlier line | Re-solve with in_order=True. |
sat | doesn't fail, or fails differently | The model is wrong. Fix it, and never report this as a bug. |
unsat | — | "None within len ≤ N", not "safe". |
unknown | — | Simplify the model. Never count it as unsat. |
Fix, and keep the harness. Patch the code, update the model and expect
unsat, and keep the reproducer as a regression test. Add the strict
harness to the project's existing fuzz targets and property tests.
Every trap you didn't strike ends as one of:
unsat with a stated bound, plus a negative control that went satFor the negative control, remove one guard or widen one field and expect
sat. If the model stays unsat, it is over-constrained and its unsat
means nothing.
sat input doesn't fail as predicted. The model's precondition is
wrong. On 2026-11-13, a Python model treated every negative index as a
silent wrap, and its input b'\x00\xc0' raised IndexError instead.sat input fails at an earlier line. Use
in_order=True. On 2026-11-13, the Go line-16 input panicked at line 14.unsat, including the buggy ones. A guard was modelled
with wide arithmetic where the source uses narrow. Run the negative control.sat. The wrapper covers only
the object you wrapped. Buffers the function builds itself are unwrapped.libclang-rt-<N>-dev is
missing. Install it, or use gcc.CHANGELOG.md (opens in a new tab)examples/c/frame.c (opens in a new tab)examples/c/fuzz.c (opens in a new tab)examples/c/model.py (opens in a new tab)examples/c/repro.c (opens in a new tab)examples/go/go.mod (opens in a new tab)examples/go/model_frame.py (opens in a new tab)examples/go/model_quoted.py (opens in a new tab)examples/go/parse.go (opens in a new tab)examples/go/z3repro_test.go (opens in a new tab)examples/javascript/model.py (opens in a new tab)examples/javascript/samples.mjs (opens in a new tab)examples/javascript/samples.test.mjs (opens in a new tab)examples/python/model_lz.py (opens in a new tab)examples/python/model_record.py (opens in a new tab)examples/python/record.py (opens in a new tab)examples/python/test_record.py (opens in a new tab)examples/wgsl/gather.wgsl (opens in a new tab)examples/wgsl/model.py (opens in a new tab)examples/wgsl/run.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
z3, fuzzing, crash-finding, symbolic-execution, input-generation
14 skills in this plugin
/assessing-impactPre-change blast-radius report for a symbol or file. Walks tree-sitting references, augments with a plain-text scan over non-parsed files (configs, plain docs), and clusters affected sites by feature (`_FEATURES.md`) or top-level package. Use when about to refactor, rename, or delete something in a repo you don't own — "what breaks if I change `validateUser`", "who calls this", "is this safe to remove", "where is this used", "blast radius", "impact analysis". This is the CONVERGENT pre-change risk skill — for "what is this repo?" use exploring-codebases; for "where is X?" use searching-codebases./declaring-invariantsFind tests that enumerate a domain by copying it, and declare the invariants a codebase depends on. Reports where a parametrize list, for-loop, or it.each iterates a hand-written subset of a dict/set/tuple/Enum that exists in the source, and names the members nothing covers. Use when reviewing tests, when a module gains a name-to-thing table, registry, enum, or dispatch map, before trusting a green suite as evidence a domain is covered, or when asked "is this test actually total", "does anything cover X", "what does this repo guarantee", "which invariants do we declare". Also for vacuous tests that pass over an empty collection, for a domain that has silently NARROWED (an enumeration cannot see that), and for recording the refutation that proves a claim can fail./describing-productsBuilds a product description repo for a software product - prose documents that say, feature by feature and event by event, what the user sees, what they can do, and exactly what happens when they do it, including when they stop halfway. Drafted from the code and tests, verified against the running product with hand checklists, and triaged into a bug list. Works for canvas editors, web apps, CLIs, chat products, mobile apps, and libraries or SDKs. Use when asked to "write a product description for X", "describe the user experience of X", "document how X behaves for the user", "make a behavior-spec repo", or for an event-by-event account of an app's behavior rather than API docs. Also resumes or extends an existing product description repo./exploring-codebasesFirst-encounter orientation on a repository nobody here has worked in yet. Runs a fixed five-step workflow — venv setup, tarball fetch, tree-sitting structural scan, featuring synthesis, then reasoning over the two — and yields an account of what the repo contains and how it is arranged, optionally written out as _FEATURES.md. Use for "I just cloned this", "what is this repo", "what does this do", "explore this repo", "give me an orientation", "what are the main features", "review what's new in this repo", or before starting work in a codebase you have not seen. This is the divergent what's-here skill. Route elsewhere for: a named symbol, a file's structure or a line range (tree-sitting); all callers of a Python symbol (searching-codebases); teaching a human the codebase through exercises (orienting-codebases); fetching or cloning a repo without analysing it (accessing-github-repos, cloning-project)./featuringGenerate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tree-sitting (structural) with semantic (why/what-for) layer./mapping-codebasesDEPRECATED — superseded by tree-sitting. This skill generated persistent _MAP.md files; tree-sitting does the same AST extraction at runtime (~700ms for 250 files) with no artifact to write, commit, or keep in sync. Use tree-sitting for "map this codebase", "explore repo", "understand structure", or any code navigation task. The final working version is archived at release mapping-codebases-v0.8.0.npx claudepluginhub oaustegard/claude-skills --plugin code-intelligenceOther plugins' skills for the same job