refactor
Skill5 starsChanged 2 months agoMITView on GitHub
Refactors Go or PHP code without changing behaviour: dry-run plan by numbers (build, tests, coverage, dependency graph), stories via /create-stories, `--apply S-NNN` execution with characterisation tests first and one green step per commit; modes <package|namespace|file>, layout, tests, framework (PHP), or every applicable mode without an argument. Use for 'refactor this package', 'migrate the layout'.
111 other projects use a version of this.
Adopted by
Most recently taken up by
- AllThingsSmitty/proven-skillstheir own version, first seen Oct 6, 2026
- GUOJIE-HONG/skillstheir own version, first seen Oct 5, 2026
- morodomi/dev-crewtheir own version, first seen Oct 5, 2026
- gilsmt/skillstheir own version, first seen Oct 4, 2026
- Integralist/agent-skillstheir own version, first seen Oct 4, 2026
- AlvaroVFon/skillstheir own version, first seen Oct 3, 2026
Used with
Projects with it also use modern-go, to-design and 9 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.
jidechaoSkillmodern-go
Modernize Go code by applying version-appropriate idioms and APIs (gofix-style transformations). Scans go.mod for the Go version, then transforms Go source files to use modern patterns—from Go 1.0 through 1.26+. Use when the user says "现代化","现代Go语言", "地道的", "idiomatic", "modernize", "modern-go", "update Go code", "gofix", or wants to upgrade Go idioms.
Also in 3 projects that use this
jidechaoSkillto-design
Generate a design document (design proposal) from a PRD, in the style of Go's official design proposals — Abstract / Background / Design / Rationale / Compatibility / Implementation, heavy on the 'why' and tradeoffs. Triggers on: to-design, prd-to-design, prd转设计文档, 生成设计文档, 写设计文档, design doc, design proposal, 设计提案, 技术设计文档.
Also in 3 projects that use this
chidekinaSkilltest-gen
Generate test cases from type constraints and specs. Creates boundary tests, edge cases, and fixtures automatically. Pact-lang inspired. Triggers on: generate tests, test from spec, create fixtures, boundary tests.
Also in 5 projects that use this
platformplatformSkilldb-query
Query the local Postgres database of the active Aspire worktree via psql.
Also in 3 projects that use this
JetBrainsSkillfix-bug
End-to-end bug fix workflow for the Exposed project. Accepts a GitHub issue (#NUMBER), YouTrack issue (EXPOSED-NUMBER), or YouTrack URL (https://youtrack.jetbrains.com/issue/EXPOSED-NUMBER). Fetches the issue, creates a failing reproducer test, commits on a new branch, implements the fix, validates, and opens a PR. Use this skill whenever the user wants to fix a bug from an issue tracker, mentions a EXPOSED issue number, or references a GitHub issue to fix.
Also in 6 projects that use this
MicrosoftSkillperf
Speed and memory performance rules for Rust crates, the Node addon, webui-framework, and webui-router.
Also in 5 projects that use this
- +2 more from jidechao
Other versions111 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 111
- github/awesome-copilot★ 40ksame name
- parcadei/Continuous-Claude-v3★ 3.9ksame name
- codeaholicguy/ai-devkit★ 1.6ksame name
- SethGammon/Citadel★ 922same name
- solatis/claude-config★ 909same name
- boshu2/agentops★ 447same name
- nwiizo/tfmcp★ 373same name
- smallnest/goal-workflow★ 287same name
- oasm-platform/open-asm★ 204same name
- sd0xdev/sd0x-harness★ 191same name
101 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 repository52 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- testing/CLAUDE.mdCLAUDE.md
- a11y-auditSkill
- adoptSkill
- api-contractSkill
- architecture-decisionSkill
- architecture-reviewSkill
- backlogSkill
- brainstormSkill
- changelogSkill
- code-reviewSkill
- collaboration-protocolSkill
- create-storiesSkill
- data-modelSkill
- dependency-auditSkill
- deploySkill
- design-systemSkill
- dev-storySkill
- docsSkill
- feature-specSkill
- game-conceptSkill
- hardenSkill
- helpSkill
- hotfixSkill
- impactSkill
- incidentSkill
- initSkill
- migrateSkill
- pentestSkill
- perf-auditSkill
- product-specSkill
- qa-planSkill
- release-checklistSkill
- retrospectiveSkill
- security-auditSkill
- setup-stackSkill
- skill-improveSkill
- skill-testSkill
- sprint-planSkill
- sprint-statusSkill
- stack-updateSkill
- startSkill
- story-doneSkill
- team-featureSkill
- team-gameSkill
- team-releaseSkill
- team-securitySkill
- tech-debtSkill
- test-setupSkill
- threat-modelSkill
- updateSkill
- ux-specSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 0 are distinctive, and 10 are very specific to this project.
0
Common
Most of the 94 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
every file goes through Task to <engineer>.
- Very specific: line 44
No mode argument and no --apply → full pass: every mode that applies, in the order layout → packages → tests, each announced before it runs.
- Very specific: line 59
Read references/baseline-go.md (Go, from the Go root) or references/baseline-php.md (PHP, from the PHP root) § Baseline and run every …
- Very specific: line 65
Scope by mode: no argument → every choice, current value first.
- Very specific: line 67
The fields per stack: read references/baseline-<stack>.md § Choices and take its field list and options.
- Very specific: line 78
Traceability and scope: Every step names the ARCH-NNN/tech-debt row it closes.
- Very specific: line 89
Read references/apply.md § Phase 6: the Phase 2 table before · after · rule, the seven conditions for COMPLETE, and PARTIAL (…) naming any …
- Very specific: line 92
After an apply: read references/apply.md § Phase 7 step 1 and run its four steps in order — story status → Review with its own docs: …
- Very specific: line 95
after a dry-run: /architecture-decision when Phase 3 changed the style or the mode was framework (Recommended then), else /create-stories …
- Very specific: line 96
after an apply: /web-studio:code-review --diff <story-path> (copy mode /code-review --diff <story-path>) (Recommended) · show the …
“Common” is measured: kept by at least 6 in 10 of the 94 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
Language, paths and names, gates, the documents-lane commit gate, the Skill tool, subagents, CI wait and the hand-off form: docs/coordination-rules.md § Skill conventions (every project loads it).
Dry-run is the default and writes no code. It delivers a plan in the chat and, on consent, a plan
document; stories come from /create-stories afterwards. Code changes happen only with --apply S-NNN
(a Ready story produced from a dry-run plan) on a refactor/S-NNN-<slug> branch:
- every file goes through
Taskto<engineer>; the parent writes no product code (§ Subagents); - "May I write?" is an
AskUserQuestionbefore the first write, andtouch .claude/.write-consentfollows the "write" answer (rule 7).
Behaviour does not change in a refactoring. A step that needs a new rule, a contract change or a
schema change is not a refactoring step: it is a /impact detour (rule 11) — in a dry-run it is listed
under "Out of scope — /impact" (Phase 4 step 3); during an apply it runs through the Skill tool
(references/apply.md Phase 5 step 5), the only other skill this one runs mid-flow.
Names used below:
<engineer>:go-engineerfor Go,php-engineerfor PHP — namespaced as § Skill conventions → Paths and names says.<hooks>,<default>, agent and command namespaces: § Skill conventions → Paths and names.- Gates: each commit, start and push gate below is recorded before the question (
<hooks>session-state.sh set Gate "/refactor Phase N: <question>") and cleared after the answer (§ Skill conventions → Gates), so a resumed session continues at that question instead of readingNext:. Skilltool: this skill runs only/impactthrough it, during an apply, after the runningTaskhas returned (§ Skill conventions → Another skill)./create-stories,/architecture-decisionand/code-revieware hand-offs in the closingAskUserQuestion, never run from here.FRAMEWORK_NAMESPACES: the regex alternativedocs/stack-reference/<framework>.mdnames for the recordedphp_framework(the valuedocs/templates/php/deptrac.yamltakes).Write/Editare for the plan document,technical-preferences.md, the story card and the sprint row only.
References: stack-reference/go.md ("Architecture style", "Layered architecture", "Tests by layer",
"Project layout"), stack-reference/php.md ("Layered architecture", "Tests by layer"), rules/go-code.md,
rules/php-code.md, rules/tests.md, docs/templates/go/ and docs/templates/php/ (linter, gate, CI
targets), docs/git-workflow.md. Per-branch detail in references/: baseline-go.md, baseline-php.md
(Phase 2 commands, Phase 3 choices), plan-orders.md (Phase 4 step order by mode), apply.md (Phases 5–7, --apply only).
Phase 1: Mode, scope, stack
- Mode from the argument.
<package|namespace|file>→ local mode.layout→ architecture migration.tests→ test hygiene.framework→ PHP only: what would move if the framework changed. It is never part of the full pass; it runs only when asked for. On a Go project →BLOCKED (framework mode is PHP-only — Go has no framework layer to move; use /refactor layout or /refactor <package>), one line, no baseline, no plan.- No mode argument and no
--apply→ full pass: every mode that applies, in the order layout → packages → tests, each announced before it runs. --apply S-NNN→ mode and scope come from the story's plan document; check the story first (Phase 5). Phases 1 and 2 run (a refactoring starts from green, and Phase 2 is the "before" column of Phase 6); Phases 3 and 4 are skipped; Phase 5 follows.
- Stack from technical-preferences: Go and PHP in this version. Anything else →
BLOCKED (refactor supports Go and PHP in this version — inventory with /tech-debt, changes through /dev-story), one line, no plan. - Read the stack's fields.
- Go:
go_architecture,go_composition_root,go_router,graphql_models,go_domain_allow. - PHP:
php_framework,php_architecture,php_static_analysis,php_cs_tool,php_domain_allow. - Both: the coverage thresholds, the layout ADR,
production/findings.md(ARCH-NNNrows the plan must close) and the lastdocs/ops/tech-debt-*.md.
- Go:
- Which questions Phase 3 asks (dry-run only).
- Without an argument the pass is also a full interview: before any step runs, every choice of Phase 3 is asked, recorded or not, with the current value first ("keep:
<value>(current)", Recommended) and the alternatives after it. This is how the owner changes the approach of a running project. - An answer equal to the current value creates no step. A different one becomes a plan step:
/architecture-decisionfirst, the migration after it. - With an argument, only the questions of that mode are asked.
- The write gate for the plan is the one question that comes at the end (Phase 4), because it asks about tables that do not exist yet.
- Without an argument the pass is also a full interview: before any step runs, every choice of Phase 3 is asked, recorded or not, with the current value first ("keep:
Phase 2: Baseline by numbers
Nothing is planned from an impression. Run every command and tabulate its output.
- Read
references/baseline-go.md(Go, from the Go root) orreferences/baseline-php.md(PHP, from the PHP root) § Baseline and run every command it lists. The Go list saves thepkg/API to${TMPDIR:-/tmp}/refactor-<scope>-pkgapi.txt, the baseline Phase 6 diffs against. - The table (metric · value · rule it is measured against) is rendered in the chat before any question (rule 7).
frameworkmode (PHP) adds one table: namespace · classes importing the framework · of which in Domain / Application / Infrastructure. The Domain and Application columns are what a framework change has to touch before Infrastructure, and underlayeredthey must be zero.- A red build or a failing test stops here:
BLOCKED (baseline red — fix first: <package>). Refactoring starts from green.
Phase 3: Choices (dry-run only)
- Scope by mode: no argument → every choice, current value first;
layout→ the fields not recorded yet;framework→ the target only (step 4). - Three
AskUserQuestions, the same choices/setup-stackrecords: architecture and shape · transport (router, GraphQL models) · thresholds and allow-list. In each, the current value (from technical-preferences, the layout ADR or the tree) is the first, Recommended option ("keep"), the alternatives follow, and the tree is shown as evidence. - The fields per stack: read
references/baseline-<stack>.md§ Choices and take its field list and options; keeping the current architecture ends thelayoutmode with thePLANNED (no migration — <style> confirmed)verdict it names. frameworkmode asks one thing only: the target framework (yii3 · symfony · laravel · slim · none). It writes nothing into technical-preferences: the currentphp_frameworkstays the truth until the ADR is accepted and the last apply step lands.- Where the answers go. The
layoutanswers are written intotechnical-preferences.mdunder the plan's write gate (Phase 4). The architecture decision goes through/architecture-decision, named in the hand-off;/refactornever writes an ADR itself.
Phase 4: Plan (the dry-run deliverable)
- Step table. Each step is small enough for one
<engineer>call and green on its own. Columns: step · what moves (from → to, by package or namespace) · mechanics (gopls rename,gofmt -r, a new package + move +goimports, an interface extracted, a struct split) · check after the step (Go:go build ./... && go test -race ./..., plus the gate orarch-checkonce they exist; PHP:composer ci) · size (files, lines). - Step order by mode. Read
references/plan-orders.mdand take the order for this run's mode (Golayout· PHPlayout· PHPframework·tests·<package|namespace|file>), its step names verbatim into the table. Invariants: alayoutorder starts with characterisation tests (without that step no move is planned), then tooling; PHPframeworkrequiresphp_architecture: layered, elsePLANNED (layout first — run /refactor layout), and its step 1 is always the/architecture-decisionADR, which--applyrequiresAccepted. - Traceability and scope. Every step names the
ARCH-NNN/tech-debt row it closes. Steps that would change behaviour, a contract, a schema or a dependency are listed under Out of scope — /impact with the reason, never absorbed. - Write gate. Render the tables in the chat, then one
AskUserQuestion: "May I writedocs/ops/refactor-<date>-<scope>.md(the tables above) and the Phase 3 answers intotechnical-preferences.md?" — write (Recommended) · show the draft/diff first · not now. After the "write" answer:touch .claude/.write-consent(rule 7; the consent-guard hook checks the marker). - Commit gate (§ Skill conventions → Documents-lane commit gate), recorded first as
Gate "/refactor Phase 4: commit the plan?"and cleared after the answer: oneAskUserQuestionofferingdocs: refactor plan <scope>staging exactly the written files, on the branch the documents lane prescribes (commit (Recommended) · leave uncommitted). - Stories are not written here. The plan document is the spec
/create-stories <plan-path>slices: one story per step group, layerbackend, the title prefixedrefactor:, the story card citing the plan. That command owns its own gate.
Dry-run verdict: PLANNED (N steps).
Phase 5: Apply (--apply S-NNN only)
Read references/apply.md § Phase 5 and follow its six steps in order: story check (Ready or In Progress with a plan document, else BLOCKED (no plan — run /refactor --dry-run first); a framework plan needs its ADR Accepted) · the one "start" consent (Gate "/refactor Phase 5: start S-NNN?") that covers every commit of the apply · branch · record the start (Started: and In Progress, committed as docs:, before the first Task) · one Task to <engineer> per step, one commit per green step, never a red commit · who wrote it.
Phase 6: Verification by numbers (--apply only)
Read references/apply.md § Phase 6: the Phase 2 table before · after · rule, the seven conditions for COMPLETE, and PARTIAL (…) naming any metric that moved the wrong way.
Phase 7: Report and hand-off
- After an apply: read
references/apply.md§ Phase 7 step 1 and run its four steps in order — story status →Reviewwith its owndocs:commit, the push gate (Gate "/refactor Phase 7: push?"), what starts CI, wait for CI. - Verdict:
PLANNED (…)|COMPLETE|PARTIAL (open: …)|BLOCKED (…). - Next step, one
AskUserQuestion:- after a dry-run:
/architecture-decisionwhen Phase 3 changed the style or the mode wasframework(Recommended then), else/create-stories <plan-path>(Recommended) · show the plan · stop here; - after an apply:
/web-studio:code-review --diff <story-path>(copy mode/code-review --diff <story-path>) (Recommended) · show the before/after table · stop here — never the bare/code-reviewin plugin mode (§ Skill conventions → Verdict and next step).
- after a dry-run:
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.

