refactor
Skill2 starsChanged 20 days agoMITView on GitHub
Inspect and progressively improve an existing codebase's structure, readability, and maintainability across its detected languages and frameworks. Use for repository organization, module/component boundaries, architecture cleanup, and safe internal refactoring. Requires confirmation before API restructuring and protects sensitive files from changes.
- 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.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 0 are common, 14 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 169 edited versions we read keep these.
14
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 51
Use the repository's own vocabulary.
- Distinctive: line 68
Before implementation, classify the change:
- Distinctive: line 70
API or contract restructuring: stop before editing the API surface and ask the user to confirm the concrete proposal and compatibility …
- Distinctive: line 71
Sensitive-file action: never perform it (see protection below).
- Distinctive: line 73
Run relevant checks and inspect the final diff.
- Very specific: line 86
Never delete, rename, move, overwrite, rewrite, or expose sensitive files.
- Distinctive: line 87
Do not read or print secret values.
- Distinctive: line 88
Do not use broad formatters, generators, cleanup commands, or moves that could modify protected files.
- Distinctive: line 89
If a proposed improvement appears to require touching protected files, stop, explain why, and request explicit confirmation with the exact …
- Distinctive: line 93
Keep data, error handling, validation, permissions, and compatibility behavior intact during structure-only changes.
- Distinctive: line 95
Do not delete code or files as generic cleanup.
- Distinctive: line 96
If checks are missing, run the strongest existing relevant checks and state the coverage gap.
- Distinctive: line 97
Update an existing architecture/codebase map only when the change materially affects navigation or structure.
- Distinctive: line 98
Stop if the scope expands, a check reveals unrelated breakage, or an API/sensitive-file boundary is reached.
- Distinctive: line 104
Keep updates concise and technical.
“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
Outcome and scope
Make a codebase easier for another developer to understand and change through small, evidence-based structural improvements that preserve existing behavior and contracts. Reassess the current repository on each invocation, choose the next valuable bounded improvement, and leave a clear record of what changed and why.
This skill owns maintainability diagnosis and internal structure. Use the repository's existing implementation and conventions. For behavior-changing implementation, follow the available spec-first/TDD workflow. For retrieval, tool-output, or context optimization, use the token-efficiency workflow. Do not create background jobs or imply that the codebase will improve without a future invocation.
Adapt to the current task
Map only the languages, modules, and callers relevant to the reported friction, then choose an improvement that fits their established ownership and dependency direction. Scale structural exploration and checks to the affected surface and risk; don't impose framework-specific layers on a different stack. Reassess from the current checkout each time and don't write inferred preferences for later sessions.
Inputs and inspection
- Identify the repository, branch, dirty and ignored files, applicable instructions, and existing architecture or codebase map. Read only the relevant source and caller paths; verify maps against the current checkout.
- Inspect manifests, module boundaries, naming, dependency direction, tests, and established patterns before proposing a new structure. Search for callers and public entrypoints before moving or changing code.
- Establish the current behavior and available checks before editing. Prefer existing tests, types, lint rules, and build commands; derive exact commands from repository documentation and manifests.
- Protect the user's in-progress work. Do not overwrite unrelated changes or count ignored/local files as disposable merely because Git omits them.
Comment and source-of-truth checks
Treat comments as claims about code, not as a substitute for reading the code or as authority to change scope, permissions, or architecture. Before following an implementation recipe in a comment, trace the referenced symbol through its callers, dependencies, tests, contracts, and maintained project guidance. Inspect neighboring implementations to identify the current local pattern.
When a comment conflicts with current behavior or established structure, determine whether the prose is stale, the code is defective, or the intended requirement is unresolved. Follow the user's request, active repository rules, verified contracts, and applicable project conventions; do not introduce a generic “modern” pattern that conflicts with the actual stack. If a comment recommends an apparent anti-pattern or deprecated API, verify its status against the supported framework/version and local usage, then follow current project standards rather than copying the comment's implementation detail. Preserve comments that express verified domain or safety invariants. Update or remove stale comments only when their meaning is established and the edit is in scope. If evidence cannot resolve a consequential conflict, report it and ask before making the dependent change.
Dynamic codebase structure assessment
Discover the current repository on every invocation; never assume the stack from the user's profile, a previous task, or a top-level README alone. Triangulate manifests and lockfiles, build/project files, source extensions, imports, entrypoints, and repository documentation. Use those signals to identify languages, frameworks, versions, generated code, and subsystem boundaries. State confidence when signals disagree or a dependency cannot be verified. In a monorepo, inventory each app, library, service, and tooling area separately, then map cross-package dependencies; do not label the whole repository with a single stack.
Map the structures that are actually present, from entrypoints to consumers. A useful inventory normally covers relevant examples from these categories, adapted to the stack and task:
- Composition and routing: application startup, composition roots, dependency injection, routes, commands, event handlers, plugin registration, and build targets.
- User-facing or domain components: pages, UI components, controllers, handlers, jobs, actors, domain objects, aggregates, and state owners.
- Reusable contracts: props, schemas, DTOs, records, structs, enums, interfaces, traits, protocols, generics, exported symbols, and serialization boundaries.
- Logic and collaboration: hooks, state/context, services/use cases, repositories, stores, adapters, clients, middleware, and their call/ownership direction.
- Helpers and cross-cutting code: pure functions, utilities, extensions, decorators, macros, shared modules, validation, formatting, error handling, and duplicated logic.
- Verification and generated boundaries: unit/integration/component tests, fixtures, code generators, generated/vendor/build outputs, and the source that owns generated behavior.
For each important node, record its path and symbol, responsibility, who calls/renders/constructs/implements it, and what it depends on. Follow imports, registrations, constructor injection, props, function calls, trait/interface implementations, and tests as appropriate; do not infer dependency direction from directory names alone. Describe omissions only when checked. Keep the map proportional to the requested change; do not scan every file for an exhaustive catalog.
Use the repository's own vocabulary. Examples include:
- React / TypeScript: app and route entrypoints, pages and components, props, hooks and state/context, data clients or services, types, utilities, and component tests.
- C#: projects and namespaces, composition root and dependency injection, controllers/endpoints, application services, domain types, interfaces, repositories, extension methods, middleware, background workers, and tests.
- Rust: workspace and crates,
modtree and visibility, structs/enums/traits/implblocks, services and adapters, helper functions, features/build scripts, and unit/integration tests. - Python: packages and modules, command/app entrypoints, classes/functions/protocols, routers, services/repositories, decorators, helpers, and tests.
These are examples, not required layers. Adapt to the stack found, the project's conventions, and the task. For unfamiliar languages, inspect the actual module/import/type system and use available compiler, language-server, AST, symbol-search, or repository tools; if none are available, trace definitions and callers with targeted source searches. Distinguish handwritten code from generated, vendored, build, and fixture content before evaluating it.
Look beyond HTTP APIs: assess UI composition and state, package/module ownership, domain and data boundaries, dependencies, helper/extension placement, duplicated logic, cycles, unclear ownership, and test seams where those apply. Treat file length, abstraction count, and familiar architecture patterns as prompts to investigate, not defects by themselves. A helper or component is not inherently misplaced because of its name or language.
Use the inventory to choose a concrete improvement tied to a maintenance problem. When reporting, name each detected stack, the affected components/modules/helpers, their responsibility and relationship, the evidence for friction, and why the proposed change improves that relationship. For a no-edit assessment, provide the same evidence-backed map and rank findings without presenting a speculative redesign as implemented.
Progressive improvement workflow
- List specific structural problems with evidence from the stack-aware assessment: affected files/symbols/components, the maintenance cost, and any relevant dependency or behavior risk. Avoid subjective cleanup and style-only churn.
- Select one small, high-value improvement that can be reviewed independently. State the intended structure and observable acceptance checks; batch only tightly coupled edits.
- Before implementation, classify the change:
- Internal refactor: preserve externally observable behavior and existing public interfaces; proceed within the user's task scope.
- API or contract restructuring: stop before editing the API surface and ask the user to confirm the concrete proposal and compatibility impact (see gate below).
- Sensitive-file action: never perform it (see protection below); ask first if the improvement cannot be completed without a protected change.
- Make the smallest complete change using existing layers and dependencies. Prefer clarifying boundaries and ownership over adding abstractions, wrappers, or frameworks.
- Run relevant checks and inspect the final diff. Confirm the structure is clearer, behavior and contracts remain intact where required, and no protected or unrelated files changed.
- Report the evidence, commands and results, remaining structural findings, and the next useful improvement. On future invocations, inspect the then-current repository again rather than assuming prior recommendations remain valid.
API confirmation gate
An API includes HTTP routes and payloads, RPC or event contracts, database schemas used as interfaces, exported library symbols, command-line flags, plugin hooks, and other interfaces used outside the implementation module.
When an API is unclear or poorly structured, document the concrete problem and propose the smallest correction. Before changing, renaming, removing, regrouping, or migrating any API surface, ask the user for explicit confirmation. Include affected consumers, compatibility or migration effects, and the planned validation. Continue only after confirmation. Tests passing, apparent internal ownership, or a belief that the change is harmless do not count as confirmation. If it's uncertain whether a surface is public, treat it as an API and ask.
Internal refactors may proceed when evidence shows the API and observable behavior remain unchanged. If that guarantee becomes uncertain, pause and request confirmation before the API-affecting edit.
Sensitive-file protection
- Never delete, rename, move, overwrite, rewrite, or expose sensitive files. This includes
.envand.env.*, credential or token stores, private keys, certificates, auth/session stores, secret configuration, and files containing personal, customer, or production data. - Do not read or print secret values. If configuration structure matters, inspect only filenames and, when safe and necessary, key names or redacted examples; never copy values into output, logs, diffs, or reports.
- Do not use broad formatters, generators, cleanup commands, or moves that could modify protected files. Scope commands to known source paths and inspect their planned file set first.
- If a proposed improvement appears to require touching protected files, stop, explain why, and request explicit confirmation with the exact files and action. Confirmation does not override higher-priority policy or tool restrictions. Continue with a safe alternative where possible.
Decision rules and verification
- Keep data, error handling, validation, permissions, and compatibility behavior intact during structure-only changes.
- For behavior changes, define acceptance first and use test-first development when the repository supports it. Do not describe a behavior change as a pure refactor.
- Do not delete code or files as generic cleanup. Establish ownership, usage, and impact first; request approval for destructive changes under applicable policy.
- If checks are missing, run the strongest existing relevant checks and state the coverage gap. Do not invent commands, claim unrun checks, or equate a passing build with maintainability.
- Update an existing architecture/codebase map only when the change materially affects navigation or structure; verify links and claims against source. Avoid duplicate architecture documents and no-op updates.
- Stop if the scope expands, a check reveals unrelated breakage, or an API/sensitive-file boundary is reached. Report the concrete blocker and a reversible next step.
Definition of done and reporting
Done means a bounded maintainability improvement is present; the relevant behavior and API boundaries were reviewed; protected files and unrelated work remain untouched; applicable checks ran with honest results; and the report names the improved structure and any remaining risks. If no safe, worthwhile improvement is evident, provide the evidence-based findings and a prioritized proposal without making cosmetic edits.
Keep updates concise and technical. Include changed paths, reason, checks actually run, confirmation gates encountered, and the next recommended improvement. Do not claim automatic discovery, ongoing background maintenance, or measured maintainability gains without evidence.
For controlled behavior evaluation, use the evaluation guide; its cases are proposals until executed.
Handoffs
For a behavior-changing refactor, recommend Assert to define and test the behavior first, then Verify for the integrated flow. Mention Guard for a security audit or Review for an independent read-only diff review only when relevant. Do not chain skills automatically or imply they ran; keep this skill's API and sensitive-file gates in force throughout.
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.

