claude-cli-advanced-starter-pack 1.0.16 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +5 -1
- package/README.md +241 -132
- package/bin/gtask.js +53 -0
- package/package.json +1 -1
- package/src/cli/menu.js +27 -0
- package/src/commands/explore-mcp/mcp-registry.js +99 -0
- package/src/commands/init.js +309 -80
- package/src/commands/install-panel-hook.js +108 -0
- package/src/commands/install-scripts.js +232 -0
- package/src/commands/install-skill.js +220 -0
- package/src/commands/panel.js +297 -0
- package/src/commands/setup-wizard.js +4 -3
- package/src/commands/test-setup.js +4 -5
- package/src/data/releases.json +209 -0
- package/src/panel/queue.js +188 -0
- package/templates/commands/ask-claude.template.md +118 -0
- package/templates/commands/ccasp-panel.template.md +72 -0
- package/templates/commands/ccasp-setup.template.md +470 -79
- package/templates/commands/create-smoke-test.template.md +186 -0
- package/templates/commands/project-impl.template.md +9 -113
- package/templates/commands/refactor-check.template.md +112 -0
- package/templates/commands/refactor-cleanup.template.md +144 -0
- package/templates/commands/refactor-prep.template.md +192 -0
- package/templates/docs/AI_ARCHITECTURE_CONSTITUTION.template.md +198 -0
- package/templates/docs/DETAILED_GOTCHAS.template.md +347 -0
- package/templates/docs/PHASE-DEV-CHECKLIST.template.md +241 -0
- package/templates/docs/PROGRESS_JSON_TEMPLATE.json +117 -0
- package/templates/docs/background-agent.template.md +264 -0
- package/templates/hooks/autonomous-decision-logger.template.js +207 -0
- package/templates/hooks/branch-merge-checker.template.js +272 -0
- package/templates/hooks/context-injector.template.js +261 -0
- package/templates/hooks/git-commit-tracker.template.js +267 -0
- package/templates/hooks/happy-mode-detector.template.js +214 -0
- package/templates/hooks/happy-title-generator.template.js +260 -0
- package/templates/hooks/issue-completion-detector.template.js +205 -0
- package/templates/hooks/panel-queue-reader.template.js +83 -0
- package/templates/hooks/phase-validation-gates.template.js +307 -0
- package/templates/hooks/session-id-generator.template.js +236 -0
- package/templates/hooks/token-budget-loader.template.js +234 -0
- package/templates/hooks/token-usage-monitor.template.js +193 -0
- package/templates/hooks/tool-output-cacher.template.js +219 -0
- package/templates/patterns/README.md +129 -0
- package/templates/patterns/l1-l2-orchestration.md +189 -0
- package/templates/patterns/multi-phase-orchestration.md +258 -0
- package/templates/patterns/two-tier-query-pipeline.md +192 -0
- package/templates/scripts/README.md +109 -0
- package/templates/scripts/analyze-delegation-log.js +299 -0
- package/templates/scripts/autonomous-decision-logger.js +277 -0
- package/templates/scripts/git-history-analyzer.py +269 -0
- package/templates/scripts/phase-validation-gates.js +307 -0
- package/templates/scripts/poll-deployment-status.js +260 -0
- package/templates/scripts/roadmap-scanner.js +263 -0
- package/templates/scripts/validate-deployment.js +293 -0
- package/templates/skills/agent-creator/skill.json +18 -0
- package/templates/skills/agent-creator/skill.md +335 -0
- package/templates/skills/hook-creator/skill.json +18 -0
- package/templates/skills/hook-creator/skill.md +318 -0
- package/templates/skills/panel/skill.json +18 -0
- package/templates/skills/panel/skill.md +90 -0
- package/templates/skills/rag-agent-creator/skill.json +18 -0
- package/templates/skills/rag-agent-creator/skill.md +307 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Phase Development Checklist
|
|
2
|
+
|
|
3
|
+
Validation gates for phased development execution.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Three levels of validation ensure quality at each development stage:
|
|
8
|
+
|
|
9
|
+
- **L1**: Quick sanity checks (< 1 minute)
|
|
10
|
+
- **L2**: Standard validation (1-5 minutes)
|
|
11
|
+
- **L3**: Comprehensive verification (5+ minutes)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## L1 Validation (Quick Check)
|
|
16
|
+
|
|
17
|
+
Run after each task completion.
|
|
18
|
+
|
|
19
|
+
### Checklist
|
|
20
|
+
|
|
21
|
+
- [ ] **Syntax Valid** - No parse errors
|
|
22
|
+
- [ ] **Imports Resolve** - No missing modules
|
|
23
|
+
- [ ] **Types Check** - No type errors (if TypeScript)
|
|
24
|
+
- [ ] **Lint Clean** - No blocking lint errors
|
|
25
|
+
|
|
26
|
+
### Commands
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# JavaScript/TypeScript
|
|
30
|
+
npx eslint --quiet <changed-files>
|
|
31
|
+
npx tsc --noEmit
|
|
32
|
+
|
|
33
|
+
# Python
|
|
34
|
+
python -m py_compile <changed-files>
|
|
35
|
+
ruff check <changed-files>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Pass Criteria
|
|
39
|
+
|
|
40
|
+
- Zero syntax errors
|
|
41
|
+
- Zero type errors
|
|
42
|
+
- Zero blocking lint errors
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## L2 Validation (Standard Check)
|
|
47
|
+
|
|
48
|
+
Run at phase completion, before phase advancement.
|
|
49
|
+
|
|
50
|
+
### Checklist
|
|
51
|
+
|
|
52
|
+
- [ ] **All L1 Checks Pass**
|
|
53
|
+
- [ ] **Unit Tests Pass** - Affected tests run
|
|
54
|
+
- [ ] **No Regressions** - Existing tests still pass
|
|
55
|
+
- [ ] **Files Created** - Expected outputs exist
|
|
56
|
+
- [ ] **Documentation Updated** - If API changed
|
|
57
|
+
|
|
58
|
+
### Commands
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Run affected tests
|
|
62
|
+
npm run test -- --findRelatedTests <changed-files>
|
|
63
|
+
|
|
64
|
+
# Verify expected files
|
|
65
|
+
ls -la <expected-output-files>
|
|
66
|
+
|
|
67
|
+
# Check documentation
|
|
68
|
+
grep -r "TODO: document" docs/
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Pass Criteria
|
|
72
|
+
|
|
73
|
+
- All unit tests pass
|
|
74
|
+
- Expected files exist
|
|
75
|
+
- No TODO documentation items for changed APIs
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## L3 Validation (Comprehensive Check)
|
|
80
|
+
|
|
81
|
+
Run at project milestones, before deployment.
|
|
82
|
+
|
|
83
|
+
### Checklist
|
|
84
|
+
|
|
85
|
+
- [ ] **All L2 Checks Pass**
|
|
86
|
+
- [ ] **Full Test Suite Pass** - All tests
|
|
87
|
+
- [ ] **E2E Tests Pass** - Critical paths
|
|
88
|
+
- [ ] **Performance Check** - No degradation
|
|
89
|
+
- [ ] **Security Scan** - No vulnerabilities
|
|
90
|
+
- [ ] **Build Succeeds** - Production build works
|
|
91
|
+
|
|
92
|
+
### Commands
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Full test suite
|
|
96
|
+
npm test
|
|
97
|
+
|
|
98
|
+
# E2E tests
|
|
99
|
+
npm run test:e2e
|
|
100
|
+
|
|
101
|
+
# Performance audit
|
|
102
|
+
npx lighthouse --output=json --quiet
|
|
103
|
+
|
|
104
|
+
# Security scan
|
|
105
|
+
npm audit
|
|
106
|
+
npx snyk test
|
|
107
|
+
|
|
108
|
+
# Production build
|
|
109
|
+
npm run build
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Pass Criteria
|
|
113
|
+
|
|
114
|
+
- 100% test pass rate
|
|
115
|
+
- E2E tests cover critical paths
|
|
116
|
+
- No high/critical vulnerabilities
|
|
117
|
+
- Build completes without errors
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Phase-Specific Gates
|
|
122
|
+
|
|
123
|
+
### Phase 1: Foundation
|
|
124
|
+
|
|
125
|
+
| Gate | Criteria |
|
|
126
|
+
|------|----------|
|
|
127
|
+
| Structure | All directories created |
|
|
128
|
+
| Config | Configuration files valid |
|
|
129
|
+
| Dependencies | All packages installed |
|
|
130
|
+
| Base Tests | Setup tests pass |
|
|
131
|
+
|
|
132
|
+
### Phase 2: Implementation
|
|
133
|
+
|
|
134
|
+
| Gate | Criteria |
|
|
135
|
+
|------|----------|
|
|
136
|
+
| Features | All tasks complete |
|
|
137
|
+
| Coverage | >80% on new code |
|
|
138
|
+
| Integration | API tests pass |
|
|
139
|
+
| Types | Full type coverage |
|
|
140
|
+
|
|
141
|
+
### Phase 3: Polish & Deploy
|
|
142
|
+
|
|
143
|
+
| Gate | Criteria |
|
|
144
|
+
|------|----------|
|
|
145
|
+
| E2E | All flows tested |
|
|
146
|
+
| Performance | Meets thresholds |
|
|
147
|
+
| Security | No vulnerabilities |
|
|
148
|
+
| Docs | Complete and current |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Automated Gate Checks
|
|
153
|
+
|
|
154
|
+
### PROGRESS.json Validation
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"validation_gates": {
|
|
159
|
+
"tasks_complete": true,
|
|
160
|
+
"files_created": true,
|
|
161
|
+
"tests_passing": true,
|
|
162
|
+
"no_errors": true,
|
|
163
|
+
"token_budget": true
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Gate Runner Script
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
// Run all gates for current phase
|
|
172
|
+
async function runValidationGates(phase) {
|
|
173
|
+
const results = {
|
|
174
|
+
tasks_complete: await checkTasksComplete(phase),
|
|
175
|
+
files_created: await checkFilesCreated(phase),
|
|
176
|
+
tests_passing: await checkTestsPassing(phase),
|
|
177
|
+
no_errors: await checkNoErrors(phase),
|
|
178
|
+
token_budget: await checkTokenBudget(phase)
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const allPassed = Object.values(results).every(r => r);
|
|
182
|
+
|
|
183
|
+
return { allPassed, results };
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Failure Handling
|
|
190
|
+
|
|
191
|
+
### L1 Failure
|
|
192
|
+
|
|
193
|
+
1. Fix immediately before proceeding
|
|
194
|
+
2. Re-run L1 checks
|
|
195
|
+
3. Continue with task
|
|
196
|
+
|
|
197
|
+
### L2 Failure
|
|
198
|
+
|
|
199
|
+
1. Identify failing gate
|
|
200
|
+
2. Create remediation task
|
|
201
|
+
3. Fix and re-validate
|
|
202
|
+
4. Update PROGRESS.json
|
|
203
|
+
|
|
204
|
+
### L3 Failure
|
|
205
|
+
|
|
206
|
+
1. Document failure details
|
|
207
|
+
2. Create tracking issue
|
|
208
|
+
3. Roll back if needed
|
|
209
|
+
4. Plan remediation
|
|
210
|
+
5. Re-execute full L3
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Quick Commands
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# L1 Quick Check
|
|
218
|
+
npm run validate:l1
|
|
219
|
+
|
|
220
|
+
# L2 Phase Check
|
|
221
|
+
npm run validate:l2
|
|
222
|
+
|
|
223
|
+
# L3 Comprehensive Check
|
|
224
|
+
npm run validate:l3
|
|
225
|
+
|
|
226
|
+
# All checks
|
|
227
|
+
npm run validate:all
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Integration with Phased Development
|
|
233
|
+
|
|
234
|
+
1. **Task Complete** → Run L1
|
|
235
|
+
2. **Phase Complete** → Run L2
|
|
236
|
+
3. **Ready to Deploy** → Run L3
|
|
237
|
+
4. **All Gates Pass** → Proceed to next phase
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
*Use these checklists to ensure quality at every stage*
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$comment": "PROGRESS.json template for phased development tracking",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"project_slug": "{{project.slug}}",
|
|
6
|
+
"project_name": "{{project.name}}",
|
|
7
|
+
"created_at": "{{date}}",
|
|
8
|
+
"last_updated": "{{date}}",
|
|
9
|
+
"current_phase": 1,
|
|
10
|
+
"overall_progress": {
|
|
11
|
+
"total_phases": 3,
|
|
12
|
+
"completed_phases": 0,
|
|
13
|
+
"total_tasks": 15,
|
|
14
|
+
"completed_tasks": 0,
|
|
15
|
+
"success_rate": 0.0
|
|
16
|
+
},
|
|
17
|
+
"phases": [
|
|
18
|
+
{
|
|
19
|
+
"phase_number": 1,
|
|
20
|
+
"title": "Foundation",
|
|
21
|
+
"status": "not_started",
|
|
22
|
+
"started_at": null,
|
|
23
|
+
"completed_at": null,
|
|
24
|
+
"tasks": [
|
|
25
|
+
{
|
|
26
|
+
"id": "P1-T1",
|
|
27
|
+
"title": "Task 1 description",
|
|
28
|
+
"status": "pending",
|
|
29
|
+
"priority": "high",
|
|
30
|
+
"estimated_tokens": 5000,
|
|
31
|
+
"actual_tokens": null,
|
|
32
|
+
"dependencies": [],
|
|
33
|
+
"files_to_modify": [],
|
|
34
|
+
"acceptance_criteria": [
|
|
35
|
+
"Criterion 1",
|
|
36
|
+
"Criterion 2"
|
|
37
|
+
],
|
|
38
|
+
"notes": ""
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": "P1-T2",
|
|
42
|
+
"title": "Task 2 description",
|
|
43
|
+
"status": "pending",
|
|
44
|
+
"priority": "medium",
|
|
45
|
+
"estimated_tokens": 3000,
|
|
46
|
+
"actual_tokens": null,
|
|
47
|
+
"dependencies": ["P1-T1"],
|
|
48
|
+
"files_to_modify": [],
|
|
49
|
+
"acceptance_criteria": [
|
|
50
|
+
"Criterion 1"
|
|
51
|
+
],
|
|
52
|
+
"notes": ""
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"validation_gates": {
|
|
56
|
+
"tasks_complete": false,
|
|
57
|
+
"files_created": false,
|
|
58
|
+
"tests_passing": false,
|
|
59
|
+
"no_errors": false,
|
|
60
|
+
"token_budget": false
|
|
61
|
+
},
|
|
62
|
+
"expected_output_files": [],
|
|
63
|
+
"token_budget": 25000,
|
|
64
|
+
"require_tests": false
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"phase_number": 2,
|
|
68
|
+
"title": "Implementation",
|
|
69
|
+
"status": "not_started",
|
|
70
|
+
"started_at": null,
|
|
71
|
+
"completed_at": null,
|
|
72
|
+
"tasks": [],
|
|
73
|
+
"validation_gates": {
|
|
74
|
+
"tasks_complete": false,
|
|
75
|
+
"files_created": false,
|
|
76
|
+
"tests_passing": false,
|
|
77
|
+
"no_errors": false,
|
|
78
|
+
"token_budget": false
|
|
79
|
+
},
|
|
80
|
+
"expected_output_files": [],
|
|
81
|
+
"token_budget": 50000,
|
|
82
|
+
"require_tests": true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"phase_number": 3,
|
|
86
|
+
"title": "Polish & Deploy",
|
|
87
|
+
"status": "not_started",
|
|
88
|
+
"started_at": null,
|
|
89
|
+
"completed_at": null,
|
|
90
|
+
"tasks": [],
|
|
91
|
+
"validation_gates": {
|
|
92
|
+
"tasks_complete": false,
|
|
93
|
+
"files_created": false,
|
|
94
|
+
"tests_passing": false,
|
|
95
|
+
"no_errors": false,
|
|
96
|
+
"token_budget": false
|
|
97
|
+
},
|
|
98
|
+
"expected_output_files": [],
|
|
99
|
+
"token_budget": 25000,
|
|
100
|
+
"require_tests": true
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"git_tracking": {
|
|
104
|
+
"pre_start_commit": null,
|
|
105
|
+
"phase_commits": [],
|
|
106
|
+
"current_stable_commit": null
|
|
107
|
+
},
|
|
108
|
+
"checkpoints": [],
|
|
109
|
+
"blockers": [],
|
|
110
|
+
"metadata": {
|
|
111
|
+
"scale": "M",
|
|
112
|
+
"estimated_total_tokens": 100000,
|
|
113
|
+
"actual_total_tokens": 0,
|
|
114
|
+
"success_target": 0.95,
|
|
115
|
+
"auto_chain_enabled": false
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Background Agent Orchestration
|
|
2
|
+
|
|
3
|
+
Template for production-grade background agent workflows.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Background agents run autonomous tasks without blocking the main conversation. Use for:
|
|
8
|
+
|
|
9
|
+
- Long-running operations (builds, tests, deployments)
|
|
10
|
+
- Parallel exploration tasks
|
|
11
|
+
- Batch processing
|
|
12
|
+
- Monitoring and validation
|
|
13
|
+
|
|
14
|
+
## Configuration
|
|
15
|
+
|
|
16
|
+
### Basic Background Agent Launch
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
// Launch agent in background
|
|
20
|
+
const result = await Task({
|
|
21
|
+
description: "Run full test suite",
|
|
22
|
+
prompt: "Execute all tests and report results...",
|
|
23
|
+
subagent_type: "Bash",
|
|
24
|
+
run_in_background: true
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// result contains output_file path
|
|
28
|
+
const outputPath = result.output_file;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Checking Background Agent Status
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// Read output file to check progress
|
|
35
|
+
const output = await Read({ file_path: outputPath });
|
|
36
|
+
|
|
37
|
+
// Parse for completion markers
|
|
38
|
+
if (output.includes('[COMPLETE]')) {
|
|
39
|
+
// Agent finished
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Production Patterns
|
|
44
|
+
|
|
45
|
+
### Pattern 1: Parallel Exploration
|
|
46
|
+
|
|
47
|
+
Launch multiple explore agents simultaneously:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// Launch in single message for parallel execution
|
|
51
|
+
const agents = await Promise.all([
|
|
52
|
+
Task({
|
|
53
|
+
description: "Search auth patterns",
|
|
54
|
+
prompt: "Find authentication implementations...",
|
|
55
|
+
subagent_type: "Explore",
|
|
56
|
+
run_in_background: true
|
|
57
|
+
}),
|
|
58
|
+
Task({
|
|
59
|
+
description: "Search API endpoints",
|
|
60
|
+
prompt: "Find all API route definitions...",
|
|
61
|
+
subagent_type: "Explore",
|
|
62
|
+
run_in_background: true
|
|
63
|
+
}),
|
|
64
|
+
Task({
|
|
65
|
+
description: "Search test patterns",
|
|
66
|
+
prompt: "Find test file patterns...",
|
|
67
|
+
subagent_type: "Explore",
|
|
68
|
+
run_in_background: true
|
|
69
|
+
})
|
|
70
|
+
]);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Pattern 2: Build Monitoring
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// Launch build in background
|
|
77
|
+
const build = await Task({
|
|
78
|
+
description: "Production build",
|
|
79
|
+
prompt: "Run npm run build and report any errors...",
|
|
80
|
+
subagent_type: "Bash",
|
|
81
|
+
run_in_background: true
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Periodically check status
|
|
85
|
+
while (!buildComplete) {
|
|
86
|
+
await sleep(10000); // Check every 10 seconds
|
|
87
|
+
const status = await Read({ file_path: build.output_file });
|
|
88
|
+
|
|
89
|
+
if (status.includes('Build complete') || status.includes('error')) {
|
|
90
|
+
buildComplete = true;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Pattern 3: Test Pipeline
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// Sequential testing with background execution
|
|
100
|
+
async function runTestPipeline() {
|
|
101
|
+
// Phase 1: Unit tests
|
|
102
|
+
const unit = await Task({
|
|
103
|
+
description: "Unit tests",
|
|
104
|
+
prompt: "Run unit tests: npm run test:unit",
|
|
105
|
+
subagent_type: "Bash",
|
|
106
|
+
run_in_background: true
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Wait for unit tests
|
|
110
|
+
const unitResult = await waitForCompletion(unit.output_file);
|
|
111
|
+
|
|
112
|
+
if (!unitResult.success) {
|
|
113
|
+
return { phase: 'unit', ...unitResult };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Phase 2: Integration tests
|
|
117
|
+
const integration = await Task({
|
|
118
|
+
description: "Integration tests",
|
|
119
|
+
prompt: "Run integration tests: npm run test:integration",
|
|
120
|
+
subagent_type: "Bash",
|
|
121
|
+
run_in_background: true
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// ... continue pipeline
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Pattern 4: Deployment Orchestration
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
async function deployWithValidation() {
|
|
132
|
+
// Pre-deployment checks (parallel)
|
|
133
|
+
const [lintResult, testResult, buildResult] = await Promise.all([
|
|
134
|
+
runBackgroundTask("lint", "npm run lint"),
|
|
135
|
+
runBackgroundTask("test", "npm test"),
|
|
136
|
+
runBackgroundTask("build", "npm run build")
|
|
137
|
+
]);
|
|
138
|
+
|
|
139
|
+
// Validate all passed
|
|
140
|
+
if (!allPassed([lintResult, testResult, buildResult])) {
|
|
141
|
+
return { success: false, stage: 'validation' };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Deploy backend
|
|
145
|
+
const backend = await runBackgroundTask(
|
|
146
|
+
"backend deploy",
|
|
147
|
+
"railway up"
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
if (!backend.success) {
|
|
151
|
+
return { success: false, stage: 'backend' };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Deploy frontend
|
|
155
|
+
const frontend = await runBackgroundTask(
|
|
156
|
+
"frontend deploy",
|
|
157
|
+
"wrangler pages deploy dist"
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// Smoke tests
|
|
161
|
+
const smoke = await runBackgroundTask(
|
|
162
|
+
"smoke tests",
|
|
163
|
+
"npm run test:smoke"
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return { success: smoke.success, stages: allStages };
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Error Handling
|
|
171
|
+
|
|
172
|
+
### Timeout Management
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
async function waitForCompletion(outputFile, timeoutMs = 300000) {
|
|
176
|
+
const startTime = Date.now();
|
|
177
|
+
|
|
178
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
179
|
+
const output = await Read({ file_path: outputFile });
|
|
180
|
+
|
|
181
|
+
if (isComplete(output)) {
|
|
182
|
+
return parseResult(output);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (hasError(output)) {
|
|
186
|
+
return { success: false, error: parseError(output) };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
await sleep(5000);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return { success: false, error: 'Timeout' };
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Graceful Degradation
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
async function robustBackgroundTask(description, prompt) {
|
|
200
|
+
try {
|
|
201
|
+
const agent = await Task({
|
|
202
|
+
description,
|
|
203
|
+
prompt,
|
|
204
|
+
subagent_type: "Bash",
|
|
205
|
+
run_in_background: true
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return await waitForCompletion(agent.output_file);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error(`Background task failed: ${description}`);
|
|
211
|
+
return { success: false, error: error.message };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Monitoring Dashboard
|
|
217
|
+
|
|
218
|
+
Create a status display for multiple background agents:
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
222
|
+
║ Background Agent Status ║
|
|
223
|
+
╠══════════════════════════════════════════════════════════════╣
|
|
224
|
+
║ Agent │ Status │ Duration │ Progress ║
|
|
225
|
+
╠══════════════════════════════════════════════════════════════╣
|
|
226
|
+
║ Unit Tests │ ✅ Complete │ 1m 23s │ 100% ║
|
|
227
|
+
║ Integration Tests │ 🔄 Running │ 2m 45s │ 67% ║
|
|
228
|
+
║ E2E Tests │ ⏳ Pending │ -- │ -- ║
|
|
229
|
+
║ Backend Deploy │ ⏳ Pending │ -- │ -- ║
|
|
230
|
+
║ Frontend Deploy │ ⏳ Pending │ -- │ -- ║
|
|
231
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Best Practices
|
|
235
|
+
|
|
236
|
+
1. **Always set timeouts** - Background agents can hang
|
|
237
|
+
2. **Log progress markers** - Enable status checking
|
|
238
|
+
3. **Handle failures gracefully** - Don't crash on agent failure
|
|
239
|
+
4. **Clean up output files** - Remove temporary files after completion
|
|
240
|
+
5. **Use appropriate agent types** - Match agent to task
|
|
241
|
+
|
|
242
|
+
## Output File Format
|
|
243
|
+
|
|
244
|
+
Background agent output files should include:
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
[START] 2026-01-30T10:00:00Z
|
|
248
|
+
Task: Description here
|
|
249
|
+
|
|
250
|
+
[PROGRESS] Step 1 complete
|
|
251
|
+
[PROGRESS] Step 2 complete
|
|
252
|
+
|
|
253
|
+
[RESULT]
|
|
254
|
+
{
|
|
255
|
+
"success": true,
|
|
256
|
+
"details": "..."
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
[COMPLETE] 2026-01-30T10:05:00Z
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
*Use this template for complex orchestration workflows*
|