/batch
Process multiple items with functional patterns. Apply operations like map, pmap (parallel), filter, and reduce to batch items efficiently.
Quick Start
/agileflow:batch map "docs/06-stories/*.md" validateThis processes all story files sequentially and validates them.
Parameters
| Parameter | Required | Description |
|---|---|---|
<operation> | Yes | One of: map, pmap, filter, reduce |
<pattern> | Yes | Glob pattern or item source |
[action] | No | Action to perform on each item |
Operations
map - Sequential Processing
Process each item one at a time:
/agileflow:batch map "src/**/*.ts" lintBest for:
- Quick validation
- Order-dependent operations
- Small batches
pmap - Parallel Processing
Process items in parallel using agent tasks:
/agileflow:batch pmap "src/components/*.tsx" add-testsBest for:
- Independent tasks
- Large batches
- Time-sensitive work
filter - Find Matching Items
Return items matching criteria:
/agileflow:batch filter stories status=readyReturns matching items without processing.
reduce - Aggregate Items
Combine items into single output:
/agileflow:batch reduce "docs/06-stories/*.md" summaryCreates aggregated report from all items.
Usage Examples
Validate all stories
/agileflow:batch map "docs/06-stories/*.md" validateSequentially validates each story file:
- Checks required frontmatter
- Validates acceptance criteria format
- Reports issues
Generate tests in parallel
/agileflow:batch pmap "src/components/*.tsx" add-testsSpawns parallel agents to add tests:
- Each component gets dedicated agent
- Agents work simultaneously
- Results collected when complete
Find ready stories
/agileflow:batch filter stories status=readyReturns all stories ready to start:
- Lists by epic
- Shows priority
- Shows estimates
Create summary report
/agileflow:batch reduce "docs/06-stories/*.md" summaryGenerates summary statistics:
- Stories by epic
- Stories by status
- Priority distribution
Loop Mode (pmap only)
Process items iteratively until tests pass with MODE=loop:
/agileflow:batch pmap "src/components/*.tsx" add-tests MODE=loopHow Loop Mode Works
- Process first item
- Run tests for that item
- If tests pass ā move to next item
- If tests fail ā continue fixing
- Repeat until all items pass or max iterations reached
Parameters
| Parameter | Default | Description |
|---|---|---|
MODE | - | Set to loop for iterative mode |
GATE | tests | Quality gate type |
MAX | 50 | Maximum iterations total |
Loop Mode Example
/agileflow:batch pmap "src/components/*.tsx" add-tests MODE=loop MAX=30Progress output shows:
- Current item being processed
- Test results for that item
- Move to next item when tests pass
- Overall progress count
Built-in Actions
| Action | Description | Works With |
|---|---|---|
validate | Check format/structure | stories, epics |
add-tests | Generate tests | source files |
lint | Run linter | source files |
format | Apply formatting | source files |
summarize | Generate summary | any |
count | Count items | any |
Custom Actions
For pmap, any action becomes the agent prompt:
/agileflow:batch pmap "src/**/*.ts" "refactor to use async/await"Each agent receives:
- File path
- Custom instruction (the action)
- Instructions to complete the work
Filter Syntax
Use field=value syntax:
/agileflow:batch filter stories status=ready epic=EP-0009Multiple criteria are AND'd together.
Common filters:
status=ready|in_progress|completed|blockedpriority=high|medium|lowepic=EP-XXXX
Output Examples
Map Operation Output
š¦ Batch: map over 12 items
š Processing: docs/06-stories/US-0042.md
ā
Valid story format
š Processing: docs/06-stories/US-0043.md
ā ļø Missing acceptance criteria
...
ā
Complete: 10 passed, 2 warnings
Pmap Operation Output
š Batch: pmap over 8 items (parallel)
š Spawning 8 parallel agents...
š task-001: Button.tsx
š task-002: Input.tsx
š task-003: Select.tsx
...
ā³ Waiting for completion...
ā
task-001: Button.tsx - 5 tests added
ā
task-002: Input.tsx - 4 tests added
ā
task-003: Select.tsx - 6 tests added
ā
Complete: 8/8 successful, 38 tests added
Filter Operation Output
š Filter: stories where status=ready
Found 3 matching stories:
1. US-0042: Add user profile settings
Epic: EP-0009 | Priority: high
2. US-0043: Implement password reset
Epic: EP-0009 | Priority: high
3. US-0045: Add notification preferences
Epic: EP-0010 | Priority: medium
Reduce Operation Output
š Reduce: 15 stories ā summary
Epic Distribution:
EP-0009: 8 stories (53%)
EP-0010: 4 stories (27%)
EP-0011: 3 stories (20%)
Status Distribution:
ready: 5 (33%)
in_progress: 3 (20%)
completed: 7 (47%)
Priority:
high: 6
medium: 7
low: 2
Best Practices
- Filter first - Reduce scope before processing
- Use map for validation - Quick checks don't need parallelism
- Use pmap for independent work - Tests, linting, formatting
- Monitor loop iterations - Don't exceed MAX unnecessarily
- Check results - Review failed items after batch completes
When to Use
Best For
- Batch operations - Apply same action to many items
- Parallel processing - Speed up independent tasks
- Filtering and searching - Find items matching criteria
- Reporting - Aggregate data across files
Not For
- Single items - Use direct commands instead
- Complex workflows - Use
/agileflow:babysitinstead - Exploratory work - Use individual commands for learning
Related Commands
On This Page
/batchQuick StartParametersOperationsmap - Sequential Processingpmap - Parallel Processingfilter - Find Matching Itemsreduce - Aggregate ItemsUsage ExamplesValidate all storiesGenerate tests in parallelFind ready storiesCreate summary reportLoop Mode (pmap only)How Loop Mode WorksParametersLoop Mode ExampleBuilt-in ActionsCustom ActionsFilter SyntaxOutput ExamplesMap Operation OutputPmap Operation OutputFilter Operation OutputReduce Operation OutputBest PracticesWhen to UseBest ForNot ForRelated Commands