Components / / Oleg / Blog / fsd-move

· 7 min read · Architecture

We're moving 200 folders. Here's one of them.

A loading spinner got a new home in 17 minutes. A script moved it, a rerun proved the move, an agent opened the PR, and a person merged. What we tried first, and why the agent never touches the code.

Our frontend app is moving to Feature-Sliced Design. About 200 old folders and 1,700 files need new homes, while other teams keep shipping features into the same code.

Until this autumn, “where does this code go?” had three answers. The docs described the layer order 12 times, in 3 versions. Four places in the repo listed which folders were old, and they didn’t agree. New code could land in any of 19 old folders.

So the first fix was boring. One file now has a row per old folder: where it goes, and what kind of job the move is. Every script reads that file, and nobody types a destination by hand. That settled where code goes. Getting it there was harder.

What we tried first

Make the lint rules errors. The import rules were errors once. If you needed a hook from an old folder, nothing was allowed, so people added eslint-disable comments. The rules went back to warnings. An import from an old folder stays a warning until that folder moves, because the only real fix is the move.

Move folders by hand. A hand move touches hundreds of import lines, so a reviewer has to read all of them to be sure nothing else changed. Nobody wants to. From 31 August to 30 September, a move PR waited a median of 21 hours for a first approval. And reading didn’t always work: one hand move carried a real code change along with the rename.

Moving one folder is easy. Moving 200, with nothing broken and nobody checking imports by eye, needed a different kind of proof.

A script moves, a rerun proves

No AI writes code in a move. A script moves the files and repairs every import, and it only does arithmetic: swap a path prefix, recompute a relative path from the file’s new home. It never reads what the code does, so it has nothing to get wrong about the code.

That property gives you the best check in the whole setup. Take a fresh copy of the main branch, run the same move command, run the same formatters, and compare the whole tree with the branch. A match proves nobody touched anything by hand. Anyone can rerun it, including on the merged commit.

A second check answers “is this only a move?” A plain diff can’t, because every import line changed. So it takes the old and new version of each file, rewrites import paths to a common form, formats both the same way, and drops the import lines. Whatever still differs is a real code change. We ran it on the hand move that carried a change, and it said no:

type: prep
- off map: 5
- off map: features/example/model/newRule.ts (added), no row places it
result: CHECK

Six more checks cover the map, types, lint on changed lines, the layer rules, related tests, and owners and docs. Each one passes or stops. A move that stops gets no retry. It says why and waits for a person. In the pilot, 14 of 23 moves passed everything first time.

One spinner, start to finish

Meet one ticket: move a loading spinner from an old folder into shared/ui. That’s 3 files, and 6 other files import them.

The spinner move from ticket to merge, in UTC. The ticket waits in the backlog a day. Then the brief, the agent's draft PR, the review bot, the approval and the merge queue take 17 minutes.
The ticket waited a day. From the brief to the merge took 17 minutes.

The ticket names one command from an approved list. We don’t trust ticket text, so it can’t add a command or skip a check. A person ran the queue on their laptop, every check passed, and they pushed the branch and handed the ticket to our agent with a short brief: open one draft PR from this branch, as it is, and change nothing.

Less than a minute later, the agent replied:

I opened the draft PR for the ticket … I made no code change and pushed no commit. … I did not run or check any of the gates listed in the body. … I did not check CI on the PR.

Read the last sentence again. The agent says what it didn’t check, so you know the proof comes from the scripts and not from the agent.

CI ran, a review bot read the 9 files and found nothing, and a person approved the PR. It merged seven minutes later.

Hand move, to first approval21 h
Medians. Grey is hand moves from 31 August to 30 September, from open to first approval. Blue is moves through the queue, from open to merge. Different endpoints, and the queue's is the longer one. Hover a bar for its value.

The two bars don’t measure the same thing, and the unfair one is the queue’s: it runs all the way to merge. The gap is what happens when a reviewer stops reading a move and checks that the proof is there.

Why the agent only opens the PR

The obvious design lets the agent do the move. We chose the opposite, for three reasons.

Whoever does the work doesn’t check it. In a move, a script does the work and the checks prove it. Nothing creative can go wrong, so an AI reviewer has nothing to look at.

Agents only open drafts. A person marks a PR ready. The agent holds to that even when a brief asks otherwise. On one pilot ticket, it replied that it couldn’t mark the PR ready and a person needed to click the button.

When something’s off, it asks. On another ticket, CI failed on formatting. The agent didn’t push a fix. It explained why the brief didn’t allow one, suggested what to do, and waited. The person said “do it”, and only then did it push.

Not every task is a move. A cleanup fixes one lint rule in one area, which is a real code change, so an agent writes it. That’s the only lane where a model writes code, and it’s the only lane with a second model checking.

Two lanes. A move: no model writes code, a script moves the files, the checks run, and a draft PR carries the facts. A cleanup: a model fixes one rule in one area, the checks and the rule count run, a second agent reads the diff, and the task gets one retry.
A second AI checks only where an AI wrote the code.

The spinner still needed a person at every handoff: run the queue, write the brief, hand off, approve, merge. Most of that is carrying things between steps.

I want the moves to run the whole way without a person carrying them, and keep a person only at the merge.

Lesson

If a rerun can prove a change, don’t make a person read it. Give the work to a script, the paperwork to an agent, and the judgment to a person, and make each one say what it didn’t check.