fowler-refactoring
Skill91 starsChanged 4 days agoApache-2.0View on GitHub
Use when refactoring code with behavior-preserving steps.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- noestradamus/skillstheir own version, first seen Oct 1, 2026
- CaliLuke/skillstheir own version, first seen May 15, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- CaliLuke/skills★ 7same name
- noestradamus/skills★ 1same name
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 repository85 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- agent-architecture-analysisSkill
- app-intents-code-reviewSkill
- artifact-analysisSkill
- axum-code-reviewSkill
- brainstorm-beagleSkill
- bubbletea-code-reviewSkill
- cloudkit-code-reviewSkill
- elixir-performance-reviewSkill
- elixir-security-reviewSkill
- elixir-writing-docsSkill
- exdoc-configSkill
- exunit-code-reviewSkill
- fastapi-code-reviewSkill
- fetch-pr-feedbackSkill
- ffi-code-reviewSkill
- fix-llm-artifactsSkill
- gen-test-planSkill
- go-architectSkill
- go-code-reviewSkill
- go-data-persistenceSkill
- go-testing-code-reviewSkill
- healthkit-code-reviewSkill
- humanize-beagleSkill
- improve-docSkill
- ios-animation-code-reviewSkill
- liveview-code-reviewSkill
- llm-artifacts-detectionSkill
- llm-judgeSkill
- macros-code-reviewSkill
- phoenix-code-reviewSkill
- postgres-code-reviewSkill
- prfaq-beagleSkill
- prometheus-go-code-reviewSkill
- pytest-code-reviewSkill
- quick-planSkill
- react-flow-code-reviewSkill
- react-flowSkill
- react-router-code-reviewSkill
- react-router-v7Skill
- receive-feedbackSkill
- refactor-repoSkill
- resolve-beagleSkill
- respond-pr-feedbackSkill
- review-ai-writingSkill
- review-elixirSkill
- review-frontendSkill
- review-goSkill
- review-iosSkill
- review-llm-artifactsSkill
- review-planSkill
- review-pythonSkill
- review-remix-v2Skill
- review-rustSkill
- review-skillSkill
- review-structureSkill
- review-tuiSkill
- review-verification-protocolSkill
- run-test-planSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 9 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
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 22
No environment variables, credentials, MCP server, or additional dependencies for these notes.
- Very specific: line 26
Read this file, then load the relevant chapter by reading its relative path (for example references/ch01-first-example.md).
- Distinctive: line 46
Use temporary adapters or delegation when a move cannot be atomic.
- Distinctive: line 47
Stop when the intended change is easier and the scoped obstacle is removed.
- Distinctive: line 52
Prefer short, reversible transformations over a long broken intermediate state.
- Distinctive: line 53
Use names to store understanding.
- Distinctive: line 56
Treat smells as investigation prompts, not proof of a defect or a numerical cleanup quota.
- Distinctive: line 57
Keep externally observable results, side effects, errors, ordering, and contracts stable.
- Distinctive: line 58
Prefer measured performance evidence to intuition.
- Distinctive: line 87
Do not treat every conditional as a demand for inheritance, or every temporary variable as harmful.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Fowler Refactoring
Apply the decision rules and small-step transformations in Martin Fowler's Refactoring: Improving the Design of Existing Code, Second Edition, with contributions by Kent Beck (2019). This is a knowledge base for improving existing code, not permission to rewrite a system or alter its behavior; it needs no package, credential, or original PDF at runtime.
When to Use
- "Refactor this without changing behavior."
- "Which refactoring fits this code smell?"
- "Separate calculation from presentation."
- "Improve these functions, data structures, APIs, or classes."
- "Explain Fowler's refactoring mechanics and tradeoffs."
Prerequisites
- For code changes: access to the relevant repository, its instructions, and its existing test/build tooling.
- Establish a passing baseline and tests for the behavior at risk; do not invent a project test command.
- No environment variables, credentials, MCP server, or additional dependencies for these notes.
How to Run
Read this file, then load the relevant chapter by reading its relative path (for example references/ch01-first-example.md).
For implementation, inspect definitions and callers with search_files and read_file, edit with patch or write_file, and invoke the repository's verified test command through terminal after each small transformation.
The chapter files are on-demand detail, not mandatory bulk reading.
Tool names (terminal, read_file, search_files, patch, write_file) denote capabilities — shell execution, file reading, content search, scoped edits, and file writing — and map to the host agent's native equivalents; they are not a required product.
Quick Reference
references/ch01-first-example.md— load the relevant chapter by relative path.search_files— definitions, callers, state writes, and existing tests.read_file— repository instructions, implementation, and test configuration.patch/write_file— scoped implementation and test edits.terminal— established tests, builds, type checks, and diff inspection.
Procedure
- Identify the actual next change or comprehension obstacle. Improve changeability, not aesthetics or line count.
- Inspect observable behavior, dependencies, mutation, error paths, and callers; establish a self-checking test baseline.
- Choose a small named transformation and load its chapter mechanics before editing.
- Separate structural work from feature work. Preserve behavior during the refactoring step.
- Make one small change, run the relevant checks through
terminal, and inspect the result. If it fails, repair or undo only that change; reduce the step size. - Use temporary adapters or delegation when a move cannot be atomic; remove obsolete paths only when consumers have migrated.
- Stop when the intended change is easier and the scoped obstacle is removed. Add the new behavior in a separate, tested step if requested.
- Report changed locations, the reason for the transformation, actual check results, and remaining uncertainty. Do not commit, push, or change public contracts without authorization.
Central decision rules
- Prefer short, reversible transformations over a long broken intermediate state.
- Use names to store understanding; extraction pays for itself when intention becomes clearer, even without reuse.
- Structure follows the expected axis of change: separate independent concerns; group behavior and data that change together.
- Inverse refactorings are legitimate choices, not contradictions. Judge the target context, not an abstract preference for more objects or fewer functions.
- Treat smells as investigation prompts, not proof of a defect or a numerical cleanup quota.
- Keep externally observable results, side effects, errors, ordering, and contracts stable; repository-specific constraints take precedence over book-era examples.
- Prefer measured performance evidence to intuition. Preserve explicit latency, memory, and concurrency requirements while changing structure.
- Fowler's private-commit rhythm illustrates recovery checkpoints; it does not authorize Git writes in the user's repository.
Chapter index
Load only the relevant file by reading its relative path (for example references/ch01-first-example.md); every file below is part of this skill.
- Chapter 1: First example — load for a complete decomposition, phase separation, and polymorphism sequence.
- Chapter 2: Principles — load for scope, timing, legacy code, published interfaces, migrations, architecture, and performance.
- Chapter 3: Code smells — load to diagnose a concrete change obstacle and select candidate transformations.
- Chapter 4: Building tests — load for self-checking baselines, isolated fixtures, boundary probes, and regression tests.
- Chapter 5: Using the catalog — load to interpret mechanics, examples, inverse moves, and their limits.
- Chapter 6: First refactorings — load for extraction, inlining, names, signatures, parameter objects, classes, transforms, and phases.
- Chapter 7: Encapsulation — load for records, collections, domain values, class boundaries, delegation, and algorithm replacement.
- Chapter 8: Moving features — load for moving functions, fields, and statements; loops; and verified dead-code removal.
- Chapter 9: Organizing data — load for variable roles, derived state, field names, value semantics, and shared identity.
- Chapter 10: Conditional logic — load for predicates, guards, polymorphism, special cases, and assertions.
- Chapter 11: Refactoring APIs — load for query/modifier separation, parameter tradeoffs, flags, setters, factories, and commands.
- Chapter 12: Inheritance — load for pulling/pushing features, type codes, hierarchy changes, and delegation migrations.
- Decision guide — load to compare inverse moves, select boundaries, or compose a multi-step refactoring.
- Glossary and source map — load for definitions, older catalog names, edition details, and PDF chapter locations.
Pitfalls
- A passing test suite reduces risk; it is not proof that all behavior is unchanged.
- Moving or repeating an expression can change mutation, exception timing, I/O, identity, or evaluation count.
- A shallow copy does not isolate nested mutable data.
- Public APIs, persisted field names, and serialization formats need an explicit compatibility plan.
- Book examples use JavaScript; check the actual language's binding, dispatch, equality, and initialization rules.
- Do not treat every conditional as a demand for inheritance, or every temporary variable as harmful.
- Source provenance uses this PDF's 1-based page positions, not the printed-page numbers embedded in catalog cross-references.
Verification
One completion check: confirm that the repository's established behavior checks pass after the final transformation and that the scoped diff contains no unapproved behavior or contract changes; report the exact command and result, or explicitly mark unverified work.
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.

