Best practices for Claude Code changedbest-practices
Nearest release: v2.1.289, published 9 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 4 Oct 2026 05:42 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 4 Oct 2026 06:07 UTC.
Upstream edited
Recorded here
Lines+4added
Lines−3removed
From line
482
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits20to this page, all time
The whole hunk
from line 482, old and new numbered
/
from line 482
482482### Fan out across files
483483
484484<Tip>
485 Loop through tasks calling `claude -p` for each. Use `--allowedTools` to scope permissions for batch operations.
485 Loop through tasks calling `claude -p` for each. Use `--allowedTools` to pre-approve tools for batch operations.
486486</Tip>
487487
488488For large migrations or analyses, you can distribute work across many parallel Claude invocations. Run [`/batch <instruction>`](/docs/en/commands#all-commands) to have Claude split the change across 5 to 30 subagents. Each subagent works in its own worktree. To drive the fan-out from your own script instead, loop over `claude -p`:
from line 496
496496 ```bash theme={null}
497497 for file in $(cat files.txt); do
498498 claude -p "Migrate $file from Python 2 to Python 3. Return OK or FAIL." \
499 --allowedTools "Edit,Bash(git commit *)"
499 --allowedTools "Edit,Bash(git commit *)" \
500 --permission-mode dontAsk
500501 done
501502 ```
502503 </Step>
503504
504505 <Step title="Test on a few files, then run on all of them">
505 Refine your prompt based on what goes wrong with the first 2-3 files, then run on the full set. The `--allowedTools` flag restricts what Claude can do, which matters when you're running unattended.
506 Refine your prompt based on what goes wrong with the first 2-3 files, then run on the full set. The `--allowedTools` flag pre-approves the tools the migration needs, and [`--permission-mode dontAsk`](/docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode) denies anything else that would need approval, which matters when you're running unattended.
506507 </Step>
507508</Steps>
508509
No line in this hunk matches that.