Use Case

AI Framework Migration

The Problem

Framework migrations are the projects everyone puts off. Migrating from React Class Components to Hooks, Express to Fastify, or JavaScript to TypeScript means touching hundreds of files with similar transformations. The work takes weeks and blocks other development.

How Stoneforge solves it

AI framework migration with Stoneforge breaks large migrations into parallel tasks. You define the transformation pattern once, and automated code migration agents apply it across your codebase concurrently.

Plan the migration dependency graph

Migrations have dependencies: you can’t migrate components before migrating the shared utilities they import. Stoneforge’s Director agent analyzes your import graph and creates a dependency-ordered plan for the AI framework migration.

# Create a plan for the migration
sf plan create --title "Migrate from JavaScript to TypeScript"

# The Director breaks this into dependency-ordered tasks:
# Phase 1 (parallel): Add tsconfig.json, install dependencies
# Phase 2 (parallel): Migrate src/types/ and src/utils/ (no deps)
# Phase 3 (parallel): Migrate src/services/ (depends on types)
# Phase 4 (parallel): Migrate src/components/ (depends on utils)
# Phase 5 (parallel): Migrate src/pages/ (depends on components)
# Phase 6: Update build config and CI pipeline

Consistent automated code migration at scale

Consistency matters in migrations. Every file should be transformed the same way. Stoneforge supports this through workspace prompts where you define the transformation rules each agent follows.

# .stoneforge/prompts/worker.md:
# "TypeScript migration rules:
#  - Use strict mode, no implicit any
#  - Prefer interface over type for object shapes
#  - Use unknown instead of any for external data
#  - Add return types to all exported functions
#  - Convert require() to import statements
#  - Preserve existing JSDoc as TSDoc"

Incremental, not big-bang

Each phase produces small, mergeable PRs. Your codebase transitions incrementally instead of through a long-lived migration branch that goes stale. If something goes wrong, you roll back one PR, not the entire migration. This approach works hand-in-hand with AI code refactoring for broader codebase improvements.

Parallel execution within phases

Within each phase of an AI framework migration, agents work in parallel. If Phase 3 has 15 service files to migrate, three agents can handle five files each. The dependency system ensures phases execute in the right order while allowing parallelism within each phase.

# Start the migration
sf serve

# Dashboard shows parallel progress:
# Worker-1: Migrating src/services/auth.js → auth.ts (45%)
# Worker-2: Migrating src/services/billing.js → billing.ts (72%)
# Worker-3: Migrating src/services/users.js → users.ts (100% ✓)

Test-driven automated code migration

Agents run existing tests against migrated code and fix any failures before submitting a merge request. For TypeScript migrations, they also check for type errors with tsc --noEmit. Pair with AI test generation to fill coverage gaps exposed during migration.

Related documentation

Frequently asked questions

What types of AI framework migration does Stoneforge handle?
Stoneforge works well for framework migrations (React to Solid, Express to Hono), language migrations (JavaScript to TypeScript, Python 2 to 3), library swaps (Moment.js to Day.js, Lodash to native), build tool migrations (Webpack to Vite), and CSS migrations (CSS Modules to Tailwind). Migrations that involve repetitive file-by-file transformations are the best fit.
How does automated code migration ensure consistency?
You define the migration pattern once in your workspace prompts, and each agent follows the same transformation rules. The Director agent creates a plan so that shared utilities and types are migrated first, with dependent modules following in the correct order.
Can I run an AI framework migration incrementally?
Yes. Stoneforge's plan system supports incremental migration. You can migrate module by module, merging each as it completes. The old and new code coexist safely because each migration task is a separate, reviewable PR.
How does automated code migration handle edge cases?
Agents read surrounding code for context rather than doing naive find-and-replace. They can handle many complex patterns, but will flag edge cases they can't resolve confidently for human review. The handoff note includes what needs manual attention.
What if the AI framework migration breaks existing tests?
Agents update tests as part of each migration task. For example, when migrating a component from Class to Hooks, the agent also updates the corresponding test file. The Steward checks that all tests pass before merging.

Ready to get started?

Set up Stoneforge in under 30 seconds and start orchestrating AI agents in parallel.