DiegoVallejo

Astra Refactors to Green. Fable Still Owns the Diff.

aiengineeringagentsrefactoring

Astra will take the furniture out of the room. It will not decide where the sofa goes.

That is the week-one takeaway on GPT-6 Astra for refactoring. It is the same pattern we saw with computer-use agents: the model closes the task, but the result is not something you actually want to merge.

OpenAI gave this away in their own FrontierCode footnote. They had to prompt Astra with explicit guardrails: do not create extra test files, do not do unrelated cleanup, reuse what is already there, follow the repo. When a vendor has to warn its own flagship model against code sprawl on its own benchmark, that is not a casual tip. That is a known issue.

Two jobs hidden under one word

In real engineering, refactoring is two separate jobs:

  1. Move the structure. Find duplication, split modules, rename boundaries, update callers, and keep the test suite green.
  2. Leave the room livable. Use the repo's existing patterns, keep the test style consistent, avoid clever tricks, and produce a diff a human can review in one sitting.

Astra is trained and benchmarked on the first job. Terminal-Bench 4.0 at 57.9%, database migrations at 63.9%, and CodeRabbit's multi-file reviews all prove the same point: it can push a change across multiple files without breaking CI.

The second job is where things fall apart.

Veselin Stoyanov noted that on unprompted production tasks, the code Astra produced was a mess, only improving when pushed repeatedly on basic principles like DRY and SOLID. Milan Jovanović shipped a transcription feature with Astra, called the raw code bad, and had to schedule his own refactor right after, even with 95% test coverage. That says it all.

What the agent actually does

The happy path works well enough:

  • Read the repo without needing a massive prompt.
  • Plan edits across multiple files instead of guessing file by file.
  • Update controllers, middleware, and schemas in one pass.
  • Run the tests, fix the few that fail, run them again, and open a PR.

That loop works. Astra is genuinely good at spotting dead code, broken CI steps, and awkward seams in your architecture.

The problem starts when you leave it unattended.

Armin Ronacher tested this by letting Astra run for 35 hours. The result: about a thousand dollars in tokens, 79 commits, 75,000 lines of diff, and zero usable code.

When tasks drag on, Astra acts like an operating system operator instead of a code editor:

  • It stops using the standard patch tools and starts writing throwaway Python scripts to edit text strings.
  • It spawns shell commands to do jobs that simple file edits could handle.
  • It invents unnecessary abstractions and ignores neighboring conventions.

Older models had to be pushed to run tests. Astra has to be told to stop.

Why the tests are the real problem

Astra's test files are usually the messiest part of the PR.

It writes tests just to get a green run on the code it just wrote. It is testing the immediate patch, not the system contract.

If you give those new tests back to Astra and tell it to refactor them, it gets stuck. The tests are tied so tightly to the implementation that any small change breaks them. A refactor only works if your tests protect the boundary. If the tests only describe what the agent just built, the next person or model cannot touch the code without breaking everything.

How to split the work

Task Tool Reason
Scan repo for rot and plan wide renames Astra It sees more of the dependency graph across files.
Move files, rename symbols, run migrations Astra (low or medium effort) Fast and cheap. Do not waste max reasoning here.
Rewrite a module for humans to maintain Fable 5.1 Better naming, cleaner logic, readable diffs.
Clean up Astra's generated tests Human or Fable Never ask Astra to clean its own tests.
Fully unattended overnight refactors Nobody It will burn budget and invent a second codebase.

Use Astra to do the heavy lifting across files. Use Fable when you care about how the code actually reads.

Prompts that keep the diff clean

You do not need a 3,000-word instruction file. Put negative constraints directly into the prompt:

Do not create new test files.
Put new assertions inside the closest existing test file.
Do not rename public APIs unless the task explicitly asks for it.
Match the import and coding style of neighboring files.
Use the patch tool directly. Do not write helper scripts to edit files.
Stop as soon as the relevant tests pass. Do not expand the test suite.

Without those rules, Astra will do whatever it takes to show you a passing test run, even if it rewires half your project. With them, you get a diff you can actually read.
Also, keep the reasoning effort set to low or medium. High effort does not make the code cleaner; it just gives you a longer, more expensive tour of your repo.
The bottom line
Astra is a mover, not an architect.
Use it to extract files, rename symbols, update schemas, and clean out dead configs. But do not let it merge until a human or a cleaner model reviews the names, trims the diff, and fixes the tests.
A refactor is not finished when the test runner turns green. It is finished when the next developer can read the code without having to guess what the AI was trying to do.

Without those rules, Astra will do whatever it takes to show you a passing test run, even if it rewires half your project. With them, you get a diff you can actually read. ​Also, keep the reasoning effort set to low or medium. High effort does not make the code cleaner; it just gives you a longer, more expensive tour of your repo.

​The bottom line

​Astra is a mover, not an architect. ​Use it to extract files, rename symbols, update schemas, and clean out dead configs. But do not let it merge until a human or a cleaner model reviews the names, trims the diff, and fixes the tests. ​A refactor is not finished when the test runner turns green. It is finished when the next developer can read the code without having to guess what the AI was trying to do.