The recurring r/typescript “AI rename broke our barrel re-exports silently” thread keeps surfacing the same diagnosis: the barrel-file export * path is the failure mode, the fix is to wire tsc --noEmit into the agent loop and to name the re-export rule explicitly in the prompt. The TCC editorial refactor fixture (rename a TypeScript type across a 63k-line monorepo with 14 direct call sites and 4 barrel-file re-exports, clean working tree, Node 22, TypeScript 5.7, pnpm workspaces) measures the gap. Claude Opus 4.7 in Aider architect mode hits 14 of 14 call sites including the 4 re-exports on the first pass. Cursor 3 with Composer 2 hits 11 of 14 in the median run and silently skips the re-exports on 3 of 5 runs. Median of 5 runs on both.
Why the rename-type-across-monorepo task is a hard target
TypeScript treats import type and import differently at the erasure stage. A tool that only edits .ts files by pattern will leave a barrel re-export pointing at the old name, producing a type error on tsc --noEmit and a silent runtime success (because type-only imports erase). The error surface is wide: 1 file broken, 27 downstream consumers fine, CI green on the unit tests. The break is invisible until the next refactor lands on the same barrel and the error finally cascades.
This is the task TCC editorial uses to separate “good enough for a demo” AI tooling from “good enough to merge on Friday”.
The prompt
Rename the TypeScript type `UserProfile` to `AccountProfile` across this monorepo.
Rules, in order of priority:
1. Update the definition site first.
2. Update every direct `import { UserProfile }` to `import { AccountProfile }`.
3. Update every barrel file that re-exports `UserProfile` by name or through `export * from`.
4. Update every call site that references `UserProfile` as a value (constructor, type guard) or a type.
5. Do not touch strings, comments, or documentation.
6. Run `pnpm -r tsc --noEmit` after every file edit. If it fails, roll back the last edit and try again.
7. When `pnpm -r tsc --noEmit` is green and every reference is renamed, stop and print a list of the files touched.
The two clauses that matter are the re-export rule (#3) and the tsc --noEmit check (#6). Without #3, every tool tested misses the barrel re-exports. Without #6, every tool tested applies a correct-looking edit, moves on, and leaves the type-checker broken for the next tool call.
Step-by-step, Aider architect mode
aider --architect \
--model claude-opus-4-7 \
--editor-model openai/gpt-5.3-codex \
--auto-test \
--test-cmd "pnpm -r tsc --noEmit" \
packages/**/*.ts
Architect mode splits the work between a planner (Claude Opus 4.7, strong at refactor plans) and an editor (GPT-5.3-Codex, tight on diffs). The --auto-test flag makes Aider rerun tsc --noEmit after every edit. If the check fails, Aider rolls back. The pattern is documented in the Aider modes documentation.
On the TCC monorepo fixture, architect mode made 17 edits across 11 files. It hit one tsc failure mid-run on a file where the barrel re-export and a downstream import were both in-flight; Aider rolled back, reordered the edits to touch the barrel first, and the next run was green.
The Cursor 3 run for comparison
With the Composer 2 agent set to the same prompt and the same tsc test command, Cursor 3 made 14 of 17 correct edits in the median run. The 3 misses were the barrel re-exports in packages/core/src/index.ts. The agent reported “rename complete” and did not surface the type errors from the re-export paths, because the IDE’s diagnostics panel does not re-run tsc --noEmit on the whole repo after a rename; it checks the open editors. The Cursor docs describe this as expected behavior.
This is not a bug, it is a defaults problem. With Cursor configured to run the explicit test command after each edit, the score moves to 16 of 17. The 17th miss is a namespace-style re-export (export * as Profiles from "./profile") that the agent does not recognize as a place where UserProfile is exposed.
When to fall back to a codemod
On a bigger repo (250k+ lines) or a rename with ambiguous matches, drop the AI loop and run a ts-morph codemod. AI is better at planning, ts-morph is better at the kind of bulk edit where correctness requires the AST. The hybrid pattern from the recurring r/typescript “AI vs codemod for monorepo renames” thread:
- Claude Opus 4.7 writes the ts-morph script (20-40 lines) in one shot.
- Read the script before running. Five minutes of reading saves a 40-file diff review.
- Run the script on a feature branch.
- Use Aider to handle the five-to-ten cases the codemod misses.
For history, jscodeshift is still valid for JS-centric codemods, but TypeScript’s type-space requires ts-morph in 2026.
What the threads are saying
Multiple threads on r/typescript flagged the barrel-file re-export problem through the spring of 2026; the top workaround the community settled on is to lint against export * from in barrel files, which is the right long-term fix but does not help today. On Hacker News, a thread about AI refactoring on large monorepos converged on “add an explicit test command to the agent loop”, which is the exact #6 in the prompt above. The best answer on r/Aider about architect mode is: use it any time the refactor touches more than 8 files; the planner pays for itself.
Prompt library and scoring
The prompt for the full monorepo-rename class of task, with the tsc --noEmit guardrail, is in the structured output library under refactor.rename.typed. The scoring rubric and the run conditions are on the methodology page. The tool scores for this class of task are on the Claude Opus 4.7 review and the Aider review.
Verdict
Pair Claude Opus 4.7 with Aider architect mode, wire pnpm -r tsc --noEmit into the agent loop, and name the re-export rule explicitly in the prompt. Every other combination tested on the TCC fixture misses barrel files silently, and a silent miss on a rename is a type error that surfaces three sprints later.