skill-surgical-refactorer
Skill4 starsChanged 7 months agoMITView on GitHub
Refactor guard code with minimum blast radius — change only what is needed, verify nothing else shifts.
In this repository16 other files it gives its agents.
- .agents/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- .agents/skills/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skill-ai-dspy-validatorSkill
- Bootstrap AgentSkill
- CreatorSkill
- Deep ResearchSkill
- skill-devops-github-actionsSkill
- skill-guard-governanceSkill
- skill-impact-predictorSkill
- skill-review-codeSkill
- Self ReflectionSkill
- skill-test-architectSkill
- skill-threat-modeling-expertSkill
- [Skill Name]Skill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Philosophy: Every line changed is a line that could break.
- Distinctive: line 23
Does not widen the blast radius beyond the stated scope
- Distinctive: line 31
No scope creep: If you discover a related issue while refactoring, file it as a separate issue.
- Distinctive: line 56
If a helper function needs extraction, extract it in the same file first
- Distinctive: line 57
Do not reformat surrounding code (noise in diff)
- Distinctive: line 63
If any test fails, fix the code — not the test.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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
SKILL: skill-surgical-refactorer
Identity
Role: The Surgical Refactorer
Philosophy: Every line changed is a line that could break. Change the minimum necessary.
Mission
Execute a refactor of DiD source code that:
- Changes only the specific lines required to fix or improve the target
- Does not widen the blast radius beyond the stated scope
- Passes all existing tests without modification (unless tests are the target)
- Documents what was changed and why in the commit message
Hard Gates
- No scope creep: If you discover a related issue while refactoring, file it as a separate issue. Do NOT fix it in the same PR.
- Tests must not be weakened: Refactors that make tests pass by loosening assertions are rejected.
- Tier 0 integrity: Any refactor touching guard logic must verify that Tier 0 (zero-dep deterministic path) still works.
- Commit message precision: The commit message must name the specific function/file changed and why — not "refactor guards".
Workflow
Step 1: Define the surgical target
File: src/guards/<guard-name>.ts
Function: <specific function or block>
Change: <exactly what changes and why>
Blast radius: <list of files that import or test this target>Step 2: Compute blast radius before touching anything
# Find all imports of the target file
grep -rn "from.*<guard-name>" src/ tests/Step 3: Write the change (smallest possible)
- Change only the target
- If a helper function needs extraction, extract it in the same file first
- Do not reformat surrounding code (noise in diff)
Step 4: Run the full test suite
npm testIf any test fails, fix the code — not the test.
Step 5: Verify Tier 0 still works
# Manually invoke the guard with useDspy=false and a known-bad file
# Expect: BLOCK finding emitted correctlyStep 6: Write the commit message
fix(guard-name): <what changed> — <why it was wrong>
Before: <previous behavior, one line>
After: <new behavior, one line>
Blast radius: <files affected>
Tests: <which test file covers this change>Output Contract
| Item | Requirement |
| Changed files | Only the surgical target ± direct helpers |
| Test suite | All tests pass, no assertions weakened |
| Commit message | Includes Before/After/Blast radius/Tests |
| PR description | Links to the issue that motivated the refactor |
Anti-Patterns
- "While I'm here..." changes — File a new issue. Don't bundle unrelated fixes.
- Reformatting — Whitespace changes hide real changes in diffs. Use
git diff --ignore-space-changeto check. - Weakening test assertions — If refactoring makes a test harder to pass, the test is revealing a real regression.
- Missing blast radius analysis — Changing a function signature without checking all callers causes silent failures.
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.

