Pricing a 2,400-File AI Migration Before the First Diff
Pricing a 2,400-file migration from the terminal
The migration sounds small: replace an internal HTTP wrapper across a TypeScript repository. Then you count 2,400 files, remember the tests, and realize an agent could reread half the tree while fixing imports. Before generating patches, I want a budget with assumptions I can inspect.
The workflow below produces an offline forecast, then replaces its assumptions with a paid pilot. The example token counts and prices are invented planning inputs, not Fluxo rates or measured performance.
1. Freeze the baseline and inventory the files
Start from a clean checkout. Keep the migration on its own branch so unrelated edits cannot inflate the pilot. — git status --short
git worktree add ../http-migration-budget -b migration/http-budget HEAD — cd ../http-migration-budget
git ls-files | rg '\.(ts|tsx)$' | rg -v '(^|/)(vendor|dist|generated)/' > /tmp/migration-files.txt — wc -l /tmp/migration-files.txt
Adjust those exclusions to your repository. This inventory is the candidate population; it does not prove every file needs changing. Generated clients and untouched packages should not quietly become billable context.
2. Select twelve files before opening the agent
A fixed random sample gives us a reproducible starting point.
python3 -c 'import pathlib,random; files=pathlib.Path("/tmp/migration-files.txt").read_text().splitlines(); print("\n".join(random.Random(42).sample(files,min(12,len(files))))))' > /tmp/migration-pilot.txt
cat /tmp/migration-pilot.txt — Inspect the selection and replace unrepresentative files deliberately. Include a simple caller, a large caller, shared types, and tests. Record those substitutions. Twelve tiny leaf modules will make a reassuring estimate that falls apart at the first shared interface.
3. Define the job that the pilot must price
Use the same instructions, tools, and test policy you intend to use for the full migration. My task description is explicit:
“Replace the legacy HTTP wrapper in the listed files. Preserve timeout, retry, and error behavior. Update affected tests. Run the relevant package checks. Report changed files, unresolved cases, and token usage.”
Fluxo gives this workflow one key and one base URL, https://api.fluxorelay.com, across its model catalog. It works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK. I would pilot Claude Sonnet 5.5 first; changing to GPT-6 Astra means measuring a separate pilot, because token volume and repair attempts can change.
Create a Fluxo account when you are ready to replace the example numbers with a measured pilot.
4. Calculate a forecast without making API calls
Save this calculator with a shell heredoc. Its four prices are hypothetical dollars per million tokens. Input means uncached input only, so cached tokens are not counted twice. The workload represents twelve completed pilot files, including test repair.
cat > /tmp/migration-budget.py <<'PY' — Use the following single command instead to avoid relying on HTML line breaks:
python3 -c 'import pathlib; pathlib.Path("/tmp/migration-budget.py").write_text("import pathlib\nfiles = len(pathlib.Path(\"/tmp/migration-files.txt\").read_text().splitlines())\npilot_files = 12\ntokens = dict(input=180000, cache_read=360000, cache_write=60000, output=36000)\nrates = dict(input=3.0, cache_read=0.30, cache_write=3.75, output=15.0)\npilot = sum(tokens[k] * rates[k] / 1000000 for k in tokens)\nbase = pilot * files / pilot_files\nprint(f\"Pilot scenario: ${pilot:.3f}\")\nprint(f\"Linear forecast: ${base:.2f}\")\nprint(f\"With 30% reserve: ${base * 1.30:.2f}\")\n")'
python3 /tmp/migration-budget.py — At 2,400 files, these assumptions produce $1.413 for the pilot, $282.60 linearly, and $367.38 with a 30% reserve. That arithmetic is exact; the workload prediction is not.
5. Replace assumptions with billed pilot usage
Run the twelve-file job, review its patches, and collect usage across every request, including failed attempts and test repairs. Replace both dictionaries with measured token categories and current prices for the selected model. Change pilot_files if your sample size differs.
Fluxo bills actual tokens, including cache reads and writes, with no monthly fee. Check whether your client reports cache writes separately; missing telemetry is an unknown, not a zero. Reconcile the pilot against billed usage before trusting the extrapolation.
6. Set a checkpoint before scaling to 2,400 files
The reserve covers uncertainty, not unlimited retries. Run the next fifty files, compare cost per accepted file with the pilot, and stop if shared abstractions cause repeated repairs. Keep engineer review time separate from API spend.
Fluxo also gives users a referral share when invited people pay; I exclude that from migration budgets. The migration should make financial sense on its own usage.