| name | description |
|---|---|
freenet-pr-creation |
Guidelines for creating high-quality Freenet pull requests. This skill should be used when creating PRs for freenet-core, freenet-stdlib, or related repositories. Emphasizes quality over speed, thorough testing, and proper review process. |
Our goal is high-quality code that won't require future fixes. Don't cut corners, be a perfectionist, don't increase tech debt. A quick fix that causes problems later wastes more time than doing it right the first time.
CRITICAL: Always ensure you're working from the latest main branch from GitHub, not a stale local copy:
cd ~/code/freenet/freenet-core/main
git fetch origin
git log --oneline -1 origin/main # Check what's latest on GitHub
git pull origin main # Update local main
git log --oneline -1 # Verify you have the latestThis prevents:
- Working on outdated code that's already been fixed
- Merge conflicts when the PR is ready
- Basing work on code that's already been superseded
Never work directly in the main worktree. Create a dedicated worktree for your branch:
cd ~/code/freenet/freenet-core/main
git worktree add ../fix-<issue-number> -b fix-<issue-number>
cd ../fix-<issue-number># CRITICAL: Verify you're in a worktree, not the main directory
pwd # Should be .../freenet-core/<branch-name>, NOT .../freenet-core/main
git branch --show-current # Should be your feature branchcargo fmt
cargo clippy --all-targets --all-features
cargo testFix all warnings and errors before pushing.
For changes affecting network behavior, contract operations, or peer communication:
- Use freenet-simulated-network-test for automated Docker-based testing (6-peer CI infrastructure)
- Use freenet-manual-multipeer-test for real machine testing across nova/vega/technic
PR titles must follow Conventional Commits - CI fails non-conforming titles:
feat:- New featurefix:- Bug fixdocs:- Documentation onlyrefactor:- Code change that neither fixes a bug nor adds a featuretest:- Adding or correcting testschore:- Maintenance tasks
Explain WHY, not just WHAT. Structure your PR description:
## Problem
[What's broken? What's the user impact? Why does it matter?]
## Approach
[Why this solution over alternatives? What's the key insight?]
## Testing
[New tests added and what scenarios they validate]
[Local validation steps performed]
[E2E testing results if applicable]
## Fixes
Closes #XXXXBad: "Add observed_addr field to ConnectRequest" Good: "The joiner can't know its public address until observed externally. Previous approach rewrote addresses at transport boundary, but that's a hack. This lets the gateway fill in the observed socket naturally since it already sees the real UDP source."
When fixing a bug, always ask: "Why didn't CI catch this?"
Investigate which test layer should have caught it:
- Unit tests for logic errors
- Integration tests for component interactions
- Network simulations for distributed behavior
- E2E tests for real-world scenarios
Document the gap in your PR description.
- Write the test before the fix
- Verify the test fails without your fix
- Verify the test passes with your fix
This ensures the test actually catches the bug, not just the happy path.
When improving tests, make the new test as general as possible while still catching the specific problem found. A test that catches a class of bugs is better than one that only catches the exact scenario you hit.
If a pattern caused a bug, search for similar patterns elsewhere in the codebase. Fix them all, or file separate issues for each.
Before running review agents, use the code-simplifier subagent to clean up and simplify the code:
Task tool with subagent_type="code-simplifier:code-simplifier":
"Review and simplify the code changes in PR #<NUMBER> (branch-name) at /path/to/worktree
Focus on the recently modified files:
- [list modified files]
Look for opportunities to simplify while preserving functionality."
The code-simplifier will:
- Remove redundant conditionals and dead code
- Condense verbose documentation
- Simplify complex tests while preserving assertions
- Fix any issues introduced by the changes
Commit any simplifications before running reviews - this ensures reviewers see the cleanest version of the code.
Once the PR is complete, code is simplified, and CI is passing, spawn three review agents in parallel using the Task tool. Each has a different focus:
"Review PR #<NUMBER> in freenet/freenet-core using this process:
STEP 1 - Code only: Read ONLY the code changes (use `gh pr diff`). Do NOT read
the PR description or comments yet. Form your own understanding of:
- What the code actually does
- What problem it appears to solve
- Any concerns about the implementation
STEP 2 - Compare: NOW read the PR description and comments. Compare your
understanding with the stated intent. Report:
- Any discrepancies between code behavior and description
- Behavior changes not mentioned in the description
- Description claims not reflected in the code
- Anything that confused you that should be documented"
"Review test coverage for PR #<NUMBER> in freenet/freenet-core.
Analyze whether the changes are adequately tested at appropriate levels:
- Unit tests: Are individual functions/methods tested?
- Integration tests: Are component interactions tested?
- Simulation tests: For network/distributed behavior, is six-peer-regression
or similar CI simulation sufficient?
Check BOTH:
- Direct changes: Is the new/modified code tested?
- Downstream impact: Does this change behavior of calling code? Is THAT tested?
Flag any scenarios that could break but aren't tested. Be specific about what
test is needed, not just 'needs more tests'.
Note: We've had serious regression problems. Be thorough. However, don't
suggest tests that would significantly slow CI without strong justification."
"Do a skeptical review of PR #<NUMBER> in freenet/freenet-core.
Assume there are bugs until proven otherwise. Look for:
- Logic errors or edge cases not handled
- Race conditions or concurrency issues
- Missing error handling or error propagation
- Resource leaks
- Performance issues (especially in hot paths)
- Security concerns
Be adversarial - how could this code fail in production?"
Take all feedback seriously. Don't cherrypick easy wins and ignore harder issues. For each point raised:
- Fix it, OR
- Explain specifically why it's not applicable
Use common sense - if a reviewer suggests building a massive test framework for a small change, that's obviously overkill. But don't dismiss feedback just because it's inconvenient.
Never ignore tests to make them pass. Pre-commit hooks will reject #[ignore]. Flaky tests are broken tests - fix the root cause, don't hide the symptom.
CI typically takes ~20 minutes (as of Dec 2025). Use:
gh pr checks <PR-NUMBER> --watchOr sleep and then check:
sleep 900 # 15 minutes, then check status
gh pr checks <PR-NUMBER>- Fix all issues found during review before requesting re-review
- Respond to inline comments inline - Don't just fix silently
- If you disagree, explain your reasoning rather than ignoring the comment
- After fixing, leave brief replies like "Fixed" or "Addressed in [commit SHA]"
- Re-request review only after substantial changes - Don't re-ping reviewers for minor tweaks; only request re-review when you've addressed significant feedback or made meaningful changes
- One logical change per PR
- If a fix reveals other issues, file separate issues rather than scope-creeping
- If the PR grows too large, consider splitting it (but avoid complex stacked PRs)
- Don't weaken tests to make them pass
- Don't add
#[ignore]without aTODO-MUST-FIXcomment and follow-up issue - Don't leave
TODOcomments for things you could fix now - Don't skip edge cases because "they probably won't happen"
End all GitHub content (PR descriptions, comments, issues) with:
[AI-assisted - Claude]
- PR title follows Conventional Commits format
- PR description explains WHY, not just WHAT
- All local checks pass (fmt, clippy, test)
- E2E tested if applicable (network/contract changes)
- Regression test added that fails without fix
- Answered "why didn't CI catch this?" and documented gap
- CI passing
- Three parallel subagent reviews completed (code-first, testing, skeptical)
- All review feedback addressed (fixed or explained why not applicable)
- All human review feedback addressed
- Responses posted to review comments
Clean up your worktree to free disk space (each worktree has its own target/ directory):
cd ~/code/freenet/freenet-core/main
git worktree remove ../fix-<issue-number>
git branch -d fix-<issue-number> # Delete local branch