agentleFS
unlockers-aiunlockers-ai/unlockers-skills-library/skills/port-refactoring/SKILL.md

port-refactoring

Skill4 starsChanged 3 months agoMITView on GitHub

Design the ideal port for an adapter to an external service (typically wrapping a generated API client) by perfecting its interface through the simplifications it allows in every caller, then plan the safe path there. Use when refactoring an adapter or data-access class toward a hexagonal port, when generated vendor types leak into domain code, or when asked what an adapter's interface should be.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    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
  1. Distinctive:

    Every live caller rewritten.

    line 31
  2. Distinctive:

    Every signal and test answered present/absent with evidence.

    line 33

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Port Refactoring

Finds the interface an adapter's callers need, in pseudo-code, before any real refactoring.

Method: docs/port-refactoring-method.md — read it first, whole. Its examples come from four adapters to one healthcare vendor; the rules are not vendor-specific.

Process

  1. Inventory per the method's step 1, including the callers a class-name search misses and the live-caller check. If no method has a live caller, stop: report the deletion proposal.
  2. Write the interface and rewrite every caller against it, in pseudo-code, outside the codebase (a proof-of-concept branch or a scratch file). Behaviour unchanged unless listed.
  3. Loop on the central step until its stop criterion holds: a full sweep finds nothing, and every remaining signal is listed with its reason.
  4. Run the signals table and the three tests, then self-review against the interface review grid. Any finding restarts step 3.
  5. Report: target interface, callers after, simplifications ranked (deleted vs moved code), defects found (check the method's defect families), TODOs, and the Phase 2 path.

Phase 2 (the real refactoring) starts only after a human has reviewed the interface.

Done criteria

  • Every live caller rewritten; leak counters at zero in callers, or each remainder listed with its reason.
  • Every signal and test answered present/absent with evidence.
  • Behaviour changes and TODOs listed separately from the target.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.