renn-studio 0.6.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.
Files changed (112) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +36 -0
  3. package/agents/renn-architect.md +1463 -0
  4. package/agents/renn-auditor.md +1053 -0
  5. package/agents/renn-codebase-mapper.md +908 -0
  6. package/agents/renn-design-reviewer.md +422 -0
  7. package/agents/renn-designer.md +814 -0
  8. package/agents/renn-detective.md +1204 -0
  9. package/agents/renn-integration-checker.md +957 -0
  10. package/agents/renn-navigator.md +659 -0
  11. package/agents/renn-plan-reviewer.md +812 -0
  12. package/agents/renn-project-scout.md +880 -0
  13. package/agents/renn-runner.md +842 -0
  14. package/agents/renn-stage-scout.md +705 -0
  15. package/agents/renn-synthesizer.md +256 -0
  16. package/bin/install.js +1466 -0
  17. package/commands/renn.add-stage.md +211 -0
  18. package/commands/renn.add-todo.md +194 -0
  19. package/commands/renn.audit-milestone.md +280 -0
  20. package/commands/renn.audit.md +219 -0
  21. package/commands/renn.check-todos.md +229 -0
  22. package/commands/renn.complete-milestone.md +136 -0
  23. package/commands/renn.continue.md +46 -0
  24. package/commands/renn.dash.md +308 -0
  25. package/commands/renn.debug.md +169 -0
  26. package/commands/renn.design-screens.md +107 -0
  27. package/commands/renn.design-system.md +100 -0
  28. package/commands/renn.discuss-stage.md +86 -0
  29. package/commands/renn.help.md +550 -0
  30. package/commands/renn.insert-stage.md +231 -0
  31. package/commands/renn.list-stage-assumptions.md +49 -0
  32. package/commands/renn.map-codebase.md +72 -0
  33. package/commands/renn.new-milestone.md +80 -0
  34. package/commands/renn.pause.md +132 -0
  35. package/commands/renn.plan-milestone-gaps.md +314 -0
  36. package/commands/renn.plan-stage.md +118 -0
  37. package/commands/renn.remove-stage.md +353 -0
  38. package/commands/renn.research-stage.md +200 -0
  39. package/commands/renn.restyle.md +98 -0
  40. package/commands/renn.run-stage.md +343 -0
  41. package/commands/renn.set-profile.md +116 -0
  42. package/commands/renn.settings.md +151 -0
  43. package/commands/renn.ship.md +52 -0
  44. package/commands/renn.start.md +95 -0
  45. package/commands/renn.status.md +530 -0
  46. package/commands/renn.watch.md +51 -0
  47. package/hooks/dist/renn-check-update.js +67 -0
  48. package/hooks/dist/renn-statusline.js +96 -0
  49. package/package.json +89 -0
  50. package/renn/references/continuation-format.md +249 -0
  51. package/renn/references/design-artifacts.md +674 -0
  52. package/renn/references/design-tokens.md +162 -0
  53. package/renn/references/gates.md +1078 -0
  54. package/renn/references/git-integration.md +254 -0
  55. package/renn/references/horsepower-profiles.md +84 -0
  56. package/renn/references/planning-config.md +189 -0
  57. package/renn/references/questioning.md +141 -0
  58. package/renn/references/security-checklist.md +2184 -0
  59. package/renn/references/tdd.md +263 -0
  60. package/renn/references/ui-brand.md +189 -0
  61. package/renn/references/verification-patterns.md +612 -0
  62. package/renn/templates/DEBUG.md +159 -0
  63. package/renn/templates/INTEL.md +283 -0
  64. package/renn/templates/RECAP.md +246 -0
  65. package/renn/templates/UAT.md +247 -0
  66. package/renn/templates/architect-prompt.md +119 -0
  67. package/renn/templates/brief.md +190 -0
  68. package/renn/templates/codebase/architecture.md +264 -0
  69. package/renn/templates/codebase/concerns.md +310 -0
  70. package/renn/templates/codebase/conventions.md +307 -0
  71. package/renn/templates/codebase/design.md +336 -0
  72. package/renn/templates/codebase/integrations.md +280 -0
  73. package/renn/templates/codebase/stack.md +186 -0
  74. package/renn/templates/codebase/structure.md +295 -0
  75. package/renn/templates/codebase/testing.md +480 -0
  76. package/renn/templates/config.json +36 -0
  77. package/renn/templates/continue-here.md +80 -0
  78. package/renn/templates/detective-prompt.md +93 -0
  79. package/renn/templates/milestone-archive.md +123 -0
  80. package/renn/templates/milestone.md +117 -0
  81. package/renn/templates/proof.md +326 -0
  82. package/renn/templates/pulse.md +176 -0
  83. package/renn/templates/research/architecture.md +206 -0
  84. package/renn/templates/research/features.md +149 -0
  85. package/renn/templates/research/pitfalls.md +202 -0
  86. package/renn/templates/research/recap.md +187 -0
  87. package/renn/templates/research/stack.md +122 -0
  88. package/renn/templates/research/ux.md +283 -0
  89. package/renn/templates/research-lite.md +146 -0
  90. package/renn/templates/research.md +582 -0
  91. package/renn/templates/specs.md +233 -0
  92. package/renn/templates/stage-prompt.md +571 -0
  93. package/renn/templates/track.md +211 -0
  94. package/renn/templates/user-setup.md +315 -0
  95. package/renn/workflows/audit-stage.md +717 -0
  96. package/renn/workflows/audit-work.md +596 -0
  97. package/renn/workflows/complete-milestone.md +875 -0
  98. package/renn/workflows/continue-project.md +306 -0
  99. package/renn/workflows/design-stage.md +2019 -0
  100. package/renn/workflows/diagnose-issues.md +231 -0
  101. package/renn/workflows/initialize-project.md +1039 -0
  102. package/renn/workflows/list-assumptions.md +178 -0
  103. package/renn/workflows/map-codebase.md +374 -0
  104. package/renn/workflows/new-milestone.md +718 -0
  105. package/renn/workflows/plan-stage.md +810 -0
  106. package/renn/workflows/research-stage.md +289 -0
  107. package/renn/workflows/run-plan.md +1844 -0
  108. package/renn/workflows/run-stage.md +692 -0
  109. package/renn/workflows/scope-stage.md +546 -0
  110. package/renn/workflows/ship-project.md +859 -0
  111. package/renn/workflows/transition.md +556 -0
  112. package/renn/workflows/watch-project.md +797 -0
