thanh-kit 2.5.4 → 2.5.5

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 (69) hide show
  1. package/package.json +1 -1
  2. package/templates/command-archive/ask.md +56 -0
  3. package/templates/command-archive/ck-help.md +129 -0
  4. package/templates/command-archive/coding-level.md +48 -0
  5. package/templates/command-archive/docs/init.md +38 -0
  6. package/templates/command-archive/docs/summarize.md +22 -0
  7. package/templates/command-archive/docs/update.md +76 -0
  8. package/templates/command-archive/journal.md +18 -0
  9. package/templates/command-archive/kanban.md +99 -0
  10. package/templates/command-archive/plan/archive.md +57 -0
  11. package/templates/command-archive/plan/red-team.md +200 -0
  12. package/templates/command-archive/plan/validate.md +188 -0
  13. package/templates/command-archive/preview.md +283 -0
  14. package/templates/command-archive/review/codebase/parallel.md +122 -0
  15. package/templates/command-archive/review/codebase.md +49 -0
  16. package/templates/command-archive/test/ui.md +92 -0
  17. package/templates/command-archive/test.md +8 -0
  18. package/templates/command-archive/use-mcp.md +38 -0
  19. package/templates/command-archive/watzup.md +8 -0
  20. package/templates/command-archive/worktree.md +109 -0
  21. package/templates/hooks/.logs/hook-log.jsonl +26 -0
  22. package/templates/settings.local.json +13 -0
  23. package/templates/commands/bootstrap/auto/fast.md +0 -111
  24. package/templates/commands/bootstrap/auto/parallel.md +0 -66
  25. package/templates/commands/bootstrap/auto.md +0 -115
  26. package/templates/commands/bootstrap.md +0 -137
  27. package/templates/commands/code/auto.md +0 -203
  28. package/templates/commands/code/no-test.md +0 -174
  29. package/templates/commands/code/parallel.md +0 -100
  30. package/templates/commands/code.md +0 -205
  31. package/templates/commands/content/cro.md +0 -43
  32. package/templates/commands/content/enhance.md +0 -14
  33. package/templates/commands/content/fast.md +0 -13
  34. package/templates/commands/content/good.md +0 -16
  35. package/templates/commands/cook/auto/fast.md +0 -26
  36. package/templates/commands/cook/auto/parallel.md +0 -49
  37. package/templates/commands/cook/auto.md +0 -15
  38. package/templates/commands/cook.md +0 -105
  39. package/templates/commands/debug.md +0 -13
  40. package/templates/commands/design/3d.md +0 -83
  41. package/templates/commands/design/describe.md +0 -23
  42. package/templates/commands/design/fast.md +0 -31
  43. package/templates/commands/design/good.md +0 -35
  44. package/templates/commands/design/screenshot.md +0 -34
  45. package/templates/commands/design/video.md +0 -34
  46. package/templates/commands/fix/ci.md +0 -17
  47. package/templates/commands/fix/fast.md +0 -19
  48. package/templates/commands/fix/hard.md +0 -39
  49. package/templates/commands/fix/logs.md +0 -26
  50. package/templates/commands/fix/parallel.md +0 -54
  51. package/templates/commands/fix/test.md +0 -20
  52. package/templates/commands/fix/types.md +0 -9
  53. package/templates/commands/fix/ui.md +0 -48
  54. package/templates/commands/fix.md +0 -43
  55. package/templates/commands/plan/ci.md +0 -33
  56. package/templates/commands/plan/cro.md +0 -69
  57. package/templates/commands/plan/fast.md +0 -82
  58. package/templates/commands/plan/hard.md +0 -108
  59. package/templates/commands/plan/parallel.md +0 -145
  60. package/templates/commands/plan/two.md +0 -45
  61. package/templates/commands/plan.md +0 -30
  62. package/templates/commands/scout/ext.md +0 -39
  63. package/templates/commands/scout.md +0 -28
  64. package/templates/commands/skill/add.md +0 -36
  65. package/templates/commands/skill/create.md +0 -29
  66. package/templates/commands/skill/fix-logs.md +0 -22
  67. package/templates/commands/skill/optimize/auto.md +0 -25
  68. package/templates/commands/skill/optimize.md +0 -34
  69. package/templates/commands/skill/update.md +0 -36
