From foundry
Iterative brainstorming skill for turning fuzzy ideas into approved tree documents. Diverges into branches, deepens and prunes them over many rounds, saves a tree doc. Run breakdown on the tree to distill it into a spec via guided questions.
npx claudepluginhub borda/ai-rig --plugin foundryThis skill is limited to using the following tools:
<objective>
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Turn an unformed idea into a branching exploration tree, then distill that tree into a spec. Idea mode is pure divergence — you grow a tree of directions, deepen promising branches, prune others, and save the result. Nothing is forced to converge prematurely. Run breakdown on the tree when ready: it asks distillation questions and writes the spec section-by-section.
Examples:
/brainstorm I want users to be able to export results as CSV
--tight — reduced-ceremony mode: cap clarifying questions at 5 (not 10), cap tree operations at 5 (not 10), require only 1 closed branch (not 2) before saving. Good for well-scoped ideas where the problem is already understood.
--deep — extended-ceremony mode: cap clarifying questions at 15, cap tree operations at 15, require 3+ closed branches before saving. Good for genuinely ambiguous problems where more exploration is valuable.
Default (no flag): behaviour unchanged — 10/10/2 bounds.
--type <type> — optional type hint for idea mode. One of: application (app/service with users/endpoints), workflow (automation, pipeline, script), utility (helper library, tool, CLI), config (.claude/ agents/skills/rules), research (investigation, survey, experiment design). Affects Step 1 scan patterns and Step 2 question framing. Omit if unsure — the skill works without it.
breakdown <tree-or-spec-file> — breakdown mode: read an already-saved tree (Status: tree) or spec (Status: draft). For a tree: ask distillation questions and write the spec section-by-section. For a spec: scan for blocking open questions then generate an ordered action plan. Skips Steps 1–6 entirely.
Task hygiene: Before creating tasks, call TaskList. For each found task:
completed if the work is clearly donedeleted if orphaned / no longer relevantin_progress only if genuinely continuingTask tracking: Before Step 1, create TaskCreate entries for all 6 steps (context scan, clarifying questions, build tree, save tree, tree review, present + gate). Then print a session plan to the user:
Brainstorming: <goal from $ARGUMENTS> Plan: context scan → clarifying questions → build tree → save tree doc → review → approval gate. Starting with a codebase scan...
Gather project context before asking anything:
README.md and any relevant files under docs/$ARGUMENTS across src/ or the project rootType-aware scan patterns (when --type is declared):
application: look for existing routes, controllers, components, API endpoints, auth middlewareworkflow: look for existing scripts, pipelines, CI configs, scheduled jobs, automation filesutility: look for existing utils/, helpers/, lib/ directories and similar functionsconfig: look for .claude/ agents, skills, rules, and settings.json entriesresearch: look for existing notes, benchmarks, prior experiment results, and related papers/ticketsWhen no --type is declared, perform the generic scan as before.
Goal: understand constraints so questions are targeted, not generic. If the idea already exists or is clearly out of scope, say so immediately and stop.
Use AskUserQuestion for every clarifying question — this renders an interactive prompt inline, not plain text.
Rules:
AskUserQuestion once, wait for the answer, then decide whether another question is neededAskUserQuestion: list lettered choices so the user can reply with just "a", "b", or "c"; mark the option you recommend with ★ (e.g., a) Option A ★ recommended) so the user has a sensible default--tight mode, 15 in --deep mode) — after the limit, proceed to Step 3 with what you havex) Enough questions — let's start building the tree so the user can move on if the problem is already well-defined> **Skill's read:** This makes me think the core challenge is X, which points toward approaches like Y). Write it as the skill speaking.Gate: do not proceed to Step 3 until the problem is well-defined or the maximum question count is reached. Aim for at least 3 questions to build enough context for a rich tree.
Type-aware question framing (when --type is declared): lead with type-appropriate questions first:
application: ask about users (who uses it?), scale, and integration points before general questionsworkflow: ask about triggers (what starts it?), inputs, outputs, and failure handling firstutility: ask about callers (who uses this library/tool?), interface shape, and scope of responsibilityconfig: ask whether this targets an existing agent/skill or is new, and what gap it fills in the current setupresearch: ask about the hypothesis or question being investigated, and what constitutes a useful findingThis step is the full creative session — grow, deepen, and prune a tree of directions. The tree is the output; convergence happens later in breakdown. Runs as a loop of tree operations.
Present 3–5 initial branches (top-level directions). For each include:
After presenting all initial branches, write an Opening framing paragraph (2–3 sentences) sharing the skill's initial read on the problem space: what it sees as the core tension, which branch(es) it finds most promising and why, and one thing it's uncertain about. This is not a recommendation to converge — divergence is still the goal — but an honest perspective to spark reaction.
Then call AskUserQuestion with one letter per branch (labelled by name), plus:
On (f): ask what direction the user is thinking, then generate 2–3 new branches incorporating it. On (g): generate 2–3 fresh branches with genuinely different framing.
User may select 1–3 branches to mark as initial focus. All other branches start as [open] too — they are not closed yet, just not the initial focus.
After seeding, enter the operations loop. Each iteration:
AskUserQuestion with the available operations:
Operations:
—. Add a one-line entry to the pruning log. Ask if the reason captures it correctly before proceeding. After executing, write 1–2 sentences reacting to what closing this branch reveals — what it tells us about where the exploration is actually headed.[merged -> <number>: <new-branch-name>] immediately in the tree summary shown after the merge, and in all subsequent tree summaries. After executing, write 1–2 sentences on what the merge suggests about where the idea is heading — what the synthesis makes clearer or harder.Always show the tree summary before calling AskUserQuestion:
Tree: <title>
├─ ▶️ Branch 1: <name>
│ ├─ 💭 1.1: <name>
│ └─ ⛔ 1.2: <name> — <reason>
├─ 💭 Branch 2: <name>
│ ├─ ▶️ 2.1: <name>
│ │ ├─ 💭 2.1.1: <name>
│ │ └─ ⛔ 2.1.2: <name> — <reason>
│ └─ ⛔ 2.2: <name> — <reason>
└─ 🔗 Branch 3: <name> [merged -> <number>: <new-branch-name>]
Open: N · Closed: N · Merged: N
Legend: ▶️ active focus · 💭 open · ⛔ closed · 🔗 merged
Use ├─, │ ├─, └─ for tree rendering. Show sub-branches indented one level per depth. Sub-branches use hierarchical dot notation: branch 2 splits into 2.1, 2.2, …; those can further split into 2.1.1, 2.1.2, … Prefix each branch with its status emoji: ▶️ for the branch currently being operated on (most recently deepened, or selected as initial focus during seeding), 💭 for all other open branches, ⛔ for closed branches (show reason after —), 🔗 for merged branches (show merge target as [merged -> <number>: <new-branch-name>]). The legend line is always the last line.
--tight mode, 15 in --deep mode) (a round = one operation)AskUserQuestion with: a) Save tree as-is ★ recommended / b) Do 2 more operations then save--tight, 3 in --deep); if fewer than the required closed branches exist, prompt: "The tree has few closed branches — consider closing 1–2 that are clearly not the right direction before saving."Assemble the tree state and write to .plans/blueprint/YYYY-MM-DD-<slug>.md using the Write tool (creates the directory if absent). The slug is derived from the title (kebab-case, max 5 words). If a file already exists at the target path (e.g., same day, same slug after a restart), append a counter suffix (-2, -3, etc.) rather than overwriting.
# <title>
**Date**: YYYY-MM-DD
**Status**: tree
## Root idea
[The original user input and the refined problem understanding built up during Step 2 — 2–3 sentences.]
## Branches
[For each branch in the tree, using this structure:]
### Branch N: <name> [open | closed — <reason> | merged into <name>]
**Core idea**: ...
**Tension it resolves**: ...
**What it trades away**: ...
[Sub-branches nested as H4 headings if present:]
#### N.1: <sub-branch name> [open | closed — <reason>]
**Core idea**: ...
[Deeper splits nest as H5 headings, e.g. `##### N.1.1: <name>`]
## Pruning log
- Branch N closed: <reason>
- Sub-branch N.1 closed: <reason>
[One bullet per closed or merged branch, in the order they were closed.]
## Open threads
[Unanswered questions, untested combinations, and constraints that surfaced during Step 3. Each thread is a one-line bullet.]
Gate: do not proceed to Step 5 until the file is written and the path is confirmed.
Before spawning, pre-compute the output path:
# timeout: 3000
BRANCH=$(git branch --show-current 2>/dev/null | tr '/' '-' || echo 'main')
OUTPUT_PATH=".temp/output-brainstorm-review-$BRANCH-$(date +%Y-%m-%d).md"
Spawn foundry:self-mentor with a tree-focused prompt (inject the pre-computed $OUTPUT_PATH in place of <output-path>):
Read .plans/blueprint/<tree-file>. Audit for tree quality only (do NOT audit `.claude/` config files — scope is the brainstorm tree only):
- Root idea: is the original problem clearly stated in the "Root idea" section?
- Branch depth: do open branches have enough detail (not just a name)?
- Closure quality: are closure reasons substantive (not just "not chosen" or "skipped")?
- Coverage: are there obvious high-level directions completely missing from the tree?
- Open threads: are there unresolved questions worth capturing?
Write your full findings to <output-path> using the Write tool.
Return ONLY a compact JSON envelope: {"status":"done","findings":N,"file":"<path>","confidence":0.N,"summary":"<one-line>"}
Passive health monitoring: the Agent tool is synchronous — Claude awaits self-mentor's response natively. If self-mentor does not return within 15 min, surface any partial output already written to .temp/ with a ⏱ marker and continue to Step 6 with an incomplete review noted.
Note: synchronous Agent calls do not support mid-call extensions per CLAUDE.md §8 — simplified monitoring is intentional for synchronous spawns.
If findings > 0: add missing details, improve closure reasons, or add open threads as needed — loop back to Step 5 (max 2 revision cycles). After 2 cycles with remaining findings, surface unresolved issues to the user and proceed to Step 6 anyway.
Gate: do not proceed to Step 6 until findings == 0 or 2 revision cycles are exhausted.
Show the tree file path and a compact tree summary (same format as Step 3). Then call AskUserQuestion with:
Gate: do not exit until the user approves. On (b): return to Step 3 with the existing tree state — add the requested branches or close the specified ones, then loop back to Step 5. Use a reduced cap of 3 additional operations for this re-entry (not a fresh full budget reset); the cap resets only at the start of Step 3, not on re-entry. On (c): loop back to Step 2. (Max 3 approval cycles — after 3 (b) responses with no convergence, surface unresolved concerns to user and stop.)
On approval, suggest: /brainstorm breakdown .plans/blueprint/<file> to distill the tree into a spec.
Triggered when $ARGUMENTS starts with breakdown followed by a file path.
Read the file at the given path. Check the **Status**: field:
Status: tree → Distillation mode (Steps D1–D4 below)Status: draft → Action plan mode (Steps B1–B3 below)Read all open branches from the file. Show the compact tree summary (same format as Step 3) and a one-sentence description of each open branch. State the count of open and closed branches.
Ask up to 5 distillation questions, one at a time via AskUserQuestion, to narrow the open branches into a single direction:
Start with these (adapt based on the tree content):
After the questions, briefly restate the distilled direction in 2–3 sentences — the synthesis of what was just decided.
Build the spec section by section, showing each section inline and asking for feedback before moving on. Write nothing to disk until the full draft is assembled.
For each section, write it inline then call AskUserQuestion:
On (b): revise inline, show updated version, re-offer. Max 2 revisions per section. On (c): incorporate context, revise if needed, re-offer.
Sections:
Section 1 — Goal (1 paragraph: what problem this solves and for whom) Derive from the distilled direction from D2. Reference the open branches that fed into it.
Section 2 — Non-goals (explicit list) Derive from closed branches and the open branches not chosen in D2.
Section 3 — Proposed design (the distilled direction with enough detail to implement) Break into sub-points. Describe what, not how. If the direction is a merge of multiple open branches, name each part.
Section 4 — Open questions (unresolved decisions) Seed from the "Open threads" section of the tree. For each, note blocking vs non-blocking and a recommended default if possible.
Section 5 — Success criteria (observable, testable outcomes) Include the criterion identified in D2 question 3. Each criterion must be concrete enough to write a pass/fail check.
Section 6 — Exploration notes (summary of closed branches and why) Draw from the Pruning log in the tree. This is context for future readers — what was considered and rejected.
Gate: do not write to disk until all 6 sections are drafted and individually approved.
Graduation checklist — verify before writing to disk:
If any item fails, call AskUserQuestion with:
On (a): jump back to the failing section in D3 (max 1 extra revision per section). On (b): proceed to write.
After all sections approved: write to .plans/blueprint/YYYY-MM-DD-<slug>.md (new file; use the tree's slug with a -spec suffix if writing alongside the tree):
# <title>
**Date**: YYYY-MM-DD
**Status**: draft
## Goal
[Section 1]
## Non-goals
[Section 2]
## Proposed design
[Section 3]
## Open questions
[Section 4]
## Success criteria
[Section 5]
## Exploration notes
[Section 6]
After writing the spec, suggest:
.claude/ config: /manage update <name> .plans/blueprint/<spec-file> or /manage create <type> <name> "description"/brainstorm breakdown .plans/blueprint/<spec-file> to generate the action planRead the spec's "Open questions" section. For each question, determine whether it is blocking (no recommended option stated and the answer is genuinely unknown) or non-blocking (spec states a recommended option or the answer is inferable).
For each blocking question: call AskUserQuestion — one at a time, in order. Non-blocking questions go into the plan table footnote.
.claude/ config change → /manage create <type> <name> "description" or /manage update <name> <spec-file>/develop:feature "<goal>" or /develop:fix "<symptom>"/develop:feature "<doc goal>"/develop:feature "<test goal>" or manual check command## Action Plan: <spec title>
Spec: <file path>
| # | Task | Invocation |
|---|------|------------|
| 1 | [first action item] | `/develop:feature "<goal>"` |
### Non-blocking open questions (resolve during implementation)
- [list, or "None"]
Call AskUserQuestion with:
On (a): proceed immediately with the invocation from task 1. On (b): output the plan table as a clean markdown block, then stop. On (c): stop and tell the user to revise the spec and re-run /brainstorm breakdown <spec>.
End with a ## Confidence block per CLAUDE.md output standards.
disable-model-invocation: true — the skill is conversational; the parent model drives all steps turn by turn.claude/ config filesYYYY-MM-DD-<kebab-slug>.md format; tree files use the base slug; spec files append -spec to the slug to avoid collisionStatus: tree; spec documents use Status: draft; breakdown auto-detects which path to take--tight) / 23 (default) / 33 (--deep) questions + operations + 3 approval cycles; breakdown distillation — max 5 questions + 6 section drafts ≈ 11; typical sessions use ~8–15 total AskUserQuestion calls across both--tight / --deep scale question and operation caps (5/15 vs default 10); --type enables type-aware scan and question framing in Steps 1–2; these flags apply to idea mode only and are ignored in breakdown.claude/ config: /manage update <name> <spec-file>; for application or mixed changes: /brainstorm breakdown .plans/blueprint/<spec-file> for the action plan