@@ -15,6 +15,159 @@ Deferring full plan generation ensures the implementation plan reflects the curr
1515 (including implementation steps) at issue creation time
1616- ` cat:work-implement-agent ` currently assumes a complete PLAN.md exists when it runs
1717
18+ ## Approaches
19+
20+ ### A: Inline lightweight plan in add + plan-builder invocation in work-implement
21+
22+ - ** Risk:** LOW
23+ - ** Scope:** 3 files (plugin/skills/add/first-use.md, plugin/skills/work-implement-agent/first-use.md,
24+ plugin/skills/plan-builder-agent/first-use.md and SKILL.md)
25+ - ** Description:** Replace plan-builder invocation in add/first-use.md with inline lightweight plan generation.
26+ Add plan-builder invocation in work-implement-agent/first-use.md before spawning the implementation subagent
27+ (only when plan.md lacks implementation steps).
28+
29+ > Selected: Approach A — minimal, targeted changes; backward compatible with existing full plan.mds.
30+
31+ ## Risk Assessment
32+
33+ - ** Risk Level:** LOW
34+ - ** Concerns:** Existing open issues have full PLAN.md files (with implementation steps). They must continue to work.
35+ - ** Mitigation:** ` cat:work-implement-agent ` checks whether plan.md already contains ` ## Sub-Agent Waves ` or
36+ ` ## Execution Steps ` before invoking plan-builder-agent. If the section exists, skip the invocation. This
37+ preserves existing full plans unchanged.
38+
39+ ## Files to Modify
40+
41+ - ` plugin/skills/add/first-use.md ` — Replace plan-builder invocation in ` issue_create ` step with inline
42+ lightweight plan.md generation (lines ~ 948–988)
43+ - ` plugin/skills/work-implement-agent/first-use.md ` — Add new "Generate implementation steps" section after
44+ displaying the implementing banner (after Step 3) and before "Read plan.md and Invoke Main Agent Waves"
45+ - ` plugin/skills/plan-builder-agent/SKILL.md ` — Update description field to remove ` /cat:add ` reference
46+ - ` plugin/skills/plan-builder-agent/first-use.md ` — Update "When to Use" section and Mode: ` initial ` description
47+
48+ ## Pre-conditions
49+
50+ - [ ] All dependent issues are closed
51+
52+ ## Sub-Agent Waves
53+
54+ ### Wave 1
55+
56+ - ** Modify ` plugin/skills/add/first-use.md ` ** : Replace the plan-builder invocation in the ` issue_create ` step
57+ with lightweight inline plan generation.
58+
59+ Locate the block starting with ` **Generate plan.md via plan-builder-agent:** ` (around line 948) through
60+ the end of the plan-builder invocation (around line 989, just before `** Apply auto-detected skill dependency
61+ updates...`).
62+
63+ Replace with ` **Generate lightweight plan.md:** ` block that:
64+ 1 . Creates a unique temporary plan.md file using ` planTempFile=$(mktemp --suffix=.md) ` (multi-instance
65+ safe — avoids name collisions when multiple ` /cat:add ` invocations run concurrently). Writes content:
66+ - ` # Plan ` header
67+ - ` ## Goal ` section containing ` ${ISSUE_DESCRIPTION} ` verbatim
68+ - ` ## Post-conditions ` section with POSTCONDITIONS items as a checklist
69+
70+ Use this bash approach (the agent writes the file using the Write tool, not a heredoc, to avoid
71+ quoting issues with variable content):
72+
73+ ```
74+ First: planTempFile=$(mktemp --suffix=.md)
75+ Then the agent writes the lightweight plan.md to ${planTempFile} using the Write tool
76+ (or Bash with printf/echo) with the following structure:
77+
78+ # Plan
79+
80+ ## Goal
81+
82+ ${ISSUE_DESCRIPTION}
83+
84+ ## Post-conditions
85+
86+ - [ ] ${postcondition_1}
87+ - [ ] ${postcondition_2}
88+ ...
89+ ```
90+
91+ 2. Passes `${planTempFile}` to `create-issue` via `planFile` parameter — same as before, but
92+ pointing to the new lightweight file instead of the plan-builder output.
93+ 3. Removes the PLAN_CONTEXT JSON file creation step.
94+ 4. Removes the `cat:plan-builder-agent` Skill tool invocation.
95+ 5. Keeps the `create-issue` bash call structure identical (only the `planFile` value changes).
96+
97+ Files: `plugin/skills/add/first-use.md`
98+
99+ - **Modify `plugin/skills/work-implement-agent/first-use.md`**: Insert a new "### Generate Implementation Steps"
100+ section between the "Step 3 (Implementing Banner)" content and the "### Read plan.md and Invoke Main Agent
101+ Waves" section (around line 153).
102+
103+ The new section:
104+
105+ ```markdown
106+ ### Generate Implementation Steps
107+
108+ Before reading Main Agent Waves, check whether plan.md already contains implementation steps:
109+
110+ ```bash
111+ PLAN_MD="${ISSUE_PATH}/plan.md" && \
112+ grep -qE '^## (Sub-Agent Waves|Execution Steps)' "${PLAN_MD}" && \
113+ echo "hasSteps=true" || echo "hasSteps=false"
114+ ```
115+
116+ ** If ` hasSteps=false ` ** (lightweight plan created by ` /cat:add ` ): invoke ` cat:plan-builder-agent ` in
117+ revise mode to generate full implementation steps before spawning the implementation subagent:
118+
119+ 1 . Read EFFORT from config:
120+ ``` bash
121+ CONFIG=$( " ${CLAUDE_PLUGIN_ROOT} /client/bin/get-config-output" effective)
122+ EFFORT=$( echo " $CONFIG " | grep -o ' "effort"[[:space:]]*:[[:space:]]*"[^"]*"' \
123+ | sed ' s/.*"effort"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/' )
124+ ```
125+
126+ 2. Invoke plan-builder-agent to add implementation steps:
127+ ```
128+ Skill tool:
129+ skill: " cat:plan-builder-agent"
130+ args: " ${CAT_AGENT_ID} ${EFFORT} revise ${ISSUE_PATH} Generate full implementation steps for
131+ this lightweight plan. Add Sub-Agent Waves or Execution Steps section with detailed step-by-step
132+ implementation guidance."
133+ ```
134+
135+ 3. After plan-builder-agent returns, re-read the updated plan.md in subsequent steps.
136+
137+ ** If ` hasSteps=true` ** (full plan with implementation steps): skip plan-builder-agent invocation.
138+ Proceed directly to " Read plan.md and Invoke Main Agent Waves" .
139+ ```
140+
141+ Files: ` plugin/skills/work-implement-agent/first-use.md `
142+
143+ - ** Modify ` plugin/skills/plan-builder-agent/SKILL.md ` ** : Update the ` description ` field:
144+ - Old: ` Invoked by /cat:add for initial plans and by /cat:work for mid-work revisions. `
145+ - New: `Invoked by /cat: work to generate full implementation steps before spawning the implementation
146+ subagent, and for mid-work revisions when requirements change during implementation.`
147+
148+ Files: ` plugin/skills/plan-builder-agent/SKILL.md `
149+
150+ - ** Modify ` plugin/skills/plan-builder-agent/first-use.md ` ** : Update two sections:
151+
152+ Section 1 — "When to Use" (around line 61-64):
153+ - Old line 63: ` - **Initial planning** (\ ` /cat: add \` ): Generate plan.md from issue description and context`
154+ - New line 63: ` - **Initial implementation** (\ ` /cat: work \` ): Generate full implementation steps from a
155+ lightweight plan.md created by \` /cat: add \` (which contains only goal and post-conditions)`
156+
157+ Section 2 — "### Mode: ` initial ` " (around line 33-48):
158+ - Old line 35: ` Used by \ ` /cat: add \` . The \` contextPath\` points to a temporary JSON file containing:`
159+ - New line 35: ` **Deprecated.** This mode was previously used by \ ` /cat: add \` . The \` revise\` mode is now
160+ used by \` /cat: work-implement-agent \` to generate full implementation steps from lightweight plan.mds.
161+ The \` contextPath\` points to a temporary JSON file containing:`
162+
163+ Files: ` plugin/skills/plan-builder-agent/first-use.md `
164+
165+ - ** Commit all three file changes in one commit** with message:
166+ ` feature: defer plan generation from add to work-implement `
167+
168+ Also include index.json closure in this same commit:
169+ - Set status to ` closed ` and progress to ` 100% ` in the issue's index.json
170+
18171## Post-conditions
19172
201731 . ` /cat:add-agent ` creates a lightweight PLAN.md containing only: goal description, pre-conditions, and
0 commit comments