重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
brainstorm-with-file by catlog22/claude-code-workflow
npx skills add https://github.com/catlog22/claude-code-workflow --skill brainstorm-with-file这是一个记录思维演进过程的交互式头脑风暴工作流。通过提问、并行子智能体分析和迭代精炼来扩展初始想法。
核心工作流:种子想法 → 扩展 → 并行子智能体探索 → 综合 → 精炼 → 结晶
关键特性:
Codex 特有功能:
spawn_agent 和批量 wait({ ids: [...] }) 实现并行子智能体执行~/.codex/agents/*.md)send_input 进行深度交互,实现在单个智能体内的多轮精炼close_agent 进行显式的生命周期管理广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
此工作流通过支持并行的阶段,实现想法的迭代探索和精炼:
关键创新在于记录思维演进,捕捉想法如何发展、视角如何不同以及见解如何在所有阶段中浮现。
{projectRoot}/.workflow/.brainstorm/BS-{slug}-{date}/
├── brainstorm.md # ⭐ 完整的思维演进时间线
├── exploration-codebase.json # 阶段 2:代码库上下文
├── perspectives/ # 阶段 2:各视角输出
│ ├── creative.json
│ ├── pragmatic.json
│ └── systematic.json
├── perspectives.json # 阶段 2:聚合的并行发现结果与综合
├── synthesis.json # 阶段 4:最终综合
└── ideas/ # 阶段 3:单个想法的深度挖掘
├── idea-1.md
├── idea-2.md
└── merged-idea-1.md
| 产物 | 用途 |
|---|---|
brainstorm.md | 使用会话元数据、种子扩展和探索方向进行初始化 |
| 会话变量 | 主题 slug、头脑风暴模式、维度、探索方向 |
| 产物 | 用途 |
|---|---|
exploration-codebase.json | 代码库上下文:相关文件、模式、架构约束 |
perspectives/*.json | 来自并行子智能体的各视角输出 |
perspectives.json | 聚合的并行发现结果与综合(趋同/冲突主题) |
更新后的 brainstorm.md | 第 2 轮:探索结果和多视角分析 |
| 产物 | 用途 |
|---|---|
ideas/{idea-slug}.md | 对选定想法的深度挖掘分析 |
更新后的 brainstorm.md | 第 3-6 轮:用户反馈、想法选择、精炼循环 |
| 产物 | 用途 |
|---|---|
synthesis.json | 最终综合:顶级想法、建议、见解 |
最终的 brainstorm.md | 包含结论的完整思维演进记录 |
检测项目根目录,确保 .workflow/ 产物位置正确:
PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
优先通过 git 获取仓库根目录;非 git 项目回退到 pwd 取当前绝对路径。 存储为 {projectRoot},后续所有 .workflow/ 路径必须以此为前缀。
工作流会根据主题和当前日期(UTC+8)自动生成唯一的会话标识符和目录结构。
会话 ID 格式:BS-{slug}-{date}
slug:小写字母数字 + 中文字符,最多 40 个字符date:YYYY-MM-DD 格式(UTC+8)会话目录:{projectRoot}/.workflow/.brainstorm/{sessionId}/
自动检测:如果会话文件夹存在且包含 brainstorm.md,则自动进入继续模式。否则,创建新会话。
头脑风暴模式:
creative:强调新颖性和创新性,约束宽松structured:平衡创造力和可行性,范围现实balanced:默认模式,适度创新并考虑实际因素目标:解析初始想法,确定探索方向、范围偏好,并初始化头脑风暴文档。
工作流根据预定义的头脑风暴维度分析主题文本。
头脑风暴维度:
| 维度 | 关键词 |
|---|---|
| technical | 技术, technical, implementation, code, 实现, architecture |
| ux | 用户, user, experience, UX, UI, 体验, interaction |
| business | 业务, business, value, ROI, 价值, market |
| innovation | 创新, innovation, novel, creative, 新颖 |
| feasibility | 可行, feasible, practical, realistic, 实际 |
| scalability | 扩展, scale, growth, performance, 性能 |
| security | 安全, security, risk, protection, 风险 |
匹配逻辑:将主题文本与关键词列表进行比较,以确定相关维度。
根据主题关键词推荐角色,然后让用户确认或覆盖。
专业角色(根据主题关键词推荐):
| 角色 | 视角智能体关注点 | 关键词 |
|---|---|---|
| system-architect | 架构、模式 | 架构, architecture, system, 系统, design pattern |
| product-manager | 业务价值、路线图 | 产品, product, feature, 功能, roadmap |
| ui-designer | 视觉设计、交互 | UI, 界面, interface, visual, 视觉 |
| ux-expert | 用户研究、可用性 | UX, 体验, experience, user, 用户 |
| data-architect | 数据建模、存储 | 数据, data, database, 存储, storage |
| test-strategist | 质量、测试 | 测试, test, quality, 质量, QA |
| subject-matter-expert | 领域知识 | 领域, domain, industry, 行业, expert |
简单视角(后备 - 始终可用):
| 视角 | 关注点 | 最适合 |
|---|---|---|
| creative | 创新、跨领域 | 产生新颖想法 |
| pragmatic | 实现、可行性 | 对想法进行现实检验 |
| systematic | 架构、结构 | 组织解决方案 |
选择策略:
对于新的头脑风暴会话,在探索前收集用户偏好。
头脑风暴模式(单选):
关注领域(多选):
约束条件(多选):
生成指导头脑风暴探索的关键问题。使用子智能体生成方向。
探索方向:
用于生成方向的子智能体:
const vectorAgent = spawn_agent({
message: `
## TASK ASSIGNMENT
### MANDATORY FIRST STEPS (Agent Execute)
1. **Read role definition**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
---
## Context
Topic: ${idea_or_topic}
User focus areas: ${userFocusAreas.join(', ')}
Constraints: ${constraints.join(', ')}
## Task
Generate 5-7 exploration vectors (questions/directions) to expand this idea:
1. Core question: What is the fundamental problem/opportunity?
2. User perspective: Who benefits and how?
3. Technical angle: What enables this technically?
4. Alternative approaches: What other ways could this be solved?
5. Challenges: What could go wrong or block success?
6. Innovation angle: What would make this 10x better?
7. Integration: How does this fit with existing systems/processes?
## Deliverables
Return structured exploration vectors for multi-perspective analysis.
`
})
const result = wait({ ids: [vectorAgent], timeout_ms: 120000 })
close_agent({ id: vectorAgent })
目的:这些方向指导每个视角子智能体的分析,并确保全面探索。
使用会话元数据和扩展内容创建主要的头脑风暴文档。
brainstorm.md 结构:
成功标准:
目标:收集代码库上下文,并通过子智能体执行并行多视角分析,以生成多样化的观点。
执行模型:并行子智能体执行 - 同时生成 3 个视角智能体,批量等待所有结果,然后聚合。
关键 API 模式:
spawn_agent × 3 → wait({ ids: [...] }) → aggregate → close_agent × 3
在生成视角智能体之前,使用内置工具了解代码库结构。
上下文收集活动:
ccw tool exec get_modules_by_depth '{}'ccw spec load --category "exploration planning"exploration-codebase.json 结构:
relevant_files[]:与主题相关的文件,带有相关性指示器existing_patterns[]:常见的代码模式和架构风格architecture_constraints[]:项目级约束integration_points[]:模块之间的关键集成模式_metadata:时间戳和上下文信息⚠️ 重要:主进程不读取角色文件。在消息中传递路径,智能体自行读取。
并行生成 3 个视角智能体:创意 + 务实 + 系统化。
视角定义:
| 视角 | 角色文件 | 关注点 |
|---|---|---|
| Creative | ~/.codex/agents/cli-explore-agent.md | 创新、跨领域灵感、挑战假设 |
| Pragmatic | ~/.codex/agents/cli-explore-agent.md | 实现可行性、工作量估算、阻碍因素 |
| Systematic | ~/.codex/agents/cli-explore-agent.md | 问题分解、模式、可扩展性 |
并行子智能体执行:
// Build shared context from codebase exploration
const explorationContext = `
CODEBASE CONTEXT:
- Key files: ${explorationResults.relevant_files.slice(0,5).map(f => f.path).join(', ')}
- Existing patterns: ${explorationResults.existing_patterns.slice(0,3).join(', ')}
- Architecture constraints: ${explorationResults.architecture_constraints.slice(0,3).join(', ')}`
// Define perspectives
const perspectives = [
{
name: 'creative',
focus: 'Innovation and novelty',
tasks: [
'Think beyond obvious solutions - what would be surprising/delightful?',
'Explore cross-domain inspiration',
'Challenge assumptions - what if the opposite were true?',
'Generate moonshot ideas alongside practical ones'
]
},
{
name: 'pragmatic',
focus: 'Implementation reality',
tasks: [
'Evaluate technical feasibility of core concept',
'Identify existing patterns/libraries that could help',
'Estimate implementation complexity',
'Highlight potential technical blockers'
]
},
{
name: 'systematic',
focus: 'Architecture thinking',
tasks: [
'Decompose the problem into sub-problems',
'Identify architectural patterns that apply',
'Map dependencies and interactions',
'Consider scalability implications'
]
}
]
// Parallel spawn - all agents start immediately
const agentIds = perspectives.map(perspective => {
return spawn_agent({
message: `
## TASK ASSIGNMENT
### MANDATORY FIRST STEPS (Agent Execute)
1. **Read role definition**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
2. Run: `ccw spec load --category "exploration planning"`
3. Read project tech context from loaded specs
---
## Brainstorm Context
Topic: ${idea_or_topic}
Perspective: ${perspective.name} - ${perspective.focus}
Session: ${sessionFolder}
${explorationContext}
## ${perspective.name.toUpperCase()} Perspective Tasks
${perspective.tasks.map(t => `• ${t}`).join('\n')}
## Deliverables
Write findings to: ${sessionFolder}/perspectives/${perspective.name}.json
Schema: {
perspective: "${perspective.name}",
ideas: [{ title, description, novelty, feasibility, rationale }],
key_findings: [],
challenged_assumptions: [],
open_questions: [],
_metadata: { perspective, timestamp }
}
## Success Criteria
- [ ] Role definition read
- [ ] 3-5 ideas generated with ratings
- [ ] Key findings documented
- [ ] JSON output follows schema
`
})
})
// Batch wait - TRUE PARALLELISM (key Codex advantage)
const results = wait({
ids: agentIds,
timeout_ms: 600000 // 10 minutes for all
})
// Handle timeout
if (results.timed_out) {
// Some agents may still be running
// Option: continue waiting or use completed results
}
// Collect results from all perspectives
const completedFindings = {}
agentIds.forEach((agentId, index) => {
const perspective = perspectives[index]
if (results.status[agentId].completed) {
completedFindings[perspective.name] = results.status[agentId].completed
}
})
// Batch cleanup
agentIds.forEach(id => close_agent({ id }))
整合所有三个并行视角智能体的结果。
perspectives.json 结构:
session_id:头脑风暴会话的引用timestamp:完成时间topic:原始想法/主题creative:创意视角发现结果(带有新颖性评级的想法)pragmatic:务实视角发现结果(带有工作量评级的方案)systematic:系统化视角发现结果(架构选项)synthesis:{convergent_themes, conflicting_views, unique_contributions}aggregated_ideas[]:来自所有视角的合并想法key_findings[]:所有视角的主要见解聚合活动:
const synthesis = {
session_id: sessionId,
timestamp: new Date().toISOString(),
topic: idea_or_topic,
// Individual perspective findings
creative: completedFindings.creative || {},
pragmatic: completedFindings.pragmatic || {},
systematic: completedFindings.systematic || {},
// Cross-perspective synthesis
synthesis: {
convergent_themes: extractConvergentThemes(completedFindings),
conflicting_views: extractConflicts(completedFindings),
unique_contributions: extractUniqueInsights(completedFindings)
},
// Aggregated for refinement
aggregated_ideas: mergeAllIdeas(completedFindings),
key_findings: mergeKeyFindings(completedFindings)
}
将探索结果附加到头脑风暴时间线。
第 2 轮部分(多视角探索):
文档标准:
成功标准:
exploration-codebase.jsonperspectives/*.jsonperspectives.jsonbrainstorm.md目标:通过多轮用户引导的探索循环,进行深度挖掘、挑战测试和想法合并,迭代精炼想法。
最大轮数:6 轮精炼(如果用户表示完成,可以提前退出)
执行模型:在同一智能体上下文中使用 send_input 进行深度交互,或者为显著不同的探索角度生成新的智能体。
向用户展示当前的想法和视角。
呈现内容:
用户反馈选项(单选):
| 选项 | 目的 | 下一步操作 |
|---|---|---|
| 深入探索 | 详细探索选定想法 | 向活动智能体发送 send_input 或生成深度挖掘智能体 |
| 继续发散 | 生成更多想法 | 使用不同角度生成新智能体 |
| 挑战验证 | 批判性测试想法 | 生成挑战智能体(唱反调者) |
| 合并综合 | 合并多个想法 | 生成合并智能体进行综合 |
| 准备收敛 | 开始收敛 | 退出精炼循环进行综合 |
当用户选择“深度挖掘”时,提供全面分析。
选项 A:向现有智能体发送 send_input(如果智能体仍处于活动状态,则首选)
// Continue with existing agent context
send_input({
id: perspectiveAgent, // Reuse agent from Phase 2 if not closed
message: `
## CONTINUATION: Deep Dive Analysis
Based on your initial exploration, the user wants deeper investigation on these ideas:
${selectedIdeas.map((idea, i) => `${i+1}. ${idea.title}`).join('\n')}
## Deep Dive Tasks
• Elaborate each concept in detail
• Identify implementation requirements and dependencies
• Analyze potential challenges and propose mitigations
• Suggest proof-of-concept approach
• Define success metrics
## Deliverables
Write to: ${sessionFolder}/ideas/{idea-slug}.md for each selected idea
## Success Criteria
- [ ] Each idea has detailed breakdown
- [ ] Technical requirements documented
- [ ] Risk analysis with mitigations
`
})
const deepDiveResult = wait({ ids: [perspectiveAgent], timeout_ms: 600000 })
选项 B:生成新的深度挖掘智能体(如果之前的智能体已关闭)
const deepDiveAgent = spawn_agent({
message: `
## TASK ASSIGNMENT
### MANDATORY FIRST STEPS (Agent Execute)
1. **Read role definition**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
2. Read: ${sessionFolder}/perspectives.json (prior findings)
3. Run: `ccw spec load --category "exploration planning"`
---
## Deep Dive Context
Topic: ${idea_or_topic}
Selected Ideas: ${selectedIdeas.map(i => i.title).join(', ')}
## Deep Dive Tasks
${selectedIdeas.map(idea => `
### ${idea.title}
• Elaborate the core concept in detail
• Identify implementation requirements
• List potential challenges and mitigations
• Suggest proof-of-concept approach
• Define success metrics
`).join('\n')}
## Deliverables
Write: ${sessionFolder}/ideas/{idea-slug}.md for each idea
Include for each:
- Detailed concept description
- Technical requirements list
- Risk/challenge matrix
- MVP definition
- Success criteria
`
})
const result = wait({ ids: [deepDiveAgent], timeout_ms: 600000 })
close_agent({ id: deepDiveAgent })
当用户选择“挑战”时,生成一个专门的挑战智能体。
const challengeAgent = spawn_agent({
message: `
## TASK ASSIGNMENT
### MANDATORY FIRST STEPS (Agent Execute)
1. **Read role definition**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
2. Read: ${sessionFolder}/perspectives.json (ideas to challenge)
---
## Challenge Context
Topic: ${idea_or_topic}
Ideas to Challenge:
${selectedIdeas.map((idea, i) => `${i+1}. ${idea.title}: ${idea.description}`).join('\n')}
## Devil's Advocate Tasks
• For each idea, identify 3 strongest objections
• Challenge core assumptions
• Identify scenarios where this fails
• Consider competitive/alternative solutions
• Assess whether this solves the right problem
• Rate survivability after challenge (1-5)
## Deliverables
Return structured challenge results:
{
challenges: [{
idea: "...",
objections: [],
challenged_assumptions: [],
failure_scenarios: [],
alternatives: [],
survivability_rating: 1-5,
strengthened_version: "..."
}]
}
## Success Criteria
- [ ] 3+ objections per idea
- [ ] Assumptions explicitly challenged
- [ ] Survivability ratings assigned
`
})
const result = wait({ ids: [challengeAgent], timeout_ms: 300000 })
close_agent({ id: challengeAgent })
当用户选择“合并”时,综合互补的想法。
const mergeAgent = spawn_agent({
message: `
## TASK ASSIGNMENT
### MANDATORY FIRST STEPS (Agent Execute)
1. **Read role definition**: ~/.codex/agents/cli-explore-agent.md (MUST read first)
2. Read: ${sessionFolder}/perspectives.json (source ideas)
---
## Merge Context
Topic: ${idea_or_topic}
Ideas to Merge:
${selectedIdeas.map((idea, i) => `
${i+1}. ${idea.title} (${idea.source_perspective})
${idea.description}
Strengths: ${idea.strengths?.join(', ') || 'N/A'}
`).join('\n')}
## Merge Tasks
• Identify complementary elements
• Resolve contradictions
• Create unified concept
• Preserve key strengths from each
• Describe the merged solution
• Assess viability of merged idea
## Deliverables
Write to: ${sessionFolder}/ideas/merged-idea-{n}.md
Include:
- Merged concept description
- Elements taken from each source idea
- Contradictions resolved (or noted as tradeoffs)
- New combined strengths
- Implementation considerations
## Success Criteria
- [ ] Coherent merged concept
- [ ] Source attributions clear
- [ ] Contradictions addressed
`
})
const result = wait({ ids: [mergeAgent], timeout_ms: 300000 })
close_agent({ id: mergeAgent })
使用每轮精炼的结果更新 brainstorm.md。
第 N 轮部分(第 3-6 轮):
| 部分 | 内容 |
|---|---|
| 用户方向 | 采取的行动和选定的想法 |
| 发现结果 | 新的发现和澄清 |
| 想法更新 | 想法分数和状态的变化 |
| 见解 | 关键学习和认识 |
| 下一步方向 | 建议的后续调查 |
文档标准:
成功标准:
brainstorm.mdideas/ 文件夹中已有选定深度挖掘的想法目标:综合最终想法,生成结论和建议,并提供后续步骤。
从精炼轮次中提取并综合所有发现结果,形成最终结论。
整合活动:
synthesis.json 结构:
session_id:会话标识符topic:原始想法/主题completed:完成时间戳total_rounds:精炼轮数top_ideas[]:前 5 个排名想法,带有分数和后续步骤parked_ideas[]:留待未来考虑的想法key_insights[]:头脑风暴过程中的关键学习recommendations:主要建议和替代方案follow_up[]:建议的后续步骤(实施、研究、验证)想法格式:
title:清晰、描述性的标题description:完整的概念描述source_perspective:哪些视角做出了贡献score:最终可行性分数(1-10)novelty:新颖性/创新性评级(1-5)feasibility:实施可行性(1-5)key_strengths:主要优势和好处main_challenges:关键挑战和限制next_steps:建议采取的后续行动附加结论部分并最终确定思维文档。
综合与结论部分:
会话统计:
根据头脑风暴结果向用户提供后续行动。
可用选项:
| 选项 | 目的 | 操作 |
|---|---|---|
| 创建实施计划 | 规划顶级想法的实施 | 启动 workflow-lite-plan |
| 创建Issue | 跟踪顶级想法以备后用 | 使用想法启动 issue:new |
| 深入分析 | 详细分析顶级想法 | 启动 workflow:analyze-with-file |
| 导出分享 | 生成可共享的报告 | 创建格式化的报告文档 |
| 完成 | 无进一步操作 | 结束工作流 |
成功标准:
synthesis.jsonbrainstorm.md维度指导头脑风暴的范围和重点:
| 维度 | 关键词 | 最适合 |
|---|---|---|
| technical | 技术, technical, implementation, code | 实施方案 |
| ux | 用户, user, experience, UI | 面向用户的设计想法 |
| business | 业务, business, value | 商业模式创新 |
| innovation | 创新, innovation, novel | 突破性想法 |
| feasibility | 可行, feasible, practical | 现实方案 |
| scalability | 扩展, scale, growth | 大规模解决方案 |
| security | 安全, security, risk | 安全考虑 |
| 模式 | 持续时间 | 强度 | 子智能体 |
|---|---|---|---|
| Creative | 15-20 分钟 | 高新颖性 | 1 个智能体,短超时 |
| Balanced | 30-60 分钟 | 混合 | 3 个并行智能体 |
| Deep | 1-2+ 小时 | 全面 | 3 个并行智能体 + 深度精炼 |
| 模式 | 用途 | 描述 |
|---|---|---|
| Parallel Divergence | 新主题 | 所有视角通过并行子智能体同时探索 |
| Sequential Deep-Dive | 有前景的想法 | 向一个智能体发送 send_input 进行阐述,其他智能体通过新智能体进行批判 |
| Debate Mode | 有争议的方案 | 生成对立的智能体来争论支持/反对 |
| Synthesis Mode | 准备决策 | 生成综合智能体,结合所有视角的见解 |
每个智能体限制:
综合保护:
ideas/ 文件夹中的单独想法文档恢复步骤:
| 情况 | 操作 | 恢复 |
|---|---|---|
| 子智能体超时 | 检查 results.timed_out,继续 wait() 或使用部分结果 | 缩小范围,使用 2 个视角而非 3 个 |
| 智能体过早关闭 | 无法恢复已关闭的智能体 | 使用 perspectives.json 中的先前上下文生成新智能体 |
| 并行智能体部分失败 | 一些视角完成,一些失败 | 使用已完成的结果,在综合中注明差距 |
| 向已关闭的智能体发送 send_input | 错误:未找到智能体 | 使用先前发现结果作为上下文生成新智能体 |
| 没有好的想法 | 重新定义问题或调整约束 | 尝试新的探索角度 |
| 用户失去参与 | 总结进度并提供休息 | 保存状态,保持智能体活动以便恢复 |
| 视角冲突 | 呈现为权衡选项 | 让用户选择首选方向 |
| 达到最大轮数 | 强制进入综合阶段 | 突出显示未解决的问题 |
| 会话文件夹冲突 | 附加时间戳后缀 | 创建唯一文件夹 |
// Safe parallel execution with error handling
try {
const agentIds = perspectives.map(p => spawn_agent({ message: buildPrompt(p) }))
const results = wait({ ids: agentIds, timeout_ms: 600000 })
if (results.timed_out) {
// Handle partial completion
const completed = agentIds.filter(id => results.status[id].completed)
const pending = agentIds.filter(id => !results.status[id].completed)
// Option 1: Continue waiting for pending
// const moreResults = wait({ ids: pending, timeout_ms: 300000 })
// Option 2: Use partial results
// processPartialResults(completed, results)
}
// Process all results
processResults(agentIds, results)
} finally {
// ALWAYS cleanup, even on errors
agentIds.forEach(id => {
try { close_agent({ id }) } catch (e) { /* ignore */ }
})
}
User initiates: TOPIC="idea or topic"
├─ No session exists → New session mode
├─ Parse topic and identify dimensions
├─ Scope with user (focus, depth, mode)
├─ Create brainstorm.md
├─ Expand seed into vectors
├─ Gather codebase context
│
├─ Execute parallel perspective exploration:
│ ├─ spawn_agent × 3 (Creative + Pragmatic + Systematic)
│ ├─ wait({ ids: [...] }) ← TRUE PARALLELISM
│ └─ close_agent × 3
│
├─ Aggregate findings with synthesis
└─ Enter multi-round refinement loop
头脑风暴技能:AI协作设计流程,将创意转化为完整规范与实施计划
97,700 周安装