Skip to content

PATTERN Cited by 1 source

AI-driven framework rewrite

Pattern

Rewrite a non-trivial framework — one previously requiring months of team-engineering — with one human engineer directing a capable AI coding agent under the right preconditions and quality-gate discipline.

Preconditions (all must hold)

  1. Well-specified target API — extensive docs, massive user base, API surface in training data, model doesn't hallucinate against it.
  2. Comprehensive test suite on the target that can be ported as executable specification — not just documentation, but verifiable behaviour.
  3. Solid foundation to build on — a battle-tested substrate (Vite for frameworks; LLVM for compilers; a widely-adopted protocol for network tools) so the rewrite is a glue + adaptation exercise, not a ground-up rebuild.
  4. State-of-the-art model that can hold the full architecture in context, reason about module interactions, produce correct code often enough to maintain momentum.

"Take any one of them away and this doesn't work nearly as well."

Workflow

  1. Architecture planning — spend hours with the model (OpenCode + Claude in vinext's case) defining what to build, in what order, which abstractions. The plan becomes "the north star."
  2. Task decomposition — define specific tasks ("implement the next/navigation shim with usePathname, useSearchParams, useRouter").
  3. Implement + test in one turn — AI writes the implementation and tests.
  4. Run the test suite.
  5. Iterate on failures — feed AI the error output; let it self-correct.
  6. Merge on green.
  7. AI-driven code review on PRs — second AI agent reviews; third addresses review comments.
  8. Browser-level verification — for UI-adjacent frameworks, use a browser-automation agent (agent-browser) to catch subtle runtime issues unit tests miss.

Quality-gate discipline — concepts/ai-agent-guardrails

AI productivity is load-bearing on the guardrails. In vinext's case:

  • 1,700+ Vitest unit tests (many ported from the Next.js repo)
  • 380 Playwright E2E tests
  • Full TS type checking (tsgo)
  • Linting (oxlint)
  • CI runs all of it on every PR

Human-in-the-loop responsibilities

  • Architecture — the AI is not a substitute for a competent human architect.
  • Prioritisation — which tasks next, which compromises are acceptable.
  • Detecting dead ends"the AI would confidently implement something that seemed right but didn't match actual Next.js behavior."
  • Course correction"I had to course-correct regularly."

Canonical numbers — vinext

  • ~1 week from first commit to 94 % API coverage.
  • ~$1,100 in Claude API tokens.
  • 800+ OpenCode sessions.
  • One engineer (an engineering manager).
  • 45+ upstream PRs to OpenCode and other dependencies (a sibling upstream-the-fix posture).

Consequences

  • Dramatically compressed time-to-rewrite for framework- class software given preconditions hold.
  • Guardrails become the primary lever for output quality.
  • Well-specified target becomes a precondition worth optimising for.
  • The existence of comprehensive test suites is more valuable than under purely-human workflows because tests function as the AI's specification.
  • The boundary of what's a "human-cognition crutch" abstraction (see concepts/layered-abstraction-as-human-crutch) becomes worth re-examining per rewrite.

Counter-indications

  • Any precondition absent.
  • Greenfield work with no target API to verify against.
  • Safety-critical domains where "eventually iterates to correct" is not acceptable.
  • Proprietary, closed, poorly-documented targets.

Seen in

Last updated · 200 distilled / 1,178 read