agentleFS
isabelle-barpisabelle-barp/agent-brain/skills/flow-legacy-migration/SKILL.md

flow-legacy-migration

Skill0 starsChanged 5 months agoApache-2.0View on GitHub

Playbook for planning and executing legacy-to-new migrations — seam analysis, strangler patterns, anti-corruption layers, parallel-run verification. Loaded by legacy-migrator; consulted by dev agents and reviewers working migration-phase tasks.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is 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.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    NOT for greenfield work, ordinary refactors inside one architecture (use /refactor), or adopting the spec system onto an unchanged codebase …

    line 17
  2. Distinctive:

    Transaction boundaries: Never cut a seam through an atomic unit of work.

    line 25
  3. Distinctive:

    Parallel-run diffing: Run both, serve legacy, compare.

    line 57

≈ “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.

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

Flow: Legacy Migration

Mechanics for the R-MIG family (.claude/rules/LEGACY_MIGRATION.md). The rules say WHAT must hold; this playbook says HOW. Where the host project's docs/MIGRATION_PLAN.md makes a concrete choice, the plan wins over a default below.

When this applies

Any of:

  • The user asks to restructure, replatform, or re-stack an existing project (/migrate-legacy).
  • docs/MIGRATION_PLAN.md exists and the current task belongs to one of its phases.
  • A task ref points at a specs/features/<phase-feature>/ whose CHANGELOG names a migration phase.

NOT for greenfield work, ordinary refactors inside one architecture (use /refactor), or adopting the spec system onto an unchanged codebase (that is the adopter flow, .claude/rules/ADOPTION.md).

Seam analysis

A seam is a place where old and new can be separated with a stable, narrow contract. Find them in docs/map/USAGES.md — never by crawling source:

  • Dependency direction. Good seam anchors have high fan-in and low fan-out (many depend on them; they depend on little) — their interface is already de-facto stable. High fan-out modules make terrible first corridors: every move drags dependencies along.
  • Data ownership. Cut where one module exclusively owns its tables/collections. A table written by N modules is a knot, not a seam — untangle ownership first (often its own phase) or route all writers through one owner before cutting.
  • Transaction boundaries. Never cut a seam through an atomic unit of work. A cut inside a transaction turns one commit into a distributed-consistency problem (sagas, outboxes, compensation) — that cost belongs in the risk register, chosen deliberately or avoided by moving the cut.
  • Reading the map. USAGES.md hot paths = corridors needing heavyweight verification (parallel-run). Dead-looking zones = cheapest corridors — confirm dead (logs/traffic, not just imports), then retire without porting. The map's listed seams are candidates, not verdicts: verify each chosen seam against the actual files the map flags — that is the one sanctioned raw-source read.

Corridor order: lowest coupling, highest value first. First corridor doubles as the seam-technique proof — pick one that fails cheap.

Strangler patterns

PatternMechanismReach for it when
Route-level interceptionGateway/router/reverse proxy sends selected routes (or a traffic %) to the new system; the rest fall through to legacyThe seam is an HTTP/RPC surface; per-route cutover and rollback = flipping routing config
Branch-by-abstractionIntroduce an interface in place; legacy impl behind it; build the new impl; flip call sites (or a flag) one at a time; delete legacy implThe seam is in-process; no deploy boundary exists; you need to migrate within one codebase commit-by-commit
Parallel-run with diffBoth implementations execute; legacy's answer is served; results are compared and divergences loggedThe corridor covers a hot path or money/data-critical logic; correctness evidence must precede cutover
Event interceptionTap the event/message stream at the boundary; a new consumer processes alongside (or instead of) the legacy consumerThe seam is asynchronous; replayable topics give you free parallel-run and rollback (re-point the consumer group)
DB views / expand-contractExpand: add new schema alongside old; dual-write or backfill; migrate readers; Contract: drop old. Views keep legacy readers working against the new shapeThe migration changes the data model itself; schema can't flip atomically with code

Combine freely: route-level interception in front, parallel-run inside, expand-contract underneath is the common full-stack shape.

Anti-corruption layers

R-MIG-03: new code never imports legacy directly. The adapter shape depends on the boundary kind:

  • HTTP boundary. A facade/proxy owned by the new side translating legacy contract ↔ new contract (paths, payload shapes, error conventions, auth). Pin the legacy contract version the facade speaks; contract drift surfaces in the facade's tests, not in new domain code.
  • Queue boundary. A translator consumer: reads legacy topics/queues, maps to new event schemas, republishes to new topics. New consumers know only new schemas. Same in reverse if legacy must hear new events.
  • DB boundary. New code reaches legacy data ONLY through a repository the new side owns (or DB views projecting legacy tables into the new shape). Direct queries against legacy tables from new modules are the violation the reviewer greps for.
  • Module-import boundary. The new side defines a port (interface in NEW domain types); one adapter wraps the legacy module and translates models both ways. Legacy calls into new code only through a facade the new side exposes — never into new internals.

One ACL per seam, owned and tested by the new side. Adapters translate to new domain types — an adapter that re-exports legacy types is a leak, not a layer. The ACL is the deletion target at retirement: when the legacy side dies, the adapter goes with it and nothing else changes.

Verification

Per R-MIG-04, critical paths need behavior-preservation evidence BEFORE legacy retirement:

  • Parallel-run diffing. Run both, serve legacy, compare. Define tolerance rules up front (timestamps, generated IDs, ordering, float rounding) so noise doesn't bury signal. Set a divergence budget (e.g. < 0.1% over 48h) — that number IS the cutover criterion and its inverse is the rollback criterion (R-MIG-02).
  • Shadow traffic. Mirror production reads to the new path without serving its responses. Cheaper than full parallel-run; sufficient for read-only corridors; useless for writes (use parallel-run with side-effect isolation, or events with a throwaway consumer).
  • Characterization-diff. Golden-master the legacy behavior (recorded input/output pairs over the seam's contract), replay against the new implementation, diff. Mechanics per .claude/rules/ADOPTION.md R-ADOPT-02. The right tool when no production traffic is available (batch jobs, libraries, CLIs).
  • Cutover checklist (minimum). Rollback procedure rehearsed, not just written · divergence budget met for the agreed window · observability live on BOTH paths through the watch window · retirement step scheduled with an owner and date (R-MIG-05) · the decision log records who flipped and why.

Divergences found during verification are triaged, never auto-resolved: legacy bug (port bug-for-bug, log a spec-flow fix), new bug (fix the new path), or intended divergence (declared as an AC in the phase spec AND entered in the corridor spec's CHANGELOG, orchestrator-applied — missing either is an R-MIG-04 violation).

Spec validation checks

Checks for migration-phase specs (specs/features/<phase-feature>/SPEC_<PHASE_FEATURE>.md), applied by code-reviewer on migration work (the only agent wired to this section — spec validators load checks from stack-detected stack-* skills and the flow-adoption Adoption overlay only, never from this file):

CheckSeverity
Migration-phase spec lacks a rollback criterion + procedure (R-MIG-02)BLOCKER
New code imports a legacy module without an ACL at the seam (R-MIG-03)BLOCKER
Phase mixes behavior change with structure change — feature work inside a migration phase (R-MIG-04)BLOCKER
Missing explicit retirement step (legacy deletion/flag-dead + /repository-map refresh, R-MIG-05)WARNING
First shippable increment exceeds ~1–2 weeks (R-MIG-01)WARNING
Critical-path corridor with no parallel-run/characterization-diff strategy namedWARNING

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.