tx block
Add blocking dependencies between tasks
Purpose
tx block creates a dependency between two tasks. The blocked task cannot be ready until the blocker is marked done.
tx enforces two rules to maintain consistency:
- No self-blocking: A task cannot block itself
- No cycles: A->B->C->A chains are not allowed
Usage
# Add a blocker: blocker-id must complete before task-id can start
tx block <task-id> <blocker-id> [options]
# Remove a blocker
tx unblock <task-id> <blocker-id>Arguments
| Argument | Required | Description |
|---|---|---|
<task-id> | Yes | The task that will be blocked |
<blocker-id> | Yes | The task that blocks it |
Options
| Option | Description |
|---|---|
--json | Output as JSON |
--help | Show help |
Examples
# tx-def456 blocks tx-abc123
tx block tx-abc123 tx-def456
# Add multiple blockers to a single task
tx block tx-feature tx-design
tx block tx-feature tx-api
tx block tx-feature tx-tests
# Remove a blocker
tx unblock tx-abc123 tx-def456import { TxClient } from '@jamesaphoenix/tx-agent-sdk'
const tx = new TxClient({ apiUrl: 'http://localhost:3456' })
// Add blocker: blockerId must complete before id can start
const task = await tx.tasks.block('tx-abc123', 'tx-def456')
// Remove blocker
const task = await tx.tasks.unblock('tx-abc123', 'tx-def456')tx_block
Add a blocking dependency between two tasks.
{
"tool": "tx_block",
"arguments": {
"taskId": "tx-abc123",
"blockerId": "tx-def456"
}
}tx_unblock
Remove a blocking dependency.
{
"tool": "tx_unblock",
"arguments": {
"taskId": "tx-abc123",
"blockerId": "tx-def456"
}
}Add a blocker
POST /api/tasks/:id/block
Content-Type: application/json
{
"blockerId": "tx-def456"
}Remove a blocker
DELETE /api/tasks/:id/block/:blockerIdExample
# Add blocker
curl -X POST http://localhost:3456/api/tasks/tx-abc123/block \
-H "Content-Type: application/json" \
-d '{"blockerId": "tx-def456"}'
# Remove blocker
curl -X DELETE http://localhost:3456/api/tasks/tx-abc123/block/tx-def456Output
Text Output
Dependency added: tx-def456 now blocks tx-abc123
Task tx-abc123:
Status: blocked
Blocked by: tx-def456JSON Output
{
"task": {
"id": "tx-abc123",
"title": "Implement login page",
"status": "blocked",
"blockedBy": ["tx-def456"],
"blocks": [],
"children": [],
"isReady": false
}
}Cycle Detection
tx uses BFS (Breadth-First Search) to detect cycles at insert time:
# This would create a cycle and will be rejected
tx block tx-a tx-b
tx block tx-b tx-c
tx block tx-c tx-a # Error: Would create cycle A->B->C->AError output:
Error: Cannot add dependency - would create cycle: tx-a -> tx-b -> tx-c -> tx-aDependency Visualization
Use tx tree to visualize task dependencies:
tx tree tx-feature
tx-feature (blocked)
├── tx-design (done) ✓
├── tx-api (active)
└── tx-tests (blocked)
└── tx-unit (ready)Agent Workflow
#!/bin/bash
# Decompose a task into subtasks with dependencies
# Create main task
MAIN=$(tx add "Build user profile page" --json | jq -r '.id')
# Create subtasks
API=$(tx add "Create profile API endpoint" --parent "$MAIN" --json | jq -r '.id')
UI=$(tx add "Build profile UI component" --parent "$MAIN" --json | jq -r '.id')
TEST=$(tx add "Write integration tests" --parent "$MAIN" --json | jq -r '.id')
# Set dependencies: UI depends on API, tests depend on both
tx block "$UI" "$API"
tx block "$TEST" "$API"
tx block "$TEST" "$UI"Related Commands
tx unblock- Remove a blocking dependencytx ready- List tasks with no blockerstx done- Complete a task and unblock dependents