refactor
Skill1 starsChanged 10 days agoApache-2.0View on GitHub
Behavior-preserving structural refactors with verification gates. Use in conversation when surveying or applying structural refactors. Also the loop entry skill when automation supplies hints (duplication_block, oversized_unit). Interactive default is survey only; apply edits when the request asks for changes to be made (for example fix, apply, or update) or automation sets agent_edit_allowed in Constraints. Not for lint-only style, features, behavior-changing bugfixes, or upgrades.
196 other projects use a version of this.
Adopted by
Most recently taken up by
- Archont561/skillstheir own version, first seen Nov 15, 2026
- nazmirket/skillstheir own version, first seen Nov 15, 2026
- qivora-labs/agentinittheir own version, first seen Nov 15, 2026
- NomadicDaddy/aiddtheir own version, first seen Nov 15, 2026
- zircote-plugins/refactortheir own version, first seen Nov 15, 2026
- vlad-ryzhkov/ai-context-engineering-for-frontendtheir own version, first seen Nov 15, 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★ 715same 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 repository56 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .apm/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- .github/workflows/CLAUDE.mdCLAUDE.md
- .cursor/rules/agent-skills.mdcCursor rule
- .cursor/rules/bats.mdcCursor rule
- .cursor/rules/github-actions-workflow.mdcCursor rule
- .cursor/rules/go.mdcCursor rule
- .cursor/rules/go-test.mdcCursor rule
- .cursor/rules/instructions.mdcCursor rule
- .cursor/rules/markdown.mdcCursor rule
- .cursor/rules/shell-script.mdcCursor rule
- .cursor/rules/terraform.mdcCursor rule
- agent-skills-reviewSkill
- changelogSkill
- ci-sweeperSkill
- docs-creatorSkill
- docs-updaterSkill
- github-actions-reviewSkill
- github-actions-validationSkill
- github-issue-autofixSkill
- github-issue-triageSkill
- github-pr-bodySkill
- github-pr-reviewSkill
- github-pr-reviseSkill
- go-reviewSkill
- go-validationSkill
- instructions-reviewSkill
- loop-verifierSkill
- markdown-validationSkill
- refactorSkill
- shell-script-reviewSkill
- shell-script-validationSkill
- tech-debtSkill
- test-gapSkill
- agent-skills-reviewSkill
- changelogSkill
- ci-sweeperSkill
- docs-creatorSkill
- docs-updaterSkill
- github-actions-reviewSkill
- github-actions-validationSkill
- github-issue-autofixSkill
- github-issue-triageSkill
- github-pr-bodySkill
- github-pr-reviewSkill
- github-pr-reviseSkill
- go-reviewSkill
- go-validationSkill
- instructions-reviewSkill
- loop-verifierSkill
- markdown-validationSkill
- shell-script-reviewSkill
- shell-script-validationSkill
- tech-debtSkill
- test-gapSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 169 edited versions we read keep these.
1
Distinctive
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 71
When intent is unclear, survey and offer to apply — edits are harder to undo than a report.
- Very specific: line 73
When agent_edit_allowed is true, resolve agent_edit_target: interactive → fix.
- Very specific: line 104
If detect JSON is absent, run scripts/detect_refactor.sh with the resolved scope (default --scope all.
“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
UTILITY SKILL — structural refactor survey and apply, not feature work.
Input
- Interactive (required): paths/symbols and optional mode — constraints in
## Constraintsor category-scope.md - Automation (optional): detect JSON with
hints[]in prompt — from a caller or optional skill detect script; not required for interactive runs. Readagent_edit_allowedandagent_edit_targetfrom## Constraintsper category-automation-envelope.md
Path allowlist, when present, arrives in ## Constraints.
Output Specification
Refactor report per common-output-format.md. Survey shape when no files are edited; apply shape when edited — within category-scope.md. Automation path: common-output-format-automation.md and category-automation-envelope.md.
Execution Scope
USE FOR:
- Survey structural candidates; dedupe, extract/inline, clarify, shallow moves; automation hints; architecture Phase A/B; characterization tests
DO NOT USE FOR:
- Lint/style-only; features/API/behavior fixes; cross-boundary apply; platform-wide architecture refactors; external debt-survey apply input
Reference Files Guide
- common-checklist.md (always read)
- common-output-format.md (always read)
- category-scope.md (always read)
- category-contract.md (always read)
- category-detect-scope.md (read on interactive path)
- category-verification.md (read when agent_edit_allowed is true)
- category-techniques.md (read when agent_edit_allowed is true)
- category-input-schema.md (read when structured mode JSON, automation detect JSON, or the optional detect script is run)
- category-automation-envelope.md (read on automation path)
- common-output-format-automation.md (read on automation path)
- common-troubleshooting.md (read on failure)
- category-pr-body-links.md (read when synthesizing the PR body)
assets/pr-body-template.mdandassets/pr-body-template-survey.md(read when synthesizing the PR body)
Workflow
Phases, modes, depth tiers, and intent: category-contract.md. Self-check gates: common-checklist.md.
Canonical sequence: resolve agent_edit_allowed → Phase A (discover/classify; emit only when stopping) → Phase B only when edit-authorized → emit one result shape (OUT-01).
Resolve agent_edit_allowed before Phase B. When structured JSON mode is present (category-input-schema.md), it wins over the interactive rows: survey → false; apply → true. Otherwise use the table. An imperative with a target ("refactor scripts/a.sh", "deduplicate these helpers") asks for changes; "use refactor on X" or "what could be refactored in X" only names the skill or asks to look, so it stays survey.
| Source | agent_edit_allowed |
| Interactive — default: the request asks to look, check, triage, or survey, or only names the skill | false — survey only; do not edit files |
| Interactive — the request asks for changes to be made (for example fix, apply, 修正して, 適用して, update, add) | true |
| Interactive — follow-up after a survey asking to apply | true |
Automation — ## Constraints | agent_edit_allowed: true or agent_edit_allowed: false from category-automation-envelope.md |
When intent is unclear, survey and offer to apply — edits are harder to undo than a report.
When agent_edit_allowed is true, resolve agent_edit_target: interactive → fix; automation → from ## Constraints. Do not branch on other caller metadata. Before Phase B, load category-techniques.md.
Phase B runs only when agent_edit_allowed is true and agent_edit_target is fix. Architecture without approved_slice never enters Phase B (INTENT-02).
Phase A — Survey (always)
Discover and classify only. Emit a final report from Phase A only when this run will not enter Phase B (see Interactive / Automation paths).
- Resolve scope (category-scope.md); parse structured/detect JSON when present (category-input-schema.md).
- Classify intent (category-contract.md).
- Architecture without
approved_slice: emit survey shape with### Architecture Proposalonly; stop (INTENT-02). Do not treat as zero-actionable no-op. - Discover candidates (SURVEY-01): structural → all in-scope; architecture Phase B → only the
approved_slice. Read targets before classifying (SURVEY-03); route apply-worthy → Candidates, else → Watch (SURVEY-02). - Structural zero actionable → emit survey no-op per common-output-format.md (Overview explains no-op); stop.
Phase B — Apply (agent_edit_allowed: true and agent_edit_target: fix)
- For each apply candidate: one technique (category-techniques.md); gate (category-verification.md); on failure revert → Deferred; continue (APPLY-01).
- Re-run gates on touched areas; emit apply shape; reconcile with
git diff --name-only(OUT-01).
Automation path (hints[] in detect JSON)
- Parse detect JSON; read
agent_edit_allowed/agent_edit_targetfrom## Constraints. - Empty/
skip→ emit survey no-op per common-output-format.md (Overview explains no-op) + Session Metrics; stop. - Phase A on all
hints[](structural only — no architecture Phase A/B). agent_edit_allowed: falseoragent_edit_target≠fix→ emit survey shape + Session Metrics (note expectedagent_edit_target: fixwhen mismatched); no Phase B.- Else → Phase B; emit apply shape + Session Metrics (category-automation-envelope.md).
Interactive path
- Resolve
agent_edit_allowed(table above). Load category-detect-scope.md. - Resolve universe from the prompt (default =
REFACTOR_SCAN_GLOBS/ skill defaults). If the user named paths/globs, narrow the universe before detect. - If detect JSON is absent, run
scripts/detect_refactor.shwith the resolved scope (default--scope all; setREFACTOR_SCAN_GLOBSfor a temporary universe). On non-zero exit orstatus: "error", read stdout and stop. - Phase A: classify every
hints[]entry and Agent-complement structural candidates (read targets — SURVEY-03). Architecture withoutapproved_slicestops inside Phase A step 3. - Empty detect alone is not a no-op if complement found apply-worthy or watch-worthy work.
agent_edit_allowed: falseoragent_edit_target≠fix→ emit survey shape; stop.- Else → Phase B; emit apply shape.
Error Handling
| Condition | Severity | Action |
Detect script non-zero exit or status: "error" (when invoked) | Fatal | Read stdout; stop — do not treat as success-path detect JSON |
Automation: empty/skip | Info | Emit survey no-op (Overview explains no-op); stop |
| Survey: zero candidates | Info | Emit survey no-op (Overview explains no-op); stop |
| Architecture request without slice | Recoverable | Architecture proposal only; stop |
| Lint-primary or feature/API candidate | Recoverable | Watch on candidate; skip apply |
| Weak or failed gate for one candidate | Recoverable | Revert that candidate; Deferred; continue |
| Cross-boundary or out-of-scope target | Recoverable | Watch on candidate; skip apply |
Edit requested but ## Constraints set agent_edit_allowed: false | Info | Survey only; note that the caller Constraints disallow edits |
agent_edit_allowed true with agent_edit_target not fix | Recoverable | Survey only; note expected agent_edit_target: fix |
Examples
- Prompt:
Survey structural refactor candidates in this package - Result: Survey report per references/common-output-format.md; apply only when
agent_edit_allowedis true,agent_edit_targetisfix, and candidates are marked apply.
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.

