Fan Out Across Files
For large migrations, split the work into many small Claude runs instead of one huge session.
Basic pattern
Section titled “Basic pattern”- Generate a list of files.
- Test the prompt on two or three files.
- Refine the prompt.
- Loop over the full list.
- Verify with tests, lint, or a build.
Example
Section titled “Example”for file in $(cat files.txt); do claude -p "Migrate $file to the new API. Return OK or FAIL." \ --allowedTools "Edit,Bash(npm test *)"doneWhy this helps
Section titled “Why this helps”- Each file gets a smaller context.
- Failures are isolated.
- You can retry individual files.
- Permission scope can be limited with
--allowedTools.
Guardrails
Section titled “Guardrails”Keep destructive commands out of unattended fan-out workflows. Start with a tiny sample and review the diff before scaling up.