Best for
- A test fails and the cause isn't immediately obvious
- Unexpected behavior occurs in production or development
- An error message doesn't directly point to the fix
freenet/freenet-agent-skills/skills/systematic-debugging/SKILL.md
Methodology for debugging non-trivial problems systematically. This skill should be used automatically when investigating bugs, test failures, or unexpected behavior that isn't immediately obvious. Emphasizes hypothesis formation, parallel investigation with subagents, and avoiding common anti-patterns like jumping to conclusions or weakening tests.
Decision brief
Methodology for debugging non-trivial problems systematically. This skill should be used automatically when investigating bugs, test failures, or unexpected behavior that isn't immediately obvious.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/freenet/freenet-agent-skills --skill "skills/systematic-debugging"Inspect the Agent Skill "systematic-debugging" from https://github.com/freenet/freenet-agent-skills/blob/294f4ad2d7c185f8e7fa4c1ec10802de5673616c/skills/systematic-debugging/SKILL.md at commit 294f4ad2d7c185f8e7fa4c1ec10802de5673616c. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
If you're working on a GitHub issue, check if it's already assigned before starting. If someone else is assigned, stop and inform the user — don't duplicate effort. If unassigned, assign it to yourself so others know it's being worked on:
If you're working on a GitHub issue, check if it's already assigned before starting. If someone else is assigned, stop and inform the user — don't duplicate effort. If unassigned, assign it to yourself so others know it's being worked on:
1. Reproduce the failure — Confirm the bug exists and is reproducible 2. Use the scope ladder — Start at the smallest scope that can demonstrate the bug: - Can you write a unit test? Try that first - Needs multiple nodes? Use the simulation framework with a deterministic seed -…
When a bug comes from production observations (user reports, telemetry, monitoring), the goal is to translate the network observation into a local reproduction as fast as possible. Live-network debugging has the slowest feedback loop — adding telemetry, redeploying, waiting — so…
Before touching any code, explicitly list potential causes:
Permission review
The documentation asks the agent to create, modify, or delete local files.
gh issue edit <ISSUE> --repo freenet/<REPO> --add-assignee @meThe documentation asks the agent to run terminal commands or scripts.
cargo test -p freenet --features simulation_tests --test sim_network -- --test-threads=1The documentation asks the agent to run terminal commands or scripts.
cargo run -p fdev -- test --seed 0xDEADBEEF single-processThe documentation asks the agent to read local files, directories, or repositories.
Read and analyze [test file] and related fixtures for [component]"The documentation asks the agent to read local files, directories, or repositories.
**Wrong:** Read file A, wait, read file B, wait, read file CEvidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 90/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 23 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Invoke this methodology automatically when:
Always prefer the smallest, most reproducible scope that demonstrates the bug. Work up the ladder only when the smaller scope can't reproduce or doesn't apply:
| Priority | Scope | When to Use | Command |
|---|---|---|---|
| 1 | Unit test | Logic errors, algorithm bugs, single-function issues | cargo test -p freenet -- specific_test |
| 2 | Mocked unit test | Transport/ring logic needing isolation | Unit test with MockNetworkBridge / MockRing |
| 3 | Simulation test | Multi-node behavior, state machines, race conditions | cargo test -p freenet --test simulation_integration -- --test-threads=1 |
| 4 | SimNetwork + FaultConfig | Fault tolerance, message loss, network partitions | SimNetwork with configured fault injection |
| 5 | fdev single-process | Quick multi-peer CI validation | cargo run -p fdev -- test --seed 42 single-process |
| 6 | freenet-test-network | 20+ peer large-scale behavior | Docker-based freenet-test-network |
| 7 | Real network | Issues that only manifest with real UDP/NAT/latency | Manual multi-peer test across machines |
Why this order matters:
If you're working on a GitHub issue, check if it's already assigned before starting. If someone else is assigned, stop and inform the user — don't duplicate effort. If unassigned, assign it to yourself so others know it's being worked on:
gh issue view <ISSUE> --repo freenet/<REPO> # Check assignees
gh issue edit <ISSUE> --repo freenet/<REPO> --add-assignee @me
SimNetwork with FaultConfigSimulation-first approach for distributed bugs:
# Run simulation tests deterministically
cargo test -p freenet --features simulation_tests --test sim_network -- --test-threads=1
# With logging to observe event sequences
RUST_LOG=info cargo test -p freenet --features simulation_tests --test sim_network -- --nocapture --test-threads=1
# Reproduce with a specific seed
cargo run -p fdev -- test --seed 0xDEADBEEF single-process
When a bug comes from production observations (user reports, telemetry, monitoring), the goal is to translate the network observation into a local reproduction as fast as possible. Live-network debugging has the slowest feedback loop — adding telemetry, redeploying, waiting — so minimize time spent there.
The workflow:
| Network Observation | Simulation Translation |
|---|---|
| "GET times out at hop 3" | #[freenet_test] with 4+ nodes, specific node_locations matching topology |
| "Peer X never responds" | Node configured to drop/delay messages via FaultConfig |
| "73% timeout rate" | FaultConfig { message_loss_rate: 0.7, .. } or unresponsive target node |
| "Works for PUT but not GET" | Test both operations — likely incomplete wiring in dispatch path |
| "Rapid connect/disconnect cycles" | Simulation with transport-level fault injection |
| "Messages dropped after acknowledgement" | FaultConfig with selective message loss after initial handshake |
#[freenet_test] or SimNetwork + FaultConfig. Use a deterministic seed.If a telemetry-monitor skill is available (project-local, not part of this plugin), use it to query the centralized OpenTelemetry collector for constraining the problem. But treat telemetry as input to simulation design, not as the primary debugging tool.
Resist the temptation to keep adding telemetry to find the root cause. Once you know what fails (operation type, peer pattern, timing), stop analyzing network data and reproduce locally. The simulation feedback loop is orders of magnitude faster.
Before touching any code, explicitly list potential causes:
Hypotheses:
1. [Most likely] The X component isn't handling Y case
2. [Possible] Race condition between A and B
3. [Less likely] Configuration mismatch in Z
Rank by likelihood based on evidence. Avoid anchoring on the first idea.
Freenet-specific hypothesis patterns:
std::time::Instant::now() instead of TimeSource, or rand::random() instead of GlobalRngJoinHandle stored and polled? what happens if the task exits?), broadcast sent to zero targets with no warning, channel overflow silently dropping messages. Look for: tokio::spawn without .await/.abort(), let _ = sender.send(), missing logging on empty target sets_ => Irrelevant catch-alls, and missing match arms are commonSee Module-Specific Debugging Guide for detailed bug patterns, data collection strategies, and test approaches per module.
For each hypothesis:
Freenet-specific data gathering:
| What You Need | How to Get It | Access |
|---|---|---|
| Event sequences | RUST_LOG=info + --nocapture on simulation tests | Everyone |
| Network message patterns | sim.get_network_stats() in simulation tests | Everyone |
| Convergence behavior | sim.await_convergence(timeout, poll, min_contracts) | Everyone |
| Virtual time state | sim.virtual_time().now_nanos() | Everyone |
| Git history of affected code | git log --oneline -20 -- path/to/file.rs | Everyone |
| Fault injection results | SimNetwork + FaultConfig, then inspect stats | Everyone |
| Gateway logs | Access to running gateway node | Limited — not all contributors |
| Aggregate telemetry | telemetry-monitor skill (if available) or production dashboards | Limited — core team only |
| Real network packet captures | Physical access to test machines | Limited — specific environments |
Note on telemetry: If a telemetry-monitor skill is available in the project, use it to query network telemetry for constraining the problem (see Phase 1b). But remember: telemetry constrains, simulation reproduces. Don't spend cycles iterating on telemetry queries when you have enough information to write a simulation test.
Asserting on freenet-core logs from E2E tests: use structured fields,
not wire-level markers. Modern freenet-core (0.2.6x and later) emits
tracing output as structured fields — phase="update_complete",
phase="relay_started", op="GET", tx="01KK70…". Legacy
wire-level grep markers (UPDATE_PROPAGATION, OP_FORWARDED, etc.)
that older tests and tutorials reference have been removed. An E2E test
that greps for them will pass forever — the line will never appear, so
the negative assertion is vacuously true, and the test gives a false
green.
When writing or fixing an E2E log assertion against a freenet node:
RUST_LOG you'll use in CI and
read what's actually emitted around the event you care about. Don't
copy a grep pattern from an old test.phase="<value>" is the most
stable; transaction IDs (tx=) are good for following a single
op across nodes.When a test fails because of a conclusively-traced upstream bug
(e.g. a freenet-core relay timeout that has an open issue and a
recognizable signature in the logs), quarantine the path, do not
remove the test. Detect the exact upstream signature, emit a Playwright
test.skip() (or equivalent) with the issue link, and let the assertion
that would have caught the upstream bug stay in place. Genuine app-side
regressions (contract errors, deserialization, panics, wrong state
contents) still fail the gate. Removing the test, or weakening the
assertion to make it always pass, loses the regression coverage you'd
otherwise get for free the day upstream is fixed.
For module-specific data gathering techniques, see Module-Specific Debugging Guide — it covers observation APIs, #[freenet_test] event capture, RUST_LOG targets, and fault injection per module.
Parallel investigation with subagents:
Use general-purpose agents with codebase-investigator instructions for independent, readonly investigations. Spawn multiple in parallel, each with a specific focus.
Spawn investigators in parallel using Task tool (subagent_type="general-purpose"):
1. "You are a codebase-investigator. [Include agents/codebase-investigator.md instructions]
Search for similar error handling patterns in the codebase related to [bug description]"
2. "You are a codebase-investigator. [Include agents/codebase-investigator.md instructions]
Check git history for recent changes to [affected module/files]"
3. "You are a codebase-investigator. [Include agents/codebase-investigator.md instructions]
Read and analyze [test file] and related fixtures for [component]"
Guidelines:
cargo test -p freenetTimeSource and GlobalRng (not std::time / rand directly)Always ask: "Why didn't CI catch this?"
Freenet has multiple test layers:
| Layer | Scope | What It Catches |
|---|---|---|
| Unit tests (~1000) | Individual functions | Logic errors, algorithm bugs |
| Integration tests (~80) | Component interactions | Interface mismatches, data flow bugs |
| Simulation tests | Multi-node deterministic | State machine bugs, race conditions, protocol errors |
fdev single-process | Quick multi-peer | Basic distributed behavior |
freenet-test-network | 20+ peers in Docker | Scale-dependent bugs, realistic network behavior |
| Real network tests | Physical machines | NAT traversal, real latency, UDP behavior |
If a bug reached production or manual testing, there's a gap. Investigate:
Which test layer should have caught this?
#[freenet_test]Why didn't the existing tests catch it?
TimeSource/GlobalRngDocument the gap — Include in the issue/PR:
codebase-investigator agents to read A, B, C concurrently, synthesize findingsstd::time::Instant::now() or rand::random() in core logicTimeSource trait and GlobalRng so simulation tests remain reproducibleRUST_LOG that any contributor can runAlternatives
event4u-app/agent-config
Use on a bug, test failure, crash, or unexpected behavior — enforce reproduce → isolate → hypothesize → verify before any fix; fires even on 'this is broken' / 'quick fix'.
NousResearch/hermes-agent
4-phase root cause debugging: understand bugs before fixing.
majiayu000/spellbook
Four-phase debugging framework for any technical issue. Use when encountering bugs, errors, or unexpected behavior. Prevents random fix attempts.
obra/superpowers
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes