Task-Loom - Project Orchestration Engine
Goal
Orchestrate large-scale PRD projects through a risk-first audit, state-machine driven workflow that decomposes requirements into a dependency graph, executes tasks in order, and verifies completion with circuit-breaker safety mechanisms.
Trigger
- User says "/task-loom init", "/task-loom audit", "/task-loom plan", "/task-loom execute"
- User has a large PRD (10,000+ lines) that needs structured decomposition and execution
- User wants risk-first audit, DAG-based task orchestration, and verification-driven project execution
Core Commands
| Command |
Phase |
Description |
/task-loom init <project_name> <prd_paths...> |
INIT |
Initialize project workspace |
/task-loom audit |
AUDIT |
Scan PRD for risks, generate audit report |
/task-loom plan |
PLAN |
Build DAG, decompose tasks |
/task-loom execute [--task T_XXX] |
EXECUTE |
Execute tasks in dependency order |
/task-loom verify [--task T_XXX] |
VERIFY |
Run tests, verify completion |
/task-loom status |
ANY |
View current project status |
/task-loom resume |
ANY |
Resume from checkpoint |
Workspace Structure
.claude/orchestra/
└── {{project_name}}/
├── manifest.json # State hub (SSoT)
├── constitution.md # Global invariants
├── vulnerability_report.md # Risk audit report
├── specs/ # Technical specification docs
└── ledgers/ # Execution ledgers
Workflow Phases
Phase 1: INIT
Trigger: /task-loom init <project_name> <prd_paths...>
Steps:
- Validate project name and PRD file existence
- Create directory structure under
.claude/orchestra/{{project_name}}/
- Parse PRD documents, calculate SHA-256 hash
- Extract global invariants (MUST/SHALL/REQUIRED keywords, security constraints) → write to
constitution.md
- Initialize
manifest.json with schema_version, project_metadata, workflow state, empty DAG
Phase 2: AUDIT
Trigger: /task-loom audit, workflow stage is INIT
Steps:
Sliding window scan (500 lines, 10% overlap) of all PRD documents
Identify risks by classification:
P0 (Critical) - Must Pause:
- Security: SQL injection, XSS, CSRF, auth bypass
- Financial: Payment logic defects, amount calculation errors
- Data: Sensitive data exposure, permission bypass
- Concurrency: Deadlocks, race conditions
- Availability: Single points of failure
P1 (High) - Should Confirm:
- Boundary conditions, missing state transitions
- Performance bottlenecks (N+1, full table scans)
- Uncovered exception scenarios
P2 (Normal) - Auto Log:
- Naming inconsistencies, documentation ambiguity
Generate vulnerability_report.md
HALT for P0 risks - user must confirm each:
🔴 P0 Risk #1: [description]
Suggestion: [fix suggestion]
Accept suggestion [Y/n/skip]?
Update manifest.json workflow.stage to AUDIT
Phase 3: PLAN
Trigger: /task-loom plan, workflow stage is AUDIT or INIT
Steps:
- Identify functional modules from PRD
- Decompose into tasks (types: MODULE_IMPL, TEST, INTEGRATE, REFACTOR)
- Build DAG with dependencies:
{
"id": "T_001",
"type": "MODULE_IMPL",
"title": "User Authentication Module",
"status": "PENDING",
"depends_on": [],
"prd_refs": ["docs/prd/auth.md L1-200"],
"artifacts": {
"spec": "specs/auth.md",
"ledger": null
}
}
- Generate
specs/*.md for each task with requirements, interfaces, data models, acceptance criteria
Phase 4: EXECUTE
Trigger: /task-loom execute [--task T_XXX], workflow stage is PLAN
CRITICAL: You must ACTUALLY WRITE CODE, not just update status.
Steps:
Task Selection: Get PENDING tasks with satisfied dependencies
python scripts/dag_manager.py --project <name> next
Context Loading (MANDATORY) - Read before writing ANY code:
.claude/orchestra/{{project_name}}/constitution.md - global invariants
.claude/orchestra/{{project_name}}/specs/T_XXX.md - task specification
.claude/orchestra/{{project_name}}/ledgers/T_YYY.md - for each dependency
Code Generation:
- Analyze task requirements from spec
- Check global invariants for constraints
- Check dependency ledgers for exported interfaces
- CREATE actual source code files
- ENSURE code follows all invariants
Generate Ledger after implementation:
# Ledger: T_001 - User Authentication Module
## Execution Info
- Task ID: T_001
- Status: COMPLETED
## Change Summary
### New Files
- src/auth/login.ts
- src/auth/middleware.ts
## Implicit Decisions
1. JWT expiry set to 24h (not specified in PRD)
## Downstream Dependencies
- T_002 needs: authMiddleware function in src/auth/middleware.ts
Update State:
python scripts/dag_manager.py --project <name> update --id T_XXX --status COMPLETED
Phase 5: VERIFY
Trigger: /task-loom verify, or auto-triggered in execute phase
Steps:
- Detect test framework (Jest/Vitest/Pytest/go test)
- Generate/update tests based on task spec
- Execute tests
- Handle failures: auto-fix, retry (max 3 times)
- Circuit breaker: After 3 failures, SYSTEM_HALT, rollback Git
Key Mechanisms
Global Invariant Injection
Before each task, inject into system prompt:
【Global Invariants - Must Adhere】
The following rules from constitution.md are immutable constraints:
1. All database transactions must use row-level locking
2. All API responses must include requestId
...
Checkpoint Resume
/task-loom resume:
- Read
manifest.json
- Check
workflow.active_task_id
- Restore task state, continue from interruption point
Circuit Breaker
| Condition |
Behavior |
| Task fails 3 times |
SYSTEM_HALT, rollback Git |
| P0 risk not confirmed |
AUDIT_HALT |
| Dependency task failed |
Task → BLOCKED |
| Test coverage < 80% |
VERIFY_HALT |
Ledger Context Transfer
Task N+1 loads predecessor context:
【Predecessor Task Context】
From T_001:
- Implicit decisions: JWT expiry 24h
- Exported interfaces: authMiddleware(), User type
Scripts
| Script |
Description |
scripts/init_workspace.py |
Initialize workspace |
scripts/dag_manager.py |
DAG state management |
scripts/risk_scanner.py |
PRD risk scanning |
scripts/spec_generator.py |
Generate task specifications |
scripts/ledger_generator.py |
Generate execution ledgers |
scripts/status_viewer.py |
Project status viewer |
scripts/resume_handler.py |
Checkpoint resume handler |
Reference Files
- risk_classifications.md - Risk classification rules
- ledger_template.md - Ledger format template
1---2name: task-loom3description: Large-scale PRD project orchestration engine with risk-first audit and DAG task execution. Trigger: user says "/task-loom init"、"大型项目编排"、"PRD 分解".4---56# Task-Loom - Project Orchestration Engine78## Goal910Orchestrate large-scale PRD projects through a risk-first audit, state-machine driven workflow that decomposes requirements into a dependency graph, executes tasks in order, and verifies completion with circuit-breaker safety mechanisms.1112## Trigger1314- User says "/task-loom init", "/task-loom audit", "/task-loom plan", "/task-loom execute"15- User has a large PRD (10,000+ lines) that needs structured decomposition and execution16- User wants risk-first audit, DAG-based task orchestration, and verification-driven project execution1718## Core Commands1920| Command | Phase | Description |21|---------|-------|-------------|22| `/task-loom init <project_name> <prd_paths...>` | INIT | Initialize project workspace |23| `/task-loom audit` | AUDIT | Scan PRD for risks, generate audit report |24| `/task-loom plan` | PLAN | Build DAG, decompose tasks |25| `/task-loom execute [--task T_XXX]` | EXECUTE | Execute tasks in dependency order |26| `/task-loom verify [--task T_XXX]` | VERIFY | Run tests, verify completion |27| `/task-loom status` | ANY | View current project status |28| `/task-loom resume` | ANY | Resume from checkpoint |2930## Workspace Structure3132```33.claude/orchestra/34└── {{project_name}}/35 ├── manifest.json # State hub (SSoT)36 ├── constitution.md # Global invariants37 ├── vulnerability_report.md # Risk audit report38 ├── specs/ # Technical specification docs39 └── ledgers/ # Execution ledgers40```4142## Workflow Phases4344### Phase 1: INIT4546**Trigger**: `/task-loom init <project_name> <prd_paths...>`4748**Steps**:491. Validate project name and PRD file existence502. Create directory structure under `.claude/orchestra/{{project_name}}/`513. Parse PRD documents, calculate SHA-256 hash524. Extract global invariants (MUST/SHALL/REQUIRED keywords, security constraints) → write to `constitution.md`535. Initialize `manifest.json` with schema_version, project_metadata, workflow state, empty DAG5455### Phase 2: AUDIT5657**Trigger**: `/task-loom audit`, workflow stage is INIT5859**Steps**:601. Sliding window scan (500 lines, 10% overlap) of all PRD documents612. Identify risks by classification:6263 **P0 (Critical) - Must Pause**:64 - Security: SQL injection, XSS, CSRF, auth bypass65 - Financial: Payment logic defects, amount calculation errors66 - Data: Sensitive data exposure, permission bypass67 - Concurrency: Deadlocks, race conditions68 - Availability: Single points of failure6970 **P1 (High) - Should Confirm**:71 - Boundary conditions, missing state transitions72 - Performance bottlenecks (N+1, full table scans)73 - Uncovered exception scenarios7475 **P2 (Normal) - Auto Log**:76 - Naming inconsistencies, documentation ambiguity77783. Generate `vulnerability_report.md`794. HALT for P0 risks - user must confirm each:80 ```81 🔴 P0 Risk #1: [description]82 Suggestion: [fix suggestion]83 Accept suggestion [Y/n/skip]?84 ```855. Update `manifest.json` workflow.stage to AUDIT8687### Phase 3: PLAN8889**Trigger**: `/task-loom plan`, workflow stage is AUDIT or INIT9091**Steps**:921. Identify functional modules from PRD932. Decompose into tasks (types: MODULE_IMPL, TEST, INTEGRATE, REFACTOR)943. Build DAG with dependencies:95 ```json96 {97 "id": "T_001",98 "type": "MODULE_IMPL",99 "title": "User Authentication Module",100 "status": "PENDING",101 "depends_on": [],102 "prd_refs": ["docs/prd/auth.md L1-200"],103 "artifacts": {104 "spec": "specs/auth.md",105 "ledger": null106 }107 }108 ```1094. Generate `specs/*.md` for each task with requirements, interfaces, data models, acceptance criteria110111### Phase 4: EXECUTE112113**Trigger**: `/task-loom execute [--task T_XXX]`, workflow stage is PLAN114115**CRITICAL**: You must ACTUALLY WRITE CODE, not just update status.116117**Steps**:1181191. **Task Selection**: Get PENDING tasks with satisfied dependencies120 ```bash121 python scripts/dag_manager.py --project <name> next122 ```1231242. **Context Loading (MANDATORY)** - Read before writing ANY code:125 - `.claude/orchestra/{{project_name}}/constitution.md` - global invariants126 - `.claude/orchestra/{{project_name}}/specs/T_XXX.md` - task specification127 - `.claude/orchestra/{{project_name}}/ledgers/T_YYY.md` - for each dependency1281293. **Code Generation**:130 - Analyze task requirements from spec131 - Check global invariants for constraints132 - Check dependency ledgers for exported interfaces133 - CREATE actual source code files134 - ENSURE code follows all invariants1351364. **Generate Ledger** after implementation:137 ```markdown138 # Ledger: T_001 - User Authentication Module139140 ## Execution Info141 - Task ID: T_001142 - Status: COMPLETED143144 ## Change Summary145 ### New Files146 - src/auth/login.ts147 - src/auth/middleware.ts148149 ## Implicit Decisions150 1. JWT expiry set to 24h (not specified in PRD)151152 ## Downstream Dependencies153 - T_002 needs: authMiddleware function in src/auth/middleware.ts154 ```1551565. **Update State**:157 ```bash158 python scripts/dag_manager.py --project <name> update --id T_XXX --status COMPLETED159 ```160161### Phase 5: VERIFY162163**Trigger**: `/task-loom verify`, or auto-triggered in execute phase164165**Steps**:1661. Detect test framework (Jest/Vitest/Pytest/go test)1672. Generate/update tests based on task spec1683. Execute tests1694. Handle failures: auto-fix, retry (max 3 times)1705. Circuit breaker: After 3 failures, SYSTEM_HALT, rollback Git171172## Key Mechanisms173174### Global Invariant Injection175176Before each task, inject into system prompt:177```178【Global Invariants - Must Adhere】179The following rules from constitution.md are immutable constraints:1801. All database transactions must use row-level locking1812. All API responses must include requestId182...183```184185### Checkpoint Resume186187`/task-loom resume`:1881. Read `manifest.json`1892. Check `workflow.active_task_id`1903. Restore task state, continue from interruption point191192### Circuit Breaker193194| Condition | Behavior |195|-----------|----------|196| Task fails 3 times | SYSTEM_HALT, rollback Git |197| P0 risk not confirmed | AUDIT_HALT |198| Dependency task failed | Task → BLOCKED |199| Test coverage < 80% | VERIFY_HALT |200201### Ledger Context Transfer202203Task N+1 loads predecessor context:204```205【Predecessor Task Context】206From T_001:207- Implicit decisions: JWT expiry 24h208- Exported interfaces: authMiddleware(), User type209```210211## Scripts212213| Script | Description |214|--------|-------------|215| `scripts/init_workspace.py` | Initialize workspace |216| `scripts/dag_manager.py` | DAG state management |217| `scripts/risk_scanner.py` | PRD risk scanning |218| `scripts/spec_generator.py` | Generate task specifications |219| `scripts/ledger_generator.py` | Generate execution ledgers |220| `scripts/status_viewer.py` | Project status viewer |221| `scripts/resume_handler.py` | Checkpoint resume handler |222223## Reference Files224225- [risk_classifications.md](references/risk_classifications.md) - Risk classification rules226- [ledger_template.md](references/ledger_template.md) - Ledger format template