@@ -0,0 +1,2019 @@
1
+ <purpose>
2
+ Run the full design pipeline for a UI stage or an entire project independently of plan-stage.
3
+
4
+ Dual-mode: operates in stage-level mode (single stage, invoked by design-screens or restyle) or project-level mode (all UI stages, invoked by design-system without a stage number). Use this workflow when a stage involves visual UI work and needs design artifacts (stylekit, screen prototypes, implementation guide) before architecture planning. Handles UI detection, UX interview, UX synthesis, design interview, Phase 1 (stylekit), Phase 2 (screens), implementation guide generation, and design artifact commits.
5
+ </purpose>
6
+
7
+ <core_principle>
8
+ Fresh context per agent. Orchestrator stays lean (~15%), each subagent gets 100% fresh 200k. Intel.md loaded early and passed to ALL agents to constrain scope. This is an extraction of plan-stage's design pipeline into a standalone command -- spawn templates and design logic are preserved verbatim to maintain artifact parity.
9
+ </core_principle>
10
+
11
+ <process>
12
+
13
+ <step name="validate_environment" priority="first">
14
+ Validate .renn/ exists and resolve model profile:
15
+
16
+ ```bash
17
+ ls .renn/ 2>/dev/null
18
+ ```
19
+
20
+ **If not found:** Error - user should run `/renn.start` first.
21
+
22
+ **Resolve model profile for agent spawning:**
23
+
24
+ ```bash
25
+ MODEL_PROFILE=$(cat .renn/config.json 2>/dev/null | grep -o '"horsepower"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "balanced")
26
+ ```
27
+
28
+ Default to "balanced" if not set.
29
+
30
+ **Model lookup table:**
31
+
32
+ | Agent | max | balanced | eco |
33
+ |-------|---------|----------|--------|
34
+ | renn-stage-scout | opus | sonnet | haiku |
35
+ | renn-architect | opus | opus | sonnet |
36
+ | renn-plan-reviewer | sonnet | sonnet | haiku |
37
+ | renn-designer | opus | sonnet | sonnet |
38
+ | renn-design-reviewer | sonnet | sonnet | haiku |
39
+
40
+ Store resolved models for use in Task calls below.
41
+ </step>
42
+
43
+ <step name="parse_arguments">
44
+ Extract from $ARGUMENTS:
45
+
46
+ - Stage number (integer or decimal like `2.1`) -- OPTIONAL in project-level mode
47
+ - `--skip-ux-interview` flag to skip UX interview
48
+ - `--restyle` flag to enter restyle mode (invoked by renn.restyle command)
49
+ - `--phase-1-only` flag to stop after Phase 1 (invoked by renn.design-system command)
50
+ - `--phase-2-only` flag to skip to Phase 2 (invoked by renn.design-screens command)
51
+
52
+ **Determine mode:**
53
+
54
+ If `--phase-1-only` flag is present AND no stage number is provided:
55
+ Set `PROJECT_LEVEL=true`
56
+ Else:
57
+ Set `PROJECT_LEVEL=false`
58
+
59
+ **If PROJECT_LEVEL=true:** Skip stage number parsing, normalization, and research check. These are stage-scoped operations that do not apply in project-level mode. Continue to validate_stage.
60
+
61
+ **If PROJECT_LEVEL=false:**
62
+
63
+ **If no stage number:** Detect next unplanned stage from track.
64
+
65
+ **Normalize stage to zero-padded format:**
66
+
67
+ ```bash
68
+ # Normalize stage number (8 -> 08, but preserve decimals like 2.1 -> 02.1)
69
+ if [[ "$STAGE" =~ ^[0-9]+$ ]]; then
70
+ STAGE=$(printf "%02d" "$STAGE")
71
+ elif [[ "$STAGE" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
72
+ STAGE=$(printf "%02d.%s" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
73
+ fi
74
+ ```
75
+
76
+ **Check for existing research:**
77
+
78
+ ```bash
79
+ ls .renn/stages/${STAGE}-*/*-research.md 2>/dev/null
80
+ ```
81
+ </step>
82
+
83
+ <step name="validate_stage">
84
+ **If PROJECT_LEVEL=true:** Skip single-stage validation. Instead, scan track.md for ALL stages and identify which are UI stages.
85
+
86
+ **Project-level track scanning:**
87
+
88
+ ```bash
89
+ # Extract all stage headings and goals from track.md
90
+ # Track uses "### Stage N:" format (anchored to ### headings)
91
+ grep -A5 "^### Stage [0-9]*:" .renn/track.md | grep -v "^\-\-$"
92
+ ```
93
+
94
+ For each stage heading found, check if it contains a [UI] tag:
95
+
96
+ ```
97
+ For each stage heading:
98
+ If heading contains [UI] (e.g., "### Stage 5: Dashboard [UI]") -> this is a UI stage
99
+ Otherwise -> not a UI stage (skip)
100
+ ```
101
+
102
+ No keyword scoring. The [UI] tag is authoritative.
103
+
104
+ Collect results:
105
+ - `UI_STAGES` -- list of stage numbers + names + goals that have [UI] tag in their heading
106
+ - `ALL_UI_GOALS` -- combined goal text from all UI stages
107
+
108
+ Validate at least one UI stage exists:
109
+
110
+ ```bash
111
+ if [ ${#UI_STAGES[@]} -eq 0 ]; then
112
+ echo "No UI stages found in track.md. Design pipeline requires at least one UI stage."
113
+ # ERROR and exit
114
+ fi
115
+ ```
116
+
117
+ Display discovered UI stages:
118
+
119
+ ```
120
+ Found {N} UI stages:
121
+ - Stage 3: Dashboard -- Main dashboard with data visualization
122
+ - Stage 5: Settings -- User settings page
123
+
124
+ Design system will cover all {N} UI stages.
125
+ ```
126
+
127
+ **If PROJECT_LEVEL=false:**
128
+
129
+ ```bash
130
+ # Strip leading zeros for track.md lookup (track uses "Stage 1:", not "Stage 01:")
131
+ STAGE_UNPADDED=$(echo "$STAGE" | sed 's/^0\+\([0-9]\)/\1/')
132
+ grep -A5 "^### Stage ${STAGE_UNPADDED}:" .renn/track.md 2>/dev/null
133
+ ```
134
+
135
+ **If not found:** Error with available stages. **If found:** Extract stage number, name, description.
136
+ </step>
137
+
138
+ <step name="ensure_stage_directory">
139
+ **If PROJECT_LEVEL=true:** Skip stage directory creation. Set project-level variable defaults instead.
140
+
141
+ ```bash
142
+ # No stage directory in project-level mode
143
+ STAGE_DIR="" # Not used in project-level mode
144
+ INTEL_CONTENT="" # No per-stage intel exists for project-level
145
+ STAGE_NAME="design-system" # For display purposes
146
+ STAGE="project" # For commit messages
147
+ COMMIT_PREFIX="design" # For commit messages (used by handle_design)
148
+ COMMIT_MSG_SCOPE="project design system" # For commit message body text
149
+
150
+ # Project-level variables are still extracted from brief.md (they are project-scoped already)
151
+ PROJECT_NAME=$(head -1 .renn/brief.md 2>/dev/null | sed 's/^# //')
152
+ PLATFORM=$(grep -m1 '^\*\*Platform:\*\*' .renn/brief.md 2>/dev/null | sed 's/\*\*Platform:\*\* //')
153
+ VIEWPORT_RAW=$(grep -m1 '^\*\*Viewport:\*\*' .renn/brief.md 2>/dev/null | sed 's/\*\*Viewport:\*\* //')
154
+ ```
155
+
156
+ Display: `Using project-level mode (no stage directory). Designing for all UI stages.`
157
+
158
+ **If PROJECT_LEVEL=false:**
159
+
160
+ ```bash
161
+ # STAGE is already normalized (08, 02.1, etc.) from parse_arguments
162
+ STAGE_DIR=$(ls -d .renn/stages/${STAGE}-* 2>/dev/null | head -1)
163
+ if [ -z "$STAGE_DIR" ]; then
164
+ # Create stage directory from track name
165
+ # Anchor to ### headings to avoid matching list items (which contain markdown ** and descriptions)
166
+ STAGE_UNPADDED=$(echo "$STAGE" | sed 's/^0\+\([0-9]\)/\1/')
167
+ STAGE_NAME=$(grep "^### Stage ${STAGE_UNPADDED}:" .renn/track.md | head -1 | sed 's/^### Stage [0-9]*: //' | sed 's/ \[UI\]$//' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
168
+ mkdir -p ".renn/stages/${STAGE}-${STAGE_NAME}"
169
+ STAGE_DIR=".renn/stages/${STAGE}-${STAGE_NAME}"
170
+ fi
171
+
172
+ # Set COMMIT_PREFIX for stage-level mode (symmetry with project-level)
173
+ COMMIT_PREFIX="${STAGE}"
174
+ COMMIT_MSG_SCOPE="Stage ${STAGE}: ${STAGE_NAME}"
175
+
176
+ # Load intel.md immediately - this informs ALL downstream agents
177
+ INTEL_CONTENT=$(cat "${STAGE_DIR}"/*-intel.md 2>/dev/null)
178
+
179
+ # Extract project name from brief.md heading (used in designer spawn)
180
+ PROJECT_NAME=$(head -1 .renn/brief.md 2>/dev/null | sed 's/^# //')
181
+
182
+ # Extract viewport context from brief.md (used in Phase 1 designer spawn)
183
+ PLATFORM=$(grep -m1 '^\*\*Platform:\*\*' .renn/brief.md 2>/dev/null | sed 's/\*\*Platform:\*\* //')
184
+ VIEWPORT_RAW=$(grep -m1 '^\*\*Viewport:\*\*' .renn/brief.md 2>/dev/null | sed 's/\*\*Viewport:\*\* //')
185
+ ```
186
+
187
+ **CRITICAL:** Store `INTEL_CONTENT` now. It must be passed to:
188
+ - **Scout** -- constrains what to research (locked decisions vs Claude's discretion)
189
+ - **Designer** -- locked decisions must be honored, not revisited
190
+ - **Reviewer** -- verifies design respects user's stated vision
191
+
192
+ If intel.md exists, display: `Using stage context from: ${STAGE_DIR}/*-intel.md`
193
+ </step>
194
+
195
+ <step name="handle_research">
196
+ **If PROJECT_LEVEL=true:** Skip handle_research entirely. Research is stage-scoped; project-level design relies on UX.md (project-level UX research) and the design interview for design preferences. Set `RESEARCH_CONTENT=""`. Continue to detect_ui_stage.
197
+
198
+ **If PROJECT_LEVEL=false:**
199
+
200
+ **If `--phase-2-only` flag is set:** Skip handle_research entirely. Do NOT check config, do NOT check for existing research.md, do NOT offer the scout agent. Research was done during /renn.design-system. Load from disk if available: `RESEARCH_CONTENT=$(cat ${STAGE_DIR}/${STAGE}-research.md 2>/dev/null || echo "")`. If the file does not exist, set `RESEARCH_CONTENT=""` (empty string). Continue to detect_ui_stage.
201
+
202
+ Check config for research setting:
203
+
204
+ ```bash
205
+ WORKFLOW_RESEARCH=$(cat .renn/config.json 2>/dev/null | grep -o '"research"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
206
+ ```
207
+
208
+ **If `checks.research` is `false`:** Skip to detect_ui_stage.
209
+
210
+ **Otherwise:**
211
+
212
+ Check for existing research:
213
+
214
+ ```bash
215
+ ls "${STAGE_DIR}"/*-research.md 2>/dev/null
216
+ ```
217
+
218
+ **If research.md exists:**
219
+ - Display: `Using existing research: ${STAGE_DIR}/${STAGE}-research.md`
220
+ - Set `RESEARCH_CONTENT` from the file
221
+ - Skip to detect_ui_stage
222
+
223
+ **If research.md missing:**
224
+
225
+ Use AskUserQuestion to offer:
226
+
227
+ ```
228
+ No research found for this stage. Research first?
229
+
230
+ Options:
231
+ Yes - Spawn scout to research before designing
232
+ No - Proceed to design without research
233
+ ```
234
+
235
+ **If "Yes":**
236
+
237
+ Display stage banner:
238
+ ```
239
+ RENN > SCOUTING STAGE {X}
240
+
241
+ Spawning scout...
242
+ ```
243
+
244
+ Gather additional context for research prompt:
245
+
246
+ ```bash
247
+ # Get stage description from track (use STAGE_UNPADDED from validate_stage)
248
+ STAGE_DESC=$(grep -A5 "^### Stage ${STAGE_UNPADDED}:" .renn/track.md)
249
+
250
+ # Get specs if they exist
251
+ SPECS=$(cat .renn/specs.md 2>/dev/null | grep -A100 "## Requirements" | head -50)
252
+
253
+ # Get prior decisions from pulse.md
254
+ DECISIONS=$(grep -A20 "### Decisions Made" .renn/pulse.md 2>/dev/null)
255
+
256
+ # INTEL_CONTENT already loaded in ensure_stage_directory
257
+
258
+ # Read UX.md for scout (if exists)
259
+ UX_CONTENT_FOR_SCOUT=$(cat .renn/research/UX.md 2>/dev/null)
260
+ ```
261
+
262
+ Fill research prompt and spawn:
263
+
264
+ ```markdown
265
+ <objective>
266
+ Research how to implement Stage {stage_number}: {stage_name}
267
+
268
+ Answer: "What do I need to know to PLAN this stage well?"
269
+ </objective>
270
+
271
+ <stage_context>
272
+ **IMPORTANT:** If intel.md exists below, it contains user decisions from /renn.discuss-stage.
273
+
274
+ - **Decisions section** = Locked choices -- research THESE deeply, don't explore alternatives
275
+ - **Claude's Discretion section** = Your freedom areas -- research options, make recommendations
276
+ - **Deferred Ideas section** = Out of scope -- ignore completely
277
+
278
+ {intel_content}
279
+ </stage_context>
280
+
281
+ <additional_context>
282
+ **Stage description:**
283
+ {stage_description}
284
+
285
+ **Specs (if any):**
286
+ {specs}
287
+
288
+ **Prior decisions from pulse.md:**
289
+ {decisions}
290
+ </additional_context>
291
+
292
+ <ux_context>
293
+ **UX.md content (if exists -- use for Stage UX Patterns section):**
294
+
295
+ If UX.md content is present below, generate a ## Stage UX Patterns section in your research.md output. Cross-reference these project-level findings with the specific stage being researched. If no UX.md content below, omit the Stage UX Patterns section.
296
+
297
+ {ux_content_for_scout}
298
+ </ux_context>
299
+
300
+ <output>
301
+ Write research findings to: {stage_dir}/{stage}-research.md
302
+ </output>
303
+ ```
304
+
305
+ ```
306
+ Task(
307
+ prompt=research_prompt,
308
+ subagent_type="renn-stage-scout",
309
+ model="{scout_model}",
310
+ description="Research Stage {stage}"
311
+ )
312
+ ```
313
+
314
+ ### Handle Scout Return
315
+
316
+ **`## RESEARCH COMPLETE`:**
317
+ - Display: `Research complete. Proceeding to design...`
318
+ - Set `RESEARCH_CONTENT` from the research file
319
+ - Continue to detect_ui_stage
320
+
321
+ **`## RESEARCH BLOCKED`:**
322
+ - Display blocker information
323
+ - Offer: 1) Provide more context, 2) Skip research and design anyway, 3) Abort
324
+ - Wait for user response
325
+
326
+ **If "No" (skip research):**
327
+ - Set `RESEARCH_CONTENT=""`
328
+ - Continue to detect_ui_stage
329
+ </step>
330
+
331
+ <step name="detect_ui_stage">
332
+ **If `--phase-2-only` flag is set:** Skip UI detection entirely. The user explicitly invoked `renn.design-screens` which is a design command -- UI stage is guaranteed. Set `UI_STAGE=true`. Continue directly to handle_ux_interview (which will also be skipped by --skip-ux-interview).
333
+
334
+ **If PROJECT_LEVEL=true:** Skip UI detection. The validate_stage step already scanned all stages from track.md for [UI] tags and confirmed at least one UI stage exists. Set `UI_STAGE=true`. The `UI_STAGES` list and `ALL_UI_GOALS` from validate_stage are available for downstream steps (handle_ux_interview and handle_design). Continue to handle_ux_interview.
335
+
336
+ **If PROJECT_LEVEL=false:**
337
+
338
+ ### UI Detection
339
+
340
+ Check the stage heading from track.md:
341
+
342
+ ```bash
343
+ STAGE_HEADING=$(grep "^### Stage ${STAGE_UNPADDED}:" .renn/track.md | head -1)
344
+ ```
345
+
346
+ If the heading contains `[UI]` -> set `UI_STAGE=true`.
347
+ If the heading does NOT contain `[UI]` -> this is not a UI stage. **ERROR and exit.** Display:
348
+
349
+ ```
350
+ Stage {N} is not a UI stage (no [UI] tag in track.md heading). Design pipeline is for UI stages only.
351
+
352
+ Use /renn.plan-stage {N} directly.
353
+ ```
354
+
355
+ No keyword matching. No UNCERTAIN state. The [UI] tag is authoritative.
356
+
357
+ Store `UI_STAGE` for use by handle_ux_interview and handle_design.
358
+ </step>
359
+
360
+ <step name="handle_ux_interview">
361
+ **Skip conditions (check in order):**
362
+ 1. UX.md does not exist -> skip (display: "No UX.md found. Skipping UX interview. Run /renn.start or /renn.new-milestone to generate UX research.")
363
+ 2. `--skip-ux-interview` flag set -> skip
364
+
365
+ **Read UX context:**
366
+
367
+ ```bash
368
+ UX_CONTENT=$(cat .renn/research/UX.md 2>/dev/null)
369
+ if [ -z "$UX_CONTENT" ]; then
370
+ echo "No UX.md found. Skipping UX interview."
371
+ UX_INTERVIEW_ANSWERS=""
372
+ UX_QUESTIONS_ASKED=0
373
+ fi
374
+
375
+ # Load stage-specific UX research section
376
+ if [ "$PROJECT_LEVEL" = "true" ]; then
377
+ # No per-stage research.md in project-level mode (research was skipped)
378
+ RESEARCH_UX_SECTION=""
379
+ else
380
+ RESEARCH_UX_SECTION=""
381
+ if [ -f "${STAGE_DIR}"/*-research.md ]; then
382
+ RESEARCH_UX_SECTION=$(sed -n '/## Stage UX Patterns/,/^## [^S]/p' "${STAGE_DIR}"/*-research.md 2>/dev/null)
383
+ fi
384
+ fi
385
+ ```
386
+
387
+ **Display banner:**
388
+
389
+ **If PROJECT_LEVEL=true:**
390
+
391
+ ```
392
+ RENN > UX INTERVIEW FOR PROJECT
393
+
394
+ Before visual design, let's discuss how users should experience this project across all UI stages.
395
+ ```
396
+
397
+ **If PROJECT_LEVEL=false:**
398
+
399
+ ```
400
+ RENN > UX INTERVIEW FOR STAGE {X}
401
+
402
+ Before visual design, let's discuss how users should experience this stage.
403
+ ```
404
+
405
+ **Generate 4-6 questions dynamically from UX.md findings (UXIN-04):**
406
+
407
+ Read UX.md content and extract questions from these categories. **If PROJECT_LEVEL=true:** generate questions spanning ALL UI stages (using `ALL_UI_GOALS` and `UI_STAGES` from validate_stage) instead of a single stage's features. The question categories remain the same -- only the scope of features considered broadens to cover all UI stages. **If PROJECT_LEVEL=false:** generate questions for the single stage as before.
408
+
409
+ **Plain-language rule:** The user may not be technical. Describe what the user would see or do — never assume they know UX terminology. Replace jargon with behavior descriptions or familiar app references. For example, say "show options one step at a time" instead of "progressive disclosure."
410
+
411
+ 1. **Critical Flows (1-2 questions):** For each critical flow with LOW or MEDIUM friction tolerance in UX.md, generate a question about how that flow should behave in this stage (or across all UI stages in project-level mode). Use third-person framing (UXIN-05):
412
+ - "When someone [does X] for the first time, should it feel more like [familiar example A] or [familiar example B]?"
413
+
414
+ 2. **Proven Patterns (1-2 questions):** For proven patterns from UX.md that apply to this stage's features (or all UI stages' features in project-level mode), ask whether to adopt the pattern. Describe what the pattern looks like, not what it's called:
415
+ - "Similar apps let users [behavior description]. Should this work the same way?"
416
+
417
+ 3. **Anti-Pattern Awareness (0-1 questions):** If UX.md identifies anti-patterns relevant to this stage (or any UI stage in project-level mode), generate one awareness question. Describe the bad experience, not the pattern name:
418
+ - "A common frustration in [domain] apps is [description of bad experience]. When that happens here, how should we handle it?"
419
+
420
+ 4. **Emotional Design (1 question):** Generate one emotional calibration question from UX.md emotional design goals. Direct framing:
421
+ - "We want people to feel [emotion] when using this. Which approach gets closer to that?"
422
+
423
+ **Question format (UXIN-02, UXIN-03):**
424
+
425
+ Every question presented via AskUserQuestion:
426
+ - 2-4 concrete options informed by UX.md findings — describe what the user sees, not the pattern name
427
+ - EVERY question includes a "Let Claude decide" option with research-backed default: "(Research suggests: [UX.md recommendation])"
428
+ - Third-person framing for interaction/flow questions (UXIN-05); direct framing for preference/calibration questions
429
+ - Track `UX_QUESTIONS_ASKED` count (target 4-6)
430
+
431
+ **Compile answers:**
432
+
433
+ ```xml
434
+ <ux_interview_answers>
435
+ ### [Question Topic 1]
436
+ Question: {question text}
437
+ Answer: {user's choice or "Let Claude decide"}
438
+ Research default: {what UX.md recommends}
439
+
440
+ ### [Question Topic 2]
441
+ Question: {question text}
442
+ Answer: {user's choice or "Let Claude decide"}
443
+ Research default: {what UX.md recommends}
444
+
445
+ ...
446
+ </ux_interview_answers>
447
+ ```
448
+
449
+ **Store for downstream:**
450
+ - `UX_INTERVIEW_ANSWERS` -- compiled answers
451
+ - `UX_QUESTIONS_ASKED` -- count for visual interview budget
452
+ - `UX_CONTENT` -- original UX.md content for synthesis
453
+ - `RESEARCH_UX_SECTION` -- stage-specific UX section for synthesis
454
+ </step>
455
+
456
+ <step name="ux_synthesis">
457
+ **Skip conditions:**
458
+ 1. handle_ux_interview was skipped -> skip (`UX_INTERVIEW_ANSWERS` is empty)
459
+ 2. `UI_STAGE` is false -> skip
460
+
461
+ **Synthesize inline (UXSY-03: no agent spawn):**
462
+
463
+ Read:
464
+ - `UX_CONTENT` (project-level UX.md research)
465
+ - `RESEARCH_UX_SECTION` (stage-specific UX patterns from research.md)
466
+ - `UX_INTERVIEW_ANSWERS` (user decisions from UX interview)
467
+
468
+ Produce `UX_BRIEF` by combining all three sources into concrete design implications.
469
+
470
+ **Brief heading differs by mode:**
471
+ - **If PROJECT_LEVEL=true:** `## UX Direction for {PROJECT_NAME}`
472
+ - **If PROJECT_LEVEL=false:** `## UX Direction for Stage {X}: {Name}`
473
+
474
+ **If PROJECT_LEVEL=true:** Include a `### UI Stages Covered` section after the heading, listing all UI stages from `UI_STAGES`:
475
+
476
+ ```markdown
477
+ ### UI Stages Covered
478
+ - Stage 3: Dashboard -- Main dashboard with data visualization
479
+ - Stage 5: Settings -- User settings page
480
+ ```
481
+
482
+ ```xml
483
+ <ux_brief>
484
+
485
+ ## UX Direction for {PROJECT_NAME or "Stage {X}: {Name}"}
486
+
487
+ {IF PROJECT_LEVEL=true:}
488
+ ### UI Stages Covered
489
+ - {list each UI stage from UI_STAGES with number, name, and goal}
490
+
491
+ {END IF}
492
+
493
+ ### Interaction Model
494
+ - [Concrete decisions from interview answers, e.g., "Inline form validation with debounced checks"]
495
+ - [Research-backed defaults for "Let Claude decide" answers, e.g., "Toast notifications for async operations, auto-dismiss 5s"]
496
+
497
+ ### Spacing and Density
498
+ - [Implied from adopted patterns, e.g., "Comfortable density -- 16px base padding, 24px section gaps"]
499
+ - [From UX.md emotional design implications, e.g., "Generous whitespace to achieve calm emotion"]
500
+
501
+ ### Component Implications
502
+ - [From adopted patterns + interview answers, e.g., "Data tables with sortable headers per UX.md proven pattern"]
503
+ - [From anti-pattern avoidance, e.g., "No infinite scroll -- paginate with clear page numbers per UX.md anti-pattern guidance"]
504
+
505
+ ### Flow Design
506
+ - [From critical flow decisions, e.g., "Onboarding: 3-step wizard with skip option and progress indicator"]
507
+ - [From friction tolerance, e.g., "Checkout: minimal friction -- single page, no account required"]
508
+
509
+ ### Emotional Guardrails
510
+ - Primary: [from UX.md + calibration answer, e.g., "confident -- clear feedback at every step"]
511
+ - Avoid: [from UX.md anti-emotion, e.g., "overwhelmed -- progressive disclosure, max 5 options per screen"]
512
+
513
+ ### Research References
514
+ - [Cross-references to UX.md sections that informed decisions]
515
+ - [Pattern names and confidence levels from research]
516
+
517
+ </ux_brief>
518
+ ```
519
+
520
+ **Rules for synthesis:**
521
+ - For answers where user made a choice: use the user's choice verbatim
522
+ - For "Let Claude decide" answers: use the research-backed default from UX.md
523
+ - Translate abstract UX principles into concrete design implications (spacing values, component types, flow structures)
524
+ - If all answers were "Let Claude decide": produce ux_brief entirely from UX.md research defaults
525
+ - Keep ux_brief concise (30-50 lines). This is a digest, not a research report
526
+
527
+ **Persist UX_BRIEF to file (EXTR-02):**
528
+
529
+ **If PROJECT_LEVEL=true:**
530
+
531
+ ```bash
532
+ mkdir -p .renn/design/
533
+ ```
534
+
535
+ Write the UX_BRIEF content to `.renn/design/ux-brief.md` as plain markdown. The file contains the synthesized UX brief sections WITHOUT XML tags -- just the markdown content between `<ux_brief>` and `</ux_brief>`.
536
+
537
+ Display: `UX brief synthesized and saved to .renn/design/ux-brief.md. Proceeding to design...`
538
+
539
+ **If PROJECT_LEVEL=false:**
540
+
541
+ Write the UX_BRIEF content to `${STAGE_DIR}/${STAGE}-ux-brief.md` as plain markdown. The file contains the synthesized UX brief sections WITHOUT XML tags -- just the markdown content between `<ux_brief>` and `</ux_brief>`.
542
+
543
+ This file survives `/clear` and is loaded by plan-stage in its read_context_files step.
544
+
545
+ Display: `UX brief synthesized and saved to ${STAGE_DIR}/${STAGE}-ux-brief.md. Proceeding to design...`
546
+
547
+ **File format (both modes):**
548
+
549
+ ```markdown
550
+ ## UX Direction for {PROJECT_NAME or "Stage {X}: {Name}"}
551
+
552
+ ### UI Stages Covered (project-level only)
553
+ - ...
554
+
555
+ ### Interaction Model
556
+ - ...
557
+
558
+ ### Spacing and Density
559
+ - ...
560
+
561
+ ### Component Implications
562
+ - ...
563
+
564
+ ### Flow Design
565
+ - ...
566
+
567
+ ### Emotional Guardrails
568
+ - ...
569
+
570
+ ### Research References
571
+ - ...
572
+ ```
573
+
574
+ **Store:** `UX_BRIEF` variable for handle_design and designer context.
575
+ </step>
576
+
577
+ <step name="handle_design">
578
+
579
+ **Load commit config for design artifact commits:**
580
+
581
+ ```bash
582
+ COMMIT_PLANNING_DOCS=$(cat .renn/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
583
+ git check-ignore -q .renn 2>/dev/null && COMMIT_PLANNING_DOCS=false
584
+ ```
585
+
586
+ ### UI Detection
587
+
588
+ UI detection has already run in detect_ui_stage. The result is confirmed:
589
+
590
+ - `UI_STAGE=true`: Continue to Existing Design Detection.
591
+
592
+ (design-stage validated `UI_STAGE=true` in detect_ui_stage. Non-UI stages error and exit at that step.)
593
+
594
+ ### Existing Design Detection (PLAN-03 partial)
595
+
596
+ ```bash
597
+ # Check if screens for this stage already exist in global location
598
+ # This requires checking if the stage previously ran Phase 2 and produced screens
599
+ # Look for design output markers in recap files
600
+ grep -l "Screen Specs" "${STAGE_DIR}"/*-recap.md 2>/dev/null
601
+ ```
602
+
603
+ If a recap references screen specs and no `--force` flag: Display "Using existing design from prior run.". Store design paths for downstream. Skip to generate_implementation_guide.
604
+
605
+ ### Mode Determination (PLAN-03)
606
+
607
+ ```bash
608
+ ls .renn/design/stylekit.yaml 2>/dev/null
609
+ ls .renn/codebase/DESIGN.md 2>/dev/null
610
+ ```
611
+
612
+ **Phase 2 only mode override (when --phase-2-only flag is set):**
613
+
614
+ If `PHASE_2_ONLY=true`:
615
+ - Check `ls .renn/design/stylekit.yaml 2>/dev/null`
616
+ - If stylekit.yaml does NOT exist: **ERROR** -- Display: "No design system found at .renn/design/stylekit.yaml\n\nRun /renn.design-system first to create the design system,\nthen run /renn.design-screens {N} to create screen prototypes." STOP.
617
+ - If stylekit.yaml exists: Set `DESIGN_MODE="screens_only"`. Skip normal mode determination. Skip Restyle Trigger. Jump directly to Phase 2.
618
+ - Load UX brief from disk (project-level path first, stage-level fallback):
619
+ ```bash
620
+ UX_BRIEF=$(cat .renn/design/ux-brief.md 2>/dev/null)
621
+ if [ -z "$UX_BRIEF" ]; then
622
+ UX_BRIEF=$(cat ${STAGE_DIR}/${STAGE}-ux-brief.md 2>/dev/null)
623
+ fi
624
+ ```
625
+ - Load research from disk (if not already loaded): `RESEARCH_CONTENT=$(cat ${STAGE_DIR}/${STAGE}-research.md 2>/dev/null)` (belt-and-suspenders with handle_research skip)
626
+
627
+ **Restyle mode override (when --restyle flag is set):**
628
+
629
+ If `RESTYLE_MODE=true`:
630
+ - Check `ls .renn/design/stylekit.yaml 2>/dev/null`
631
+ - If stylekit.yaml does NOT exist: **ERROR** -- Display: "No existing design to restyle. Run `/renn.design-system` first." STOP.
632
+ - If stylekit.yaml exists: Set `DESIGN_MODE="screens_only"`. Skip the normal priority order below. Jump directly to the Restyle Trigger (PLAN-07) section.
633
+
634
+ **Normal mode determination (when --restyle flag is NOT set):**
635
+
636
+ Priority order (check in this sequence):
637
+ 1. If stylekit.yaml exists: `DESIGN_MODE="screens_only"` (approved design system takes precedence)
638
+ 2. Else if .renn/codebase/DESIGN.md exists: `DESIGN_MODE="translate"` (brownfield design detected)
639
+ 3. Else: `DESIGN_MODE="full"` (greenfield, no existing design)
640
+
641
+ ### Translate Mode Checkpoint (only when DESIGN_MODE="translate")
642
+
643
+ **If `DESIGN_MODE` is NOT "translate": Skip this subsection.**
644
+
645
+ Present `checkpoint:decision`:
646
+
647
+ ```
648
+ Existing design patterns detected in .renn/codebase/DESIGN.md
649
+
650
+ Your project already has a visual design system. How should RENN handle it?
651
+
652
+ Options:
653
+ Absorb - Extract existing patterns into RENN stylekit as-is (fastest, no interview)
654
+ Extend - Extract existing patterns + discuss enhancements (balanced)
655
+ Replace - Ignore existing patterns, create fresh design system (full interview)
656
+
657
+ Select: absorb, extend, or replace
658
+ ```
659
+
660
+ Routing:
661
+ - `absorb`: Set `TRANSLATE_STRATEGY="absorb"`. Skip the design interview entirely. Read `.renn/codebase/DESIGN.md` content into `TRANSLATION_CONTEXT`. Display: "Absorbing existing design. Skipping interview..."
662
+ - `extend`: Set `TRANSLATE_STRATEGY="extend"`. Read `.renn/codebase/DESIGN.md` content into `TRANSLATION_CONTEXT`. Continue to the scoped interview (see Scoped Interview below).
663
+ - `replace`: Set `DESIGN_MODE="full"`. Display: "Replacing existing design. Running full interview..." Continue to existing greenfield flow (design interview, Phase 1, etc.) as if DESIGN.md did not exist.
664
+
665
+ ### Scoped Interview (only when TRANSLATE_STRATEGY="extend")
666
+
667
+ **If `TRANSLATE_STRATEGY` is NOT "extend": Skip this subsection.**
668
+
669
+ This is a shortened version of the full design interview, focused on gaps in the existing design.
670
+
671
+ #### Step 1: Analyze DESIGN.md for Gaps
672
+
673
+ Read TRANSLATION_CONTEXT (the DESIGN.md content). For each core design question, determine if DESIGN.md already answers it:
674
+
675
+ | Core Question | Already Answered If |
676
+ |---------------|---------------------|
677
+ | Visual style | DESIGN.md describes a clear visual personality |
678
+ | Color direction | Color System section has a defined palette |
679
+ | Typography | Typography section has specific font families |
680
+ | Layout density | Component Inventory shows consistent spacing patterns |
681
+ | Dark mode | Dark Mode section has a strategy other than "not implemented" |
682
+ | Responsive | Component Inventory or Visual Patterns show responsive behavior |
683
+
684
+ Track which questions are UNANSWERED (gaps).
685
+
686
+ #### Step 2: Generate Extension Gray Areas
687
+
688
+ Generate 2-3 gray areas based on what DESIGN.md is MISSING. These are aspects where the existing design has no clear direction and the user should weigh in.
689
+
690
+ Example: If DESIGN.md has colors and fonts but no dark mode and no spacing scale:
691
+ - "Dark mode strategy" -- Should we add dark mode support?
692
+ - "Spacing refinement" -- Your current spacing seems ad-hoc. Standardize to a scale?
693
+
694
+ #### Step 3: Deep-Dive Gaps
695
+
696
+ For each unanswered core question and generated gray area, use AskUserQuestion with 2-4 options (following the same pattern as the full interview):
697
+ - Include "Let Claude decide" option on every question
698
+ - Follow the same recommendation guidelines (subjective = recommend specific, technical = recommend "Let Claude decide")
699
+
700
+ Target: 3-7 total questions (shorter than the full interview's 8-15).
701
+
702
+ #### Step 4: Compile Extension Preferences
703
+
704
+ Compile answers into `DESIGN_EXTENSION_PREFERENCES` using this format:
705
+
706
+ ```xml
707
+ <design_extension_preferences>
708
+
709
+ ## Extension Direction
710
+
711
+ ### Aspects Preserved from Existing Design
712
+ - Color system: {summary from DESIGN.md}
713
+ - Typography: {summary from DESIGN.md}
714
+ - {other preserved aspects}
715
+
716
+ ### Aspects Extended
717
+ {For each gap where user answered:}
718
+ ### [Gap Area]
719
+ Pick: {user's choice OR "Designer's choice"}
720
+ Context: {any elaboration}
721
+
722
+ ### Designer Autonomy
723
+ The following aspects are marked as "Designer's choice":
724
+ - {list of "Let Claude decide" items}
725
+
726
+ </design_extension_preferences>
727
+ ```
728
+
729
+ Display: "Extension preferences captured. Proceeding to design system creation..."
730
+
731
+ ### Restyle Trigger (PLAN-07)
732
+
733
+ Only when `DESIGN_MODE="screens_only"` (existing stylekit detected):
734
+
735
+ **If RESTYLE_MODE=true:** Skip the restyle checkpoint entirely. Set `DESIGN_MODE="screens_only"`.
736
+
737
+ Display:
738
+ ```
739
+ Restyling: creating new screen prototypes with existing design system.
740
+ To create an entirely new design system, run /renn.design-system instead.
741
+ ```
742
+
743
+ **If RESTYLE_MODE is NOT set (normal flow):** Present the existing checkpoint:
744
+
745
+ ```
746
+ Existing stylekit found at .renn/design/stylekit.yaml
747
+
748
+ Options:
749
+ Use existing - Create new screens using current design system
750
+ Restyle - Create a new visual direction (replaces current stylekit)
751
+
752
+ Select: use-existing or restyle
753
+ ```
754
+
755
+ If `use-existing`: Continue with `DESIGN_MODE="screens_only"`.
756
+ If `restyle`: Set `DESIGN_MODE="full"`. Designer receives existing stylekit as reference context.
757
+
758
+ ### Design Interview
759
+
760
+ **If `DESIGN_MODE="screens_only"`: Skip interview entirely.** Preferences are already baked into the existing stylekit.
761
+
762
+ **If `DESIGN_MODE="translate"` and `TRANSLATE_STRATEGY="absorb"`: Skip interview entirely.** Designer will extract existing patterns as-is.
763
+
764
+ **If `DESIGN_MODE="translate"` and `TRANSLATE_STRATEGY="extend"`: Skip this section.** The scoped interview above already captured extension preferences.
765
+
766
+ **If `DESIGN_MODE="full"`:** Run the progressive design interview.
767
+
768
+ Display banner:
769
+
770
+ **If PROJECT_LEVEL=true:**
771
+
772
+ ```
773
+ RENN > PROJECT DESIGN -- DESIGN INTERVIEW
774
+
775
+ Before creating your project design system, let me understand your vision.
776
+ ```
777
+
778
+ **If PROJECT_LEVEL=false:**
779
+
780
+ ```
781
+ RENN > DESIGNING STAGE {X} -- DESIGN INTERVIEW
782
+
783
+ Before creating your design system, let me understand your vision.
784
+ ```
785
+
786
+ If this is a restyle (DESIGN_MODE was set to "full" via the restyle trigger), acknowledge it: "You're restyling. Let me ask about your new direction."
787
+
788
+ #### Step 1: Analyze Project Context
789
+
790
+ Read available project context to generate design-relevant gray areas:
791
+
792
+ 1. Read brief.md for project domain and value proposition
793
+ 2. Read stage goal from track.md for what's being built
794
+ 3. Read research.md (if exists) for technical context
795
+ 4. Read intel.md (if exists) for existing decisions
796
+
797
+ Generate 3-5 gray areas SPECIFIC to this project. These are design decisions that would change the outcome and the user should weigh in on.
798
+
799
+ **Plain-language rule:** The user may not be technical. Describe what they'd see or experience — not design terminology. Use familiar app references where helpful.
800
+
801
+ Examples:
802
+
803
+ For a "personal dashboard" project:
804
+ - "How packed the screen feels" -- Lots of data in tight rows, or spacious cards with breathing room?
805
+ - "The overall vibe" -- Feels like a serious work tool, or a friendly personal app?
806
+ - "How you interact with things" -- Drag things around? Edit right on the page? Or click to open a separate panel?
807
+
808
+ For a "documentation site" project:
809
+ - "What you see first" -- A big welcome section, or straight into the content?
810
+ - "The personality" -- Precise and technical, or warm and approachable?
811
+ - "How you find things" -- A big menu with everything visible, a simple top bar, or a sidebar?
812
+
813
+ NOT generic: "UI layout", "Color scheme", "Typography choices" -- these are categories, not gray areas.
814
+
815
+ **Map core design questions to gray areas.** Each of the 6 core design preferences should have a natural home in one of the generated gray areas:
816
+
817
+ | Core Question | Natural Fit Examples |
818
+ |---------------|---------------------|
819
+ | Overall feel (professional/modern/warm/bold) | The overall vibe, Visual identity |
820
+ | Color mood (warm/cool/neutral/bright) | The overall vibe, Visual identity |
821
+ | Font style (clean modern/classic book/code-style) | How content reads, Reading experience |
822
+ | How packed the screen feels (spacious/balanced/dense) | How packed the screen feels, Content density |
823
+ | Dark or light (dark-default/toggle/light-only) | Can be its own area or fit under Look and feel |
824
+ | Screen sizes (desktop-first/all-sizes/desktop-only) | Can be its own area or fit under Device strategy |
825
+
826
+ Track which core questions are mapped to which gray areas.
827
+
828
+ #### Step 2: Present Gray Areas for Selection
829
+
830
+ Use AskUserQuestion with multiSelect: true:
831
+
832
+ ```
833
+ - header: "Design Direction"
834
+ - question: "Which design areas should we discuss for [stage name]?"
835
+ - options: [3-5 project-specific gray areas, each with a short description of what questions it covers]
836
+ ```
837
+
838
+ Do NOT include a "skip all" option. The user ran design to get design -- give them real choices. Core design questions embedded in unselected areas will be caught by the fallback round (Step 4).
839
+
840
+ #### Step 3: Deep-Dive Each Selected Area
841
+
842
+ For each selected area, in order:
843
+
844
+ 1. Announce the area: "Let's talk about [area]."
845
+
846
+ 2. Ask 3-4 questions using AskUserQuestion, each with 2-4 concrete options:
847
+ - Include the core design question(s) mapped to this area as structured AskUserQuestion calls
848
+ - Every question MUST include a "Let Claude decide" option
849
+ - For subjective/brand questions (visual style, color direction): recommend a specific option (label it "(Recommended)")
850
+ - For opinionated/technical questions (typography pairing, spacing rhythm, border radius): recommend "Let Claude decide" (label it "(Recommended)")
851
+ - For mixed questions (layout density, dark mode, responsive): recommend a specific option
852
+ - Each subsequent question informed by previous answers in this area
853
+ - After the core question(s), ask 1-2 project-specific follow-up questions for the gray area
854
+ - **Plain-language rule:** Describe what the user would see, not design terminology. Say "rounded friendly buttons vs sharp clean edges" not "border-radius values"
855
+
856
+ 3. After 3-4 questions for the area, offer: "More questions about [area], or move to next?"
857
+ - If "More questions": ask 2-3 more, then check again
858
+ - If "Next area": proceed to next selected area
859
+
860
+ **Scope guardrail:** If the user suggests something outside the stage domain during discussion:
861
+ ```
862
+ "[Feature] sounds like a new capability -- that belongs in its own stage.
863
+ Let's focus on the design direction for [current stage]."
864
+ ```
865
+
866
+ **Target up to {VISUAL_BUDGET} questions across all areas, where VISUAL_BUDGET = 15 - UX_QUESTIONS_ASKED.** If UX interview was skipped (UX_QUESTIONS_ASKED=0), target 8-15. The combined interview (UX + visual) should take 2-3 minutes, not 10.
867
+
868
+ #### Step 4: Core Question Fallback
869
+
870
+ After all selected gray areas are discussed, check which core design questions were NOT asked (because their containing gray area was deselected or no gray area naturally contained them).
871
+
872
+ ```
873
+ CORE_QUESTIONS = [visual_style, color_direction, typography, layout_density, dark_mode, responsive]
874
+ ASKED_QUESTIONS = [questions already embedded in gray area discussions]
875
+ REMAINING = CORE_QUESTIONS - ASKED_QUESTIONS
876
+ ```
877
+
878
+ If REMAINING is not empty, present: "A few more design essentials:"
879
+
880
+ For each remaining core question, use AskUserQuestion with the standard options:
881
+
882
+ - **Overall feel:** Professional and minimal, Clean and modern, Warm and inviting, Bold and expressive, Let Claude decide
883
+ - **Color mood:** Warm tones (earthy, sunset), Cool tones (ocean, sky), Neutral (grays, black & white), Bright and colorful, Let Claude decide (Recommended)
884
+ - **Font style:** Clean modern fonts (like most apps), Classic book-style fonts (like newspapers), Code-style fonts (like a terminal), A mix of styles, Let Claude decide (Recommended)
885
+ - **How packed the screen feels:** Lots of breathing room, Balanced (not too sparse, not too tight), Information-dense (show as much as possible), Let Claude decide (Recommended)
886
+ - **Dark or light:** Dark background by default, Light with a dark mode toggle, Light only, Let Claude decide
887
+ - **Screen sizes:** Starts on desktop, adapts to phones, Works on all screen sizes equally, Desktop only, Let Claude decide
888
+
889
+ #### Step 5: Pexels API Key Collection
890
+
891
+ After all design questions are answered, collect the Pexels API key as part of the same flow.
892
+
893
+ ```bash
894
+ PEXELS_KEY=$(cat .renn/secrets.json 2>/dev/null | grep -o '"pexels_api_key"[[:space:]]*:[[:space:]]*"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' || echo "")
895
+ ```
896
+
897
+ If key already exists in secrets.json: read silently, no prompt. Display: "Pexels key found."
898
+
899
+ If empty or missing, present as AskUserQuestion:
900
+
901
+ ```
902
+ - header: "One last thing"
903
+ - question: "Pexels API key enables real stock images in prototypes. Get a free key at https://www.pexels.com/api/"
904
+ - options:
905
+ - "Paste my key" -- I have a key ready
906
+ - "Skip" -- Use placeholder images instead
907
+ ```
908
+
909
+ If user selects "Paste my key", prompt for the key value. Then:
910
+ 1. Read existing `.renn/secrets.json` content (if file exists) to preserve other fields
911
+ 2. Merge `{"pexels_api_key": "{user_input}"}` into the existing JSON object
912
+ 3. Write merged JSON back to `.renn/secrets.json`
913
+ 4. Set `PEXELS_KEY` to the provided value
914
+ 5. Display: "Pexels API key saved."
915
+
916
+ If user selects "Skip":
917
+ 1. Set `PEXELS_KEY="NOT_AVAILABLE"`
918
+ 2. Display: "Using placeholder images."
919
+ 3. Do NOT create or modify secrets.json
920
+
921
+ Ensure `.renn/secrets.json` is gitignored:
922
+
923
+ ```bash
924
+ grep -q "secrets.json" .gitignore 2>/dev/null || echo ".renn/secrets.json" >> .gitignore
925
+ ```
926
+
927
+ #### Step 6: Compile Design Preferences
928
+
929
+ Compile all collected answers into a `DESIGN_PREFERENCES` variable using this format:
930
+
931
+ ```xml
932
+ <design_preferences>
933
+
934
+ ## Design Direction
935
+
936
+ ### Visual Style
937
+ Pick: {user's choice OR "Designer's choice"}
938
+ Context: {any elaboration from follow-up questions}
939
+
940
+ ### Color Direction
941
+ Pick: {user's choice OR "Designer's choice"}
942
+ Context: {any elaboration}
943
+
944
+ ### Typography
945
+ Pick: {user's choice OR "Designer's choice"}
946
+ Context: {any elaboration}
947
+
948
+ ### Layout
949
+ Pick: {user's choice OR "Designer's choice"}
950
+ Context: {any elaboration}
951
+
952
+ ### Dark Mode
953
+ Pick: {user's choice OR "Designer's choice"}
954
+
955
+ ### Responsive
956
+ Pick: {user's choice OR "Designer's choice"}
957
+
958
+ ## Project-Specific Insights
959
+
960
+ ### [Gray Area 1 that was discussed]
961
+ - {Decision or preference captured}
962
+ - {Another decision}
963
+
964
+ ### [Gray Area 2 that was discussed]
965
+ - {Decision or preference captured}
966
+
967
+ ## Designer Autonomy
968
+
969
+ The following aspects are marked as "Designer's choice" -- you have creative autonomy:
970
+ - {list of items where user picked "Let Claude decide"}
971
+
972
+ For these items, make opinionated choices that serve the project's domain and stage goals. Explain your reasoning in the design return.
973
+
974
+ </design_preferences>
975
+ ```
976
+
977
+ Store in `DESIGN_PREFERENCES` for use in the Phase 1 spawn template.
978
+
979
+ Display: "Design preferences captured. Proceeding to design system creation..."
980
+
981
+ ### Initialize Counters
982
+
983
+ ```
984
+ auto_revision_count = 0
985
+ user_revision_count = 0
986
+ ```
987
+
988
+ ### Two-Phase Design Orchestration
989
+
990
+ The design workflow runs in two phases with an approval gate between them. Each phase has its own designer spawn, reviewer spawn, auto-revision loop, approval gate, and user revision loop.
991
+
992
+ - **Full mode:** Phase 1 (stylekit) then Phase 2 (screens)
993
+ - **screens_only mode:** Phase 2 only (stylekit already approved from a prior stage)
994
+
995
+ ---
996
+
997
+ ### Phase 1: Design System (ONLY when DESIGN_MODE="full")
998
+
999
+ **If `DESIGN_MODE="screens_only"`: Skip Phase 1 entirely. Jump to Phase 2.**
1000
+
1001
+ #### Phase 1 -- Assemble Designer Context and Spawn
1002
+
1003
+ 11 context variables (plus `phase`):
1004
+
1005
+ | Variable | Source |
1006
+ |----------|--------|
1007
+ | `design_mode` | DESIGN_MODE ("full" or "translate") |
1008
+ | `phase` | "stylekit" |
1009
+ | `stage_name` | parse_args |
1010
+ | `stage_goal` | track.md stage details |
1011
+ | `research_content` | `${STAGE_DIR}/research.md` content |
1012
+ | `intel_content` | INTEL_CONTENT (loaded in ensure_stage_directory) |
1013
+ | `design_preferences` | DESIGN_PREFERENCES (compiled from design interview Step 6) |
1014
+ | `pexels_key` | Pexels API key check result |
1015
+ | `stage_dir` | STAGE_DIR path |
1016
+ | `translation_context` | TRANSLATION_CONTEXT (DESIGN.md content, only when DESIGN_MODE="translate") |
1017
+ | `translation_strategy` | TRANSLATE_STRATEGY ("absorb" or "extend", only when DESIGN_MODE="translate") |
1018
+ | `design_extension_preferences` | DESIGN_EXTENSION_PREFERENCES (only when TRANSLATE_STRATEGY="extend") |
1019
+ | `ux_brief` | UX_BRIEF (from ux_synthesis step, if non-empty) |
1020
+ | `project_name` | PROJECT_NAME (from brief.md heading) |
1021
+ | `platform` | PLATFORM (from brief.md Context section) |
1022
+ | `viewport_raw` | VIEWPORT_RAW (from brief.md Context section) |
1023
+
1024
+ Note: `stylekit_content` and `component_names` are NOT passed in Phase 1 (they don't exist yet).
1025
+
1026
+ Phase 1 designer spawn template:
1027
+
1028
+ ```
1029
+ <design_context>
1030
+
1031
+ **Project Name:** {PROJECT_NAME}
1032
+ **Mode:** {DESIGN_MODE}
1033
+ **Phase:** stylekit
1034
+
1035
+ {IF PROJECT_LEVEL=true:}
1036
+ **Scope:** All UI stages
1037
+ **UI Stages:**
1038
+ {for each stage in UI_STAGES: "- Stage {N}: {name} -- {goal}"}
1039
+ {END IF}
1040
+
1041
+ {IF PROJECT_LEVEL=false:}
1042
+ **Stage:** {stage_name}
1043
+ **Goal:** {stage_goal}
1044
+ {END IF}
1045
+
1046
+ {DESIGN_PREFERENCES}
1047
+
1048
+ {IF UX_BRIEF is non-empty:}
1049
+
1050
+ **UX Brief (from UX research + interview):**
1051
+ {UX_BRIEF}
1052
+
1053
+ This ux_brief provides concrete UX direction based on research and user interview answers.
1054
+ Use it to inform spacing/density decisions, component selection, and interaction patterns.
1055
+ The ux_brief is INFORMATIONAL -- it supplements design preferences but does not override them.
1056
+
1057
+ {END IF}
1058
+
1059
+ {IF PLATFORM is not "web" AND VIEWPORT_RAW is non-empty:}
1060
+
1061
+ **Viewport Context (from brief.md):**
1062
+ **Platform:** {PLATFORM}
1063
+ **Target Viewport:** {VIEWPORT_RAW}
1064
+
1065
+ Use this viewport metadata to populate the stylekit.yaml viewport section (step 3b) and apply viewport wrapping to screen prototypes (step 2b). Parse the target viewport string to extract width, height, frame ID, and other viewport schema fields.
1066
+
1067
+ {END IF}
1068
+
1069
+ {IF DESIGN_MODE == "translate":}
1070
+
1071
+ **Translation Mode:**
1072
+ **Strategy:** {TRANSLATE_STRATEGY}
1073
+
1074
+ <translation_context>
1075
+ {TRANSLATION_CONTEXT}
1076
+ </translation_context>
1077
+
1078
+ {IF TRANSLATE_STRATEGY == "extend":}
1079
+ {DESIGN_EXTENSION_PREFERENCES}
1080
+ {END IF}
1081
+
1082
+ **Translation Instructions:**
1083
+ - Extract concrete values from the existing design into the three-layer token architecture
1084
+ - Map colors, fonts, spacing, shadows, border radii to proper primitive/semantic/component tokens
1085
+ - For absorb: reproduce existing design faithfully, fill gaps with sensible defaults based on the extracted palette
1086
+ - For extend: reproduce existing design, then enhance using the extension preferences above
1087
+ - SKIP the anti-generic checklist (existing design is intentional, not AI-generated)
1088
+ - Generate stylekit-preview.html for user verification: "Does this represent your existing design?"
1089
+
1090
+ {END IF}
1091
+
1092
+ **Research:**
1093
+ {research_content}
1094
+
1095
+ **Intel (raw -- extract design-relevant decisions yourself):**
1096
+ {intel_content}
1097
+
1098
+ **Token Schema Reference:** Follow the 3-layer architecture (primitive, semantic, component) from the design token specification. W3C DTCG $type/$value structure. Namespace mapping: primitive.color.* -> --color-*, primitive.typography.family.* -> --font-*, primitive.typography.size.* -> --text-*, etc. All :root values resolved to concrete CSS (no var() references inside :root block). Stylekit.css uses plain :root {} custom properties, not Tailwind v4 @theme syntax. HTML boilerplate uses Tailwind v3 CDN with inline tailwind.config mapping tokens to theme extensions.
1099
+ **Component Schema Reference:** Follow the component inventory format: required fields are name, description, category, properties, tokens, states, responsive, accessibility, preview. State vocabulary fixed at 8: default, hover, active, focus, disabled, loading, error, empty. Token-driven preview using semantic Tailwind classes.
1100
+
1101
+ **Pexels API Key:** {pexels_key}
1102
+
1103
+ **Output Directories:**
1104
+ - Stylekit: .renn/design/
1105
+ - Components: .renn/design/components/
1106
+ - Preview: .renn/design/stylekit-preview.html
1107
+
1108
+ </design_context>
1109
+ ```
1110
+
1111
+ For Phase 1 revisions, append a `<revision_context>` block:
1112
+
1113
+ ```
1114
+ <revision_context>
1115
+
1116
+ **Revision:** {N} of 3
1117
+ **Phase:** stylekit
1118
+ **Source:** {reviewer | user}
1119
+ **Feedback:**
1120
+ {feedback_text}
1121
+
1122
+ **Current artifacts on disk:**
1123
+ {list of existing artifact paths}
1124
+
1125
+ Revise the design system based on the feedback above. When changing tokens, cascade changes to all affected components and the preview (see Cascading Token Revisions rule). Overwrite files in place (git tracks previous versions).
1126
+ Return ## DESIGN REVISION (not ## DESIGN COMPLETE) to signal this is a revision.
1127
+
1128
+ </revision_context>
1129
+ ```
1130
+
1131
+ Display banner before spawning:
1132
+
1133
+ **If PROJECT_LEVEL=true:**
1134
+
1135
+ ```
1136
+ RENN > PROJECT DESIGN -- PHASE 1: DESIGN SYSTEM
1137
+ {IF DESIGN_MODE == "translate":}
1138
+ Spawning designer (mode: translate, strategy: {TRANSLATE_STRATEGY}, phase: stylekit)...
1139
+ {ELSE:}
1140
+ Spawning designer (mode: full, phase: stylekit)...
1141
+ {END IF}
1142
+ ```
1143
+
1144
+ **If PROJECT_LEVEL=false:**
1145
+
1146
+ ```
1147
+ RENN > DESIGNING STAGE {X} -- PHASE 1: DESIGN SYSTEM
1148
+ {IF DESIGN_MODE == "translate":}
1149
+ Spawning designer (mode: translate, strategy: {TRANSLATE_STRATEGY}, phase: stylekit)...
1150
+ {ELSE:}
1151
+ Spawning designer (mode: full, phase: stylekit)...
1152
+ {END IF}
1153
+ ```
1154
+
1155
+ Spawn:
1156
+
1157
+ **If PROJECT_LEVEL=true:**
1158
+
1159
+ ```
1160
+ Task(
1161
+ prompt=designer_prompt,
1162
+ subagent_type="renn-designer",
1163
+ model="{designer_model}",
1164
+ description="Design Project - Phase 1 (stylekit)"
1165
+ )
1166
+ ```
1167
+
1168
+ **If PROJECT_LEVEL=false:**
1169
+
1170
+ ```
1171
+ Task(
1172
+ prompt=designer_prompt,
1173
+ subagent_type="renn-designer",
1174
+ model="{designer_model}",
1175
+ description="Design Stage {stage} - Phase 1 (stylekit)"
1176
+ )
1177
+ ```
1178
+
1179
+ Parse designer return: `## DESIGN COMPLETE` or `## DESIGN REVISION`. Verify `**Phase:** stylekit` in the return.
1180
+
1181
+ #### Phase 1 -- Spawn Reviewer
1182
+
1183
+ Reviewer spawn template:
1184
+
1185
+ ```
1186
+ <review_context>
1187
+
1188
+ **Mode:** full
1189
+ **Phase:** stylekit
1190
+ **Designer Output:**
1191
+ {designer_return}
1192
+
1193
+ **Artifact Paths:**
1194
+ {artifact_paths}
1195
+
1196
+ Review stylekit, components, and preview for spec compliance, anti-generic aesthetics, and overall quality.
1197
+ Phase scope: token structure, component YAML, preview HTML, full anti-generic checklist, component consistency.
1198
+ Return REVIEW PASSED or ISSUES FOUND with actionable feedback.
1199
+
1200
+ </review_context>
1201
+ ```
1202
+
1203
+ **If PROJECT_LEVEL=true:**
1204
+
1205
+ ```
1206
+ Task(
1207
+ prompt=reviewer_prompt,
1208
+ subagent_type="renn-design-reviewer",
1209
+ model="{reviewer_model}",
1210
+ description="Review design Phase 1 (stylekit) for project"
1211
+ )
1212
+ ```
1213
+
1214
+ **If PROJECT_LEVEL=false:**
1215
+
1216
+ ```
1217
+ Task(
1218
+ prompt=reviewer_prompt,
1219
+ subagent_type="renn-design-reviewer",
1220
+ model="{reviewer_model}",
1221
+ description="Review design Phase 1 (stylekit) for Stage {stage}"
1222
+ )
1223
+ ```
1224
+
1225
+ #### Phase 1 -- Auto-Revision Loop
1226
+
1227
+ Same logic as the standard auto-revision pattern, using the shared `auto_revision_count`:
1228
+
1229
+ If `## ISSUES FOUND`:
1230
+ 1. Increment `auto_revision_count`
1231
+ 2. If `auto_revision_count <= 2`:
1232
+ - Display: "Reviewer found issues. Auto-revising... (attempt {auto_revision_count}/2)"
1233
+ - Re-spawn designer with Phase 1 context + revision_context (source: "reviewer", feedback: reviewer's issue list)
1234
+ - After designer returns: re-spawn reviewer (phase: stylekit)
1235
+ - Loop back to check reviewer return
1236
+ 3. If `auto_revision_count > 2`:
1237
+ - Display: "Auto-revision limit reached. Escalating to user."
1238
+ - Present Phase 1 escalation (see Phase 1 Escalation below)
1239
+
1240
+ If `## REVIEW PASSED`:
1241
+ - Reset `auto_revision_count = 0`
1242
+ - Proceed to Phase 1 Approval Gate
1243
+
1244
+ #### Phase 1 -- Approval Gate
1245
+
1246
+ **Step 1 -- Auto-open preview in browser:**
1247
+
1248
+ Build the file list for Phase 1: `.renn/design/stylekit-preview.html` ONLY.
1249
+
1250
+ ```bash
1251
+ # EXECUTE THIS NOW -- open Phase 1 preview before showing gate
1252
+ GATE_FILES=".renn/design/stylekit-preview.html"
1253
+ for file in $GATE_FILES; do
1254
+ if [[ -f "$file" ]]; then
1255
+ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
1256
+ start "" "$file"
1257
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
1258
+ open "$file"
1259
+ elif command -v xdg-open &>/dev/null; then
1260
+ xdg-open "$file" &>/dev/null &
1261
+ elif command -v cmd.exe &>/dev/null; then
1262
+ cmd.exe /c start "" "$file"
1263
+ fi
1264
+ sleep 0.5
1265
+ fi
1266
+ done
1267
+ ```
1268
+
1269
+ **Step 2 -- Present checkpoint:human-verify:**
1270
+
1271
+ **If PROJECT_LEVEL=true:**
1272
+
1273
+ ```
1274
+ what-built: "Design system for project"
1275
+ how-to-verify:
1276
+ 1. Review design system preview in browser (auto-opened):
1277
+ - .renn/design/stylekit-preview.html (colors, typography, spacing, components)
1278
+ 2. Check that color palette matches your brand vision
1279
+ 3. Verify typography feels right for your project
1280
+ 4. Review component styling (buttons, cards, inputs, etc.)
1281
+ Note: This project-level design system will be used across all UI stages.
1282
+ resume-signal: Type "approved" or describe what to change (e.g., "make primary color darker", "switch to a serif font")
1283
+ ```
1284
+
1285
+ **If PROJECT_LEVEL=false:**
1286
+
1287
+ ```
1288
+ what-built: "Design system for Stage {N}: {stage_name}"
1289
+ how-to-verify:
1290
+ 1. Review design system preview in browser (auto-opened):
1291
+ - .renn/design/stylekit-preview.html (colors, typography, spacing, components)
1292
+ 2. Check that color palette matches your brand vision
1293
+ 3. Verify typography feels right for your project
1294
+ 4. Review component styling (buttons, cards, inputs, etc.)
1295
+ Note: Screen layouts are created in the next phase after you approve this design system.
1296
+ resume-signal: Type "approved" or describe what to change (e.g., "make primary color darker", "switch to a serif font")
1297
+ ```
1298
+
1299
+ #### Phase 1 -- User Revision Loop
1300
+
1301
+ If user types "approved": Proceed to Phase 1 -> Phase 2 transition.
1302
+
1303
+ If user provides feedback:
1304
+ 1. Increment `user_revision_count`
1305
+ 2. If `user_revision_count <= 3`:
1306
+ - Re-spawn designer with Phase 1 context + revision_context (source: "user", feedback: user's text). Note: revision_context includes the cascade instruction.
1307
+ - After designer returns: re-spawn reviewer (phase: stylekit)
1308
+ - If reviewer passes: present updated Phase 1 gate
1309
+ - If reviewer fails: enter Phase 1 auto-revision loop, then present to user
1310
+ 3. If `user_revision_count > 3`: Present Phase 1 escalation
1311
+
1312
+ #### Phase 1 -- Escalation
1313
+
1314
+ Present `checkpoint:decision`:
1315
+
1316
+ **If PROJECT_LEVEL=true:**
1317
+
1318
+ ```
1319
+ Design system has reached the revision limit.
1320
+
1321
+ Current state: {summary of latest designer output}
1322
+ {IF reviewer issues exist:} Reviewer concerns: {summary of latest issues}
1323
+
1324
+ Options:
1325
+ Accept - Use current design system as-is
1326
+ Restart - Start over with a completely new design direction
1327
+ Skip - Skip design for this project (no design system will be created)
1328
+
1329
+ Select: accept, restart, or skip
1330
+ ```
1331
+
1332
+ **If PROJECT_LEVEL=false:**
1333
+
1334
+ ```
1335
+ Design system has reached the revision limit.
1336
+
1337
+ Current state: {summary of latest designer output}
1338
+ {IF reviewer issues exist:} Reviewer concerns: {summary of latest issues}
1339
+
1340
+ Options:
1341
+ Accept - Use current design system as-is (proceed to screen design)
1342
+ Restart - Start over with a completely new design direction
1343
+ Skip - Skip ALL design for this stage (no screens will be created)
1344
+
1345
+ Select: accept, restart, or skip
1346
+ ```
1347
+
1348
+ Behavior:
1349
+ - `accept`: Proceed to Phase 2 with current stylekit (treated as approved).
1350
+ - `restart`: Delete `.renn/design/` contents (stylekit, CSS, components, preview). Reset both counters to 0. Re-run Phase 1 from designer spawn.
1351
+ - `skip`: Delete `.renn/design/` contents. Set `HAS_DESIGN=false`. Skip Phase 2. Continue to present_final_status.
1352
+
1353
+ **CRITICAL:** Phase 1 skip aborts BOTH phases. There is no path where Phase 1 is skipped but Phase 2 runs.
1354
+
1355
+ #### Phase 1 -- Commit Design Artifacts
1356
+
1357
+ **After Phase 1 approval (before Phase 2 transition):**
1358
+
1359
+ ```bash
1360
+ if [ "$COMMIT_PLANNING_DOCS" = "true" ]; then
1361
+ git add .renn/design/stylekit.yaml
1362
+ git add .renn/design/stylekit.css
1363
+ git add .renn/design/stylekit-preview.html
1364
+ git add .renn/design/components/
1365
+ git commit -m "docs(${COMMIT_PREFIX}): approve Phase 1 design system
1366
+
1367
+ Phase 1 (stylekit) approved for ${COMMIT_MSG_SCOPE}
1368
+ - Design tokens: stylekit.yaml + stylekit.css
1369
+ - Component inventory committed
1370
+ - Preview: stylekit-preview.html"
1371
+ else
1372
+ echo "Skipping Phase 1 design commit (commit_docs: false)"
1373
+ fi
1374
+ ```
1375
+
1376
+ #### Phase 1 -- Stop for design-system command
1377
+
1378
+ **If `--phase-1-only` flag is set:**
1379
+ - Skip Phase 2 entirely
1380
+ - Skip implementation guide generation
1381
+ - Route to the command's `<offer_next>` section
1382
+ - STOP
1383
+
1384
+ **Otherwise:** Continue to Phase 1 -> Phase 2 transition as normal.
1385
+
1386
+ #### Phase 1 -> Phase 2 Transition
1387
+
1388
+ After Phase 1 approval (or accept-as-is):
1389
+
1390
+ 1. Reset counters for Phase 2:
1391
+ ```
1392
+ auto_revision_count = 0
1393
+ user_revision_count = 0
1394
+ ```
1395
+
1396
+ 2. Store Phase 1 artifacts for Phase 2 context:
1397
+ ```
1398
+ APPROVED_STYLEKIT_PATH=".renn/design/stylekit.yaml"
1399
+ APPROVED_COMPONENT_NAMES=$(ls .renn/design/components/ 2>/dev/null)
1400
+ ```
1401
+
1402
+ 3. Proceed to Phase 2.
1403
+
1404
+ ---
1405
+
1406
+ ### Phase 2: Screen Prototypes (runs for BOTH full and screens_only modes)
1407
+
1408
+ #### Phase 2 -- Assemble Designer Context and Spawn
1409
+
1410
+ | Variable | Source |
1411
+ |----------|--------|
1412
+ | `design_mode` | Original mode determination result (full or screens_only) |
1413
+ | `phase` | "screens" |
1414
+ | `stage_name` | parse_args |
1415
+ | `stage_goal` | track.md stage details |
1416
+ | `research_content` | `${STAGE_DIR}/research.md` content |
1417
+ | `intel_content` | INTEL_CONTENT |
1418
+ | `stylekit_content` | Content of `.renn/design/stylekit.yaml` (read now -- locked, do not modify) |
1419
+ | `component_names` | `ls .renn/design/components/` directory listing |
1420
+ | `pexels_key` | Pexels API key check result |
1421
+ | `stage_dir` | STAGE_DIR path |
1422
+ | `existing_screens` | `ls .renn/design/screens/*.yaml 2>/dev/null` with name + description for each |
1423
+ | `ux_brief` | UX_BRIEF (from ux_synthesis step, if non-empty) |
1424
+ | `project_name` | PROJECT_NAME (from brief.md heading) |
1425
+
1426
+ **Assemble existing screen context:**
1427
+
1428
+ ```bash
1429
+ EXISTING_SCREENS=""
1430
+ for spec in .renn/design/screens/*.yaml; do
1431
+ [ -f "$spec" ] || continue
1432
+ screen_name=$(grep -m1 "^screen:" "$spec" | sed 's/screen: //')
1433
+ description=$(grep -m1 "^description:" "$spec" | sed 's/description: //')
1434
+ EXISTING_SCREENS="${EXISTING_SCREENS}\n- ${screen_name}: ${description}"
1435
+ done
1436
+ ```
1437
+
1438
+ If `EXISTING_SCREENS` is empty, the designer creates all screens as new. If populated, the designer reads each relevant existing screen before deciding whether to create new or update.
1439
+
1440
+ Phase 2 designer spawn template:
1441
+
1442
+ ```
1443
+ <design_context>
1444
+
1445
+ **Project Name:** {PROJECT_NAME}
1446
+ **Mode:** {design_mode}
1447
+ **Phase:** screens
1448
+
1449
+ {IF PROJECT_LEVEL=true:}
1450
+ **Scope:** All UI stages
1451
+ **UI Stages:**
1452
+ {for each stage in UI_STAGES: "- Stage {N}: {name} -- {goal}"}
1453
+ {END IF}
1454
+
1455
+ {IF PROJECT_LEVEL=false:}
1456
+ **Stage:** {stage_name}
1457
+ **Goal:** {stage_goal}
1458
+ {END IF}
1459
+
1460
+ **Research:**
1461
+ {research_content}
1462
+
1463
+ **Intel (raw -- extract design-relevant decisions yourself):**
1464
+ {intel_content}
1465
+
1466
+ {IF UX_BRIEF is non-empty:}
1467
+
1468
+ **UX Brief (from UX research + interview):**
1469
+ {UX_BRIEF}
1470
+
1471
+ This ux_brief provides concrete UX direction. Reference it for flow design,
1472
+ component density, and interaction patterns when creating screen layouts.
1473
+ The ux_brief is INFORMATIONAL -- it supplements intel decisions.
1474
+
1475
+ {END IF}
1476
+
1477
+ **Approved Stylekit:** (locked -- do not modify)
1478
+ {stylekit_content}
1479
+
1480
+ **Available Components:**
1481
+ {component_names}
1482
+
1483
+ **Pexels API Key:** {pexels_key}
1484
+
1485
+ **Existing Screens** (at .renn/design/screens/ -- read before creating):
1486
+ {EXISTING_SCREENS}
1487
+
1488
+ **Output Directory:**
1489
+ - Screen specs and prototypes: .renn/design/screens/
1490
+
1491
+ </design_context>
1492
+ ```
1493
+
1494
+ For Phase 2 revisions, append:
1495
+
1496
+ ```
1497
+ <revision_context>
1498
+
1499
+ **Revision:** {N} of 3
1500
+ **Phase:** screens
1501
+ **Source:** {reviewer | user}
1502
+ **Feedback:**
1503
+ {feedback_text}
1504
+
1505
+ **Current artifacts on disk:**
1506
+ {list of existing artifact paths}
1507
+
1508
+ Revise screen prototypes based on the feedback above. The design system (stylekit, components) is locked -- do not modify tokens or existing components. Overwrite prototype files in place (git tracks previous versions).
1509
+ Return ## DESIGN REVISION (not ## DESIGN COMPLETE) to signal this is a revision.
1510
+
1511
+ </revision_context>
1512
+ ```
1513
+
1514
+ Display banner:
1515
+
1516
+ **If PROJECT_LEVEL=true:**
1517
+
1518
+ ```
1519
+ RENN > PROJECT DESIGN -- PHASE 2: SCREEN PROTOTYPES
1520
+
1521
+ Spawning designer (mode: {design_mode}, phase: screens)...
1522
+ ```
1523
+
1524
+ **If PROJECT_LEVEL=false:**
1525
+
1526
+ ```
1527
+ RENN > DESIGNING STAGE {X} -- PHASE 2: SCREEN PROTOTYPES
1528
+
1529
+ Spawning designer (mode: {design_mode}, phase: screens)...
1530
+ ```
1531
+
1532
+ Spawn:
1533
+
1534
+ **If PROJECT_LEVEL=true:**
1535
+
1536
+ ```
1537
+ Task(
1538
+ prompt=designer_prompt,
1539
+ subagent_type="renn-designer",
1540
+ model="{designer_model}",
1541
+ description="Design Project - Phase 2 (screens)"
1542
+ )
1543
+ ```
1544
+
1545
+ **If PROJECT_LEVEL=false:**
1546
+
1547
+ ```
1548
+ Task(
1549
+ prompt=designer_prompt,
1550
+ subagent_type="renn-designer",
1551
+ model="{designer_model}",
1552
+ description="Design Stage {stage} - Phase 2 (screens)"
1553
+ )
1554
+ ```
1555
+
1556
+ Parse designer return: `## DESIGN COMPLETE` or `## DESIGN REVISION`. Verify `**Phase:** screens` in the return.
1557
+
1558
+ #### Phase 2 -- Spawn Reviewer
1559
+
1560
+ ```
1561
+ <review_context>
1562
+
1563
+ **Mode:** {design_mode}
1564
+ **Phase:** screens
1565
+ **Designer Output:**
1566
+ {designer_return}
1567
+
1568
+ **Artifact Paths:**
1569
+ {artifact_paths}
1570
+
1571
+ Review screen specs and prototypes for spec compliance and overall quality.
1572
+ Phase scope: screen spec YAML, screen prototype HTML, layout coherence, responsive overrides, images. Skip stylekit/component checks (already approved).
1573
+ Return REVIEW PASSED or ISSUES FOUND with actionable feedback.
1574
+
1575
+ </review_context>
1576
+ ```
1577
+
1578
+ **If PROJECT_LEVEL=true:**
1579
+
1580
+ ```
1581
+ Task(
1582
+ prompt=reviewer_prompt,
1583
+ subagent_type="renn-design-reviewer",
1584
+ model="{reviewer_model}",
1585
+ description="Review design Phase 2 (screens) for project"
1586
+ )
1587
+ ```
1588
+
1589
+ **If PROJECT_LEVEL=false:**
1590
+
1591
+ ```
1592
+ Task(
1593
+ prompt=reviewer_prompt,
1594
+ subagent_type="renn-design-reviewer",
1595
+ model="{reviewer_model}",
1596
+ description="Review design Phase 2 (screens) for Stage {stage}"
1597
+ )
1598
+ ```
1599
+
1600
+ #### Phase 2 -- Auto-Revision Loop
1601
+
1602
+ Same logic as Phase 1, using the reset `auto_revision_count`:
1603
+
1604
+ If `## ISSUES FOUND`:
1605
+ 1. Increment `auto_revision_count`
1606
+ 2. If `auto_revision_count <= 2`:
1607
+ - Display: "Reviewer found issues. Auto-revising... (attempt {auto_revision_count}/2)"
1608
+ - Re-spawn designer with Phase 2 context + revision_context (source: "reviewer", feedback: reviewer's issue list)
1609
+ - After designer returns: re-spawn reviewer (phase: screens)
1610
+ - Loop back to check reviewer return
1611
+ 3. If `auto_revision_count > 2`:
1612
+ - Display: "Auto-revision limit reached. Escalating to user."
1613
+ - Present Phase 2 escalation (see Phase 2 Escalation below)
1614
+
1615
+ If `## REVIEW PASSED`:
1616
+ - Reset `auto_revision_count = 0`
1617
+ - Proceed to Phase 2 Approval Gate
1618
+
1619
+ #### Phase 2 -- Approval Gate
1620
+
1621
+ **Step 1 -- Auto-open prototypes in browser:**
1622
+
1623
+ Build the file list for Phase 2: `.renn/design/screens/*.html` ONLY (screen prototypes created or modified this session, not stylekit-preview.html).
1624
+
1625
+ ```bash
1626
+ # EXECUTE THIS NOW -- open Phase 2 prototypes before showing gate
1627
+ # Use the designer's structured return to get only new/modified screen files
1628
+ # The designer return lists artifacts with [NEW] and [MODIFIED] markers
1629
+ # Parse the artifact list from the designer's last return to get specific files
1630
+ GATE_FILES=""
1631
+ for f in .renn/design/screens/*.html; do
1632
+ [ -f "$f" ] || continue
1633
+ # Only include screens that the designer created or modified this session
1634
+ # The designer's structured return lists specific files -- parse them
1635
+ GATE_FILES="$GATE_FILES $f"
1636
+ done
1637
+ # NOTE: The orchestrator should filter GATE_FILES using the artifact paths
1638
+ # from the designer's ## DESIGN COMPLETE return (new + modified only).
1639
+ # If the designer return is not parseable, fall back to opening all screens
1640
+ # in .renn/design/screens/ (user can identify which are relevant).
1641
+ for file in $GATE_FILES; do
1642
+ if [[ -f "$file" ]]; then
1643
+ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
1644
+ start "" "$file"
1645
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
1646
+ open "$file"
1647
+ elif command -v xdg-open &>/dev/null; then
1648
+ xdg-open "$file" &>/dev/null &
1649
+ elif command -v cmd.exe &>/dev/null; then
1650
+ cmd.exe /c start "" "$file"
1651
+ fi
1652
+ sleep 0.5
1653
+ fi
1654
+ done
1655
+ ```
1656
+
1657
+ **Step 2 -- Present checkpoint:human-verify:**
1658
+
1659
+ **If PROJECT_LEVEL=true:**
1660
+
1661
+ ```
1662
+ what-built: "Screen prototypes for project"
1663
+ how-to-verify:
1664
+ 1. Review screen prototypes in browser (auto-opened):
1665
+ {For each [NEW] screen from designer return:}
1666
+ - .renn/design/screens/{screen-name}.html [NEW] -- {description}
1667
+ {For each [MODIFIED] screen from designer return:}
1668
+ - .renn/design/screens/{screen-name}.html [MODIFIED] -- {modification summary}
1669
+ 2. Check that layouts match your vision for each screen
1670
+ 3. Verify components are used consistently across screens
1671
+ 4. Review responsive behavior if applicable
1672
+ Note: The design system (colors, fonts, spacing) was approved in the previous phase. Screen feedback should be about layout and content, not colors/fonts.
1673
+ resume-signal: Type "approved" or describe what to change
1674
+ ```
1675
+
1676
+ **If PROJECT_LEVEL=false:**
1677
+
1678
+ ```
1679
+ what-built: "Screen prototypes for Stage {N}: {stage_name}"
1680
+ how-to-verify:
1681
+ 1. Review screen prototypes in browser (auto-opened):
1682
+ {For each [NEW] screen from designer return:}
1683
+ - .renn/design/screens/{screen-name}.html [NEW] -- {description}
1684
+ {For each [MODIFIED] screen from designer return:}
1685
+ - .renn/design/screens/{screen-name}.html [MODIFIED] -- {modification summary}
1686
+ 2. Check that layouts match your vision for each screen
1687
+ 3. Verify components are used consistently across screens
1688
+ 4. Review responsive behavior if applicable
1689
+ Note: The design system (colors, fonts, spacing) was approved in the previous phase. Screen feedback should be about layout and content, not colors/fonts.
1690
+ {IF DESIGN_MODE is screens_only:}
1691
+ Note: Using existing design system from a prior stage. If you want to change the visual identity, restart with a restyle.
1692
+ resume-signal: Type "approved" or describe what to change
1693
+ ```
1694
+
1695
+ #### Phase 2 -- User Revision Loop
1696
+
1697
+ If user types "approved": Store design output. Continue to generate_implementation_guide.
1698
+
1699
+ If user provides feedback:
1700
+ 1. Increment `user_revision_count`
1701
+ 2. If `user_revision_count <= 3`:
1702
+ - Re-spawn designer with Phase 2 context + revision_context (source: "user", feedback: user's text)
1703
+ - After designer returns: re-spawn reviewer (phase: screens)
1704
+ - If reviewer passes: present updated Phase 2 gate
1705
+ - If reviewer fails: enter Phase 2 auto-revision loop, then present to user
1706
+ 3. If `user_revision_count > 3`: Present Phase 2 escalation
1707
+
1708
+ #### Phase 2 -- Escalation
1709
+
1710
+ Present `checkpoint:decision`:
1711
+
1712
+ **If PROJECT_LEVEL=true:**
1713
+
1714
+ ```
1715
+ Screen prototypes have reached the revision limit.
1716
+
1717
+ Current state: {summary of latest designer output}
1718
+ {IF reviewer issues exist:} Reviewer concerns: {summary of latest issues}
1719
+
1720
+ Options:
1721
+ Accept - Use current screen prototypes as-is (proceed to implementation guide)
1722
+ Restart - Start over with new screen layouts (design system stays locked)
1723
+ Skip - Skip screen design (stylekit exists but no screen specs for this project)
1724
+
1725
+ Select: accept, restart, or skip
1726
+ ```
1727
+
1728
+ **If PROJECT_LEVEL=false:**
1729
+
1730
+ ```
1731
+ Screen prototypes have reached the revision limit.
1732
+
1733
+ Current state: {summary of latest designer output}
1734
+ {IF reviewer issues exist:} Reviewer concerns: {summary of latest issues}
1735
+
1736
+ Options:
1737
+ Accept - Use current screen prototypes as-is (proceed to implementation guide)
1738
+ Restart - Start over with new screen layouts (design system stays locked)
1739
+ Skip - Skip screen design (stylekit exists but no screen specs for this stage)
1740
+
1741
+ Select: accept, restart, or skip
1742
+ ```
1743
+
1744
+ Behavior:
1745
+ - `accept`: Store current screen artifacts as approved. Continue to Store Design Output.
1746
+ - `restart`: Revert current session's screen changes only (NOT all screens in .renn/design/screens/):
1747
+ - For screens marked [NEW] in the designer's return: delete the .yaml and .html files from .renn/design/screens/
1748
+ - For screens marked [MODIFIED] in the designer's return: `git checkout .renn/design/screens/{screen-name}.yaml .renn/design/screens/{screen-name}.html` to restore pre-session state
1749
+ - The stylekit and screens from prior stages are untouched.
1750
+ Reset Phase 2 counters to 0. Re-run Phase 2 from designer spawn.
1751
+ - `skip`: Revert current session's screen changes (same scoped approach as restart). Stylekit remains. Continue to Store Design Output (HAS_DESIGN still true since stylekit exists, but no new/modified screen specs for this stage).
1752
+
1753
+ ---
1754
+
1755
+ #### Phase 2 -- Commit Design Artifacts
1756
+
1757
+ **After Phase 2 approval (before Store Design Output):**
1758
+
1759
+ ```bash
1760
+ if [ "$COMMIT_PLANNING_DOCS" = "true" ]; then
1761
+ git add .renn/design/screens/
1762
+ git commit -m "docs(${COMMIT_PREFIX}): approve Phase 2 screen prototypes
1763
+
1764
+ Phase 2 (screens) approved for ${COMMIT_MSG_SCOPE}
1765
+ - Screen specs and prototypes committed"
1766
+ else
1767
+ echo "Skipping Phase 2 design commit (commit_docs: false)"
1768
+ fi
1769
+ ```
1770
+
1771
+ ### Store Design Output
1772
+
1773
+ After Phase 2 approval (or accept-as-is escalation), store the design output paths:
1774
+
1775
+ ```
1776
+ # Screen specs are now at the global location
1777
+ # Use the designer's return to know which screens belong to this stage
1778
+ DESIGN_SCREEN_SPECS=$(ls .renn/design/screens/*.yaml 2>/dev/null)
1779
+ DESIGN_STYLEKIT_PATH=".renn/design/stylekit.yaml"
1780
+ HAS_DESIGN=true
1781
+ ```
1782
+
1783
+ If Phase 2 was skipped but Phase 1 completed (Phase 2 skip escalation):
1784
+
1785
+ ```
1786
+ DESIGN_SCREEN_SPECS=""
1787
+ DESIGN_STYLEKIT_PATH=".renn/design/stylekit.yaml"
1788
+ HAS_DESIGN=true
1789
+ ```
1790
+
1791
+ </step>
1792
+
1793
+ <step name="generate_implementation_guide">
1794
+ **Trigger:** `HAS_DESIGN=true` (design phase completed and approved).
1795
+
1796
+ **Skip if:** `.renn/design/implementation-guide.md` already exists AND no design artifacts have changed since last generation:
1797
+
1798
+ ```bash
1799
+ if [ "$HAS_DESIGN" != "true" ]; then
1800
+ # No design -- skip entirely
1801
+ :
1802
+ elif [ -f ".renn/design/implementation-guide.md" ]; then
1803
+ # Guide exists -- check if design artifacts changed since guide was generated
1804
+ GUIDE_MTIME=$(stat -c %Y .renn/design/implementation-guide.md 2>/dev/null || stat -f %m .renn/design/implementation-guide.md 2>/dev/null)
1805
+ DESIGN_CHANGED=false
1806
+ for f in .renn/design/screens/*.html .renn/design/stylekit.yaml .renn/design/stylekit.css; do
1807
+ [ -f "$f" ] || continue
1808
+ FILE_MTIME=$(stat -c %Y "$f" 2>/dev/null || stat -f %m "$f" 2>/dev/null)
1809
+ if [ "$FILE_MTIME" -gt "$GUIDE_MTIME" ] 2>/dev/null; then
1810
+ DESIGN_CHANGED=true
1811
+ break
1812
+ fi
1813
+ done
1814
+ if [ "$DESIGN_CHANGED" = "false" ]; then
1815
+ echo "Implementation guide up to date. Skipping regeneration."
1816
+ # Skip to present_final_status
1817
+ fi
1818
+ fi
1819
+ ```
1820
+
1821
+ If skip conditions are not met, proceed with generation:
1822
+
1823
+ ### 1. Detect CSS Framework
1824
+
1825
+ ```bash
1826
+ # Check for Tailwind
1827
+ TAILWIND_VERSION=""
1828
+ if grep -q '"tailwindcss"' package.json 2>/dev/null; then
1829
+ TAILWIND_VERSION=$(grep '"tailwindcss"' package.json | grep -oE '[0-9]+\.[0-9]+')
1830
+ fi
1831
+
1832
+ # Determine CSS framework
1833
+ CSS_FRAMEWORK="unknown"
1834
+ if [ -n "$TAILWIND_VERSION" ]; then
1835
+ if echo "$TAILWIND_VERSION" | grep -qE '^4\.'; then
1836
+ CSS_FRAMEWORK="tailwind-v4"
1837
+ else
1838
+ CSS_FRAMEWORK="tailwind-v3"
1839
+ fi
1840
+ elif grep -q '"styled-components"' package.json 2>/dev/null; then
1841
+ CSS_FRAMEWORK="styled-components"
1842
+ elif ls src/**/*.module.css 2>/dev/null | head -1; then
1843
+ CSS_FRAMEWORK="css-modules"
1844
+ else
1845
+ CSS_FRAMEWORK="vanilla-css"
1846
+ fi
1847
+
1848
+ echo "Detected CSS framework: $CSS_FRAMEWORK"
1849
+ ```
1850
+
1851
+ ### 2. Read Prototype HTML File List
1852
+
1853
+ ```bash
1854
+ PROTOTYPE_FILES=$(ls .renn/design/screens/*.html 2>/dev/null)
1855
+ STYLEKIT_YAML=".renn/design/stylekit.yaml"
1856
+ STYLEKIT_CSS=".renn/design/stylekit.css"
1857
+ ```
1858
+
1859
+ ### 3. Spawn Implementation Guide Generator
1860
+
1861
+ Display:
1862
+ ```
1863
+ RENN > GENERATING IMPLEMENTATION GUIDE
1864
+
1865
+ Detected CSS framework: {CSS_FRAMEWORK}
1866
+ Spawning guide generator...
1867
+ ```
1868
+
1869
+ Spawn a focused Task call (uses designer_model tier -- no new agent needed):
1870
+
1871
+ ```
1872
+ Task(
1873
+ prompt="You are generating a design implementation guide that bridges HTML prototypes (Tailwind v3 CDN) to the project's actual CSS framework.\n\n" +
1874
+ "<guide_context>\n" +
1875
+ "**Project CSS Framework:** " + CSS_FRAMEWORK + "\n" +
1876
+ "**Stylekit YAML:** Read @.renn/design/stylekit.yaml\n" +
1877
+ "**Stylekit CSS:** Read @.renn/design/stylekit.css\n" +
1878
+ "**HTML Prototypes:** Read each file in .renn/design/screens/*.html\n\n" +
1879
+ "Generate .renn/design/implementation-guide.md with these sections (5 required + 1 conditional):\n\n" +
1880
+ "## Framework Detection\n" +
1881
+ "- CSS framework: {detected}\n" +
1882
+ "- Version: {detected}\n" +
1883
+ "- Configuration approach: {e.g., 'Tailwind v4 CSS-first config' or 'CSS custom properties in :root'}\n\n" +
1884
+ "## Token System Translation\n" +
1885
+ "- How to implement stylekit.yaml tokens in the project's framework\n" +
1886
+ "- Exact file path and syntax for the project's CSS system\n" +
1887
+ "- Token namespace mapping (stylekit token names -> project CSS custom properties or framework equivalents)\n" +
1888
+ "- For vanilla CSS: map to CSS custom properties in :root {} (stylekit.css is directly usable)\n" +
1889
+ "- For Tailwind v3: map to tailwind.config theme extensions\n" +
1890
+ "- For Tailwind v4: map to CSS-first @theme declarations in the project's CSS entry point\n" +
1891
+ "- For CSS Modules: map to shared CSS custom properties imported in each module\n" +
1892
+ "- For styled-components: map to a theme object with token values\n\n" +
1893
+ "## Icon System\n" +
1894
+ "- Icon library used in prototypes: {detect from HTML -- typically Material Symbols Rounded}\n" +
1895
+ "- npm install command for the project\n" +
1896
+ "- Import pattern for the project's framework\n" +
1897
+ "- Usage syntax (component vs font vs SVG)\n\n" +
1898
+ "## Animation Patterns\n" +
1899
+ "- List each @keyframes animation found in prototypes and stylekit.css\n" +
1900
+ "- Where to define them in the project (globals.css, tailwind config, CSS module)\n" +
1901
+ "- How to reference them (utility class, CSS class name, animation property)\n\n" +
1902
+ "## Component Class Mapping\n" +
1903
+ "- For each screen prototype: list key visual sections\n" +
1904
+ "- For each section: the Tailwind v3 CDN classes used and their project-framework equivalent\n" +
1905
+ "- Focus on classes that DIFFER between v3 CDN and the project framework\n" +
1906
+ "- Skip structural classes (flex, grid, items-center) that are identical across frameworks\n\n" +
1907
+ "## Viewport Translation (ONLY if stylekit.yaml has a viewport section)\n" +
1908
+ "- If NO viewport section exists in stylekit.yaml: OMIT this section entirely\n" +
1909
+ "- If viewport section exists:\n" +
1910
+ " - Target viewport type and dimensions from stylekit.yaml\n" +
1911
+ " - How to constrain the app's root layout to viewport dimensions in the project's framework\n" +
1912
+ " - For React Native/Flutter: map viewport dimensions to root container constraints\n" +
1913
+ " - For web targeting mobile: meta viewport tag, CSS max-width on app container, media queries\n" +
1914
+ " - For wearable: circular clip-path or border-radius constraints, safe area considerations\n" +
1915
+ " - Device-specific safe areas (notch, home indicator, status bar) and how to handle them\n" +
1916
+ " - RTL handling if direction is rtl (CSS logical properties, framework RTL support)\n\n" +
1917
+ "**Target:** 100-250 lines (longer if viewport section included). Summary document, not full prototype inline.\n" +
1918
+ "**Output:** Write to .renn/design/implementation-guide.md\n" +
1919
+ "</guide_context>",
1920
+ subagent_type="general-purpose",
1921
+ model="{designer_model}",
1922
+ description="Generate implementation guide for CSS framework: " + CSS_FRAMEWORK
1923
+ )
1924
+ ```
1925
+
1926
+ ### 4. Verify Guide Was Created
1927
+
1928
+ ```bash
1929
+ if [ ! -f ".renn/design/implementation-guide.md" ]; then
1930
+ echo "WARNING: Implementation guide was not created. Continuing without guide."
1931
+ fi
1932
+ ```
1933
+
1934
+ Display: `Implementation guide generated at .renn/design/implementation-guide.md`
1935
+ </step>
1936
+
1937
+ <step name="commit_implementation_guide">
1938
+ **Trigger:** `generate_implementation_guide` step completed and `.renn/design/implementation-guide.md` exists on disk.
1939
+
1940
+ ```bash
1941
+ if [ "$COMMIT_PLANNING_DOCS" = "true" ] && [ -f ".renn/design/implementation-guide.md" ]; then
1942
+ git add .renn/design/implementation-guide.md
1943
+ git commit -m "docs(${COMMIT_PREFIX}): generate implementation guide
1944
+
1945
+ Implementation guide for ${COMMIT_MSG_SCOPE}
1946
+ - CSS framework translation mappings
1947
+ - Token system bridging: prototype -> project"
1948
+ fi
1949
+ ```
1950
+
1951
+ This commit runs for ALL invocation modes (design-system, design-screens), fixing the bug where the implementation guide was never committed on single-design-stage projects.
1952
+ </step>
1953
+
1954
+ <step name="present_final_status">
1955
+ Route to the command's `<offer_next>` section.
1956
+
1957
+ Display the design-specific completion banner with actual artifact paths:
1958
+
1959
+ **If `HAS_DESIGN=true` AND `PROJECT_LEVEL=true`:**
1960
+
1961
+ ```
1962
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1963
+ RENN ► PROJECT DESIGN COMPLETE
1964
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1965
+
1966
+ Design artifacts:
1967
+ Stylekit: .renn/design/stylekit.yaml
1968
+ CSS: .renn/design/stylekit.css
1969
+ Preview: .renn/design/stylekit-preview.html
1970
+ Components: .renn/design/components/
1971
+ Guide: .renn/design/implementation-guide.md
1972
+
1973
+ Design system ready. Run /renn.design-screens {N} for each UI stage, then /renn.plan-stage {N}.
1974
+ ```
1975
+
1976
+ **If `HAS_DESIGN=true` AND `PROJECT_LEVEL=false`:**
1977
+
1978
+ ```
1979
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1980
+ RENN ► DESIGN COMPLETE FOR STAGE {X}
1981
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1982
+
1983
+ Design artifacts:
1984
+ Stylekit: .renn/design/stylekit.yaml
1985
+ CSS: .renn/design/stylekit.css
1986
+ Preview: .renn/design/stylekit-preview.html
1987
+ Components: .renn/design/components/
1988
+ Screens: .renn/design/screens/
1989
+ Guide: .renn/design/implementation-guide.md
1990
+
1991
+ Ready for /renn.plan-stage {X} to create executable runs.
1992
+ ```
1993
+
1994
+ **If `HAS_DESIGN=false` AND `PROJECT_LEVEL=true`:**
1995
+
1996
+ ```
1997
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1998
+ RENN ► PROJECT DESIGN SKIPPED
1999
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2000
+
2001
+ Design was skipped for this project.
2002
+
2003
+ You can still run /renn.plan-stage {N} for each stage -- they will proceed without design artifacts.
2004
+ ```
2005
+
2006
+ **If `HAS_DESIGN=false` AND `PROJECT_LEVEL=false`:**
2007
+
2008
+ ```
2009
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2010
+ RENN ► DESIGN SKIPPED FOR STAGE {X}
2011
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2012
+
2013
+ Design was skipped for this stage.
2014
+
2015
+ You can still run /renn.plan-stage {X} -- it will proceed without design artifacts.
2016
+ ```
2017
+ </step>
2018
+
2019
+ </process>