refactor
Skill453 starsChanged 4 months agoApache-2.0View on GitHub
Restructure or clean up code with no behavior change, proved by before-and-after checks. Use when: asked to clean up, extract, dedupe or simplify, even one function.
196 other projects use a version of this.
Adopted by
Most recently taken up by
- Doist/todoist-aitheir own version, first seen Nov 9, 2026
- Doist/todoist-clitheir own version, first seen Nov 8, 2026
- rvdbreemen/OTGW-firmwaretheir own version, first seen Nov 8, 2026
- paulocsb/worldcup-fifa-pooltheir own version, first seen Nov 8, 2026
- DnsQueen/orcinus-skillstheir own version, first seen Nov 8, 2026
- taixuann/development-spacetheir own version, first seen Nov 8, 2026
Used with
Projects with it also use ascii-diagram, debug-fix and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
SethGammonSkillascii-diagram
Generate perfectly aligned ASCII diagrams — architecture, flow, sequence, box-and-arrow. Uses a programmatic character-grid approach so alignment is guaranteed by math, not token prediction. Includes post-render verification.
Also in 4 projects that use this
zebbernSkilldebug-fix
Find and fix a bug or issue — from any source (GitHub issue, error message, user report, or observed behavior)
Also in 4 projects that use this
parcadeiSkillagent-context-isolation
Agent Context Isolation
Also in 3 projects that use this
parcadeiSkillagentica-infrastructure
Reference guide for Agentica multi-agent infrastructure APIs
Also in 3 projects that use this
- +8 more from parcadei
Other versions196 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 196
- github/awesome-copilot★ 41ksame name
- unkeyed/unkey★ 5.5ksame name
- parcadei/Continuous-Claude★ 3.9ksame name
- parcadei/Continuous-Claude-v2★ 3.9ksame name
- parcadei/Continuous-Claude-v3★ 3.9ksame name
- adobe/S3Mock★ 1.2ksame name
- SethGammon/Citadel★ 927same name
- poshan0126/dotclaude★ 871same name
- JordanCoin/codemap★ 710same name
- membrane/api-gateway★ 658same name
186 more not listed
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 repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cli/AGENTS.mdAGENTS.md
- agent-nativeSkill
- agy-nativeSkill
- architectureSkill
- claude-execSkill
- codex-execSkill
- councilSkill
- craft-goalSkill
- docSkill
- domainSkill
- ergonomicsSkill
- idea-genieSkill
- implementSkill
- interviewSkill
- memorySkill
- navigateSkill
- orchestrateSkill
- planSkill
- postmortemSkill
- premortemSkill
- researchSkill
- reverse-engineerSkill
- reviewSkill
- rpiSkill
- securitySkill
- skill-builderSkill
- skill-evalSkill
- testSkill
- triageSkill
- using-gcSkill
- validateSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 169 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
Differences between near-duplicates: When merging duplicated branches, carry every difference (constants, comparisons, messages, extra …
- Distinctive: line 59
Run the focused check and the smallest regression check the changed surface justifies, error paths included, and record that honest …
- Very specific: line 82
When nothing can be executed (no runtime, no tests, code supplied in a message), neutrality is unproven: give the exact before/after …
- Distinctive: line 118
Use the caller's vocabulary for extracted operations and types.
- Distinctive: line 122
When the caller-chosen transformation can be cut more than one way (which lines an extraction takes, where a chosen interface sits), probe …
- Distinctive: line 126
Run the probe in disposable isolation (a scratch branch, worktree, or copied tree the caller's policy allows): rough in the seam, see what …
“Common” is measured: kept by at least 6 in 10 of the 169 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Refactor — one structural experiment
Refactor changes structure while preserving observable behavior. It performs one caller-selected transformation and reports the result. "Behavior-preserving" is a claim to prove with before/after checks, never to assert.
What counts as behavior
Unless the caller explicitly excluded a surface, all of these must survive:
- Messages and exit codes. Error and output text compares byte-for-byte; exit codes, error types and which input raises which error stay the same. Scripts and callers parse them. Preserve an inconsistent message and report it; normalizing it is a behavior change.
- Differences between near-duplicates. When merging duplicated branches, carry every difference (constants, comparisons, messages, extra steps) as a parameter or a branch. Do not unify a difference the caller has not declared accidental.
- Interfaces. Public signatures, defaults, return types, persisted field names, protocol values and CLI flags. Renaming one is a compatibility change unless the accepted scope provides for it.
- Order and coverage. Branch priority, default handling, evaluation count, side-effect order, and the set of tests that run. A pre-existing red that vanishes, or a test that stops running, is a behavior change.
- Protective checks. Trust-boundary validation, data-loss guards, security controls and accessibility affordances stay, even when another layer, upstream or downstream, duplicates one or no test reaches it. The neutrality gates cannot see their removal, so looking redundant is no reason to delete one.
Procedure
- Name the preserved behavior, the focused acceptance surface and the concrete structural problem for its callers, in the caller's domain terms.
- Run the focused check and the smallest regression check the changed surface justifies, error paths included, and record that honest baseline, including reproducible ambient failures. Add any characterization test the transformation needs now, before the edit, so it is part of the baseline. For output-producing surfaces (generators, serializers, formatters, reports), hash the output over fixed inputs. When the caller's evaluation compares the built program before and after the change, pin the starting source, build its baseline before edits and keep that binary and the comparison inputs.
- Apply one bounded transformation: extract, move, rename, inline, simplify a conditional, reduce parameters, encapsulate, substitute existing code, or delete dead code; the refactoring catalog holds per-pattern safety checks. Judge it by what callers must understand and where a domain rule must change, not by file size.
- A bug or suspicious inconsistency found on the way is reported separately (location, why it looks wrong) and left unfixed. Fixing it inside the refactor hides a behavior change the caller did not authorize.
- Rerun exactly the step-2 checks over the same inputs and compare any output hashes byte-for-byte.
- Report, then stop. A red result is evidence for the caller; this skill does not revert, narrow, retry, commit, validate, or route subsequent work.
When nothing can be executed (no runtime, no tests, code supplied in a
message), neutrality is unproven: give the exact before/after commands and
inputs the caller must run, error paths included, and list every surface under
not checked.
transformation: <the one change>
preserved: <behavior and surfaces from step 1>
checks: <command>: before -> <result>; after -> <result> (or "not run")
outputs: <before/after hashes when the surface produces output>
abstraction: <a new one and the second use or contract that justifies it, or "none">
diff: <files touched>; only those the transformation names, plus tests added before the change
suspected bugs: <file:line, why>; reported, not fixed
not checked: <surfaces no check covered>; present even when emptyNeutrality gates
The checks from step 2 give the same result after as before: no new red, no
vanished red, identical output hashes. A mismatch is a behavior diff to surface
and explain, never to shrug at; the caller decides whether to keep, narrow, or
reverse it. A gate skipped or narrowed after the fact is the post-hoc
neutrality failure mode — the diff decides what got tested. Name any surface
the gates did not cover under not checked.
Boundaries and tests
Choosing where to restructure, or a new module boundary, is Architecture's job; this skill executes one transformation in the area the caller selected. Reject a wrapper that only adds another name or pushes the same coordination into its callers. Keep internal test seams private when callers need no substitution. Exercise the preserved behavior through the caller-facing boundary; retain existing tests until equivalent coverage of their distinct cases is demonstrated. Moving a test is not permission to delete the behavior it protected.
Use the caller's vocabulary for extracted operations and types. A naming ambiguity that changes behavior belongs with the existing domain definition; consult Domain only when that distinction needs work.
When the caller-chosen transformation can be cut more than one way (which lines an extraction takes, where a chosen interface sits), probe before you cut. A choice between module boundaries the caller has not made goes to Architecture first. Run the probe in disposable isolation (a scratch branch, worktree, or copied tree the caller's policy allows): rough in the seam, see what it forces — signature churn, import cycles, test rewrites — then discard the probe and keep only the knowledge. Stop condition: at most two probes; if the second candidate seam also fights back, report both findings to the caller instead of trying a third. Cutting the first imaginable seam directly into the working tree is the premature seam failure mode: the wrong boundary calcifies because reverting it now costs more than living with it.
References
- Behavior-preserving simplification — refactoring catalog and per-pattern safety checks
- Codebase design — Matt Pocock; the wrapper and test-seam rules under Boundaries and tests adapt it.
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.

