From auto-claude-skills
Transforms, migrates, refactors, or generates code across many files at once using claude -p with manifest, dry-run, and log-based retry for safe bulk operations.
How this skill is triggered — by the user, by Claude, or both
Slash command
/auto-claude-skills:batch-scriptingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Structured protocol for bulk file operations using `claude -p`. Teaches a safe, resumable pattern — not a framework.
Structured protocol for bulk file operations using claude -p. Teaches a safe, resumable pattern — not a framework.
Build the full file list FIRST. Show it to the user. Get explicit approval before proceeding.
# Session-scoped working directory — prevents concurrent session collisions
BATCH_DIR=$(mktemp -d /tmp/agent-batch-XXXXXX)
# Generate manifest — adapt the glob/grep to the specific task
find src -name "*.ts" -not -path "*/node_modules/*" > "$BATCH_DIR/manifest.txt"
echo "Found $(wc -l < "$BATCH_DIR/manifest.txt") files. Review the list:"
cat "$BATCH_DIR/manifest.txt"
Never skip manifest review. The user must see and approve the file list.
Process 2-3 representative files first. Show full diffs. Get user approval before the full run.
# Pick representative files (first, middle, last)
head -1 "$BATCH_DIR/manifest.txt" | xargs -I{} claude -p "Transform {} as follows: [PROMPT]. Output ONLY the transformed file content." > "$BATCH_DIR/dry-run-output.txt"
diff /path/to/original "$BATCH_DIR/dry-run-output.txt"
If the dry run does not look right, adjust the prompt and re-run. Do NOT proceed to the full batch with a bad prompt.
Loop over the manifest. Log pass/fail per file. Use atomic writes (write to .tmp, then move).
while IFS= read -r file; do
if claude -p "Transform $file as follows: [PROMPT]. Output ONLY the file content." > "${file}.tmp" 2>/dev/null; then
mv "${file}.tmp" "$file"
echo "OK: $file" >> "$BATCH_DIR/results.log"
else
rm -f "${file}.tmp"
echo "FAIL: $file" >> "$BATCH_DIR/results.log"
fi
done < "$BATCH_DIR/manifest.txt"
After the batch, check the log. Re-run only the failures.
# Check results
echo "Results:"
grep -c "^OK:" "$BATCH_DIR/results.log"
grep -c "^FAIL:" "$BATCH_DIR/results.log"
# Retry failures
grep "^FAIL:" "$BATCH_DIR/results.log" | cut -d' ' -f2 > "$BATCH_DIR/retry.txt"
# Re-run step 3 with $BATCH_DIR/retry.txt as input
After the full batch completes, run the project's test suite and linter. Review the full git diff.
# Run tests
[project test command]
# Review scope of changes
git diff --stat
git diff # full diff for review
# Clean up session directory
rm -rf "$BATCH_DIR"
For 100+ files, process in chunks of 20. Pause between chunks for user confirmation.
split -l 20 "$BATCH_DIR/manifest.txt" "$BATCH_DIR/chunk-"
for chunk in "$BATCH_DIR/chunk-"*; do
echo "Processing chunk: $chunk ($(wc -l < "$chunk") files)"
# Run step 3 loop on this chunk
echo "Chunk complete. Continue? [y/n]"
done
grep FAIL is your resume mechanism.claude -p handles its own rate limiting. If you hit limits, reduce chunk size or wait.wc -l "$BATCH_DIR/results.log" tells you where you are.verification-before-completion after batch completesdispatching-parallel-agents insteadCreates bite-sized, testable implementation plans from specs or requirements, with file structure and task decomposition. Activates before coding multi-step tasks.
npx claudepluginhub damianpapadopoulos/auto-claude-skills