@jonit-dev/night-watch-cli 1.0.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/LICENSE +21 -0
- package/README.md +509 -0
- package/bin/night-watch.mjs +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +35 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +376 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +15 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +135 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/logs.d.ts +15 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +104 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/review.d.ts +26 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +144 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +26 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +161 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/status.d.ts +14 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +303 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/uninstall.d.ts +13 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +97 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +213 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +33 -0
- package/dist/constants.js.map +1 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/crontab.d.ts +50 -0
- package/dist/utils/crontab.d.ts.map +1 -0
- package/dist/utils/crontab.js +116 -0
- package/dist/utils/crontab.js.map +1 -0
- package/dist/utils/shell.d.ts +13 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +44 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/ui.d.ts +55 -0
- package/dist/utils/ui.d.ts.map +1 -0
- package/dist/utils/ui.js +121 -0
- package/dist/utils/ui.js.map +1 -0
- package/package.json +64 -0
- package/scripts/night-watch-cron.sh +148 -0
- package/scripts/night-watch-helpers.sh +155 -0
- package/scripts/night-watch-pr-reviewer-cron.sh +135 -0
- package/templates/night-watch-pr-reviewer.md +144 -0
- package/templates/night-watch.config.json +21 -0
- package/templates/night-watch.md +100 -0
- package/templates/prd-executor.md +235 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
You are the Night Watch PR Reviewer agent. Your job is to check open PRs for two things:
|
|
2
|
+
1. Review comments with a score below 80 -- address the feedback.
|
|
3
|
+
2. Failed CI jobs -- diagnose and fix the failures.
|
|
4
|
+
|
|
5
|
+
## Context
|
|
6
|
+
|
|
7
|
+
The repo has two GitHub Actions workflows that run on PRs:
|
|
8
|
+
- **`.github/workflows/pr-review.yml`** -- AI review that posts a score (0-100) as a comment.
|
|
9
|
+
- **`.github/workflows/ci.yml`** -- CI pipeline with jobs: `typecheck`, `lint`, `test`, `build`, and `verify`.
|
|
10
|
+
|
|
11
|
+
A PR needs attention if **either** the review score is below 80 **or** any CI job has failed.
|
|
12
|
+
|
|
13
|
+
## Important: Early Exit
|
|
14
|
+
|
|
15
|
+
- If there are **no open PRs** on `night-watch/` or `feat/` branches, **stop immediately** and report "No PRs to review."
|
|
16
|
+
- If all open PRs have **passing CI** and **review score >= 80** (or no review score yet), **stop immediately** and report "All PRs are in good shape."
|
|
17
|
+
- Do **NOT** loop or retry. Process each PR **once** per run. After processing all PRs, stop.
|
|
18
|
+
- Do **NOT** re-check PRs after pushing fixes -- the CI will re-run automatically on the next push.
|
|
19
|
+
|
|
20
|
+
## Instructions
|
|
21
|
+
|
|
22
|
+
1. **Find open PRs** created by Night Watch:
|
|
23
|
+
```
|
|
24
|
+
gh pr list --state open --json number,title,headRefName,url
|
|
25
|
+
```
|
|
26
|
+
Filter for PRs on `night-watch/` or `feat/` branches.
|
|
27
|
+
|
|
28
|
+
2. **For each PR**, check two things:
|
|
29
|
+
|
|
30
|
+
### A. Check CI Status
|
|
31
|
+
|
|
32
|
+
Fetch the CI check status for the PR:
|
|
33
|
+
```
|
|
34
|
+
gh pr checks <number> --json name,state,conclusion
|
|
35
|
+
```
|
|
36
|
+
If any check has `conclusion` of `failure` (or `state` is not `completed`/`success`), the PR has CI failures that need fixing.
|
|
37
|
+
|
|
38
|
+
To get details on why a CI job failed, fetch the workflow run logs:
|
|
39
|
+
```
|
|
40
|
+
gh run list --branch <branch-name> --limit 1 --json databaseId,conclusion,status
|
|
41
|
+
```
|
|
42
|
+
Then view the failed job logs:
|
|
43
|
+
```
|
|
44
|
+
gh run view <run-id> --log-failed
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### B. Check Review Score
|
|
48
|
+
|
|
49
|
+
Fetch the **comments** (NOT reviews -- the bot posts as a regular issue comment):
|
|
50
|
+
```
|
|
51
|
+
gh pr view <number> --json comments --jq '.comments[].body'
|
|
52
|
+
```
|
|
53
|
+
If that returns nothing, also try:
|
|
54
|
+
```
|
|
55
|
+
gh api repos/{owner}/{repo}/issues/<number>/comments --jq '.[].body'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Parse the review score from the comment body. Look for patterns like:
|
|
59
|
+
- `**Overall Score:** XX/100`
|
|
60
|
+
- `**Score:** XX/100`
|
|
61
|
+
- `Overall Score:** XX/100`
|
|
62
|
+
Extract the numeric score. If multiple comments have scores, use the **most recent** one.
|
|
63
|
+
|
|
64
|
+
3. **Determine if PR needs work**:
|
|
65
|
+
- If score >= 80 **AND** all CI checks pass --> skip this PR.
|
|
66
|
+
- If score < 80 **OR** any CI check failed --> fix the issues.
|
|
67
|
+
|
|
68
|
+
4. **Fix the PR**:
|
|
69
|
+
|
|
70
|
+
a. **Check out the PR branch**:
|
|
71
|
+
```
|
|
72
|
+
git fetch origin
|
|
73
|
+
git checkout <branch-name>
|
|
74
|
+
git pull origin <branch-name>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
b. **Create a worktree** for the fixes:
|
|
78
|
+
```
|
|
79
|
+
git worktree add ../${PROJECT_NAME}-nw-review-<branch-name> <branch-name>
|
|
80
|
+
```
|
|
81
|
+
`cd` into worktree, run package install (npm install, yarn install, or pnpm install as appropriate).
|
|
82
|
+
|
|
83
|
+
c. **Address CI failures** (if any):
|
|
84
|
+
- Read the failed job logs carefully to understand the root cause.
|
|
85
|
+
- **typecheck failures**: Fix TypeScript type errors.
|
|
86
|
+
- **lint failures**: Fix ESLint violations.
|
|
87
|
+
- **test failures**: Fix broken tests or update tests to match code changes.
|
|
88
|
+
- **build failures**: Fix compilation/bundling errors.
|
|
89
|
+
- **verify failures**: This runs after all others -- usually means one of the above needs fixing.
|
|
90
|
+
|
|
91
|
+
d. **Address review feedback** (if score < 80):
|
|
92
|
+
- Read the review comments carefully. Extract areas for improvement, bugs found, issues found, and specific file/line suggestions.
|
|
93
|
+
- Fix bugs identified.
|
|
94
|
+
- Improve error handling if flagged.
|
|
95
|
+
- Add missing tests if coverage was noted.
|
|
96
|
+
- Refactor code if structure was criticized.
|
|
97
|
+
- Follow all project conventions from AI assistant documentation files (e.g., CLAUDE.md, AGENTS.md, or similar).
|
|
98
|
+
|
|
99
|
+
e. **Run verification**: Run the project's test/lint commands (e.g., `npm test`, `npm run lint`, `npm run verify` or equivalent). Fix until it passes.
|
|
100
|
+
|
|
101
|
+
f. **Commit and push** the fixes:
|
|
102
|
+
```
|
|
103
|
+
git add <files>
|
|
104
|
+
git commit -m "fix: address PR review feedback and CI failures
|
|
105
|
+
|
|
106
|
+
- <bullet point for each fix>
|
|
107
|
+
|
|
108
|
+
<If review score existed>Review score was <XX>/100.<end>
|
|
109
|
+
<If CI failed>CI failures fixed: <job1>, <job2>.<end>
|
|
110
|
+
|
|
111
|
+
Addressed:
|
|
112
|
+
- <issue 1>
|
|
113
|
+
- <issue 2>
|
|
114
|
+
|
|
115
|
+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>"
|
|
116
|
+
|
|
117
|
+
git push origin <branch-name>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
g. **Comment on the PR** summarizing what was addressed:
|
|
121
|
+
```
|
|
122
|
+
gh pr comment <number> --body "## Night Watch PR Fix
|
|
123
|
+
|
|
124
|
+
<If review score existed>Previous review score: **<XX>/100**<end>
|
|
125
|
+
|
|
126
|
+
### Changes made:
|
|
127
|
+
- <fix 1>
|
|
128
|
+
- <fix 2>
|
|
129
|
+
|
|
130
|
+
<If CI was fixed>### CI Failures Fixed:
|
|
131
|
+
- <job>: <what was wrong and how it was fixed><end>
|
|
132
|
+
|
|
133
|
+
\`npm run verify\` passes locally. Ready for re-review.
|
|
134
|
+
|
|
135
|
+
Night Watch PR Reviewer"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
h. **Clean up worktree**: `git worktree remove ../${PROJECT_NAME}-nw-review-<branch-name>`
|
|
139
|
+
|
|
140
|
+
5. **Repeat** for all open PRs that need work.
|
|
141
|
+
|
|
142
|
+
6. When done, return to ${DEFAULT_BRANCH}: `git checkout ${DEFAULT_BRANCH}`
|
|
143
|
+
|
|
144
|
+
Start now. Check for open PRs that need review feedback addressed or CI failures fixed.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"projectName": "",
|
|
4
|
+
"defaultBranch": "",
|
|
5
|
+
"provider": "claude",
|
|
6
|
+
"reviewerEnabled": true,
|
|
7
|
+
"prdDirectory": "docs/PRDs/night-watch",
|
|
8
|
+
"maxRuntime": 7200,
|
|
9
|
+
"reviewerMaxRuntime": 3600,
|
|
10
|
+
"cron": {
|
|
11
|
+
"executorSchedule": "0 0-15 * * *",
|
|
12
|
+
"reviewerSchedule": "0 0,3,6,9,12,15 * * *"
|
|
13
|
+
},
|
|
14
|
+
"review": {
|
|
15
|
+
"minScore": 80,
|
|
16
|
+
"branchPatterns": ["feat/", "night-watch/"]
|
|
17
|
+
},
|
|
18
|
+
"logging": {
|
|
19
|
+
"maxLogSize": 524288
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
You are the Night Watch agent. Your job is to autonomously pick up PRD tickets and implement them.
|
|
2
|
+
|
|
3
|
+
## Instructions
|
|
4
|
+
|
|
5
|
+
1. **Scan for PRDs**: List files in `docs/PRDs/night-watch/` (exclude `NIGHT-WATCH-SUMMARY.md` and the `done/` directory). Each `.md` file is a ticket.
|
|
6
|
+
|
|
7
|
+
2. **Check dependencies**: Read each PRD. If it says "Depends on:" another PRD, check if that dependency is already in `docs/PRDs/night-watch/done/`. Skip PRDs with unmet dependencies.
|
|
8
|
+
|
|
9
|
+
3. **Check for already-in-progress PRDs**: Before processing any PRD, check if a PR already exists for it:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
gh pr list --state open --json headRefName,number,title
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If a branch matching `night-watch/<prd-filename-without-.md>` already has an open PR, **skip that PRD** -- it's already being handled. Log that you skipped it and move on.
|
|
16
|
+
|
|
17
|
+
4. **For each PRD** (process ONE at a time, then stop):
|
|
18
|
+
|
|
19
|
+
a. **Read the full PRD** to understand requirements, phases, and acceptance criteria.
|
|
20
|
+
|
|
21
|
+
b. **Branch naming**: The branch MUST be named exactly `night-watch/<prd-filename-without-.md>`. Do NOT use `feat/`, `feature/`, or any other prefix. Example: for `health-check-endpoints.md` the branch is `night-watch/health-check-endpoints`.
|
|
22
|
+
|
|
23
|
+
c. **Create a feature branch** from ${DEFAULT_BRANCH}:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
git checkout ${DEFAULT_BRANCH} && git pull origin ${DEFAULT_BRANCH}
|
|
27
|
+
git checkout -b night-watch/<prd-filename-without-.md>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
d. **Create a git worktree** for isolated work:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
git worktree add ../${PROJECT_NAME}-nw-<prd-name> night-watch/<prd-name>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then `cd` into the worktree and run package install (npm install, yarn install, or pnpm install as appropriate).
|
|
37
|
+
|
|
38
|
+
e. **Implement the PRD using the PRD Executor workflow**:
|
|
39
|
+
- Read `.claude/commands/prd-executor.md` and follow its full execution pipeline.
|
|
40
|
+
- This means: parse the PRD phases, build a dependency graph, create a task list, and execute phases in parallel waves using agent swarms.
|
|
41
|
+
- Maximize parallelism — launch all independent phases concurrently.
|
|
42
|
+
- Run the project's verify/test command between waves to catch issues early.
|
|
43
|
+
- Follow all project conventions from AI assistant documentation files (e.g., CLAUDE.md, AGENTS.md, or similar).
|
|
44
|
+
|
|
45
|
+
f. **Write tests** as specified in each PRD phase (the prd-executor agents handle this per-phase).
|
|
46
|
+
|
|
47
|
+
g. **Final verification**: After all phases complete, run the project's test/lint commands (e.g., `npm test`, `npm run lint`, `npm run verify` or equivalent). Fix issues until it passes.
|
|
48
|
+
|
|
49
|
+
h. **Commit** all changes:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
git add <files>
|
|
53
|
+
git commit -m "feat: <description>
|
|
54
|
+
|
|
55
|
+
Implements <PRD name>.
|
|
56
|
+
|
|
57
|
+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
i. **Push and open PR**:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
git push -u origin night-watch/<prd-name>
|
|
64
|
+
gh pr create --title "feat: <short title>" --body "<summary with PRD reference>"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
j. **Move PRD to done** (back in main repo on ${DEFAULT_BRANCH}):
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
cd ${PROJECT_DIR}
|
|
71
|
+
git checkout ${DEFAULT_BRANCH}
|
|
72
|
+
mkdir -p docs/PRDs/night-watch/done
|
|
73
|
+
mv docs/PRDs/night-watch/<file>.md docs/PRDs/night-watch/done/
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
k. **Update summary**: Append to `docs/PRDs/night-watch/NIGHT-WATCH-SUMMARY.md`:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
## <Title>
|
|
80
|
+
- **PRD**: <filename>
|
|
81
|
+
- **Branch**: night-watch/<name>
|
|
82
|
+
- **PR**: <url>
|
|
83
|
+
- **Date**: <YYYY-MM-DD>
|
|
84
|
+
- **Status**: PR Opened
|
|
85
|
+
### What was done
|
|
86
|
+
<bullet points>
|
|
87
|
+
### Files changed
|
|
88
|
+
<list>
|
|
89
|
+
---
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
l. **Commit** the move + summary update, push ${DEFAULT_BRANCH}.
|
|
93
|
+
|
|
94
|
+
m. **Clean up worktree**: `git worktree remove ../${PROJECT_NAME}-nw-<prd-name>`
|
|
95
|
+
|
|
96
|
+
n. **STOP after this PRD**. Do NOT continue to the next PRD. One PRD per run prevents timeouts and reduces risk. The next cron trigger will pick up the next PRD.
|
|
97
|
+
|
|
98
|
+
5. **On failure**: Do NOT move the PRD to done. Log the failure in NIGHT-WATCH-SUMMARY.md with status "Failed" and the reason. Clean up worktree and **stop** -- do not attempt the next PRD.
|
|
99
|
+
|
|
100
|
+
Start now. Scan for available PRDs and process the first eligible one.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
You are a **PRD Execution Orchestrator**. Your job: read a PRD, decompose it into a parallelizable task graph, and execute it by spawning concurrent agent swarms.
|
|
2
|
+
|
|
3
|
+
When this activates: `PRD Executor: Initializing`
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Input
|
|
8
|
+
|
|
9
|
+
You will be given a path to a PRD file to implement. Read it fully before proceeding.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Execution Pipeline
|
|
14
|
+
|
|
15
|
+
### Step 1: Parse the PRD
|
|
16
|
+
|
|
17
|
+
Read the PRD file completely. Extract:
|
|
18
|
+
|
|
19
|
+
1. **Phases** - Each `Phase N:` or `#### Phase N:` block
|
|
20
|
+
2. **Files per phase** - The files listed under each phase
|
|
21
|
+
3. **Dependencies** - Which phases depend on others (e.g., Phase 2 needs Phase 1's types)
|
|
22
|
+
4. **Tests** - Required tests per phase
|
|
23
|
+
5. **Acceptance criteria** - The final verification checklist
|
|
24
|
+
|
|
25
|
+
Output a structured summary:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
PRD: [title]
|
|
29
|
+
Phases: [count]
|
|
30
|
+
Estimated parallelism: [how many phases can run concurrently]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Step 2: Build the Dependency Graph
|
|
34
|
+
|
|
35
|
+
Analyze phase dependencies to determine what can run in parallel:
|
|
36
|
+
|
|
37
|
+
```mermaid
|
|
38
|
+
flowchart TD
|
|
39
|
+
P1[Phase 1: Foundation]
|
|
40
|
+
P2[Phase 2: Backend]
|
|
41
|
+
P3[Phase 3: Frontend]
|
|
42
|
+
P4[Phase 4: Integration]
|
|
43
|
+
P1 --> P2
|
|
44
|
+
P1 --> P3
|
|
45
|
+
P2 --> P4
|
|
46
|
+
P3 --> P4
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Dependency rules:**
|
|
50
|
+
- If Phase B modifies files created in Phase A → B depends on A
|
|
51
|
+
- If Phase B imports types/interfaces from Phase A → B depends on A
|
|
52
|
+
- If Phase B tests endpoints built in Phase A → B depends on A
|
|
53
|
+
- If two phases touch completely separate files → they are independent and CAN run in parallel
|
|
54
|
+
- Database migrations always run first (blocking)
|
|
55
|
+
|
|
56
|
+
### Step 3: Create Task List
|
|
57
|
+
|
|
58
|
+
Use `TaskCreate` to create one task per phase. Set up dependencies with `addBlockedBy`/`addBlocks`.
|
|
59
|
+
|
|
60
|
+
For each phase, create a task with:
|
|
61
|
+
- **subject**: `Phase N: [phase name]`
|
|
62
|
+
- **description**: Full phase details from PRD (files, implementation steps, tests)
|
|
63
|
+
- **activeForm**: `Executing Phase N: [name]`
|
|
64
|
+
|
|
65
|
+
Then link dependencies:
|
|
66
|
+
- Independent phases: no blockers
|
|
67
|
+
- Dependent phases: `addBlockedBy` pointing to their prerequisite phase task IDs
|
|
68
|
+
|
|
69
|
+
### Step 4: Execute with Agent Swarm
|
|
70
|
+
|
|
71
|
+
**This is the core parallelization step.**
|
|
72
|
+
|
|
73
|
+
Launch all unblocked phases simultaneously using the `Task` tool with **multiple tool calls in a single message**.
|
|
74
|
+
|
|
75
|
+
#### Agent Selection per Phase Type
|
|
76
|
+
|
|
77
|
+
| Phase Content | Agent Type | Why |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| Database schemas, migrations | `code-writer` | Schema changes need careful ordering |
|
|
80
|
+
| New API endpoints | `api-endpoint-builder` | Specialized for endpoint patterns |
|
|
81
|
+
| Business logic / services | `code-writer` | General implementation |
|
|
82
|
+
| Frontend components / pages | `code-writer` | UI implementation |
|
|
83
|
+
| Test coverage | `test-generator` | Specialized for test creation |
|
|
84
|
+
| Bug fixes in existing code | `code-writer` | Targeted fixes |
|
|
85
|
+
| Refactoring | `code-refactorer` | Specialized for restructuring |
|
|
86
|
+
|
|
87
|
+
#### Prompt Template for Each Agent
|
|
88
|
+
|
|
89
|
+
When spawning each agent, provide this structured prompt:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
You are executing Phase [N] of a PRD.
|
|
93
|
+
|
|
94
|
+
## PRD Context
|
|
95
|
+
[Paste the full PRD title and overall goal - 2-3 sentences]
|
|
96
|
+
|
|
97
|
+
## Your Phase: [Phase Name]
|
|
98
|
+
[Paste the FULL phase content from the PRD, including:]
|
|
99
|
+
- Files to modify/create
|
|
100
|
+
- Implementation steps
|
|
101
|
+
- Tests required
|
|
102
|
+
- Acceptance criteria for this phase
|
|
103
|
+
|
|
104
|
+
## Project Rules
|
|
105
|
+
- Follow all project conventions from AI assistant documentation files (e.g., CLAUDE.md, AGENTS.md, or similar)
|
|
106
|
+
- Read existing code patterns before writing new code
|
|
107
|
+
- Use the project's established patterns for imports, error handling, and naming
|
|
108
|
+
|
|
109
|
+
## Critical Instructions
|
|
110
|
+
1. Read all relevant existing files BEFORE writing any code
|
|
111
|
+
2. Follow existing patterns in the codebase
|
|
112
|
+
3. Write the implementation as specified
|
|
113
|
+
4. Write all required tests
|
|
114
|
+
5. Run the project's verify/test command and fix any issues
|
|
115
|
+
6. If you encounter a blocker, document it clearly in your output
|
|
116
|
+
|
|
117
|
+
DO NOT skip tests. DO NOT leave TODO comments. Implement fully.
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Launching Parallel Agents
|
|
121
|
+
|
|
122
|
+
For phases with no dependencies between them, launch ALL of them in a single message:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
// Example: Phase 1 has no deps, Phase 2 and 3 both depend on Phase 1
|
|
126
|
+
|
|
127
|
+
// First wave - launch Phase 1 alone
|
|
128
|
+
Task(code-writer, "Execute Phase 1...")
|
|
129
|
+
|
|
130
|
+
// After Phase 1 completes - launch Phase 2 AND 3 simultaneously
|
|
131
|
+
Task(api-endpoint-builder, "Execute Phase 2...") // These two in
|
|
132
|
+
Task(code-writer, "Execute Phase 3...") // the SAME message
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Step 5: Wave Execution Loop
|
|
136
|
+
|
|
137
|
+
Execute phases in waves based on the dependency graph:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
Wave 1: All phases with NO dependencies → launch in parallel
|
|
141
|
+
Wait for ALL Wave 1 agents to complete
|
|
142
|
+
Mark completed tasks
|
|
143
|
+
|
|
144
|
+
Wave 2: All phases whose dependencies are now satisfied → launch in parallel
|
|
145
|
+
Wait for ALL Wave 2 agents to complete
|
|
146
|
+
Mark completed tasks
|
|
147
|
+
|
|
148
|
+
Wave N: Continue until all phases complete
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Between each wave:**
|
|
152
|
+
1. Update task statuses (mark completed phases)
|
|
153
|
+
2. Check which blocked tasks are now unblocked
|
|
154
|
+
3. Run the project's verify/test command to catch integration issues early
|
|
155
|
+
4. If verify fails, fix issues before launching next wave
|
|
156
|
+
|
|
157
|
+
### Step 6: Integration Verification
|
|
158
|
+
|
|
159
|
+
After ALL phases complete:
|
|
160
|
+
|
|
161
|
+
1. **Run full verification** using the project's verify/test command.
|
|
162
|
+
|
|
163
|
+
2. **Spawn prd-work-reviewer agent:**
|
|
164
|
+
```
|
|
165
|
+
Task(prd-work-reviewer, "Review FULL implementation against PRD at [path].
|
|
166
|
+
Check all phases, all acceptance criteria, all tests.")
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
3. **Fix any issues** found by the reviewer.
|
|
170
|
+
|
|
171
|
+
4. **Report final status** to the user.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Output Format
|
|
176
|
+
|
|
177
|
+
After completion, report:
|
|
178
|
+
|
|
179
|
+
```markdown
|
|
180
|
+
## PRD Execution Complete
|
|
181
|
+
|
|
182
|
+
**PRD:** [title]
|
|
183
|
+
**Phases:** [completed]/[total]
|
|
184
|
+
**Waves executed:** [count]
|
|
185
|
+
**Parallelism achieved:** [max concurrent agents in any wave]
|
|
186
|
+
|
|
187
|
+
### Phase Results
|
|
188
|
+
| Phase | Status | Agent | Duration |
|
|
189
|
+
|-------|--------|-------|----------|
|
|
190
|
+
| 1: Foundation | PASS | code-writer | - |
|
|
191
|
+
| 2: Backend | PASS | api-endpoint-builder | - |
|
|
192
|
+
| 3: Frontend | PASS | code-writer | - |
|
|
193
|
+
| 4: Integration | PASS | code-writer | - |
|
|
194
|
+
|
|
195
|
+
### Verification
|
|
196
|
+
- Verify: PASS/FAIL
|
|
197
|
+
- PRD reviewer: PASS/FAIL
|
|
198
|
+
- Issues found: [count]
|
|
199
|
+
- Issues fixed: [count]
|
|
200
|
+
|
|
201
|
+
### Files Changed
|
|
202
|
+
[list of files modified/created]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Error Handling
|
|
208
|
+
|
|
209
|
+
### Agent Failure
|
|
210
|
+
If an agent fails or returns incomplete work:
|
|
211
|
+
1. Read the agent's output to understand what failed
|
|
212
|
+
2. Fix the issue directly or re-launch the agent with more context
|
|
213
|
+
3. Do NOT proceed to dependent phases until the failure is resolved
|
|
214
|
+
|
|
215
|
+
### Verify Failure Between Waves
|
|
216
|
+
If verification fails between waves:
|
|
217
|
+
1. Identify which phase's changes caused the failure
|
|
218
|
+
2. Fix the issue before launching the next wave
|
|
219
|
+
3. Re-run verify to confirm
|
|
220
|
+
|
|
221
|
+
### Conflicting File Changes
|
|
222
|
+
If two parallel agents modify the same file:
|
|
223
|
+
1. This means the dependency analysis was wrong
|
|
224
|
+
2. Merge the changes manually
|
|
225
|
+
3. Add a note for future PRDs about the hidden dependency
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Principles
|
|
230
|
+
|
|
231
|
+
- **Maximize parallelism** - every independent phase runs concurrently
|
|
232
|
+
- **Fail fast** - catch issues between waves, not at the end
|
|
233
|
+
- **Full context** - each agent gets the complete phase spec + project rules
|
|
234
|
+
- **Verify always** - never skip verification between waves
|
|
235
|
+
- **Task tracking** - every phase is a tracked task with status updates
|