What AI agents don't ask about folders
Most of Resumer is written by AI agents. I describe what I want, a coding agent writes it, a reviewer agent checks it against the repo's rules, and an architect agent gets the questions that are about structure rather than code. I review and I merge.
This post is about a problem none of us caught for a while. Code ended up in the wrong folder, a little at a time, and every single step looked fine.
How the drift happened
I was reviewing the PR for the autosave change and I noticed that the editor's main file, src/components/forms/Form.tsx, had grown a lot of logic above its return statement. So I asked the agent whether it could move into a custom hook. The agent agreed. The preview dialog, the Start over dialog and the notices became their own components, and the export, Start over, warning and LinkedIn handlers became hooks.
The components went into forms/, and the hooks into forms/hooks/, next to Form.tsx. That was the obvious place. I didn't ask where they should go, and the agent didn't either. The problem that was bothering me was solved - happy days!
The next PR was for the More actions menu. The menu and its LinkedIn dialogs went into forms/ as well. Then the menu and the preview needed one shared PDF download path, and a fifth hook joined the others.
So now forms/hooks/ held five hooks: useAutosaveWarning, useExportJson, useStartOver, useLinkedInImportHandlers and usePdfDownload, and none of them had anything to do with a form...
The realization
On the evening when I was reading the More actions menu change there were two things that bothered me outright.
First, the new component ResumePdfDocument.tsx sat under src/lib/pdf/. Second, the PDF hook usePdfDownload.ts used useResumeSnapshot rather than getting the data from the form.
That second one was when I figured out that the same questions were valid for all the hooks in this dir.
A little later I added one more thought. The preview dialog lived in forms/ too, while the rest of the preview components lived in a folder called resume/. It was obvious that the preview dialog had to move to resume/, and that the folder had to be renamed to preview/, since that is what it actually holds.
The reviewer's answer: not a rule miss
Piere, the reviewer agent, agreed with both of my remarks, but it made a distinction I found useful. Moving the PDF component was small and could go into the menu change. The hooks were "a design call, not a rule miss". AGENTS.md, the file that tells agents how the repo is laid out, said hooks go in forms/hooks/. Every agent had followed it.
The real problem, Piere said, was that forms/ already held build-page parts that weren't forms. It offered two ways out:
- (a) keep the layout and reword
AGENTS.mdso "forms" means the whole build page, or - (b) move the menu, dialogs, notices and hooks into something like
src/components/build/, in a separate change.
It also said this was a call for Archie, the architect agent, not something to fix inside a reviewed menu change.
The architect's rule
Archie answered with a rule I now think about every time a file gets added:
A folder is named for what it renders.
forms/ keeps only the editors that use react-hook-form. Hooks live next to the components that call them. That settled it in favour of option (b).
Archie also split the work. The PDF component move went into the More actions menu PR, since that file was new there anyway, and it now lives at src/components/pdf/ResumePdfDocument.tsx. Everything else went into a move-only follow-up PR after the menu PR was merged.
The move
The follow-up PR was opened the same day. It moved 18 files and changed no behaviour:
| Before | After |
|---|---|
forms/BuildMenu.tsx, LinkedInImportDialogs.tsx, Notices.tsx, StartOverDialog.tsx |
src/components/build/ |
forms/hooks/ (the five hooks) |
src/components/build/hooks/ |
resume/ (seven preview components and their styles) |
src/components/preview/ |
forms/PreviewDialog.tsx |
src/components/preview/PreviewDialog.tsx |
src/components/forms/ now holds Form.tsx, the editor components that use react-hook-form, their styles and one example hook. The empty forms/hooks/ folder is gone. There are no re-export files at the old paths.
One wrinkle is still there. PreviewDialog.tsx imports the PdfDownload type from src/components/build/hooks/usePdfDownload.ts, so preview/ now depends on build/. No rule forbids it. It's a type, not behaviour, and I left it.
The part that would have hurt
The same change updated AGENTS.md, the agent rules in .cursor/rules/ and two agent skills. That wasn't tidying. One rule, verify.mdc, tells agents to check the form, the preview and the PDF by hand whenever certain folders change. Before the move, it named three folders under src/components/ as plain text, with no patterns: forms, resume and pdf.
At this time the Resumer repo has no automated tests. The agent skills and rules are most of the safety net. If resume/ had been renamed and the rule left alone, the check would have stopped firing for preview changes, and nothing would have complained. It had already missed things: the PDF component sat under src/lib/pdf/ during the menu work, which the rule didn't list.
The rule now lists src/components/forms/, src/components/build/, src/components/preview/, src/components/document/, src/components/pdf/ and src/lib/pdf/.
The proof for the move was what this repo can offer: lint, a production build and a scripted browser run on /build covering preview, both PDF downloads, Export JSON, reload and Start over. No test suite, because there isn't one yet.
So what did I learn?
Agents are very good at writing code and following the layout they find. A new hook goes next to the other hooks. A new dialog goes next to the other dialogs. That's usually right, everything works as expected and the code is pretty good, which is exactly why I did not stop to ask whether the folder still meant what its name said.
Part of the reason is that I got sucked in by the speed. Features shipped faster than I was used to. Every time I leave a review comment, the agents pick it up and whether or not they push back (yes, a lot of times they do), it gets resolved super quickly. When it feels that good to keep asking for the next thing, it becomes easy to skip the step where you stop and look at the shape of the whole.
So the folder layout is an instruction, whether I write it down or not. Nobody broke a rule here. The rules described a layout that had already drifted, and agents kept following them.
Two habits came out of this. When a file is the first of its kind in a folder, I ask where it belongs before I approve it. And when a folder moves, the docs and rules that name it move in the same change, because a stale path doesn't fail. It just stops checking.
If we zoom out a little bit - the way we build software has changed. In the before times documentation was never a top priority in any software team I have been in. It seems that now it matters more - you get better results from coding agents when there are good skill and rule files for them to follow. Boring, right? I guess the good news is that they can write it themselves.
The menu this all started from is covered in How the More actions menu is built.