Fuzz Target Localizer
Purpose
This skill helps an agent quickly narrow a Python repository down to a small set of high-value fuzz targets. It produces:
- A ranked list of important files
- A ranked list of important functions and methods
- A summary of existing unit tests and inferred oracles
- A final shortlist of functions-under-test (FUTs) for fuzzing, each with a structured "note to self" for follow-up actions
When to use
Use this skill when the user asks to:
- Find the best functions to fuzz in a Python package/library
- Identify parsers, decoders, validators, or boundary code that is fuzz-worthy
- Decide what to fuzz based on existing test coverage and API surface
- Produce a structured shortlist of fuzz targets with harness guidance
- Automating testing pipeline setup for a new or existing Python project.
Do not use this skill when the user primarily wants to fix a specific bug,
refactor code, or implement a harness immediately
(unless they explicitly ask for target selection first).
Inputs expected from the environment
The agent should assume access to:
- Repository filesystem
- Ability to read files
- Ability to run local commands (optional but recommended)
Preferred repository listing command:
- Use
tree to get a fast, high-signal view of repository structure (limit depth if needed).
If tree is not available, fall back to a recursive listing via other standard shell tooling.
Outputs
Produce result:
A report in any format with the following information: - Localize important files - Localize important functions - Summarize existing unit tests - Decide function under test for fuzzing
This file should be placed in the root of the repository as APIs.txt,
which servers as the guidelines for future fuzzing harness implementation.
Guardrails
- Prefer analysis and reporting over code changes.
- Do not modify source code unless the user explicitly requests changes.
- If running commands could be disruptive, default to read-only analysis.
- Avoid assumptions about runtime behavior; base conclusions on code and tests.
- Explicitly consider existing tests in the repo when selecting targets and deciding harness shape.
- Keep the final FUT shortlist small (typically 1–5).
Localize important files
Goal
Produce a ranked list of files that are most likely to contain fuzz-worthy logic: parsing, decoding, deserialization, validation, protocol handling, file/network boundaries, or native bindings.
Procedure
Build a repository map
- Start with a repository overview using
tree to identify:
- Root packages and layouts (src/ layout vs flat layout)
- Test directories and configs
- Bindings/native directories
- Examples, docs, and tooling directories
- Identify packaging and metadata files such as:
- pyproject.toml
- setup.cfg
- setup.py
- Identify test configuration and entry points:
- tests/
- conftest.py
- pytest.ini
- tox.ini
- noxfile.py
Exclude low-value areas
- Skip: virtual environments, build outputs, vendored code, documentation-only directories, examples-only directories, generated files.
Score files using explainable heuristics
Assign a file a higher score when it matches more of these indicators:
- Public API exposure: init.py re-exports, all, api modules
- Input boundary keywords in file path or symbols: parse, load, dump, decode, encode, deserialize, serialize, validate, normalize, schema, protocol, message
- Format handlers: json, yaml, xml, csv, toml, protobuf, msgpack, pickle
- Regex-heavy or templating-heavy code
- Native boundaries: ctypes, cffi, cython, extension modules, bindings
- Central modules: high import fan-in across the package
- Test adjacency: directly imported or heavily referenced by tests
Rank and select
- Produce a Top-N list (default 10–30) with a short rationale per file.
Output format
For each file:
- path
- score (relative, not necessarily normalized)
- rationale (2–5 bullets)
- indicators_hit (list)
Localize important functions
Goal
From the important files, identify and rank functions or methods that are strong fuzz targets while minimizing full-body reading until needed.
Approach 1: AST-based header and docstring scan
For each localized Python file, parse it using Python’s ast module and extract only:
- Module docstring
- Function and async function headers (name, args, defaults, annotations, decorators)
- Class headers and method headers
- Docstrings for modules, classes, and functions/methods
Do not read full function bodies during the initial pass unless needed for disambiguation or final selection.
Procedure
Build per-file declarations via AST
- Parse the file with
ast
- Enumerate:
- Top-level functions
- Classes and their methods
- Nested functions only if they are likely to be directly fuzzable via an exposed wrapper
- For each symbol, collect:
- Fully-qualified name
- Signature details (as available from AST)
- Decorators
- Docstring (if present)
- Location information (file, line range if available)
Generate an initial candidate set using headers and docstrings
Prioritize functions/methods that:
- Accept bytes, str, file-like objects, dicts, or user-controlled payloads
- Convert between representations (raw ↔ structured)
- Perform validation, normalization, parsing, decoding, deserialization
- Touch filesystem/network/protocol boundaries
- Call into native extensions or bindings
- Clearly document strictness, schemas, formats, or error conditions
Use tests to refine candidate selection early
- Before reading full bodies, check if tests reference these functions/modules:
- Direct imports in tests
- Fixtures that exercise particular entry points
- Parameterizations over formats and inputs
- Down-rank candidates that are already well-covered unless they are high-risk boundaries (parsers/native bindings).
Confirm with targeted reading only for top candidates
For the top candidates (typically 10–20), read the full function bodies and capture:
- Preconditions and assumptions
- Internal helpers called
- Error handling style and exception types
- Any obvious invariants and postconditions
- Statefulness and global dependencies
Rank and shortlist
Rank candidates using an explainable rubric:
- Input surface and reachability
- Boundary risk (parsing/decoding/native)
- Structural complexity (from targeted reading only)
- Existing test coverage strength and breadth
- Ease of harnessing
Output format
For each function/method:
- qualname
- file
- line_range (if available)
- score (relative)
- rationale (2–6 bullets)
- dependencies (key helpers, modules, external state)
- harnessability (low/medium/high)
Approach 2: Scanning all important files yourself
For each localized Python file, read the file contents directly to extract:
- Module docstring and overall structure
- Function and async function definitions (name, args, defaults, annotations, decorators)
- Class definitions and their methods
- Full function bodies and implementation details
- Docstrings for modules, classes, and functions/methods
This approach reads complete file contents, allowing for deeper analysis at the cost of higher token usage.
Procedure
Read important files sequentially
- For each file from the important files list, read the full contents.
- Extract by direct inspection:
- Top-level functions and their complete implementations
- Classes and their methods with full bodies
- Nested functions if they are exposed or called by public APIs
- For each symbol, collect:
- Fully-qualified name
- Complete signature (from source text)
- Decorators
- Docstring (if present)
- Full function body
- Location information (file, approximate line range)
Generate an initial candidate set using full source analysis
Prioritize functions/methods that:
- Accept bytes, str, file-like objects, dicts, or user-controlled payloads
- Convert between representations (raw ↔ structured)
- Perform validation, normalization, parsing, decoding, deserialization
- Touch filesystem/network/protocol boundaries
- Call into native extensions or bindings
- Contain complex control flow, loops, or recursive calls
- Handle exceptions or edge cases
- Clearly document strictness, schemas, formats, or error conditions
Analyze implementation details from full bodies
For each candidate function, inspect the body for:
- Preconditions and assumptions (explicit checks, assertions, early returns)
- Internal helpers called and their purposes
- Error handling style and exception types raised
- Invariants and postconditions (explicit or implicit)
- Statefulness and global dependencies
- Input transformations and data flow
- Native calls or external process invocations
- Resource allocation and cleanup patterns
Use tests to refine candidate selection
- Check if tests reference these functions/modules:
- Direct imports in tests
- Fixtures that exercise particular entry points
- Parameterizations over formats and inputs
- Down-rank candidates that are already well-covered unless they are high-risk boundaries (parsers/native bindings).
- Note which aspects of each function are tested vs untested.
Rank and shortlist
Rank candidates using an explainable rubric:
- Input surface and reachability
- Boundary risk (parsing/decoding/native)
- Structural complexity (from full body analysis)
- Existing test coverage strength and breadth
- Ease of harnessing
- Observable implementation risks (unsafe operations, unchecked inputs, complex state)
Output format
For each function/method:
- qualname
- file
- line_range (if available)
- score (relative)
- rationale (2–6 bullets)
- dependencies (key helpers, modules, external state)
- harnessability (low/medium/high)
- implementation_notes (key observations from body analysis)
Summarize existing unit tests
Goal
Summarize what is already tested, infer test oracles, and identify gaps that fuzzing can complement.
Hard requirement
Always inspect and incorporate existing tests in the repository when:
- Ranking functions
- Selecting FUTs
- Designing input models and oracles
- Proposing seed corpus sources
Procedure
Inventory tests
- Locate tests and their discovery configuration (pytest.ini, pyproject.toml, tox.ini, noxfile.py).
- Enumerate test modules and map them to source modules via imports.
- Identify shared fixtures and data factories (conftest.py, fixture files, test utilities).
Summarize test intent
For each test module:
- What behaviors are asserted
- What inputs are used
- What exceptions are expected
- What invariants are implied
Infer oracles and properties
Common fuzz-friendly oracles include:
- Round-trip properties
- Idempotence of normalization
- Parser consistency across equivalent inputs
- Deterministic output given deterministic input
- No-crash and no-hang for malformed inputs
Identify coverage gaps
- FUT candidates with no direct tests
- Input classes not covered by tests (size extremes, malformed encodings, deep nesting, edge unicode, invalid schemas)
- Code paths guarded by complex conditionals or exception handlers with no tests
Output format
- test_map: module_under_test → tests → asserted behaviors
- inferred_oracles: list of reusable invariants with the functions they apply to
- gaps: ranked list of untested or weakly-tested candidates
Decide function under test for fuzzing
Goal
Select a final set of FUTs (typically 1–5) and produce a structured "note to self" for each FUT so the agent can proceed to harness implementation, corpus seeding, and fuzz execution.
Selection criteria
Prefer FUTs that maximize:
- Security/robustness payoff (parsing, decoding, validation, native boundary)
- Reachability with minimal setup
- Low existing test assurance or narrow test input coverage
- High fuzzability (simple input channel, clear oracle or crash-only target)
Explicitly weigh:
- What tests already cover (and what they do not)
- What seeds can be extracted from tests, fixtures, and sample data
Required "note to self" template
For each selected FUT, produce exactly this structure:
Fuzzing Target Note
- Target:
- File / location:
- Why this target:
- Input surface:
- Boundary or native considerations:
- Complexity or path depth:
- Current test gaps:
- Callable contract:
- Required imports or initialization:
- Preconditions:
- Determinism concerns:
- External dependencies:
- Input model:
- Primary payload type:
- Decoding or parsing steps:
- Constraints to respect:
- Edge classes to emphasize:
- Oracles:
- Must-hold properties:
- Acceptable exceptions:
- Suspicious exceptions:
- Crash-only vs correctness-checking:
- Harness plan:
- Recommended approach:
- Minimal harness signature:
- Seed corpus ideas:
- Timeouts and resource limits:
- Risk flags:
- Native extension involved:
- Potential DoS paths:
- External I/O:
- Next actions:
Output format
- selected_futs: list of chosen FUTs with brief justification
- notes_to_self: one "Fuzzing Target Note" per FUT
Final JSON block
At the end of the report, include a JSON object with:
- important_files: [{path, score, rationale, indicators_hit}]
- important_functions: [{qualname, file, line_range, score, rationale, dependencies, harnessability}]
- test_summary: {test_map, inferred_oracles, gaps}
- selected_futs: [{qualname, file, line_range, justification}]
- notes_to_self: [{target_qualname, note}]
1---2name: discover-important-function3description: When given a project codebase, this skill observes the important functions in the codebase for future action.4---5
6# Fuzz Target Localizer
7
8## Purpose
9
10This skill helps an agent quickly narrow a Python repository down to a small set of high-value fuzz targets. It produces:
11
12- A ranked list of important files
13- A ranked list of important functions and methods
14- A summary of existing unit tests and inferred oracles
15- A final shortlist of functions-under-test (FUTs) for fuzzing, each with a structured "note to self" for follow-up actions
16
17## When to use
18
19Use this skill when the user asks to:
20
21- Find the best functions to fuzz in a Python package/library
22- Identify parsers, decoders, validators, or boundary code that is fuzz-worthy
23- Decide what to fuzz based on existing test coverage and API surface
24- Produce a structured shortlist of fuzz targets with harness guidance
25- Automating testing pipeline setup for a new or existing Python project.
26
27Do not use this skill when the user primarily wants to fix a specific bug,
28refactor code, or implement a harness immediately
29(unless they explicitly ask for target selection first).
30
31## Inputs expected from the environment
32
33The agent should assume access to:
34
35- Repository filesystem
36- Ability to read files
37- Ability to run local commands (optional but recommended)
38
39Preferred repository listing command:
40
41- Use `tree` to get a fast, high-signal view of repository structure (limit depth if needed).
42
43If `tree` is not available, fall back to a recursive listing via other standard shell tooling.
44
45## Outputs
46
47Produce result:
48
49A report in any format with the following information: - Localize important files - Localize important functions - Summarize existing unit tests - Decide function under test for fuzzing
50This file should be placed in the root of the repository as `APIs.txt`,
51which servers as the guidelines for future fuzzing harness implementation.
52
53## Guardrails
54
55- Prefer analysis and reporting over code changes.
56- Do not modify source code unless the user explicitly requests changes.
57- If running commands could be disruptive, default to read-only analysis.
58- Avoid assumptions about runtime behavior; base conclusions on code and tests.
59- Explicitly consider existing tests in the repo when selecting targets and deciding harness shape.
60- Keep the final FUT shortlist small (typically 1–5).
61
62---
63
64# Localize important files
65
66## Goal
67
68Produce a ranked list of files that are most likely to contain fuzz-worthy logic: parsing, decoding, deserialization, validation, protocol handling, file/network boundaries, or native bindings.
69
70## Procedure
71
721. Build a repository map
73 - Start with a repository overview using `tree` to identify:
74 - Root packages and layouts (src/ layout vs flat layout)
75 - Test directories and configs
76 - Bindings/native directories
77 - Examples, docs, and tooling directories
78 - Identify packaging and metadata files such as:
79 - pyproject.toml
80 - setup.cfg
81 - setup.py
82 - Identify test configuration and entry points:
83 - tests/
84 - conftest.py
85 - pytest.ini
86 - tox.ini
87 - noxfile.py
88
892. Exclude low-value areas
90 - Skip: virtual environments, build outputs, vendored code, documentation-only directories, examples-only directories, generated files.
91
923. Score files using explainable heuristics
93 Assign a file a higher score when it matches more of these indicators:
94 - Public API exposure: **init**.py re-exports, **all**, api modules
95 - Input boundary keywords in file path or symbols: parse, load, dump, decode, encode, deserialize, serialize, validate, normalize, schema, protocol, message
96 - Format handlers: json, yaml, xml, csv, toml, protobuf, msgpack, pickle
97 - Regex-heavy or templating-heavy code
98 - Native boundaries: ctypes, cffi, cython, extension modules, bindings
99 - Central modules: high import fan-in across the package
100 - Test adjacency: directly imported or heavily referenced by tests
101
1024. Rank and select
103 - Produce a Top-N list (default 10–30) with a short rationale per file.
104
105## Output format
106
107For each file:
108
109- path
110- score (relative, not necessarily normalized)
111- rationale (2–5 bullets)
112- indicators_hit (list)
113
114---
115
116# Localize important functions
117
118## Goal
119
120From the important files, identify and rank functions or methods that are strong fuzz targets while minimizing full-body reading until needed.
121
122## Approach 1: AST-based header and docstring scan
123
124For each localized Python file, parse it using Python’s `ast` module and extract only:
125
126- Module docstring
127- Function and async function headers (name, args, defaults, annotations, decorators)
128- Class headers and method headers
129- Docstrings for modules, classes, and functions/methods
130
131Do not read full function bodies during the initial pass unless needed for disambiguation or final selection.
132
133### Procedure
134
1351. Build per-file declarations via AST
136 - Parse the file with `ast`
137 - Enumerate:
138 - Top-level functions
139 - Classes and their methods
140 - Nested functions only if they are likely to be directly fuzzable via an exposed wrapper
141 - For each symbol, collect:
142 - Fully-qualified name
143 - Signature details (as available from AST)
144 - Decorators
145 - Docstring (if present)
146 - Location information (file, line range if available)
147
1482. Generate an initial candidate set using headers and docstrings
149 Prioritize functions/methods that:
150 - Accept bytes, str, file-like objects, dicts, or user-controlled payloads
151 - Convert between representations (raw ↔ structured)
152 - Perform validation, normalization, parsing, decoding, deserialization
153 - Touch filesystem/network/protocol boundaries
154 - Call into native extensions or bindings
155 - Clearly document strictness, schemas, formats, or error conditions
156
1573. Use tests to refine candidate selection early
158 - Before reading full bodies, check if tests reference these functions/modules:
159 - Direct imports in tests
160 - Fixtures that exercise particular entry points
161 - Parameterizations over formats and inputs
162 - Down-rank candidates that are already well-covered unless they are high-risk boundaries (parsers/native bindings).
163
1644. Confirm with targeted reading only for top candidates
165 For the top candidates (typically 10–20), read the full function bodies and capture:
166 - Preconditions and assumptions
167 - Internal helpers called
168 - Error handling style and exception types
169 - Any obvious invariants and postconditions
170 - Statefulness and global dependencies
171
1725. Rank and shortlist
173 Rank candidates using an explainable rubric:
174 - Input surface and reachability
175 - Boundary risk (parsing/decoding/native)
176 - Structural complexity (from targeted reading only)
177 - Existing test coverage strength and breadth
178 - Ease of harnessing
179
180### Output format
181
182For each function/method:
183
184- qualname
185- file
186- line_range (if available)
187- score (relative)
188- rationale (2–6 bullets)
189- dependencies (key helpers, modules, external state)
190- harnessability (low/medium/high)
191
192## Approach 2: Scanning all important files yourself
193
194For each localized Python file, read the file contents directly to extract:
195
196- Module docstring and overall structure
197- Function and async function definitions (name, args, defaults, annotations, decorators)
198- Class definitions and their methods
199- Full function bodies and implementation details
200- Docstrings for modules, classes, and functions/methods
201
202This approach reads complete file contents, allowing for deeper analysis at the cost of higher token usage.
203
204### Procedure
205
2061. Read important files sequentially
207 - For each file from the important files list, read the full contents.
208 - Extract by direct inspection:
209 - Top-level functions and their complete implementations
210 - Classes and their methods with full bodies
211 - Nested functions if they are exposed or called by public APIs
212 - For each symbol, collect:
213 - Fully-qualified name
214 - Complete signature (from source text)
215 - Decorators
216 - Docstring (if present)
217 - Full function body
218 - Location information (file, approximate line range)
219
2202. Generate an initial candidate set using full source analysis
221 Prioritize functions/methods that:
222 - Accept bytes, str, file-like objects, dicts, or user-controlled payloads
223 - Convert between representations (raw ↔ structured)
224 - Perform validation, normalization, parsing, decoding, deserialization
225 - Touch filesystem/network/protocol boundaries
226 - Call into native extensions or bindings
227 - Contain complex control flow, loops, or recursive calls
228 - Handle exceptions or edge cases
229 - Clearly document strictness, schemas, formats, or error conditions
230
2313. Analyze implementation details from full bodies
232 For each candidate function, inspect the body for:
233 - Preconditions and assumptions (explicit checks, assertions, early returns)
234 - Internal helpers called and their purposes
235 - Error handling style and exception types raised
236 - Invariants and postconditions (explicit or implicit)
237 - Statefulness and global dependencies
238 - Input transformations and data flow
239 - Native calls or external process invocations
240 - Resource allocation and cleanup patterns
241
2424. Use tests to refine candidate selection
243 - Check if tests reference these functions/modules:
244 - Direct imports in tests
245 - Fixtures that exercise particular entry points
246 - Parameterizations over formats and inputs
247 - Down-rank candidates that are already well-covered unless they are high-risk boundaries (parsers/native bindings).
248 - Note which aspects of each function are tested vs untested.
249
2505. Rank and shortlist
251 Rank candidates using an explainable rubric:
252 - Input surface and reachability
253 - Boundary risk (parsing/decoding/native)
254 - Structural complexity (from full body analysis)
255 - Existing test coverage strength and breadth
256 - Ease of harnessing
257 - Observable implementation risks (unsafe operations, unchecked inputs, complex state)
258
259### Output format
260
261For each function/method:
262
263- qualname
264- file
265- line_range (if available)
266- score (relative)
267- rationale (2–6 bullets)
268- dependencies (key helpers, modules, external state)
269- harnessability (low/medium/high)
270- implementation_notes (key observations from body analysis)
271
272---
273
274# Summarize existing unit tests
275
276## Goal
277
278Summarize what is already tested, infer test oracles, and identify gaps that fuzzing can complement.
279
280## Hard requirement
281
282Always inspect and incorporate existing tests in the repository when:
283
284- Ranking functions
285- Selecting FUTs
286- Designing input models and oracles
287- Proposing seed corpus sources
288
289## Procedure
290
2911. Inventory tests
292 - Locate tests and their discovery configuration (pytest.ini, pyproject.toml, tox.ini, noxfile.py).
293 - Enumerate test modules and map them to source modules via imports.
294 - Identify shared fixtures and data factories (conftest.py, fixture files, test utilities).
295
2962. Summarize test intent
297 For each test module:
298 - What behaviors are asserted
299 - What inputs are used
300 - What exceptions are expected
301 - What invariants are implied
302
3033. Infer oracles and properties
304 Common fuzz-friendly oracles include:
305 - Round-trip properties
306 - Idempotence of normalization
307 - Parser consistency across equivalent inputs
308 - Deterministic output given deterministic input
309 - No-crash and no-hang for malformed inputs
310
3114. Identify coverage gaps
312 - FUT candidates with no direct tests
313 - Input classes not covered by tests (size extremes, malformed encodings, deep nesting, edge unicode, invalid schemas)
314 - Code paths guarded by complex conditionals or exception handlers with no tests
315
316## Output format
317
318- test_map: module_under_test → tests → asserted behaviors
319- inferred_oracles: list of reusable invariants with the functions they apply to
320- gaps: ranked list of untested or weakly-tested candidates
321
322---
323
324# Decide function under test for fuzzing
325
326## Goal
327
328Select a final set of FUTs (typically 1–5) and produce a structured "note to self" for each FUT so the agent can proceed to harness implementation, corpus seeding, and fuzz execution.
329
330## Selection criteria
331
332Prefer FUTs that maximize:
333
334- Security/robustness payoff (parsing, decoding, validation, native boundary)
335- Reachability with minimal setup
336- Low existing test assurance or narrow test input coverage
337- High fuzzability (simple input channel, clear oracle or crash-only target)
338
339Explicitly weigh:
340
341- What tests already cover (and what they do not)
342- What seeds can be extracted from tests, fixtures, and sample data
343
344## Required "note to self" template
345
346For each selected FUT, produce exactly this structure:
347
348Fuzzing Target Note
349
350- Target:
351- File / location:
352- Why this target:
353 - Input surface:
354 - Boundary or native considerations:
355 - Complexity or path depth:
356 - Current test gaps:
357- Callable contract:
358 - Required imports or initialization:
359 - Preconditions:
360 - Determinism concerns:
361 - External dependencies:
362- Input model:
363 - Primary payload type:
364 - Decoding or parsing steps:
365 - Constraints to respect:
366 - Edge classes to emphasize:
367- Oracles:
368 - Must-hold properties:
369 - Acceptable exceptions:
370 - Suspicious exceptions:
371 - Crash-only vs correctness-checking:
372- Harness plan:
373 - Recommended approach:
374 - Minimal harness signature:
375 - Seed corpus ideas:
376 - Timeouts and resource limits:
377- Risk flags:
378 - Native extension involved:
379 - Potential DoS paths:
380 - External I/O:
381- Next actions:
382 1.
383 2.
384 3.
385 4.
386
387## Output format
388
389- selected_futs: list of chosen FUTs with brief justification
390- notes_to_self: one "Fuzzing Target Note" per FUT
391
392---
393
394# Final JSON block
395
396At the end of the report, include a JSON object with:
397
398- important_files: [{path, score, rationale, indicators_hit}]
399- important_functions: [{qualname, file, line_range, score, rationale, dependencies, harnessability}]
400- test_summary: {test_map, inferred_oracles, gaps}
401- selected_futs: [{qualname, file, line_range, justification}]
402- notes_to_self: [{target_qualname, note}]