refactor
Skill1 starsChanged 4 months agoMITView on GitHub
Make the smallest safe, behavior-preserving edits that make changed code easier to scan, name, and maintain. Language-agnostic. Works from the current git diff. Use when the user asks to refactor, clean up, tidy, restructure, reorganize, or improve the readability of changed code without changing behavior, exports, public APIs, routes, or schemas. For language-specific rules, prefer the python, javascript, typescript, or go refactor variants when the diff is dominated by one language.
- Reads credentials
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 repository25 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- build-serviceSkill
- client-cycle-slidesSkill
- commitSkill
- mysqlSkill
- nekiSkill
- postgresSkill
- vitessSkill
- api-key-supportSkill
- api-responsesSkill
- oauth-supportSkill
- rbac-supportSkill
- resource-scaffoldSkill
- reviewSkill
- go-refactorSkill
- go-reviewSkill
- init-projectSkill
- javascript-refactorSkill
- javascript-reviewSkill
- configifySkill
- python-refactorSkill
- python-reviewSkill
- typescript-refactorSkill
- typescript-reviewSkill
- write-like-sokhibjonSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
28 rules. 0 are common, 18 are distinctive, and 10 are very specific to this project.
0
Common
Most of the 169 edited versions we read keep these.
18
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
- Distinctive: line 27
Prefer project conventions first, formatter/linter rules second, official language idioms third, and external style guides only when the …
- Distinctive: line 40
If there is no diff, ask which files or range to refactor.
- Distinctive: line 51
If present, fix CRITICAL findings first, then WARNING, then SUGGESTION.
- Distinctive: line 56
Follow the local convention even when another style guide would be acceptable.
- Very specific: line 57
Do not impose generic structure such as src/, mirrored tests/, .env.example, or VERSION unless the repo already uses it.
- Very specific: line 61
Search with regex before editing (ripgrep needs -P for the \x{...} escape):
- Very specific: line 67
If matches are noisy, inspect or narrow with fzf, for example:
- Very specific: line 84
Use exactly one format for code-section markers: the file's comment leader, a single space, MARK:, a single space, then the label (e.g.
- Very specific: line 95
No space after the colon: # MARK:helpers -> # MARK: helpers
- Very specific: line 96
No space after the leader: #MARK: helpers -> # MARK: helpers
- Distinctive: line 122
Ask before high-risk changes unless the user explicitly requested them.
- Distinctive: line 125
Prefer clear names, direct control flow, low nesting, and locality.
- Very specific: line 128
Add MARK:, TODO:, NOTE:, constants, helpers, or docstrings only when they solve a real readability problem.
- Distinctive: line 131
Prefer deleting boilerplate over rewriting it.
- Very specific: line 136
After file moves or renames, remove empty orphan directories and update affected imports/exports/tests.
- Distinctive: line 140
Run the nearest relevant formatter, linter, typecheck, or tests when discoverable.
- Distinctive: line 141
Prefer targeted checks unless the change is broad.
- Distinctive: line 143
If verification cannot run, say why.
- Distinctive: line 152
Never change observable behavior unless explicitly asked.
- Distinctive: line 153
Never remove or rename exported symbols unless explicitly asked.
- Distinctive: line 154
Never remove function, class, or method docstrings.
- Very specific: line 155
Never replace structured logging with print or console.log.
- Distinctive: line 156
Never stage unrelated files.
- Distinctive: line 157
Never force generic architecture on a repo with its own convention.
- Distinctive: line 158
Never add comments, docstrings, constants, helpers, or section markers just to satisfy a checklist.
- Very specific: line 160
Always normalize existing section markers to a single <leader> MARK: <label> format.
- Distinctive: line 161
Prefer code that a human understands on first pass over cleverness.
- Distinctive: line 162
If a file is already clean, skip it and say so.
“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
You are a strict, pragmatic refactor workflow. Work from the current diff. Make the smallest safe edits that make changed code easier to scan, name, and maintain without changing behavior, exports, public APIs, routes, schemas, or unrelated code.
Prefer project conventions first, formatter/linter rules second, official language idioms third, and external style guides only when the repo has no clear convention.
Workflow
Inspect the worktree (read-only):
git status --porcelain=v1 git diff HEAD git diff --cachedIf there is no diff, ask which files or range to refactor.
- Use optional review context:
Review findings live at a per-project path so concurrent refactors never collide:
/tmp/<dirname>/code-review.md, where<dirname>is the current directory's name (e.g./tmp/agent-setup/code-review.md).cat "/tmp/$(basename "$PWD")/code-review.md" 2>/dev/null- If present, fix CRITICAL findings first, then WARNING, then SUGGESTION.
- Find project conventions:
- Inspect nearby files, package/config files, formatter/linter settings, tests, imports, names, and file layout.
- Follow the local convention even when another style guide would be acceptable.
- Do not impose generic structure such as
src/, mirroredtests/,.env.example, orVERSIONunless the repo already uses it.
- Normalize em-dashes globally:
Search with regex before editing (ripgrep needs
-Pfor the\x{...}escape):rg -n -P '\x{2014}'If matches are noisy, inspect or narrow with
fzf, for example:rg -l -P '\x{2014}' | fzf --multiReplace safe matches with ASCII
-. Perl must decode UTF-8 (-CSD), or\x{2014}matches nothing:perl -CSD -0pi -e 's/\x{2014}/-/g' <files>- Skip semantic data values, snapshots, fixtures, URLs, or tests where the exact character matters.
- Normalize section markers:
- Use exactly one format for code-section markers: the file's comment leader, a single
space,
MARK:, a single space, then the label (e.g.# MARK: helpers,// MARK: helpers). Keep the leader appropriate to the language (#,//,--). Find every variant before editing (case-insensitive):
rg -n -i 'mark:?\b'- Rewrite alternates to the canonical form. Common variants to fix:
- Missing colon:
# MARK helpers-># MARK: helpers - No space after the colon:
# MARK:helpers-># MARK: helpers - No space after the leader:
#MARK: helpers-># MARK: helpers - Wrong case:
# mark: helpers,# Mark: helpers-># MARK: helpers - Xcode-style dash separator:
// MARK: - helpers->// MARK: helpers - Surrounding decoration such as dashes or
===around the label
- Missing colon:
- Preserve the label text and the language's comment leader; only normalize the marker shape.
- Skip matches inside strings, data, fixtures, or docs where
MARKis not a code section marker.
- Use exactly one format for code-section markers: the file's comment leader, a single
space,
- Analyze changed code:
- Naming consistency across analogous files, services, routers, helpers, and shims.
- Dead imports, unreachable code, stale comments, boilerplate comments, and redundant docstrings.
- Long functions, deep nesting, unclear control flow, duplicated logic, and misleading names.
- Error handling, logging, type safety, magic values, and module boundaries.
- Classify risk before editing:
- Low risk: unused imports, local renames, stale comments, docstring cleanup, simple formatting, tiny helper extraction.
- Medium risk: moving code inside a file, reorganizing private helpers, changing internal imports.
- High risk: file moves, export changes, route/path changes, broad renames, new modules, public API changes, test rewrites.
- Apply useful low-risk changes directly.
- Apply medium-risk changes only when the readability win is clear.
- Ask before high-risk changes unless the user explicitly requested them.
- Improve scanability:
- Prefer clear names, direct control flow, low nesting, and locality.
- Group code as imports, constants, types, helpers, public API, private internals, and exports when that matches the file.
- Add
MARK:,TODO:,NOTE:, constants, helpers, or docstrings only when they solve a real readability problem. NewMARK:markers must use the canonical<leader> MARK: <label>form from step 5. - Prefer deleting boilerplate over rewriting it.
- Apply focused edits:
- Edit only files needed for the refactor.
- Preserve behavior, public interfaces, dependency shape, and unrelated user changes.
- After file moves or renames, remove empty orphan directories and update affected imports/exports/tests.
- Verify:
- Run the nearest relevant formatter, linter, typecheck, or tests when discoverable.
- Prefer targeted checks unless the change is broad.
- For rename/move batches, run the full test suite and build when discoverable.
- If verification cannot run, say why.
- Summarize:
- List files changed and why.
- Note risky refactors skipped.
- Report verification results.
Rules
- Never change observable behavior unless explicitly asked.
- Never remove or rename exported symbols unless explicitly asked.
- Never remove function, class, or method docstrings.
- Never replace structured logging with
printorconsole.log. - Never stage unrelated files.
- Never force generic architecture on a repo with its own convention.
- Never add comments, docstrings, constants, helpers, or section markers just to satisfy a checklist.
- Always normalize existing section markers to a single
<leader> MARK: <label>format. - Prefer code that a human understands on first pass over cleverness.
- If a file is already clean, skip it and say so.
</content>
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.

