refactoring
Skill1 starsChanged 4 months agoMITView on GitHub
Refatoração segura: catálogo de code smells, técnicas de Fowler (extract/inline/move/rename), refatorar sob rede de testes, strangler fig e regra do escoteiro. Use quando o usuário mencionar: "refatorar", "refactoring", "code smell", "limpar o código", "melhorar sem mudar comportamento", "extract method", "código legado", "reduzir complexidade", "dívida técnica". Liga com [[testing]] e [[tech-debt]].
58 other projects use a version of this.
Adopted by
Most recently taken up by
- ishandutta2007/Awesome-Claude-Skillstheir own version, first seen Nov 8, 2026
- larchanka/skillstheir own version, first seen Nov 8, 2026
- REPOZY/superpowers-optimizedtheir own version, first seen Nov 8, 2026
- nisarth/claude-skills-storetheir own version, first seen Nov 8, 2026
- ericwang200608-beep/LANYANT-Skillstheir own version, first seen Nov 8, 2026
- AnyOrgName/php-skillstheir own version, first seen Nov 8, 2026
Used with
Projects with it also use dependency-management, multi-agent-orchestration and 5 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.
dkprogSkilldependency-management
Apply when wiring dependencies, integrating external services, or designing interfaces between modules. Ensures loose coupling through dependency injection, interface segregation, and proper abstraction boundaries.
Also in 3 projects that use this
javalenciacaiSkillmulti-agent-orchestration
Design and coordinate multi-agent systems where specialized agents work together to solve complex problems. Covers agent communication, task delegation, workflow orchestration, and result aggregation. Use when building coordinated agent teams, complex workflows, or systems requiring specialized expertise across domains.
Also in 3 projects that use this
MicrosoftSkillerror-handling
统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。
Also in 7 projects that use this
AWSSkillplanning
Discovers user intent and generates a structured, step-by-step plan for model customization workflows. This skill must always be activated alongside any other skill when the user's request relates to model customization — including fine-tuning, training, building, customizing, reviewing data, or getting advice on approach, regardless of domain. Do not skip this skill even if the immediate ask is narrow (e.g., reviewing data format or a single workflow step), because planning discovers the full scope of work needed. Also activate when the user wants to resume, continue, or modify an existing plan.
Also in 6 projects that use this
AnthropicSkilldocumentation
Write and maintain technical documentation. Trigger with "write docs for", "document this", "create a README", "write a runbook", "onboarding guide", or when the user needs help with any form of technical writing — API docs, architecture docs, or operational runbooks.
Also in 9 projects that use this
diego-tobalinaSkilllogging
Logging best practices for Java (SLF4J/Logback) and Node.js (Winston/Pino). Use for structured logging, log levels, and avoiding sensitive data exposure.
Also in 3 projects that use this
Other versions58 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 58
- handsontable/handsontable★ 22ksame name
- ciembor/agent-rules-books★ 2.8ksame name
- hitobito/hitobito★ 485same name
- databrickslabs/ontobricks★ 457same name
- DevelopersGlobal/ai-agent-skills★ 216same name
- REPOZY/superpowers-optimized★ 146same name
- extra-org/extra★ 119same name
- tmcfarlane/team-avatar★ 112same name
- larchanka/skills★ 50same name
- nimadorostkar/Claude-Skills-collection★ 33same name
48 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 repository70 other files it gives its agents.
- agent-creationSkill
- handoffSkill
- task-distributorSkill
- task-plannerSkill
- accessibilitySkill
- airbnb-designSkill
- airtable-designSkill
- atlassian-designSkill
- carbon-designSkill
- cloudscape-designSkill
- coinbase-designSkill
- discord-designSkill
- duolingo-designSkill
- figma-designSkill
- fluent-designSkill
- linear-designSkill
- material-designSkill
- meta-designSkill
- netflix-designSkill
- notion-designSkill
- nubank-designSkill
- one-ui-designSkill
- pinterest-designSkill
- polaris-designSkill
- premium-web-designSkill
- primer-designSkill
- reddit-designSkill
- revolut-designSkill
- robinhood-designSkill
- salesforce-lightning-designSkill
- slack-designSkill
- spectrum-designSkill
- spotify-designSkill
- stripe-designSkill
- tiktok-designSkill
- twitch-designSkill
- uber-base-designSkill
- vercel-geist-designSkill
- visionos-designSkill
- whatsapp-designSkill
- economicsSkill
- legal-basicsSkill
- negotiationSkill
- politicalSkill
- api-designSkill
- architectureSkill
- caching-strategiesSkill
- ci-cdSkill
- database-designSkill
- event-drivenSkill
- observabilitySkill
- payment-systemsSkill
- performanceSkill
- qaSkill
- securitySkill
- system-designSkill
- testingSkill
- clone-websiteSkill
- graphifySkill
- remotionSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 53 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 60
No mesmo commit/PR de uma feature (mistura difícil de revisar e reverter).
- Distinctive: line 68
Commit atômico "refactor: ..." separado de features.
“Common” is measured: kept by at least 6 in 10 of the 53 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
Refactoring
Você atua como engenheiro que melhora código com disciplina. Definição estrita: refatorar é mudar a estrutura interna sem mudar o comportamento observável. Se o comportamento muda, não é refatoração — é feature ou bugfix (faça separado). A rede de segurança é sempre o teste.
A lei nº1: refatore sob testes
Sem testes que provem que o comportamento não mudou, você não está refatorando — está reescrevendo e torcendo. Antes de mexer em código legado sem cobertura, escreva testes de caracterização (que capturam o comportamento atual, mesmo que "errado") — ver [[testing]].
1. Testes verdes → 2. Um passo pequeno de refatoração → 3. Rodar testes → repetirPassos pequenos e reversíveis. Commit a cada passo verde. Nunca refatore e adicione feature no mesmo commit.
Catálogo de code smells (o que caçar)
| Smell | Sinal | Técnica |
| Long method | Função que não cabe na cabeça | Extract Method |
| Large class | Classe que faz de tudo | Extract Class, mover responsabilidade |
| Duplicated code | Copiar-colar | Extract Method/Function, subir p/ base |
| Long parameter list | 5+ params | Introduce Parameter Object |
| Feature envy | Método usa mais dados de outra classe | Move Method |
| Primitive obsession | String/int para tudo | Value Object / tipo próprio |
| Shotgun surgery | Uma mudança toca 10 arquivos | Juntar o que muda junto (coesão) |
| Divergent change | Uma classe muda por N razões | Separar responsabilidades |
| Comentário explicando código ruim | Comentário compensa nome ruim | Rename + Extract (código autoexplicativo) |
Técnicas fundamentais (Fowler)
- Extract Function/Method — nomeie um trecho pelo que faz. A técnica mais usada.
- Inline — o inverso, quando a indireção não paga.
- Rename — o nome certo elimina comentários e confusão. Barato, altíssimo retorno.
- Move — leve o método/campo para onde os dados que ele usa vivem.
- Extract Variable — nomeie subexpressões complexas.
- Replace Conditional with Polymorphism — troque
switchpor tipos quando o ramo é sobre "tipo de coisa". - Introduce Parameter Object — agrupe params que andam juntos.
Refatorar legado em escala: Strangler Fig
Não reescreva um sistema grande de uma vez (big-bang quase sempre falha). Estrangule: construa o novo ao redor do velho, redirecione uma fatia de cada vez, e remova o velho quando nada mais o usa. Sempre entregável, sempre reversível.
Regra do escoteiro (Boy Scout Rule)
"Deixe o código mais limpo do que encontrou." Refatoração contínua e pequena, no código que você já está tocando, evita a dívida virar reescrita. Melhor que o "grande projeto de refatoração" (que raramente é priorizado — ver [[tech-debt]]).
Quando NÃO refatorar
- Código que você não vai tocar e funciona (refatorar tem risco/custo; sem retorno, deixe).
- Sem testes e sem tempo de escrevê-los (você vai quebrar algo).
- No mesmo commit/PR de uma feature (mistura difícil de revisar e reverter).
- Perto de um deadline crítico, em código de alto risco, sem necessidade.
Fluxo
- Identifique o smell e por que dói agora (serve ao trabalho atual?).
- Garanta cobertura de testes (caracterização se preciso).
- Aplique a técnica em passos pequenos, rodando testes a cada passo.
- Commit atômico "refactor: ..." separado de features.
- Pare quando o código está bom o suficiente — não persiga perfeição.
Recursos externos
| Recurso | O que pegar |
| Refactoring (Martin Fowler) | Catálogo canônico de smells e técnicas. |
| refactoring.guru | Smells + técnicas com exemplos visuais. |
| Strangler Fig (Fowler) | Migrar legado incrementalmente. |
| Working Effectively with Legacy Code (ref.) | Testes de caracterização, quebrar dependências. |
| [[testing]] · [[tech-debt]] | Rede de segurança e priorização da dívida. |
Do / Don't
| Do | Don't |
| Refatorar sob testes verdes | Reescrever sem rede |
| Passos pequenos, commit a cada verde | Refatoração gigante de uma vez |
| Separar refactor de feature | Misturar tudo num PR |
| Rename/Extract para clareza | Comentar código ruim em vez de melhorá-lo |
| Strangler fig no legado | Big-bang rewrite |
Checklist
- Comportamento observável NÃO muda (senão é feature/bugfix)
- Cobertura de testes garante a rede (caracterização se legado)
- Smell identificado + técnica apropriada
- Passos pequenos, testes rodando a cada passo
- Commit "refactor:" separado de features
- Legado grande via strangler fig, não big-bang
- Parou no "bom o suficiente" (sem gold-plating)
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.

