Skip to content

Fan Out Across Files

For large migrations, split the work into many small Claude runs instead of one huge session.

  1. Generate a list of files.
  2. Test the prompt on two or three files.
  3. Refine the prompt.
  4. Loop over the full list.
  5. Verify with tests, lint, or a build.
Terminal window
for file in $(cat files.txt); do
claude -p "Migrate $file to the new API. Return OK or FAIL." \
--allowedTools "Edit,Bash(npm test *)"
done
  • Each file gets a smaller context.
  • Failures are isolated.
  • You can retry individual files.
  • Permission scope can be limited with --allowedTools.

Keep destructive commands out of unattended fan-out workflows. Start with a tiny sample and review the diff before scaling up.