claude-mcp-workflow 0.1.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/.claude-plugin/plugin.json +13 -0
- package/.mcp.json +9 -0
- package/LICENSE +21 -0
- package/README.md +260 -0
- package/build/dashboard.d.ts +4 -0
- package/build/dashboard.d.ts.map +1 -0
- package/build/dashboard.js +91 -0
- package/build/dashboard.js.map +1 -0
- package/build/engine.d.ts +55 -0
- package/build/engine.d.ts.map +1 -0
- package/build/engine.js +486 -0
- package/build/engine.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +60 -0
- package/build/index.js.map +1 -0
- package/build/loader.d.ts +29 -0
- package/build/loader.d.ts.map +1 -0
- package/build/loader.js +166 -0
- package/build/loader.js.map +1 -0
- package/build/modifier.d.ts +42 -0
- package/build/modifier.d.ts.map +1 -0
- package/build/modifier.js +96 -0
- package/build/modifier.js.map +1 -0
- package/build/storage.d.ts +12 -0
- package/build/storage.d.ts.map +1 -0
- package/build/storage.js +62 -0
- package/build/storage.js.map +1 -0
- package/build/tools.d.ts +7 -0
- package/build/tools.d.ts.map +1 -0
- package/build/tools.js +316 -0
- package/build/tools.js.map +1 -0
- package/build/types.d.ts +417 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +82 -0
- package/build/types.js.map +1 -0
- package/dashboard/dagre.min.js +801 -0
- package/dashboard/index.html +652 -0
- package/hooks/hooks.json +24 -0
- package/hooks/workflow-cleanup.sh +51 -0
- package/hooks/workflow-start.sh +79 -0
- package/package.json +44 -0
- package/templates/bug-fix.yaml +283 -0
- package/templates/code-review.yaml +164 -0
- package/templates/coding.yaml +176 -0
- package/templates/debugging.yaml +162 -0
- package/templates/explore.yaml +90 -0
- package/templates/file-code.yaml +69 -0
- package/templates/file-review.yaml +164 -0
- package/templates/investigate.yaml +84 -0
- package/templates/master.yaml +202 -0
- package/templates/new-feature.yaml +41 -0
- package/templates/planning.yaml +85 -0
- package/templates/refactoring.yaml +56 -0
- package/templates/reflection.yaml +61 -0
- package/templates/skills/architecture/SKILL.md +55 -0
- package/templates/skills/coding-skill-selector/SKILL.md +25 -0
- package/templates/skills/lang-haxe/SKILL.md +257 -0
- package/templates/skills/lang-python/SKILL.md +16 -0
- package/templates/skills/math/SKILL.md +14 -0
- package/templates/skills/preferences/SKILL.md +25 -0
- package/templates/skills/task-delegation/SKILL.md +53 -0
- package/templates/skills/web-reading/SKILL.md +62 -0
- package/templates/subagent.yaml +67 -0
- package/templates/testing.yaml +120 -0
- package/templates/web-research.yaml +53 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# SessionEnd hook: abandon active workflow sessions for this Claude Code instance.
|
|
3
|
+
# Skips sessions referenced in plan files (they should survive context clears).
|
|
4
|
+
# Modifies JSON files directly — does NOT depend on MCP server / dashboard being alive.
|
|
5
|
+
read -t 1 -r INPUT
|
|
6
|
+
STATE_DIR="${STATE_DIR:-$HOME/.claude/workflow-state}"
|
|
7
|
+
PLANS_DIR="$HOME/.claude/plans"
|
|
8
|
+
NOW=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
|
|
9
|
+
ABANDONED_SIDS=()
|
|
10
|
+
|
|
11
|
+
for f in "$STATE_DIR"/*.json; do
|
|
12
|
+
[ -f "$f" ] || continue
|
|
13
|
+
SID=$(jq -r "select(.stack | length > 0) | select(.context.claude_code_pid == $PPID) | .session_id" "$f" 2>/dev/null)
|
|
14
|
+
[ -n "$SID" ] || continue
|
|
15
|
+
# Skip if session referenced in plan files
|
|
16
|
+
[ -d "$PLANS_DIR" ] && grep -rql "$SID" "$PLANS_DIR"/ 2>/dev/null && continue
|
|
17
|
+
# Abandon: clear stack, set outcome, append history entry
|
|
18
|
+
TMP="${f}.tmp"
|
|
19
|
+
jq --arg now "$NOW" '
|
|
20
|
+
.history += [{ frame: .active_frame, event: "abandon", at: $now }] |
|
|
21
|
+
.stack = [] |
|
|
22
|
+
.active_frame = -1 |
|
|
23
|
+
.outcome = "abandoned" |
|
|
24
|
+
.updated_at = $now
|
|
25
|
+
' "$f" > "$TMP" 2>/dev/null && mv "$TMP" "$f" || rm -f "$TMP"
|
|
26
|
+
ABANDONED_SIDS+=("$SID")
|
|
27
|
+
done
|
|
28
|
+
|
|
29
|
+
# Cascade: abandon children of abandoned sessions
|
|
30
|
+
cascade_abandon() {
|
|
31
|
+
local parent_sid="$1"
|
|
32
|
+
for f in "$STATE_DIR"/*.json; do
|
|
33
|
+
[ -f "$f" ] || continue
|
|
34
|
+
local child_sid
|
|
35
|
+
child_sid=$(jq -r --arg pid "$parent_sid" 'select(.parent_session_id == $pid) | select(.stack | length > 0) | .session_id' "$f" 2>/dev/null)
|
|
36
|
+
[ -n "$child_sid" ] || continue
|
|
37
|
+
TMP="${f}.tmp"
|
|
38
|
+
jq --arg now "$NOW" '
|
|
39
|
+
.history += [{ frame: .active_frame, event: "cascade_abandon", at: $now }] |
|
|
40
|
+
.stack = [] |
|
|
41
|
+
.active_frame = -1 |
|
|
42
|
+
.outcome = "abandoned" |
|
|
43
|
+
.updated_at = $now
|
|
44
|
+
' "$f" > "$TMP" 2>/dev/null && mv "$TMP" "$f" || rm -f "$TMP"
|
|
45
|
+
cascade_abandon "$child_sid"
|
|
46
|
+
done
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for sid in "${ABANDONED_SIDS[@]}"; do
|
|
50
|
+
cascade_abandon "$sid"
|
|
51
|
+
done
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# SessionStart hook: detect context (new session / plan resume / context clear)
|
|
3
|
+
# and instruct agent accordingly.
|
|
4
|
+
|
|
5
|
+
# --- 0. Ensure base skills exist ---
|
|
6
|
+
# lang-* skills are dependencies of coding-skill-selector — only copied together with it.
|
|
7
|
+
# If user deletes a lang-* skill, it stays deleted until coding-skill-selector is also removed.
|
|
8
|
+
SKILLS_SRC="${CLAUDE_PLUGIN_ROOT}/templates/skills"
|
|
9
|
+
SKILLS_DST="$HOME/.claude/skills"
|
|
10
|
+
if [ -d "$SKILLS_SRC" ]; then
|
|
11
|
+
mkdir -p "$SKILLS_DST"
|
|
12
|
+
COPY_LANG=false
|
|
13
|
+
[ ! -d "$SKILLS_DST/coding-skill-selector" ] && COPY_LANG=true
|
|
14
|
+
for skill_dir in "$SKILLS_SRC"/*/; do
|
|
15
|
+
[ -d "$skill_dir" ] || continue
|
|
16
|
+
skill_name=$(basename "$skill_dir")
|
|
17
|
+
if [ "$COPY_LANG" = false ] && [[ "$skill_name" == lang-* ]]; then continue; fi
|
|
18
|
+
if [ ! -d "$SKILLS_DST/$skill_name" ]; then
|
|
19
|
+
cp -r "$skill_dir" "$SKILLS_DST/$skill_name"
|
|
20
|
+
fi
|
|
21
|
+
done
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
read -t 1 -r INPUT
|
|
25
|
+
TRANSCRIPT=$(echo "$INPUT" | jq -r '.transcript_path // empty')
|
|
26
|
+
STATE_DIR="${STATE_DIR:-$HOME/.claude/workflow-state}"
|
|
27
|
+
PLANS_DIR="$HOME/.claude/plans"
|
|
28
|
+
|
|
29
|
+
ZED_SUFFIX=""
|
|
30
|
+
if [[ -n "$ZED_ENVIRONMENT" ]]; then
|
|
31
|
+
ZED_SUFFIX=" Then load skill ide-zed (Skill tool)."
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# --- Helper: find active planning session from plan files ---
|
|
35
|
+
find_plan_session() {
|
|
36
|
+
[ -d "$PLANS_DIR" ] || return
|
|
37
|
+
for plan in "$PLANS_DIR"/*.md; do
|
|
38
|
+
[ -f "$plan" ] || continue
|
|
39
|
+
# Extract session ID from ## Workflow section (Session line: `<hex>`)
|
|
40
|
+
local sid
|
|
41
|
+
sid=$(grep -A5 '^## Workflow' "$plan" | grep 'Session' | grep -oE '[a-f0-9]{7,}' | head -1)
|
|
42
|
+
[ -n "$sid" ] || continue
|
|
43
|
+
# Check if this session is active and in planning state
|
|
44
|
+
local state_file="$STATE_DIR/${sid}.json"
|
|
45
|
+
[ -f "$state_file" ] || continue
|
|
46
|
+
local wf
|
|
47
|
+
wf=$(jq -r 'select(.stack | length > 0) | .stack[-1].workflow // empty' "$state_file" 2>/dev/null)
|
|
48
|
+
if [ "$wf" = "planning" ]; then
|
|
49
|
+
echo "$sid"
|
|
50
|
+
return
|
|
51
|
+
fi
|
|
52
|
+
done
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# --- 1. Transcript exists and has content → same process ---
|
|
56
|
+
if [ -n "$TRANSCRIPT" ] && [ -s "$TRANSCRIPT" ]; then
|
|
57
|
+
# Check for ExitPlanMode → plan resume after context clear
|
|
58
|
+
if grep -q 'ExitPlanMode' "$TRANSCRIPT" 2>/dev/null; then
|
|
59
|
+
PLAN_SID=$(grep -oE 'transition\(\\"[a-f0-9]+\\"' "$TRANSCRIPT" | tail -1 | grep -oE '[a-f0-9]{7,}')
|
|
60
|
+
if [ -n "$PLAN_SID" ]; then
|
|
61
|
+
echo "PLAN RESUME (same process): call transition(\"$PLAN_SID\", \"planned\") to resume planning session.$ZED_SUFFIX"
|
|
62
|
+
exit 0
|
|
63
|
+
fi
|
|
64
|
+
fi
|
|
65
|
+
# Has content but no plan → context clear
|
|
66
|
+
echo "Context was cleared. Call status() to check for active session and restore context.$ZED_SUFFIX"
|
|
67
|
+
exit 0
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# --- 2. Transcript empty or missing → new process ---
|
|
71
|
+
# Check plans/ for active planning sessions (cross-process plan resume)
|
|
72
|
+
PLAN_SID=$(find_plan_session)
|
|
73
|
+
if [ -n "$PLAN_SID" ]; then
|
|
74
|
+
echo "PLAN RESUME (new process): active planning session $PLAN_SID found. Call transition(\"$PLAN_SID\", \"planned\") to resume.$ZED_SUFFIX"
|
|
75
|
+
exit 0
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# --- 3. Nothing found → fresh start ---
|
|
79
|
+
echo "STOP. Call mcp__plugin_workflow_wf__start (no args) first.$ZED_SUFFIX"
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "claude-mcp-workflow",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Structured workflow orchestration for AI agents via finite-state machines",
|
|
5
|
+
"author": "AxGord <axgord@gmail.com> (https://github.com/AxGord)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/AxGord/claude-workflow.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/AxGord/claude-workflow",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "build/index.js",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"start": "node build/index.js"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@dagrejs/dagre": "^1.1.4",
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
22
|
+
"express": "^4.21.0",
|
|
23
|
+
"proper-lockfile": "^4.1.2",
|
|
24
|
+
"yaml": "^2.6.0",
|
|
25
|
+
"zod": "^3.24.0"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"build/",
|
|
29
|
+
"templates/",
|
|
30
|
+
"hooks/",
|
|
31
|
+
"dashboard/",
|
|
32
|
+
".claude-plugin/",
|
|
33
|
+
".mcp.json"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/express": "^5.0.0",
|
|
40
|
+
"@types/node": "^22.10.0",
|
|
41
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
42
|
+
"typescript": "^5.7.0"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
name: bug-fix
|
|
2
|
+
description: "Standard bug fix workflow"
|
|
3
|
+
initial: classify
|
|
4
|
+
max_transitions: 50
|
|
5
|
+
|
|
6
|
+
states:
|
|
7
|
+
classify:
|
|
8
|
+
task: "Classify bug type"
|
|
9
|
+
prompt: |
|
|
10
|
+
Classify the bug before proceeding.
|
|
11
|
+
|
|
12
|
+
Look at the user's report:
|
|
13
|
+
- Does it include a screenshot or describe a VISUAL problem (layout, overlap, wrong color, missing element)?
|
|
14
|
+
- Or is it a LOGIC problem (wrong data, crash, incorrect calculation, serialization error)?
|
|
15
|
+
|
|
16
|
+
Choose:
|
|
17
|
+
- `visual` → UI/layout bug — requires debug bridge, screenshots, visual reproduction
|
|
18
|
+
- `logic` → data/logic bug — reproducible via unit tests or logs
|
|
19
|
+
transitions:
|
|
20
|
+
visual: reproduce_visual
|
|
21
|
+
logic: reproduce_logic
|
|
22
|
+
|
|
23
|
+
reproduce_visual:
|
|
24
|
+
task: "Reproduce the bug visually"
|
|
25
|
+
prompt: |
|
|
26
|
+
Reproduce the bug VISUALLY before proceeding — reading code is NOT reproduction.
|
|
27
|
+
|
|
28
|
+
DO NOT fix the bug here. You may add trace/log statements to help reproduce,
|
|
29
|
+
but do NOT modify production logic. The fix belongs in the `fix` state.
|
|
30
|
+
|
|
31
|
+
MANDATORY STEPS (all required, in order):
|
|
32
|
+
1. Understand the exact user path that triggers the bug (which button, which file, which action)
|
|
33
|
+
2. Build and launch the app with debug bridge (`-debug -DFASTBOOT -DDEBUG_API -DHEADLESS`)
|
|
34
|
+
3. Follow the SAME path the user described to trigger the bug
|
|
35
|
+
4. Take a screenshot and VERIFY the bug is visible
|
|
36
|
+
5. Describe what you see — compare with the user's report
|
|
37
|
+
|
|
38
|
+
STOP — self-check before transitioning:
|
|
39
|
+
- Did you LAUNCH the app and take a SCREENSHOT? If not, you haven't reproduced.
|
|
40
|
+
- Can you show the screenshot? If not, you haven't reproduced yet.
|
|
41
|
+
- "I can see from the code that..." is NOT evidence. Run the app.
|
|
42
|
+
|
|
43
|
+
DO NOT skip visual reproduction. Running unit tests is NOT reproduction for visual bugs.
|
|
44
|
+
DO NOT transition to `reproduced` without a screenshot proving the bug exists.
|
|
45
|
+
|
|
46
|
+
If the bug requires file operations, use the tm-interactive-debug skill recipes.
|
|
47
|
+
transitions:
|
|
48
|
+
reproduced: diagnose
|
|
49
|
+
cant_reproduce: clarify
|
|
50
|
+
|
|
51
|
+
reproduce_logic:
|
|
52
|
+
task: "Reproduce the bug with tests"
|
|
53
|
+
prompt: |
|
|
54
|
+
Reproduce the bug by EXECUTING code — reading source is NOT reproduction.
|
|
55
|
+
|
|
56
|
+
DO NOT fix the bug here. You may add trace/log statements or write test code
|
|
57
|
+
to help reproduce, but do NOT modify production logic. The fix belongs in the `fix` state.
|
|
58
|
+
|
|
59
|
+
MANDATORY STEPS (all required, in order):
|
|
60
|
+
1. Understand the exact scenario that triggers the bug
|
|
61
|
+
2. Write a minimal FAILING test that demonstrates the wrong behavior
|
|
62
|
+
3. BUILD and RUN the test — show the actual output
|
|
63
|
+
4. Describe: EXPECTED vs ACTUAL — what should happen vs what does happen
|
|
64
|
+
|
|
65
|
+
STOP — self-check before transitioning:
|
|
66
|
+
- Did you EXECUTE something (build + run)? Reading code ≠ reproduction.
|
|
67
|
+
- Can you paste the failing output? If not, you haven't reproduced yet.
|
|
68
|
+
- "I can see from the code that..." is NOT evidence. Run the code.
|
|
69
|
+
|
|
70
|
+
DO NOT transition to `reproduced` without concrete executed evidence
|
|
71
|
+
(test failure output, wrong runtime output, crash log).
|
|
72
|
+
|
|
73
|
+
If the bug is hard to cover with a unit test (UI state, complex setup, timing),
|
|
74
|
+
transition `try_visual` to reproduce via debug bridge instead.
|
|
75
|
+
transitions:
|
|
76
|
+
reproduced: diagnose
|
|
77
|
+
try_visual: reproduce_visual
|
|
78
|
+
cant_reproduce: clarify
|
|
79
|
+
|
|
80
|
+
diagnose:
|
|
81
|
+
task: "Diagnose root cause"
|
|
82
|
+
prompt: |
|
|
83
|
+
Find the root cause of the bug.
|
|
84
|
+
|
|
85
|
+
DO NOT fix the bug here. You may add trace/log statements to narrow down
|
|
86
|
+
the cause, but do NOT modify production logic. The fix belongs in the `fix` state.
|
|
87
|
+
|
|
88
|
+
After diagnosing, assess how many files need fixing:
|
|
89
|
+
- 1 file → `single`
|
|
90
|
+
- 2+ files → `multi`
|
|
91
|
+
transitions:
|
|
92
|
+
single: fix_single
|
|
93
|
+
multi: fix_delegate
|
|
94
|
+
unclear: add_logging
|
|
95
|
+
|
|
96
|
+
add_logging:
|
|
97
|
+
task: "Add diagnostic logging"
|
|
98
|
+
prompt: "Add logging for diagnostics, run again."
|
|
99
|
+
max_visits: 3
|
|
100
|
+
transitions:
|
|
101
|
+
single: fix_single
|
|
102
|
+
multi: fix_delegate
|
|
103
|
+
still_unclear: escalate
|
|
104
|
+
|
|
105
|
+
fix_single:
|
|
106
|
+
sub_workflow: file-code
|
|
107
|
+
on_complete: review
|
|
108
|
+
on_fail: review
|
|
109
|
+
|
|
110
|
+
fix_delegate:
|
|
111
|
+
task: "Delegate per-file fixes to agents"
|
|
112
|
+
prompt: |
|
|
113
|
+
MANDATORY FIRST ACTION — call `Skill("coding-skill-selector")` to load language/domain skills BEFORE doing anything else in this state. Do NOT skip this step.
|
|
114
|
+
|
|
115
|
+
The fix spans multiple files. Produce a per-file plan with interface contracts,
|
|
116
|
+
then spawn one Agent per file for parallel implementation.
|
|
117
|
+
Use `subagent_type="general-purpose"`, `model="opus"`.
|
|
118
|
+
|
|
119
|
+
For each file, include in the agent prompt VERBATIM:
|
|
120
|
+
---
|
|
121
|
+
IMPORTANT: Override the default CLAUDE.md rule about start().
|
|
122
|
+
Do NOT call start() without arguments.
|
|
123
|
+
Instead, your FIRST action must be:
|
|
124
|
+
mcp__plugin_workflow_wf__start({ workflow: "file-code", parent_session_id: "<SESSION_ID>" })
|
|
125
|
+
where <SESSION_ID> is the current session ID (substitute it before sending).
|
|
126
|
+
Then follow the file-code workflow states until completion.
|
|
127
|
+
---
|
|
128
|
+
Also include:
|
|
129
|
+
- The file path
|
|
130
|
+
- The diagnosis and root cause
|
|
131
|
+
- The per-file fix plan
|
|
132
|
+
- Interface contracts with other files
|
|
133
|
+
|
|
134
|
+
Launch ALL file agents in parallel. Wait for all to complete. Collect reports.
|
|
135
|
+
|
|
136
|
+
After ALL reports are collected:
|
|
137
|
+
1. Abort orphaned child workflow sessions.
|
|
138
|
+
2. Transition `done`.
|
|
139
|
+
transitions:
|
|
140
|
+
done: integrate
|
|
141
|
+
|
|
142
|
+
integrate:
|
|
143
|
+
task: "Cross-file integration check"
|
|
144
|
+
prompt: |
|
|
145
|
+
All file agents have completed. Verify integration:
|
|
146
|
+
|
|
147
|
+
1. **Interface contracts** — do all files satisfy the contracts?
|
|
148
|
+
2. **Import resolution** — are all cross-file imports correct?
|
|
149
|
+
3. **Conflict resolution** — did agents make conflicting assumptions? Fix any.
|
|
150
|
+
4. **Missing glue** — any wiring code needed?
|
|
151
|
+
|
|
152
|
+
Fix any issues found directly. Then → transition `done`.
|
|
153
|
+
transitions:
|
|
154
|
+
done: review
|
|
155
|
+
|
|
156
|
+
review:
|
|
157
|
+
task: "Route review by scope"
|
|
158
|
+
prompt: |
|
|
159
|
+
Route to the correct review approach based on how many files were changed:
|
|
160
|
+
- `single` → 1 file changed
|
|
161
|
+
- `multi` → 2+ files changed
|
|
162
|
+
transitions:
|
|
163
|
+
single: review_single
|
|
164
|
+
multi: review_delegate
|
|
165
|
+
|
|
166
|
+
review_single:
|
|
167
|
+
sub_workflow: file-review
|
|
168
|
+
on_complete: test
|
|
169
|
+
on_fail: write_fix
|
|
170
|
+
|
|
171
|
+
review_delegate:
|
|
172
|
+
task: "Delegate per-file review to agents"
|
|
173
|
+
prompt: |
|
|
174
|
+
Spawn one Agent per changed file for deep review.
|
|
175
|
+
Use `subagent_type="general-purpose"`, `model="opus"`.
|
|
176
|
+
|
|
177
|
+
For each file, include in the agent prompt VERBATIM:
|
|
178
|
+
---
|
|
179
|
+
IMPORTANT: Override the default CLAUDE.md rule about start().
|
|
180
|
+
Do NOT call start() without arguments.
|
|
181
|
+
Instead, your FIRST action must be:
|
|
182
|
+
mcp__plugin_workflow_wf__start({ workflow: "file-review", parent_session_id: "<SESSION_ID>" })
|
|
183
|
+
where <SESSION_ID> is the current session ID (substitute it before sending).
|
|
184
|
+
Then follow the file-review workflow states until completion.
|
|
185
|
+
---
|
|
186
|
+
Also include:
|
|
187
|
+
- The file path
|
|
188
|
+
- How to get the diff: `git diff HEAD -- <filepath>`
|
|
189
|
+
- Review scope: `diff`
|
|
190
|
+
|
|
191
|
+
Launch ALL file agents in parallel. Collect reports.
|
|
192
|
+
|
|
193
|
+
After ALL reports are collected:
|
|
194
|
+
1. Abort orphaned child workflow sessions.
|
|
195
|
+
2. Transition `done`.
|
|
196
|
+
transitions:
|
|
197
|
+
done: cross_file
|
|
198
|
+
|
|
199
|
+
cross_file:
|
|
200
|
+
task: "Cross-file review analysis"
|
|
201
|
+
prompt: |
|
|
202
|
+
Review the big picture — things per-file agents can't see:
|
|
203
|
+
- [ ] Duplication across files
|
|
204
|
+
- [ ] Missing updates to consumers of changed interfaces
|
|
205
|
+
- [ ] Consistency across files
|
|
206
|
+
- [ ] Integration between changed components
|
|
207
|
+
|
|
208
|
+
Choose:
|
|
209
|
+
- `ok` → no issues, proceed to testing
|
|
210
|
+
- `fix` → found issues that need fixing
|
|
211
|
+
transitions:
|
|
212
|
+
ok: test
|
|
213
|
+
fix: write_fix
|
|
214
|
+
|
|
215
|
+
write_fix:
|
|
216
|
+
task: "Fix review issues"
|
|
217
|
+
prompt: |
|
|
218
|
+
Fix the issues found during review. After fixing, transition back to review.
|
|
219
|
+
transitions:
|
|
220
|
+
done: review
|
|
221
|
+
|
|
222
|
+
test:
|
|
223
|
+
sub_workflow: testing
|
|
224
|
+
on_complete: verify_route
|
|
225
|
+
on_fail: write_fix
|
|
226
|
+
|
|
227
|
+
verify_route:
|
|
228
|
+
task: "Route to correct verification"
|
|
229
|
+
prompt: |
|
|
230
|
+
Route to the correct verification based on the bug type classified at the start.
|
|
231
|
+
|
|
232
|
+
Check the classify decision:
|
|
233
|
+
- Was the bug classified as `visual`? → transition `visual`
|
|
234
|
+
- Was the bug classified as `logic`? → transition `logic`
|
|
235
|
+
transitions:
|
|
236
|
+
visual: verify_visual
|
|
237
|
+
logic: verify_logic
|
|
238
|
+
|
|
239
|
+
verify_visual:
|
|
240
|
+
task: "Verify the fix visually"
|
|
241
|
+
prompt: |
|
|
242
|
+
Verify the original bug is fixed VISUALLY.
|
|
243
|
+
|
|
244
|
+
MANDATORY STEPS:
|
|
245
|
+
1. Build and launch the app with debug bridge
|
|
246
|
+
2. Follow the SAME path used during reproduction
|
|
247
|
+
3. Take a screenshot and VERIFY the bug is gone
|
|
248
|
+
4. Compare before/after — describe the visual difference
|
|
249
|
+
|
|
250
|
+
DO NOT transition to `confirmed` without a screenshot proving the fix works.
|
|
251
|
+
transitions:
|
|
252
|
+
confirmed: done
|
|
253
|
+
still_broken: diagnose
|
|
254
|
+
|
|
255
|
+
verify_logic:
|
|
256
|
+
task: "Verify the fix with tests"
|
|
257
|
+
prompt: |
|
|
258
|
+
Verify the original bug is fixed.
|
|
259
|
+
|
|
260
|
+
MANDATORY STEPS:
|
|
261
|
+
1. Run the same test/scenario used during reproduction
|
|
262
|
+
2. Confirm it now passes — show the output
|
|
263
|
+
3. Check for regressions in related tests
|
|
264
|
+
|
|
265
|
+
DO NOT transition to `confirmed` without concrete evidence (test passing, correct output).
|
|
266
|
+
transitions:
|
|
267
|
+
confirmed: done
|
|
268
|
+
still_broken: diagnose
|
|
269
|
+
|
|
270
|
+
clarify:
|
|
271
|
+
task: "Clarify bug details"
|
|
272
|
+
prompt: "Ask the user for more details about the bug."
|
|
273
|
+
transitions:
|
|
274
|
+
got_info_visual: reproduce_visual
|
|
275
|
+
got_info_logic: reproduce_logic
|
|
276
|
+
|
|
277
|
+
escalate:
|
|
278
|
+
prompt: "Could not diagnose. Report to the user."
|
|
279
|
+
terminal: true
|
|
280
|
+
|
|
281
|
+
done:
|
|
282
|
+
prompt: "Bug fixed and verified."
|
|
283
|
+
terminal: true
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
name: code-review
|
|
2
|
+
description: "Code review workflow"
|
|
3
|
+
initial: overview
|
|
4
|
+
max_transitions: 50
|
|
5
|
+
|
|
6
|
+
states:
|
|
7
|
+
overview:
|
|
8
|
+
task: "Review the changes overview"
|
|
9
|
+
prompt: |
|
|
10
|
+
Do these steps in order, then transition `understood`:
|
|
11
|
+
|
|
12
|
+
1. Determine review scope:
|
|
13
|
+
- **First check git status in system prompt** — if it shows uncommitted changes
|
|
14
|
+
(staged or unstaged), those ARE the changes to review. Do NOT ask the user.
|
|
15
|
+
- User specified files/commits/PR → use that scope
|
|
16
|
+
- Nothing specified AND no changes in system prompt → ask the user
|
|
17
|
+
- NEVER default to `git diff master` or full branch diff
|
|
18
|
+
2. Determine review depth from user's request:
|
|
19
|
+
- "check changes" / "review diff" / default → `scope: diff` (only review changed lines)
|
|
20
|
+
- "review file" / "check whole file" / "bring to order" → `scope: full` (review entire file)
|
|
21
|
+
Save the scope via `context_set(key: "review_scope", value: "diff" or "full")`.
|
|
22
|
+
3. Get changed file names ONLY (`--name-only`). Do NOT read full diffs.
|
|
23
|
+
**Git pathspec gotcha (zsh):** to exclude paths, use `-- . ':(exclude)path'`,
|
|
24
|
+
NOT `-- ':!path'` — the latter silently returns empty results in zsh.
|
|
25
|
+
|
|
26
|
+
Output the file list, then → transition `understood`.
|
|
27
|
+
transitions:
|
|
28
|
+
understood: deep_review
|
|
29
|
+
|
|
30
|
+
deep_review:
|
|
31
|
+
task: "Route review by scope"
|
|
32
|
+
prompt: |
|
|
33
|
+
Call `Skill("coding-skill-selector")` to load language/domain skills — you will
|
|
34
|
+
need them for cross-file analysis and summarization.
|
|
35
|
+
|
|
36
|
+
Route based on how many files changed:
|
|
37
|
+
- `single` → 1 file changed — review via file-review sub-workflow (yourself)
|
|
38
|
+
- `multi` → 2+ files changed — spawn file-review agents in parallel
|
|
39
|
+
transitions:
|
|
40
|
+
single: review_single
|
|
41
|
+
multi: review_delegate
|
|
42
|
+
|
|
43
|
+
review_single:
|
|
44
|
+
sub_workflow: file-review
|
|
45
|
+
on_complete: cross_file
|
|
46
|
+
on_fail: cross_file
|
|
47
|
+
|
|
48
|
+
review_delegate:
|
|
49
|
+
task: "Deep per-file review via agents"
|
|
50
|
+
prompt: |
|
|
51
|
+
Spawn one Agent per changed file for deep review.
|
|
52
|
+
Use `subagent_type="general-purpose"`, `model="opus"`.
|
|
53
|
+
|
|
54
|
+
For each file, include in the agent prompt VERBATIM:
|
|
55
|
+
---
|
|
56
|
+
IMPORTANT: Override the default CLAUDE.md rule about start().
|
|
57
|
+
Do NOT call start() without arguments.
|
|
58
|
+
Instead, your FIRST action must be:
|
|
59
|
+
mcp__plugin_workflow_wf__start({ workflow: "file-review", parent_session_id: "<SESSION_ID>" })
|
|
60
|
+
where <SESSION_ID> is the current session ID (substitute it before sending).
|
|
61
|
+
Then follow the file-review workflow states until completion.
|
|
62
|
+
---
|
|
63
|
+
Also include:
|
|
64
|
+
- The file path
|
|
65
|
+
- How to get the diff (e.g. `git diff HEAD~1 -- <filepath>`)
|
|
66
|
+
- The review scope (from context key `review_scope`):
|
|
67
|
+
- `diff` → "Review ONLY the changed lines. Report pre-existing issues separately as 'pre-existing' severity, do NOT mix with diff issues."
|
|
68
|
+
- `full` → "Review the ENTIRE file for all issues, not just the diff."
|
|
69
|
+
|
|
70
|
+
Launch ALL file agents in parallel (single message, multiple Agent tool calls).
|
|
71
|
+
Wait for all to complete. Collect their reports.
|
|
72
|
+
|
|
73
|
+
After ALL reports are collected:
|
|
74
|
+
1. Abort orphaned child workflow sessions — call `sessions` to find
|
|
75
|
+
any active `file-review` sessions that are children of this session,
|
|
76
|
+
then `abort` each one. Agents may finish without reaching
|
|
77
|
+
the terminal workflow state, leaving zombie sessions behind.
|
|
78
|
+
2. Immediately transition `done`. Do not stop to report status.
|
|
79
|
+
transitions:
|
|
80
|
+
done: cross_file
|
|
81
|
+
|
|
82
|
+
cross_file:
|
|
83
|
+
task: "Cross-file analysis"
|
|
84
|
+
prompt: |
|
|
85
|
+
Now look at the big picture — things a per-file agent can't see:
|
|
86
|
+
|
|
87
|
+
- [ ] Duplication across files: did different files introduce similar code?
|
|
88
|
+
- [ ] Missing updates: if an interface/type changed, are all consumers updated?
|
|
89
|
+
- [ ] Consistency: do the changes follow the same patterns across files?
|
|
90
|
+
- [ ] Test coverage: are changed behaviors covered by tests? Missing test files?
|
|
91
|
+
- [ ] Integration: do the changed components work together correctly?
|
|
92
|
+
- [ ] Blast radius: are there callers/dependents that weren't updated?
|
|
93
|
+
|
|
94
|
+
Add any cross-file findings to the review.
|
|
95
|
+
transitions:
|
|
96
|
+
done: summarize
|
|
97
|
+
|
|
98
|
+
summarize:
|
|
99
|
+
task: "Summarize review findings"
|
|
100
|
+
prompt: |
|
|
101
|
+
Aggregate all findings from per-file reviews and cross-file analysis.
|
|
102
|
+
Categorize every finding into one of two buckets:
|
|
103
|
+
|
|
104
|
+
**Obvious fixes** — clear bugs, typos, style violations, missing error handling,
|
|
105
|
+
naming issues — things that have an objectively correct fix and don't need discussion.
|
|
106
|
+
|
|
107
|
+
**Debatable concerns** — architectural choices, alternative approaches, trade-offs,
|
|
108
|
+
style preferences where the codebase has no clear convention — things that need
|
|
109
|
+
the user's input before changing.
|
|
110
|
+
|
|
111
|
+
Present the summary clearly with both buckets. If there are no issues at all → `approve`.
|
|
112
|
+
If there are any issues → `has_issues`.
|
|
113
|
+
transitions:
|
|
114
|
+
approve: done
|
|
115
|
+
has_issues: apply_fixes
|
|
116
|
+
|
|
117
|
+
apply_fixes:
|
|
118
|
+
task: "Apply obvious fixes"
|
|
119
|
+
prompt: |
|
|
120
|
+
Apply all obvious fixes identified in the summary — bugs, typos, style violations,
|
|
121
|
+
missing error handling, naming issues. Fix them directly without asking.
|
|
122
|
+
|
|
123
|
+
Do NOT touch debatable concerns — those go to discussion.
|
|
124
|
+
|
|
125
|
+
After fixing: if there are debatable concerns remaining → `has_concerns`.
|
|
126
|
+
If everything was obvious and already fixed → `all_clear`.
|
|
127
|
+
transitions:
|
|
128
|
+
has_concerns: discuss
|
|
129
|
+
all_clear: done
|
|
130
|
+
|
|
131
|
+
discuss:
|
|
132
|
+
task: "Discuss debatable concerns"
|
|
133
|
+
prompt: |
|
|
134
|
+
Present each debatable concern to the user. For each one, explain:
|
|
135
|
+
- What the current code does
|
|
136
|
+
- What the concern is
|
|
137
|
+
- Your suggestion (if any)
|
|
138
|
+
|
|
139
|
+
Discuss with the user and reach agreement on what to change and what to leave.
|
|
140
|
+
|
|
141
|
+
After discussion, route based on scope of agreed changes:
|
|
142
|
+
- Many changes / architectural / multi-file refactoring → `plan` (enters planning mode)
|
|
143
|
+
- Few small stylistic or localized fixes → `code` (direct coding)
|
|
144
|
+
- User decided to change nothing → `skip`
|
|
145
|
+
transitions:
|
|
146
|
+
plan: plan_changes
|
|
147
|
+
code: code_changes
|
|
148
|
+
skip: done
|
|
149
|
+
|
|
150
|
+
plan_changes:
|
|
151
|
+
task: "Plan agreed changes"
|
|
152
|
+
sub_workflow: planning
|
|
153
|
+
on_complete: done
|
|
154
|
+
on_fail: done
|
|
155
|
+
|
|
156
|
+
code_changes:
|
|
157
|
+
task: "Apply agreed changes"
|
|
158
|
+
sub_workflow: coding
|
|
159
|
+
on_complete: done
|
|
160
|
+
on_fail: done
|
|
161
|
+
|
|
162
|
+
done:
|
|
163
|
+
prompt: "Review complete."
|
|
164
|
+
terminal: true
|