SKILL.md--- name: batch description: Execute batch operations on multiple files in parallel. Automatically discovers files, splits into chunks, and processes with parallel worker agents. Use `/batch` followed by operation and file pattern. For many independent single-turn transforms (translate/rewrite/extract each file into a new file) that can wait minutes to hours, you may suggest the user type `/batch-api` themselves for the half-price asynchronous Batch API — you cannot invoke it, and it is not suited to in-place edits or tasks needing tool feedback. argument-hint: '<operation> <file-pattern>' allowedTools: - task - glob - grep_search - read_file - edit - write_file - run_shell_command - ask_user_question --- # /batch - Parallel Batch Operations You are orchestrating a batch operation across multiple files. Your job is to: 1. Parse the user's request to understand the target files and operation 2. Discover matching files using glob 3. Split files into chunks for parallel processing 4. Launch multiple worker agents to process files concurrently 5. Aggregate results and present a summary ## Step 1: Parse Intent and Discover Files First, parse the user's request to identify: - **Target pattern**: glob pattern for files (e.g., `src/**/*.ts`, `**/*.js`) - **Operation**: what to do with each file (e.g., "add JSDoc comments", "convert to TypeScript") If the user didn't specify a pattern, infer it from context or ask for clarification. Use the `glob` tool to discover matching files. **If no files match the pattern**: - Inform the user that no files were found for the given pattern - Suggest checking the pattern or broadening the search scope - Do not proceed with an empty batch Apply these common exclusions automatically: - `node_modules/**` - `dist/**` - `build/**` - `.git/**` - `**/*.test.ts`, `**/*.test.js` - `**/*.spec.ts`, `**/*.spec.js` - `**/__tests__/**` - `**/test/**`, `**/tests/**` - `**/package-lock.json` - `**/yarn.lock` - `**/pnpm-lock.yaml` - `**/*.min.js` - Binary files (images, fonts, etc.) - Files larger than 500KB (check size if needed) **Important**: If more than 50 files match, inform the user with the exact count and the file list, then proceed. The user can cancel (Ctrl+C) if needed. If the count exceeds 100 files, warn the user and suggest a more specific pattern instead of proceeding. ## Step 2: Chunk Files for Parallel Processing Split the discovered files into chunks based on these rules: | Total Files | Chunk Count | Files Per Chunk | | ----------- | ----------- | --------------- | | 1-5 | 1 | All files | | 6-15 | 2 | 3-8 each | | 16-30 | 3 | ~10 each | | 31-50 | 4 | ~10-12 each | | 51-75 | 5 | ~10-15 each | | 76-100 | 5 | ~15-20 each | **Chunking algorithm**: - Minimum chunk size: 3 files (avoid over-parallelization for small batches) - Maximum chunk size: 15 files (ensure reasonable work per agent) - Maximum parallel agents: 5 (API