boy-scout-rule
Skill2 starsChanged 9 months agoMITView on GitHub
Use after making tests pass to apply incremental refactoring improvements to touched code and its immediate neighbors, during code review, or before committing changes
1 other project uses a version of this.
Adopted by
Most recently taken up by
- JordanCoin/codingskillstheir own version, first seen Feb 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- JordanCoin/codingskills★ 10same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- architecture-decision-recordsSkill
- domain-driven-designSkill
- functional-core-imperative-shellSkill
- git-commit-messageSkill
- react-best-practicesSkill
- revise-for-claritySkill
- ux-design-principlesSkill
- ux-prototypingSkill
- ux-visual-evaluationSkill
- visual-feedback-loopSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
The guardrail: If a refactoring would show up as an unrelated change in a code review diff, it's out of scope.
- Distinctive: line 22
Run through after tests go green.
- Very specific: line 50
If code mixes business logic with I/O → apply functional-core-imperative-shell checklist
- Very specific: line 51
If code is React (.tsx/.jsx) → apply react-best-practices Section 1 (component responsibility)
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Boy Scout Rule — Leave the Code Cleaner Than You Found It
Concrete refactoring checklist for after tests pass and during code review. Replaces vague "clean up" guidance with specific patterns to look for.
Scope
Refactor: touched code + immediate neighbors.
- Touched code: Anything you wrote or modified in this task.
- Immediate neighbors: Functions your code calls, functions that call your code, types your code uses. If your changes made adjacent code harder to read or revealed existing mess, clean it up.
- Out of scope: Code you only read for context. Refactoring that would require new tests beyond the task's scope — note it as a follow-up task instead.
The guardrail: If a refactoring would show up as an unrelated change in a code review diff, it's out of scope.
Refactor Checklist
Run through after tests go green. Check your code and its immediate neighbors.
Structural clarity
- Extract function — Any code block doing a distinct thing that you have to read to understand? Name it.
- Reduce nesting — More than 2 levels of indentation? Use early returns, guard clauses, or extract the inner logic.
- Simplify conditionals — Complex boolean expression? Extract to a named variable or function (
isEligibleForDiscountinstead oftotal > 100 && !isTrial && coupon.active). - Rename for clarity — Do names describe what, not how? Would a new team member understand without reading the implementation?
Structural design
- Consolidate duplication — Did you write something similar to existing code? Three similar implementations = extract the common pattern. Two might be coincidence.
- Right-size functions — Does any function do more than one thing? Split by responsibility. If you can't describe what it does without "and," it's too big.
- Flatten data flow — Is data passed through intermediaries that don't use it? Restructure to reduce pass-through.
Code Review Refactor Checklist
Apply during code review. The reviewer has the full diff and can spot cross-cutting patterns.
Cross-cutting patterns
- Emerging abstractions — Did multiple tasks create similar code? Three similar implementations is the signal to consolidate.
- Inconsistent patterns — Does the new code handle something differently from existing code nearby? Pick one pattern and make them consistent.
- Growing modules — Did this task push a file past the point where it's easy to navigate? Flag for splitting.
- Leaky abstractions — Does the caller need to know implementation details to use this code correctly? Tighten the interface.
Related skill checks
- If code mixes business logic with I/O → apply
functional-core-imperative-shellchecklist - If code is React (
.tsx/.jsx) → applyreact-best-practicesSection 1 (component responsibility)
What NOT to flag as refactoring
- Formatting/whitespace changes — that's the linter's job
- Renaming across the whole codebase when only one file was touched
- Refactoring that would require its own unrelated tests — note as a follow-up task
Related Skills
- Prerequisite:
visual-feedback-loop(for UI tasks — verify appearance before refactoring) - Pairs with:
functional-core-imperative-shell(if code mixes business logic with I/O),react-best-practices(if code is React),domain-driven-design(rename to match ubiquitous language)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

