fuzzing
What it does
This skill shows your agent how to write and register fuzz tests using the FuzzTest framework. It is for developers who want to test code that reads untrusted input.
When to use it
- ✓When you ask your AI to add a fuzz test to a C++ unit test file.
- ✓When you want to check a parser or data handler for crashes with random input.
- ✓When you need to set up a build output folder that enables fuzzing.
Skill link
https://github.com/chromium/chromium/blob/main/agents/skills/fuzzing/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you write a fuzz test for my C++ URL parser so it checks for crashes with random input?”
5 new skills a week. 1 minute to read.
How it works
The skill guides the AI to write a property function that checks some rule about the code, then register it with a FUZZ_TEST macro. The fuzzer then tries many inputs to look for failures.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Fuzzing (Chromium)
1. Setup
Ensure the output directory is configured:
gn gen out/fuzz --args='enable_fuzztest_fuzz=true is_debug=false is_asan=true \
is_component_build=false use_remoteexec=true'
2. Implement the FUZZ_TEST
Add to *_unittest.cc alongside existing tests:
#include "third_party/fuzztest/src/fuzztest/fuzztest.h"
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
// 1. Define the property function. Use a descriptive name that reflects
// the property being tested (e.g., "ParseFooDoesNotCrash" or "RoundTripIsLossless").
void MyPropertyFunctionDoesNotCrash(int i, const std::string& s) {
// Call code under test. Focus on functions parsing untrusted input, complex
// state machines, or data processing.
bool result = MyComponent::DoSomething(i, s);
// Add test assertions about invariants (e.g. "roundtrip equality", "valid
// output structure"). Sanitizers like ASAN catch crashes.
EXPECT_TRUE(result);
}
// 2. Register with FUZZ_TEST macro
FUZZ_TEST(MyComponentFuzzTest, MyPropertyFunctionDoesNotCrash)
.WithDomains(
fuzztest::InRange(0, 100),
fuzztest::Arbitrary<std::string>()
);
For complex types:
- Construct from primitives: If the object has a parsing constructor (e.g.
GURL(string)), accept the primitive and construct it inside your test function. - Define a local domain: Use
fuzztest::Constructororfuzztest::Mapto build valid objects.auto ArbitraryFoo() { return fuzztest::Constructor<Foo>(fuzztest::InRange(0, 10)); }
3. Register in BUILD.gn
You MUST register the test in the fuzztests list (in alphabetical order)
of the executable test target.
Case A: File is in a test() target
test("my_component_unittests") {
sources = [ "my_component_unittest.cc" ]
# Format: SuiteName.TestName
fuzztests = [
"MyComponentFuzzTest.MyPropertyFunctionDoesNotCrash",
]
# No dependency changes are needed here. The build system
# automatically adds FuzzTest dependencies for targets
# with a `fuzztests` list.
}
Case B: File is in a source_set(): Add //third_party/fuzztest:fuzztest
to deps.
source_set("tests") {
sources = [ "my_component_unittest.cc" ]
deps = [
"//third_party/fuzztest:fuzztest",
# ...
]
}
Find the executable test() target that depends on this source_set():
gn refs out/fuzz //path/to:source_set --testonly=true --type=executable --all
Then, ensure it lists the fuzz test in its fuzztests variable (in alphabetical
order).
4. Mandatory verification workflow
The task is incomplete until you successfully execute this sequence:
- Find the target and Build
Find the executable test() target that contains your test file:
gn refs out/fuzz //path/to/my_component_unittest.cc --type=executable --all
Build the identified target (e.g. unit_tests or browser_tests):
autoninja --quiet -C out/fuzz <target_name>
Note: If the build fails with an include not allowed by DEPS error, see the
Common Issues & Fixes section below.
- Verify unit tests pass
./out/fuzz/<target_name> \
--gtest_filter="MyComponentFuzzTest.MyPropertyFunctionDoesNotCrash"
- Verify fuzzing mode doesn't crash
./out/fuzz/<target_name> \
--fuzz="MyComponentFuzzTest.MyPropertyFunctionDoesNotCrash" --fuzz_for=10s
Resources
- Chromium Guide:
testing/libfuzzer/getting_started.md - Macro Usage:
third_party/fuzztest/src/doc/fuzz-test-macro.md - Domains:
third_party/fuzztest/src/doc/domains-reference.md - Fixtures:
third_party/fuzztest/src/doc/fixtures.md
Common Issues & Fixes
Build failure: include not allowed by DEPS
Symptom: Build fails with an error like:
ERROR: include not allowed by DEPS: third_party/fuzztest/...
Fix: You must allow the fuzztest include in the nearest DEPS file
(usually in the same directory as your test or a parent directory). Add
+third_party/fuzztest to specific_include_rules for your test files:
specific_include_rules = {
".*_unittest\\.cc": [
"+third_party/fuzztest",
],
}
FAQ
What is fuzz testing?
Fuzz testing sends many random or unusual inputs to code to find crashes or broken rules. It is good at finding bugs that normal tests miss.
Do I need to be a C++ expert to use this?
You need some C++ knowledge to use it well. The skill helps your AI write the test code and the build settings.
Does this skill work outside the Chromium project?
The examples come from Chromium, but the FuzzTest pattern is a general framework. Its steps can be applied to other C++ projects.
Details
Original description by the author
Implements, registers, and verifies fuzz tests in Chromium. Use when the user asks to add or write fuzzers in C++, or mentions fuzz testing or FUZZ_TEST.
repo: chromium/chromium
Popularity
- GitHub stars
- 25k
- Ranking position
- #10057
- License
- BSD-3-Clause
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
gn-deps-debugging
25kHelps your agent fix build errors caused by missing or wrong dependencies in GN build files, without adding broad, unneeded ones.
java-memory-leaks
25kHelps your agent find and fix Java memory leaks in Android apps by reading leak reports from LeakCanary.
jni-type-conversion
25kHelps your agent replace manual Java-to-C++ conversion code with simpler @JniType annotations in Android code.
loadline
25kHelps your agent run LoadLine benchmarks that measure how fast web pages load on Android and desktop Chrome.
Similar skills
test-driven-development
311kTeaches your agent to write a failing test first, watch it fail, then write the smallest code that passes, before building any feature or fix.
verification-before-completion
311kTeaches your agent to run real checks and read their output before claiming that a task, fix, or build is complete or passing.
migrate-to-shoehorn
310kReplaces risky type casts in your test files with the shoehorn library, so tests can use partial data and still pass type checks.