From freenet-freenet-agent-skills
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.
npx claudepluginhub freenet/freenet-agent-skills --plugin freenetThis skill uses the workspace's default tool permissions.
Invoke this methodology automatically when:
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
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.
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 run