@@ -0,0 +1,200 @@
1
+ ---
2
+ description: Adversarial plan review — spawn hostile reviewers to find flaws, security holes, false assumptions, failure modes
3
+ argument-hint: [plan-path]
4
+ ---
5
+
6
+ ## Your Mission
7
+
8
+ Adversarially review an implementation plan by spawning parallel reviewer subagents that try to tear it apart. Each reviewer adopts a different hostile lens. You then adjudicate findings, and the user decides which to apply.
9
+
10
+ **Mindset:** Like hiring someone who hates the implementer to destroy their work.
11
+
12
+ ## Plan Resolution
13
+
14
+ 1. If `$ARGUMENTS` provided → Use that path
15
+ 2. Else check `## Plan Context` section → Use active plan path
16
+ 3. If no plan found → Ask user to specify path or run `/plan` first
17
+
18
+ ## Workflow
19
+
20
+ ### Step 1: Read Plan Files
21
+
22
+ Read the plan directory:
23
+ - `plan.md` — Overview, phases, dependencies
24
+ - `phase-*.md` — All phase files (full content)
25
+ - Note: architecture decisions, assumptions, scope, risks, implementation steps
26
+
27
+ Collect all plan file paths for reviewers to read directly.
28
+
29
+ ### Step 2: Scale Reviewer Count
30
+
31
+ Scale reviewers based on plan complexity:
32
+
33
+ | Phase Count | Reviewers | Lenses Selected |
34
+ |-------------|-----------|-----------------|
35
+ | 1-2 phases | 2 | Security Adversary + Assumption Destroyer |
36
+ | 3-5 phases | 3 | + Failure Mode Analyst |
37
+ | 6+ phases | 4 | + Scope & Complexity Critic (all lenses) |
38
+
39
+ ### Step 3: Define Adversarial Lenses
40
+
41
+ Available lenses (select per Step 2):
42
+
43
+ | Reviewer | Lens | Focus |
44
+ |----------|------|-------|
45
+ | **Security Adversary** | Attacker mindset | Auth bypass, injection, data exposure, privilege escalation, supply chain, OWASP top 10 |
46
+ | **Failure Mode Analyst** | Murphy's Law | Race conditions, data loss, cascading failures, recovery gaps, deployment risks, rollback holes |
47
+ | **Assumption Destroyer** | Skeptic | Unstated dependencies, false "will work" claims, missing error paths, scale assumptions, integration assumptions |
48
+ | **Scope & Complexity Critic** | YAGNI enforcer | Over-engineering, premature abstraction, unnecessary complexity, missing MVP cuts, scope creep, gold plating |
49
+
50
+ ### Step 4: Spawn Reviewers
51
+
52
+ Launch reviewers simultaneously via Task tool with `subagent_type: "code-reviewer"`.
53
+
54
+ **Each reviewer prompt MUST include:**
55
+ 1. This override: `"IGNORE your default code-review instructions. You are reviewing a PLAN DOCUMENT, not code. There is no code to lint, build, or test. Focus exclusively on plan quality."`
56
+ 2. Their specific adversarial lens and persona
57
+ 3. The plan file paths so they can read original files directly
58
+ 4. These instructions:
59
+
60
+ ```
61
+ You are a hostile reviewer. Your job is to DESTROY this plan.
62
+ Adopt the {LENS_NAME} perspective. Find every flaw you can.
63
+
64
+ Rules:
65
+ - Be specific: cite exact phase/section where the flaw lives
66
+ - Be concrete: describe the failure scenario, not just "could be a problem"
67
+ - Rate severity: Critical (blocks success) | High (significant risk) | Medium (notable concern)
68
+ - Skip trivial observations (style, naming, formatting) — not worth reporting.
69
+ - No praise. No "overall looks good". Only findings.
70
+ - 5-10 findings per reviewer. Quality over quantity.
71
+
72
+ Output format per finding:
73
+ ## Finding {N}: {title}
74
+ - **Severity:** Critical | High | Medium
75
+ - **Location:** Phase {X}, section "{name}"
76
+ - **Flaw:** {what's wrong}
77
+ - **Failure scenario:** {concrete description of how this fails}
78
+ - **Evidence:** {quote from plan or missing element}
79
+ - **Suggested fix:** {brief recommendation}
80
+ ```
81
+
82
+ ### Step 5: Collect, Deduplicate & Cap
83
+
84
+ After all reviewers complete:
85
+ 1. Collect all findings
86
+ 2. Deduplicate overlapping findings (merge if same root issue)
87
+ 3. Sort by severity: Critical → High → Medium
88
+ 4. **Cap at 15 findings:** Keep all Critical, top High by specificity, note dropped Medium count
89
+
90
+ ### Step 6: Adjudicate
91
+
92
+ For each finding, the main agent evaluates and proposes a disposition:
93
+
94
+ | Disposition | Meaning |
95
+ |-------------|---------|
96
+ | **Accept** | Valid flaw — plan should be updated |
97
+ | **Reject** | False positive, acceptable risk, or already handled |
98
+
99
+ **Adjudication format:**
100
+
101
+ ```markdown
102
+ ## Red Team Findings
103
+
104
+ ### Finding 1: {title} — {SEVERITY}
105
+ **Reviewer:** {lens name}
106
+ **Location:** {phase/section}
107
+ **Flaw:** {description}
108
+ **Failure scenario:** {concrete scenario}
109
+ **Disposition:** Accept | Reject
110
+ **Rationale:** {why accept/reject — be specific}
111
+ ```
112
+
113
+ ### Step 7: User Review
114
+
115
+ Present the adjudicated findings to the user via `AskUserQuestion`:
116
+
117
+ ```
118
+ Review red-team findings. Which dispositions do you want to change?
119
+ ```
120
+
121
+ Options:
122
+ - "Looks good, apply accepted findings" — proceed with current Accept/Reject
123
+ - "Let me review each one" — walk through findings individually
124
+ - "Reject all, plan is fine" — discard all findings
125
+
126
+ **If "Let me review each one":**
127
+ For each finding marked Accept, ask via `AskUserQuestion`:
128
+ - "Apply this fix to the plan?"
129
+ - Options: "Yes, apply" | "No, reject" | "Modify suggestion"
130
+
131
+ **If "Modify suggestion":**
132
+ Ask via `AskUserQuestion`: "Describe your modification to this finding's suggested fix:"
133
+ (user provides free text via "Other" option)
134
+ Record the modified suggestion in the finding's "Suggested fix" field.
135
+ Set disposition to "Accept (modified)" in the Red Team Review table.
136
+
137
+ ### Step 8: Apply to Plan
138
+
139
+ For each accepted finding:
140
+ 1. Locate the target phase file and section
141
+ 2. Add the fix/note inline with a marker:
142
+ ```markdown
143
+ <!-- Red Team: {finding title} — {date} -->
144
+ ```
145
+ 3. If finding requires new content, add to the most relevant section
146
+ 4. If finding requires removing/changing content, edit in place
147
+
148
+ After applying, add a `## Red Team Review` section to `plan.md`.
149
+ If section already exists (repeat run), **append** a new session block — never overwrite history.
150
+
151
+ **Placement order in plan.md** (bottom of file):
152
+ 1. `## Red Team Review` (before validation)
153
+ 2. `## Validation Log` (after red-team)
154
+
155
+ This ordering matches the execution sequence: red-team → validate.
156
+
157
+ ```markdown
158
+ ## Red Team Review
159
+
160
+ ### Session — {YYYY-MM-DD}
161
+ **Findings:** {total} ({accepted} accepted, {rejected} rejected)
162
+ **Severity breakdown:** {N} Critical, {N} High, {N} Medium
163
+
164
+ | # | Finding | Severity | Disposition | Applied To |
165
+ |---|---------|----------|-------------|------------|
166
+ | 1 | {title} | Critical | Accept | Phase 2 |
167
+ | 2 | {title} | High | Reject | — |
168
+ ```
169
+
170
+ ## Output
171
+
172
+ After completion, provide summary:
173
+ - Total findings by severity
174
+ - Accepted vs rejected count
175
+ - Files modified
176
+ - Key risks addressed
177
+ - Remaining concerns (if any rejected findings were borderline)
178
+
179
+ ## Next Steps (MANDATORY)
180
+
181
+ After providing the summary, remind the user:
182
+
183
+ > **Plan updated with red-team findings.** Consider running:
184
+ > ```
185
+ > /plan:validate {ABSOLUTE_PATH_TO_PLAN_DIR}/plan.md
186
+ > ```
187
+ > to re-validate decisions after changes, then:
188
+ > ```
189
+ > /cook --auto {ABSOLUTE_PATH_TO_PLAN_DIR}/plan.md
190
+ > ```
191
+ > to implement.
192
+
193
+ ## Important Notes
194
+
195
+ **IMPORTANT:** Reviewers must be HOSTILE, not helpful. No softening language.
196
+ **IMPORTANT:** Deduplicate aggressively — reviewers will find overlapping issues.
197
+ **IMPORTANT:** Adjudication must be evidence-based. Don't reject valid findings to be nice.
198
+ **IMPORTANT:** If plan has a Validation Log from `/plan:validate`, reviewers should check if validation answers introduced new assumptions.
199
+ **IMPORTANT:** Sacrifice grammar for concision in reports.
200
+ **IMPORTANT:** Reviewers read plan files directly — do NOT duplicate content in a summary.
@@ -0,0 +1,188 @@
1
+ ---
2
+ description: Validate plan with critical questions interview
3
+ argument-hint: [plan-path]
4
+ ---
5
+
6
+ ## Your mission
7
+
8
+ Interview the user with critical questions to validate assumptions, confirm decisions, and surface potential issues in an implementation plan before coding begins.
9
+
10
+ ## Plan Resolution
11
+
12
+ 1. If `$ARGUMENTS` provided → Use that path
13
+ 2. Else check `## Plan Context` section → Use active plan path
14
+ 3. If no plan found → Ask user to specify path or run `/plan --hard` first
15
+
16
+ ## Configuration (from injected context)
17
+
18
+ Check `## Plan Context` section for validation settings:
19
+ - `mode` - Controls auto/prompt/off behavior
20
+ - `questions` - Range like `3-8` (min-max)
21
+
22
+ These values are automatically injected from user config. Use them as constraints.
23
+
24
+ ## Workflow
25
+
26
+ ### Step 1: Read Plan Files
27
+
28
+ Read the plan directory:
29
+ - `plan.md` - Overview and phases list
30
+ - `phase-*.md` - All phase files
31
+ - Look for decision points, assumptions, risks, tradeoffs
32
+
33
+ ### Step 2: Extract Question Topics
34
+
35
+ Scan plan content for:
36
+
37
+ | Category | Keywords to detect |
38
+ |----------|-------------------|
39
+ | **Architecture** | "approach", "pattern", "design", "structure", "database", "API" |
40
+ | **Assumptions** | "assume", "expect", "should", "will", "must", "default" |
41
+ | **Tradeoffs** | "tradeoff", "vs", "alternative", "option", "choice", "either/or" |
42
+ | **Risks** | "risk", "might", "could fail", "dependency", "blocker", "concern" |
43
+ | **Scope** | "phase", "MVP", "future", "out of scope", "nice to have" |
44
+
45
+ ### Step 3: Generate Questions
46
+
47
+ For each detected topic, formulate a concrete question:
48
+
49
+ **Question format rules:**
50
+ - Each question must have 2-4 concrete options
51
+ - Mark recommended option with "(Recommended)" suffix
52
+ - Include "Other" option is automatic - don't add it
53
+ - Questions should surface implicit decisions
54
+
55
+ **Example questions:**
56
+
57
+ ```
58
+ Category: Architecture
59
+ Question: "How should the validation results be persisted?"
60
+ Options:
61
+ 1. Save to plan.md frontmatter (Recommended) - Updates existing plan
62
+ 2. Create validation-answers.md - Separate file for answers
63
+ 3. Don't persist - Ephemeral validation only
64
+ ```
65
+
66
+ ```
67
+ Category: Assumptions
68
+ Question: "The plan assumes API rate limiting is not needed. Is this correct?"
69
+ Options:
70
+ 1. Yes, rate limiting not needed for MVP
71
+ 2. No, add basic rate limiting now (Recommended)
72
+ 3. Defer to Phase 2
73
+ ```
74
+
75
+ ### Step 4: Interview User
76
+
77
+ Use `AskUserQuestion` tool to present questions.
78
+
79
+ **Rules:**
80
+ - Use question count from `## Plan Context` → `Validation: mode=X, questions=MIN-MAX`
81
+ - Group related questions when possible (max 4 questions per tool call)
82
+ - Focus on: assumptions, risks, tradeoffs, architecture
83
+
84
+ ### Step 5: Document Answers
85
+
86
+ After collecting answers, update `plan.md` with a detailed validation log. If a `## Validation Log` section already exists (from previous sessions), **append** a new session block — never overwrite history.
87
+
88
+ 1. Add or append to `## Validation Log` section in `plan.md`:
89
+
90
+ ```markdown
91
+ ## Validation Log
92
+
93
+ ### Session 1 — {YYYY-MM-DD}
94
+ **Trigger:** {what prompted this validation — initial plan creation, re-validation after scope change, etc.}
95
+ **Questions asked:** {count}
96
+
97
+ #### Questions & Answers
98
+
99
+ 1. **[{Category}]** {full question text}
100
+ - Options: {A} | {B} | {C}
101
+ - **Answer:** {user's choice}
102
+ - **Custom input:** {verbatim "Other" text if user selected Other, otherwise omit this line}
103
+ - **Rationale:** {why this decision matters for implementation}
104
+
105
+ 2. **[{Category}]** {full question text}
106
+ - Options: {A} | {B} | {C}
107
+ - **Answer:** {user's choice}
108
+ - **Custom input:** {verbatim text, omit if N/A}
109
+ - **Rationale:** {why this matters}
110
+
111
+ #### Confirmed Decisions
112
+ - {decision}: {choice} — {brief why}
113
+
114
+ #### Action Items
115
+ - [ ] {specific change needed based on answers}
116
+
117
+ #### Impact on Phases
118
+ - Phase {N}: {what needs updating and why}
119
+ ```
120
+
121
+ **Recording rules:**
122
+ - **Full question text**: Copy the exact question asked, not a summary
123
+ - **All options**: List every option that was presented
124
+ - **Verbatim custom input**: If user selected "Other" and typed custom text, record it exactly as entered — this often contains critical context
125
+ - **Rationale**: Explain why the decision affects implementation (helps future agents understand intent)
126
+ - **Session numbering**: Increment session number from last existing session. First validation = Session 1
127
+ - **Trigger**: State what prompted this validation round (initial, re-validation, scope change, etc.)
128
+
129
+ 2. If answers require plan changes, document them in `#### Impact on Phases` section.
130
+
131
+ ### Step 6: Propagate Changes to Phases (Auto-Apply)
132
+
133
+ **Auto-propagate** validation decisions to affected phase files.
134
+
135
+ **Process:**
136
+ 1. Parse "Impact on Phases" section → If empty, skip and report "No phase changes required"
137
+ 2. For each phase reference (accepts "Phase 2", "phase-02", "P2"):
138
+ - Glob for `phase-{N:02d}-*.md` → If missing, warn and skip
139
+ - Locate target section (exact → fuzzy → fallback to Key Insights)
140
+ - Apply change + add marker: `<!-- Updated: Validation Session N - {change} -->`
141
+ - Skip if same-session marker already exists (prevent duplication)
142
+
143
+ **Section mapping:**
144
+ | Change Type | Target Section |
145
+ |-------------|----------------|
146
+ | Requirements | Requirements |
147
+ | Architecture | Architecture |
148
+ | Scope | Overview / Implementation Steps |
149
+ | Risk | Risk Assessment |
150
+ | Unknown | Key Insights (new subsection) |
151
+
152
+ **Error handling:** Best-effort — log warnings for missing files/sections, continue with others, report all in Output.
153
+
154
+ ## Output
155
+
156
+ After validation completes, provide summary:
157
+ - Number of questions asked
158
+ - Key decisions confirmed
159
+ - **Phase propagation results:**
160
+ - ✅ Files updated (with section names)
161
+ - ⚠️ Warnings (skipped phases, fallback sections)
162
+ - ❌ Errors (if any write failures)
163
+ - Any items flagged for plan revision
164
+ - Recommendation: proceed to implementation or revise plan first
165
+
166
+ ## Next Steps (MANDATORY)
167
+
168
+ **IMPORTANT:** After providing the validation summary, you MUST remind the user with the **full absolute path**:
169
+
170
+ > **Best Practice:** Run `/clear` before implementing to start with fresh context.
171
+ > Then run:
172
+ > ```
173
+ > /cook --auto {ABSOLUTE_PATH_TO_PLAN_DIR}/plan.md
174
+ > ```
175
+ > *(Replace with actual absolute path, e.g., `/home/user/project/plans/260203-1234-feature/plan.md`)*
176
+ >
177
+ > **Why `--auto`?** Plan was already validated - safe to skip review gates.
178
+ > **Why absolute path?** After `/clear`, the new session loses context. Worktree paths won't be discoverable without the full path.
179
+ >
180
+ > Fresh context helps Claude focus solely on implementation without planning context pollution, improving plan adherence.
181
+
182
+ This reminder is **NON-NEGOTIABLE** - always output it at the end of validation with the actual absolute path.
183
+
184
+ ## Important Notes
185
+
186
+ **IMPORTANT:** Only ask questions about genuine decision points - don't manufacture artificial choices.
187
+ **IMPORTANT:** If plan is simple with few decisions, it's okay to ask fewer than min questions.
188
+ **IMPORTANT:** Prioritize questions that could change implementation significantly.
@@ -0,0 +1,283 @@
1
+ ---
2
+ description: View files/directories OR generate visual explanations, slides, diagrams
3
+ arguments:
4
+ - name: path
5
+ description: Path to file/directory to preview, OR topic for generation modes
6
+ required: false
7
+ ---
8
+
9
+ Universal viewer + visual generator. View existing content OR generate new visual explanations.
10
+
11
+ ## Usage
12
+
13
+ ### View Mode (existing behavior)
14
+ - `/preview <file.md>` - View markdown file in novel-reader UI
15
+ - `/preview <directory/>` - Browse directory contents
16
+ - `/preview --stop` - Stop running server
17
+
18
+ ### Generation Mode (new)
19
+ - `/preview --explain <topic>` - Generate visual explanation (ASCII + Mermaid + prose)
20
+ - `/preview --slides <topic>` - Generate presentation slides (one concept per slide)
21
+ - `/preview --diagram <topic>` - Generate focused diagram (ASCII + Mermaid)
22
+ - `/preview --ascii <topic>` - Generate ASCII-only diagram (terminal-friendly)
23
+
24
+ ## Examples
25
+
26
+ ```bash
27
+ # View mode
28
+ /preview plans/my-plan/plan.md # View markdown file
29
+ /preview plans/ # Browse plans directory
30
+
31
+ # Generation mode
32
+ /preview --explain OAuth flow # Generate OAuth explanation
33
+ /preview --slides API architecture # Generate architecture slides
34
+ /preview --diagram data flow # Generate data flow diagram
35
+ /preview --ascii auth process # Generate ASCII-only diagram
36
+ ```
37
+
38
+ ## Argument Resolution
39
+
40
+ When processing arguments, follow this priority order:
41
+
42
+ 1. **`--stop`** → Stop server (exit)
43
+ 2. **Generation flags** (`--explain`, `--slides`, `--diagram`, `--ascii`) → Generation mode
44
+ 3. **Resolve path from argument:**
45
+ - If argument is an explicit path → use directly
46
+ - If argument is a contextual reference (e.g., "that file", "the report", "this") → resolve from recent conversation context (look for file paths, URLs, or recently mentioned files)
47
+ 4. **Resolved path exists on filesystem** → View mode
48
+ 5. **Path doesn't exist or can't resolve** → Ask user to clarify which file they meant
49
+
50
+ **Topic-to-slug conversion:**
51
+ - Lowercase the topic
52
+ - Replace spaces/special chars with hyphens
53
+ - Remove non-alphanumeric except hyphens
54
+ - Collapse multiple hyphens → single hyphen
55
+ - Trim leading/trailing hyphens
56
+ - **Max 80 chars** - truncate at word boundary if longer
57
+ - If result is empty (topic was all special chars) → Error: ask for valid topic
58
+
59
+ Example: `OAuth 2.0 Flow` → `oauth-2-0-flow.md`
60
+
61
+ **Multiple flags:** If multiple generation flags provided, use first one; remaining treated as topic.
62
+ Example: `/preview --explain --slides topic` → `--explain` mode, topic = "--slides topic"
63
+
64
+ **Placeholder `{topic}`:** Replaced with original user input in title case (not the slug).
65
+
66
+ ## Execution
67
+
68
+ **IMPORTANT:** Run server as Claude Code background task using `run_in_background: true` with the Bash tool. This makes the server visible in `/tasks` and manageable via `KillShell`.
69
+
70
+ The skill is located at `.claude/skills/markdown-novel-viewer/`.
71
+
72
+ ### Stop Server
73
+
74
+ If `--stop` flag is provided:
75
+
76
+ ```bash
77
+ node .claude/skills/markdown-novel-viewer/scripts/server.cjs --stop
78
+ ```
79
+
80
+ ### Start Server
81
+
82
+ Otherwise, run the `markdown-novel-viewer` server as CC background task with `--foreground` flag (keeps process alive for CC task management):
83
+
84
+ ```bash
85
+ # Determine if path is file or directory
86
+ INPUT_PATH="{{path}}"
87
+ if [[ -d "$INPUT_PATH" ]]; then
88
+ # Directory mode - browse
89
+ node .claude/skills/markdown-novel-viewer/scripts/server.cjs \
90
+ --dir "$INPUT_PATH" \
91
+ --host 0.0.0.0 \
92
+ --open \
93
+ --foreground
94
+ else
95
+ # File mode - view markdown
96
+ node .claude/skills/markdown-novel-viewer/scripts/server.cjs \
97
+ --file "$INPUT_PATH" \
98
+ --host 0.0.0.0 \
99
+ --open \
100
+ --foreground
101
+ fi
102
+ ```
103
+
104
+ **Critical:** When calling the Bash tool:
105
+ - Set `run_in_background: true` to run as CC background task
106
+ - Set `timeout: 300000` (5 minutes) to prevent premature termination
107
+ - Parse JSON output and report URL to user
108
+
109
+ Example Bash tool call:
110
+ ```json
111
+ {
112
+ "command": "node .claude/skills/markdown-novel-viewer/scripts/server.cjs --dir \"path\" --host 0.0.0.0 --open --foreground",
113
+ "run_in_background": true,
114
+ "timeout": 300000,
115
+ "description": "Start preview server in background"
116
+ }
117
+ ```
118
+
119
+ After starting, parse the JSON output (e.g., `{"success":true,"url":"http://localhost:3456/view?file=...","networkUrl":"http://192.168.1.x:3456/view?file=..."}`) and report:
120
+ - Local URL for browser access
121
+ - Network URL for remote device access (if available)
122
+ - Inform user that server is now running as CC background task (visible in `/tasks`)
123
+
124
+ **CRITICAL:** MUST display the FULL URL including path and query string (e.g., `http://localhost:3456/view?file=/path/to/file.md`). NEVER truncate to just `host:port` (e.g., `http://localhost:3456`). The full URL is required for direct file access.
125
+
126
+ ---
127
+
128
+ ## Generation Mode
129
+
130
+ When `--explain`, `--slides`, `--diagram`, or `--ascii` flag is provided:
131
+
132
+ ### Step 1: Determine Output Location
133
+
134
+ 1. Check if there's an active plan context (from `## Plan Context` in hook injection)
135
+ 2. If active plan exists: save to `{plan_dir}/visuals/{topic-slug}.md`
136
+ 3. If no active plan: save to `plans/visuals/{topic-slug}.md`
137
+ 4. Create `visuals/` directory if it doesn't exist
138
+
139
+ ### Step 2: Generate Content
140
+
141
+ **Mermaid Diagram Syntax:**
142
+ When generating ` ```mermaid ` code blocks, use `/mermaidjs-v11` skill for v11 syntax rules.
143
+
144
+ **Essential rules (always apply):**
145
+ - Quote node text with special characters: `A["text with /slashes"]`
146
+ - Escape brackets in labels: `A["array[0]"]`
147
+
148
+ Use the appropriate template based on flag:
149
+
150
+ #### --explain (Visual Explanation)
151
+ ```markdown
152
+ # Visual Explanation: {topic}
153
+
154
+ ## Overview
155
+ Brief description of what we're explaining.
156
+
157
+ ## Quick View (ASCII)
158
+ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
159
+ │ Component A │───>│ Component B │───>│ Component C │
160
+ └─────────────┘ └─────────────┘ └─────────────┘
161
+
162
+ ## Detailed Flow
163
+ \```mermaid
164
+ sequenceDiagram
165
+ participant A as Component A
166
+ participant B as Component B
167
+ A->>B: Request
168
+ B-->>A: Response
169
+ \```
170
+
171
+ ## Key Concepts
172
+ 1. **Concept A** - Explanation
173
+ 2. **Concept B** - Explanation
174
+
175
+ ## Code Example (if applicable)
176
+ \```typescript
177
+ // Relevant code snippet with comments
178
+ \```
179
+ ```
180
+
181
+ #### --slides (Presentation Format)
182
+ ```markdown
183
+ # {Topic} - Visual Presentation
184
+
185
+ ---
186
+
187
+ ## Slide 1: Introduction
188
+ - One concept per slide
189
+ - Bullet points only
190
+
191
+ ---
192
+
193
+ ## Slide 2: The Problem
194
+ \```mermaid
195
+ flowchart TD
196
+ A[Problem] --> B[Impact]
197
+ \```
198
+
199
+ ---
200
+
201
+ ## Slide 3: The Solution
202
+ - Key point 1
203
+ - Key point 2
204
+
205
+ ---
206
+
207
+ ## Slide 4: Summary
208
+ Key takeaways...
209
+ ```
210
+
211
+ #### --diagram (Focused Diagram)
212
+ ```markdown
213
+ # Diagram: {topic}
214
+
215
+ ## ASCII Version
216
+ ┌──────────────────────────────────────────┐
217
+ │ Architecture │
218
+ ├─────────────┬──────────────┬─────────────┤
219
+ │ Layer 1 │ Layer 2 │ Layer 3 │
220
+ └─────────────┴──────────────┴─────────────┘
221
+
222
+ ## Mermaid Version
223
+ \```mermaid
224
+ flowchart TB
225
+ subgraph Layer1[Layer 1]
226
+ A[Component A]
227
+ end
228
+ subgraph Layer2[Layer 2]
229
+ B[Component B]
230
+ end
231
+ A --> B
232
+ \```
233
+ ```
234
+
235
+ #### --ascii (Terminal-Friendly Only)
236
+ ```
237
+ ┌────────────────────────────────────────────────────────┐
238
+ │ {Topic} Overview │
239
+ ├────────────────────────────────────────────────────────┤
240
+ │ │
241
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
242
+ │ │ Input │──────>│ Process │──────>│ Output │ │
243
+ │ └─────────┘ └─────────┘ └─────────┘ │
244
+ │ │
245
+ │ Legend: │
246
+ │ ──────> Data flow │
247
+ │ ────── Connection │
248
+ │ │
249
+ └────────────────────────────────────────────────────────┘
250
+ ```
251
+
252
+ ### Step 3: Save and Preview
253
+
254
+ 1. Write generated content to determined path
255
+ 2. Start preview server with the generated file:
256
+ ```bash
257
+ node .claude/skills/markdown-novel-viewer/scripts/server.cjs \
258
+ --file "<generated-file-path>" \
259
+ --host 0.0.0.0 \
260
+ --open \
261
+ --foreground
262
+ ```
263
+
264
+ ### Step 4: Report to User
265
+
266
+ Report:
267
+ - Generated file path
268
+ - Preview URL (local + network)
269
+ - Remind: file saved in plan's `visuals/` folder for future reference
270
+
271
+ ## Error Handling
272
+
273
+ | Error | Action |
274
+ |-------|--------|
275
+ | Invalid topic (empty) | Ask user to provide a topic |
276
+ | Flag without topic (`/preview --explain`) | Ask user: "Please provide a topic: `/preview --explain <topic>`" |
277
+ | Topic becomes empty after sanitization | Ask user to provide topic with alphanumeric characters |
278
+ | File write failure | Report error, suggest checking permissions |
279
+ | Server startup failure | Check if port in use, try `/preview --stop` first |
280
+ | No generation flag + unresolvable reference | Ask user to clarify which file they meant |
281
+ | Existing file at output path | Overwrite with new content (no prompt) |
282
+ | Server already running | Reuse existing server instance, just open new URL |
283
+ | Parent `plans/` dir missing | Create directories recursively before write |