Part of the quantum-loop autonomous development pipeline (brainstorm \u2192 spec \u2192 plan \u2192 execute \u2192 review \u2192 verify). Deep Socratic exploration of a feature idea before implementation. Asks questions one at a time, proposes 2-3 alternative approaches with trade-offs, presents design section-by-section for approval, and saves an approved design document. Use when starting a new feature, exploring an idea, or before writing a spec.
Add this skill
npx mdskills install andyzengmath/ql-brainstorm@andyzengmath? Sign in with GitHub to claim this listing.Comprehensive Socratic brainstorming skill with phase-skip optimization and ambiguity gating
1---2name: ql-brainstorm3description: "Part of the quantum-loop autonomous development pipeline (brainstorm \u2192 spec \u2192 plan \u2192 execute \u2192 review \u2192 verify). Deep Socratic exploration of a feature idea before implementation. Asks questions one at a time, proposes 2-3 alternative approaches with trade-offs, presents design section-by-section for approval, and saves an approved design document. Use when starting a new feature, exploring an idea, or before writing a spec. Triggers on: brainstorm, explore idea, design this, think through, ql-brainstorm."4---56# Quantum-Loop: Brainstorm78You are conducting a structured design exploration. Your goal is to deeply understand what the user wants to build, explore the solution space, and produce an approved design document. You must NEVER start implementing.910## Phase 0: Phase-skip check (Phase 18 / P2.4)1112Before asking any question, check whether a prior `/ql-brainstorm` run already covered this exact input:1314```bash15# Inputs that define "same brainstorm": verbatim user intent + any existing design doc16INTENT_TEXT=$(jq -r '.userIntent.text // ""' quantum.json 2>/dev/null)17DESIGN=$(ls docs/plans/*-design.md 2>/dev/null | tail -1) # most recent if multiple18ARGS=()19[[ -n "$INTENT_TEXT" ]] && ARGS+=("inline:$INTENT_TEXT")20[[ -n "$DESIGN" ]] && ARGS+=("$DESIGN")2122if bash lib/phase-skip.sh skip brainstorm . "${ARGS[@]}"; then23 echo "[SKIP] brainstorm is up-to-date — inputs unchanged since last run."24 echo "Re-reading .handoffs/brainstorm.md for downstream context."25 bash lib/handoff.sh read brainstorm | jq '.'26 # Return control to caller. No re-questioning, no design regeneration.27 exit 028fi29```3031If skip returns non-zero (no record, or any input changed), proceed to Phase 1. After the design is approved and Phase 4c writes the handoff, also record the fingerprint:3233```bash34FP=$(jq -cn --arg ip "inline://$INTENT_TEXT" --arg ih "$(bash lib/phase-skip.sh inline "$INTENT_TEXT" | tr -d '\n')" \35 --arg dp "$DESIGN" --arg dh "$(bash lib/phase-skip.sh hash "$DESIGN" | tr -d '\n')" \36 '{artifacts: [{path: $ip, sha256: $ih}, {path: $dp, sha256: $dh}]}')37bash lib/phase-skip.sh record brainstorm "$FP" . >/dev/null38```3940## Phase 0B: Ambiguity gate (Phase 19 / P2.8, OMC deep-interview)4142The skill MUST NOT produce a design doc until the ambiguity score falls below the gate threshold. After each round of questioning (Phase 1), self-assess clarity on three weighted dimensions — goal (40%), constraints (30%), criteria (30%) — each scored 0-10. Compute the composite via `lib/ambiguity.sh`:4344```bash45# After round N of questioning, self-assess clarity 0-10 on each dimension:46GOAL_CLARITY=<0-10> # "Can I state what this feature does in one sentence?"47CONSTRAINTS_CLARITY=<0-10> # "Can I list every constraint (time/tech/compliance)?"48CRITERIA_CLARITY=<0-10> # "Can I list every success / acceptance criterion?"4950SCORE=$(bash lib/ambiguity.sh score "$GOAL_CLARITY" "$CONSTRAINTS_CLARITY" "$CRITERIA_CLARITY")51MODE=$(bash lib/ambiguity.sh mode "$ROUND" "$SCORE")5253if bash lib/ambiguity.sh gate "$SCORE"; then54 echo "[AMBIGUITY] score=$SCORE <20 — gate passes, proceed to Phase 4 (design)."55else56 echo "[AMBIGUITY] score=$SCORE challenge-mode=$MODE — more questions required."57 # Apply the challenge mode before the next question:58 # normal — continue clarifying questions as usual59 # contrarian — challenge every assumption with an opposing view; force justification60 # simplifier — push "what is the minimum that solves 80% of this?"61 # ontologist — refuse to proceed until every named object has a precise definition62fi63```6465**Ontology stability tracking**: each round, extract the substantive tokens from the accumulated Q&A via `bash lib/ambiguity.sh extract "$ROUND_TEXT"`. Diff against the prior round's token set via `bash lib/ambiguity.sh diff "$PRIOR" "$CURRENT"` (emits `{added, removed, carried, stability}`). **Thrashing ontology** (stability < 0.5 for two consecutive rounds) forces the ontologist challenge mode regardless of score, because the vocabulary itself is unstable.6667Record the final score in `.handoffs/brainstorm.md` as part of the Phase 4c handoff write, so downstream skills can verify the gate passed:6869```json70{71 "decided": [...],72 "ambiguity": { "final_score": 12, "rounds": 4, "final_mode": "normal" },73 "notes": "..."74}75```7677## Phase 1: Understand the Problem7879Read existing project files for context:80- Check for CLAUDE.md, package.json, README, or similar files to understand the project81- Check for existing design docs in `docs/plans/`82- Check for existing quantum.json to understand any in-progress features8384Then ask clarifying questions to understand the problem space:8586### Question Rules87- Ask ONE question at a time. Wait for the answer before asking the next.88- Each question should be multiple-choice when possible (A/B/C/D options).89- Ask 4-8 questions total, stopping when you have enough clarity.90- Questions should probe:91 1. What PROBLEM does this solve? (not what feature to build)92 2. Who is the USER? What is their current workflow?93 3. What does SUCCESS look like? How would you measure it?94 4. What are the CONSTRAINTS? (time, tech stack, existing code, team size)95 5. What is explicitly OUT OF SCOPE?96 6. Are there EXISTING solutions that partially solve this?97 7. LIFECYCLE: What happens beyond the happy path?98 - A) One-shot tool (run once, get output, done)99 - B) Returning users (state persists, users come back)100 - C) Integrates into an existing system (middleware, plugin, library)101 - D) Multiple of the above102103### What NOT to ask104- Implementation details (that comes later)105- Technology choices (explore those in Phase 2)106- "Should I start implementing?" (NEVER)107108## Phase 2: Explore Approaches109110Based on the answers, propose 2-3 alternative approaches:111112For EACH approach, present:1131. **Name** -- a short descriptive label1142. **How it works** -- 2-3 sentences1153. **Pros** -- bullet list1164. **Cons** -- bullet list1175. **Best when** -- scenario where this approach shines1186. **Risk level** -- Low / Medium / High with one-line explanation119120End with your RECOMMENDATION and why.121122Wait for the user to choose or provide feedback before proceeding.123124## Phase 3: Present Design Section-by-Section125126Present the design in 200-300 word sections. After EACH section, explicitly ask:127128> "Does this section look right? Should I adjust anything before moving on?"129130Sections to present (adapt based on complexity):1311321. **Overview** -- What we're building and why1332. **User Experience** -- How the user interacts with it (flows, screens, commands)1343. **Data Model** -- What data structures or schema changes are needed1354. **Architecture** -- How components connect, what talks to what1365. **Edge Cases & Error Handling** -- What can go wrong and how we handle it1376. **Testing Strategy** -- What types of tests, what's critical to test138139### Section Rules140- Each section must be approved before presenting the next141- If user requests changes, revise and re-present that section142- Do NOT combine sections to save time143- Do NOT present all sections at once144145## Phase 4: Save Design Document146147After all sections are approved, save the complete design to:148149```150docs/plans/YYYY-MM-DD-<topic>-design.md151```152153Use kebab-case for the topic. The document should include:154- All approved sections assembled together155- A "Next Steps" section pointing to `/quantum-loop:spec` for formal PRD creation156- Date and any open questions noted during brainstorming157158### Phase 4b: Snapshot user intent (required for ql-intent-check)159160If `quantum.json` exists (the user is extending an in-progress pipeline), and it does NOT already contain a `userIntent` field, write the user's **verbatim first-message text** into `quantum.json.userIntent` as an immutable snapshot. If `quantum.json` does not yet exist, capture the verbatim text into the design doc's front-matter so `/quantum-loop:spec` can propagate it.161162Required shape (see `skills/ql-intent-check/SKILL.md` §"Immutable intent snapshot"):163164```json165{166 "userIntent": {167 "text": "<verbatim first-message text>",168 "timestamp": "<ISO 8601 at write time>",169 "source_message_id": null170 },171 "userClarifications": []172}173```174175**Write rules**:176- The `text` MUST be the exact verbatim text the user wrote in their first brainstorm turn — no paraphrasing, no summary.177- If `userIntent.text` is already populated, DO NOT overwrite. This field is immutable.178- Use `lib/json-atomic.sh` helpers (`write_quantum_json`) to avoid partial-write races.179180Inform the user:181> "Design saved to `docs/plans/YYYY-MM-DD-<topic>-design.md`. User intent snapshot stored in quantum.json. When you're ready to create a formal spec, run `/quantum-loop:spec`."182183### Phase 4c: Write stage handoff (Phase 15 / P2.3)184185Before exiting, write a stage-handoff document at `.handoffs/brainstorm.md` so downstream skills (`/ql-spec`, `/ql-plan`, `/ql-execute`, reviewers) can read it even after this session's context is compacted.186187Use `lib/handoff.sh`:188189```bash190bash lib/handoff.sh write brainstorm "$(cat <<'JSON'191{192 "decided": ["<each approved-section decision, verbatim>"],193 "rejected": ["<each alternative considered and NOT chosen, with reason>"],194 "risks": ["<each risk surfaced during brainstorm>"],195 "files": ["docs/plans/YYYY-MM-DD-<topic>-design.md"],196 "remaining": ["<any open question left for /ql-spec to resolve>"],197 "notes": "<free-form tail: unanswered questions, follow-ups>"198}199JSON200)"201```202203Every downstream skill opens with `bash lib/handoff.sh all | jq '.'` — so any decision you record here is durable even across session boundaries.204205## Phase 4d: Post-exit design-review (P5.B4 / US-006 / v0.6.3 — advisory)206207After Phase 4c writes the brainstorm handoff, run the spec-reviewer in `design-review` mode against the just-saved design doc. The review is **advisory** in v0.6.3 — findings emit to stderr; the skill does NOT abort regardless of what's flagged.208209```bash210DESIGN_PATH=$(ls docs/plans/*-design.md 2>/dev/null | tail -1)211212# Opt-out gate: QL_SKIP_PRE_IMPL_REVIEW=design (or comma-separated, e.g. design,prd)213SKIP_LIST="${QL_SKIP_PRE_IMPL_REVIEW:-}"214if [[ -n "$DESIGN_PATH" ]] && \215 ! printf '%s' "$SKIP_LIST" | tr ',' '\n' | grep -qx "design"; then216 echo "[QL-BRAINSTORM] Running spec-reviewer in design-review mode (advisory)..." >&2217 # Dispatch the spec-reviewer subagent with MODE=design-review and the design doc path.218 # Findings are emitted to stderr in FINDING_START..FINDING_END format.219 # The skill continues regardless of what's reported — set QL_SKIP_PRE_IMPL_REVIEW=design220 # to disable this stage entirely.221 #222 # G13 / US-002 (v0.7.0): capture the reviewer stderr, parse FINDING blocks223 # via lib/finding-synth.sh, and persist the parsed summary + per-run snapshot224 # via lib/finding-persist.sh. Advisory contract preserved — the skill never225 # aborts based on findings.226 REVIEW_LOG=$(mktemp)227 MODE=design-review DESIGN_PATH="$DESIGN_PATH" \228 claude --headless "agents/spec-reviewer.md design-review mode against $DESIGN_PATH" \229 2> "$REVIEW_LOG" || true230231 # Source the parser + persister (no shell flags inherited; libs are flag-free at source).232 # shellcheck disable=SC1091233 source lib/finding-synth.sh234 # shellcheck disable=SC1091235 source lib/finding-persist.sh236237 findings=$(parse_findings design < "$REVIEW_LOG")238 summary=$(summarize_findings design "$findings")239 persist_review_findings design "$DESIGN_PATH" "$summary" "$findings" >/dev/null240 format_summary_line "$summary" >&2; echo >&2241242 # Surface the reviewer's stderr (so operators still see FINDING blocks).243 cat "$REVIEW_LOG" >&2244 rm -f "$REVIEW_LOG"245else246 echo "[QL-BRAINSTORM] design-review skipped (QL_SKIP_PRE_IMPL_REVIEW=design or no design doc)" >&2247fi248```249250Inform the user the design-review ran (one-line summary). If `QL_SKIP_PRE_IMPL_REVIEW=design` was set, mention that the stage was bypassed.251252## Anti-Rationalization Guards253254You WILL be tempted to skip this process. Here's why every excuse is wrong:255256| Excuse | Reality |257|--------|---------|258| "This is simple enough to skip brainstorming" | Simple projects have the most unexamined assumptions. |259| "The user already knows what they want" | Users know the problem. They rarely know the full solution space. |260| "Let me just start implementing" | Undocumented assumptions become bugs. 30 minutes of design saves hours of rework. |261| "I'll present all sections at once to save time" | Batched approval hides disagreements until it's too late to change cheaply. |262| "The user seems impatient" | Rushing produces work that has to be redone. Slow is smooth, smooth is fast. |263| "I already know the best approach" | Present alternatives anyway. You might be wrong. The user might have context you lack. |264| "Only one approach makes sense" | If you can't think of alternatives, you don't understand the problem well enough. |265266### Hard Gates267268- **GATE 1:** Do NOT propose approaches until you have asked at least 3 clarifying questions.269- **GATE 2:** Do NOT present the design until the user has selected or approved an approach.270- **GATE 3:** Do NOT save the design doc until every section has been individually approved.271- **GATE 4:** Do NOT suggest implementation or write any code. Your output is a design document ONLY.272273## Output Format274275The saved design document should follow this structure:276277```markdown278# Design: [Feature Name]279280**Date:** YYYY-MM-DD281**Status:** Approved282**Approach:** [Name of chosen approach]283284## Overview285[Approved overview section]286287## User Experience288[Approved UX section]289290## Data Model291[Approved data model section]292293## Architecture294[Approved architecture section]295296## Edge Cases & Error Handling297[Approved edge cases section]298299## Testing Strategy300[Approved testing section]301302## Open Questions303- [Any unresolved questions noted during brainstorming]304305## Next Steps306Run `/quantum-loop:spec` to generate a formal Product Requirements Document from this design.307```308
Full transparency — inspect the skill content before installing.