CDX-301e · Module 2
Bulk File Operations
3 min read
Bulk file operations are the bread and butter of batch processing in Codex Cloud. The pattern: identify a set of files that need the same transformation, partition them into non-overlapping groups, submit each group as a parallel task, and merge the results. Common operations include codemod application (update import paths, rename symbols, migrate API patterns), test generation (write tests for untested modules), and documentation generation (add JSDoc comments, generate API docs, update README sections).
Partitioning strategy matters. The naive approach — one file per task — creates excessive overhead from VM boot time and branch management. The other extreme — all files in one task — loses all parallelism benefit. The sweet spot is partitioning by module or directory: each task handles 5-20 related files that share context. This gives the agent enough context to make consistent changes while keeping task scope manageable.
# Bulk codemod: migrate all components to new prop pattern
DIRS=(components/auth components/dashboard components/settings \
components/profile components/billing)
for dir in "${DIRS[@]}"; do
codex cloud "in src/${dir}/, refactor all components to use \
the new PropTypes pattern from src/types/props.ts. \
Update imports, replace inline type definitions, \
and ensure all existing tests pass." &
done
wait
# Verify: run full test suite across all changes
codex cloud "merge all codemod branches, run full test suite, \
report any failures with file paths and error messages"
- Enumerate the scope List all files that need the transformation. Use `find` or `grep` to identify candidates. Verify the list is complete — missed files create inconsistency.
- Create a reference example Manually transform one file to the target pattern. Include this file in the prompt as the canonical example for all tasks to follow.
- Partition by context Group files that share imports, types, or patterns into the same task. Cross-module consistency is harder to maintain across tasks than within them.