Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Automates fuzz test creation for Go projects using Go's native fuzzing engine with consistent software testing patterns. Use when creating fuzz tests, mutation testing, or when the user mentions fuzzing, coverage-guided testing, or property-based testing.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-15 | ✗→✓ | ▲ Improved | 102% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 174% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 35% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 59% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 180% | 0% |
Instructions for AI coding agents on automating fuzz test creation using consistent software testing patterns in this Go project.
> Go's native fuzzing engine uses code coverage instrumentation to automatically guide input generation toward unexplored code paths, maximizing bug discovery without manual intervention.
> Fuzz testing automatically generates random inputs to discover edge cases and unexpected behaviors that manual testing might miss.
> Helps identify security vulnerabilities, crashes, and undefined behaviors by testing with malformed, unexpected, or extreme inputs.
> Fuzz tests can run continuously to explore the input space over time, discovering new edge cases as the corpus grows.
> Once a crash or bug is found, the input is saved in the corpus to prevent regression in future test runs.
The FIRST principles for fuzz testing focus on creating effective and discoverable tests.
> Fuzz tests should use efficient seed corpus and focused fuzz targets to maximize coverage discovery within practical time constraints during CI.
> Each fuzz test should be self-contained and test a single function or behavior independently from other fuzz tests.
> Fuzz tests with a fixed corpus should produce deterministic results, ensuring that discovered crashes are reproducible and regression corpus inputs are stable.
> Fuzz tests should clearly detect and report panics, invariant violations, and unexpected behaviors without requiring manual inspection.
> Fuzz tests should be introduced alongside unit tests for functions that accept external inputs or perform calculations with boundary conditions.
Coverage-Guided Fuzzing is the primary fuzzing technique used by Go's native fuzzing engine. It automatically instruments code to track coverage and guides input generation toward unexplored code paths, maximizing code exploration and bug discovery.
Corpus-Driven Fuzzing is a software testing technique that uses a collection of seed inputs (corpus) as the starting point for generating new test inputs through mutation.
Property-Based Testing is a testing approach that verifies invariants and properties that should hold true for all inputs, rather than testing specific input-output pairs.
Boundary Value Fuzzing focuses on testing edge cases and boundary conditions with randomly generated inputs around critical thresholds.
Crash Detection is the process of identifying inputs that cause panics, runtime errors, or undefined behavior in the code under test.
Identify functions in pkg/ or internal/ that accept external inputs, perform calculations, or have edge cases worth fuzzing (e.g., pkg/<package>/<file>.go).
Create fuzz tests in the same package (e.g., pkg/<package>/<file>_test.go).
Focus on functions that:
Structure all fuzz tests using the template pattern.
Optionally provide seed inputs in testdata/fuzz/<FuzzTestName>/ directory to guide fuzzing toward interesting inputs.
| Command | Description | | -------------------------------------- | -------------------------------------------- | | make go-test-fuzz | Execute fuzz tests for a specified duration | | ls -la testdata/fuzz/<FuzzTestName>/ | Inspect the seed corpus and generated inputs |
> Use the standard Go testing package with testing.F for fuzz tests. Go's fuzzing engine automatically uses coverage-guided fuzzing to explore code paths.
> The fuzzing engine tracks code coverage during execution and prioritizes inputs that explore new code paths. No manual configuration is required - coverage guidance is automatic.
> Include testing and any packages needed for the function under test.
> Name fuzz functions with the Fuzz prefix followed by the function name (e.g., FuzzPercent for testing Percent()).
> Use f.Add() to provide seed inputs that cover important edge cases and known valid/invalid inputs. The fuzzer will mutate these seeds while maximizing coverage.
> The fuzz target function receives *testing.T and randomly generated inputs. It should: > - Validate inputs before calling the function under test (skip invalid inputs with t.Skip() if necessary) > - Call the function with fuzzed inputs > - Assert invariants and properties that must always hold true > - Not crash or panic for any input
> Fuzz tests should verify that functions handle errors gracefully without panicking.
> Use explicit checks with t.Errorf() or t.Fatalf() to report violations of expected properties.
Use this template for new fuzz test functions. Replace placeholders with actual values and adjust as needed for the use case.
For functions with multiple parameters, use a struct array to define test cases.
gofunc Fuzz<FunctionName>(f *testing.F) { // Seed corpus with edge cases using testcases array testcases := []struct { param1 <type> param2 <type> // Add more parameters as needed }{ {<value1>, <value2>}, // description of test case {<value1>, <value2>}, // description of test case // Add more test cases } for _, tc := range testcases { f.Add(tc.param1, tc.param2) // Use f.Add to provide a seed corpus } f.Fuzz(func(t *testing.T, param1 <type>, param2 <type>) { // Arrange // Optional: skip invalid inputs or prepare test conditions // Example: if input < 0 { t.Skip("negative inputs not interesting") } // Act got, err := <Function>(param1, param2) // Assert // Verify properties that should always hold true // Example 1: Function should never panic // Example 2: If no error, result should meet certain properties // Example 3: If error, result should be in expected error state if err != nil { // Verify error cases // Example: if got != 0 { t.Errorf("expected zero result on error, got %v", got) } } else { // Verify success cases and invariants // Example: if got < 0 { t.Errorf("result should be non-negative, got %v", got) } } }) }
For functions with a single parameter, use a slice array to define test cases.
gofunc Fuzz<FunctionName>(f *testing.F) { // Seed corpus with edge cases using testcases array testcases := []<type>{ <value1>, // description <value2>, // description // Add more test cases } for _, tc := range testcases { f.Add(tc) // Use f.Add to provide a seed corpus } f.Fuzz(func(t *testing.T, param <type>) { // Arrange // Optional: skip invalid inputs or prepare test conditions // Act got, err := <Function>(param) // Assert // Verify properties and invariants if err != nil { // Verify error cases } else { // Verify success cases } }) }
Other measured skills in the registry, with their headline benchmark lift.