关于 brainstorm-prompt-optimizer
将原始想法整理为适用于 `/specs.brainstorm` 的提示词,帮助团队为功能规格编写做准备。重点包括 EARS 需求、带标签的验收标准及明确的范围边界。
主要功能
- 01将想法整理为结构化提示词
- 02分析项目背景与范围
- 03采用 EARS 需求语法
- 04为验收标准添加标签
- 05补充非目标与负面需求
适用场景
- 01为 `/specs.brainstorm` 准备想法
- 02在编写规格前明确功能范围
- 03将简单功能请求转为结构化需求
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ giuseppe-trisciuoglio/ developer-kit --skill brainstorm-prompt-optimizer安装后在 Claude Code 中输入/brainstorm-prompt-optimizer确认已加载。
详细介绍
脑暴提示词优化器
将原始想法转化为优化后的提示词,以便用于脑暴工作流(/specs.brainstorm)。
此技能会梳理想法,使其传入 /specs.brainstorm 后,能够产出更完善的功能规格说明,遵循 EARS 语法、正确的验收标准分类,并包含完整的非目标/否定性需求部分。
适用场景
- 用户想在运行
/specs.brainstorm前优化一个想法 - 用户说“为脑暴准备这个想法”“增强脑暴提示词”
- 用户提出一个简单想法,希望将其整理成更适合脑暴的形式
- 用户询问“把这个准备成脑暴提示词”
- 用户说“imposta per brainstorm”“prepara idea per brainstorm”
不适用场景
- 用户想优化代码或性能(使用相应技能)
- 用户想进行通用提示词工程(使用 prompt-engineering 技能)
- 用户想分析现有提示词
- 用户要求直接执行某项任务
- 用户想修复 Bug 或修改现有行为 → 转交给
specs.change-spec
工作原理
仅输出优化后的提示词——不要提供分析、报告或建议。
此工作流会将原始想法转化为结构化提示词,使其用于 /specs.brainstorm 时能够产出更完善的功能规格说明。
工作流
阶段 1:识别项目上下文
检查项目文件以了解环境:
CLAUDE.md→ 项目约定docs/specs/architecture.md→ 现有架构约束docs/specs/ontology.md→ 现有领域术语
技术栈检测:
package.json→ Node.js/TypeScript/Reactpom.xml/build.gradle→ Java/Spring Bootrequirements.txt/pyproject.toml→ Python
阶段 2:分析想法
解析原始想法,识别:
- 核心操作:需要构建/创建什么(例如,“添加身份验证”“创建搜索功能”)
- 目标领域:系统中的哪些部分会受到影响
- 隐含范围:哪些内容自然包含在内,哪些不包含
- 用户视角:谁会从此功能中受益
- 业务价值:此功能为何重要
阶段 3:确定范围大小
估算复杂度,帮助 /specs.brainstorm:
- 小型:单个用户故事、1-3 个实体、简单流程 → 3-8 个任务
- 中型:2-4 个用户故事、4-8 个实体 → 8-15 个任务
- 大型:5 个以上用户故事、9 个以上实体 → 可能需要拆分(提醒用户)
阶段 4:构建优化后的提示词
构建结构化提示词,包含以下组件(与 /specs.brainstorm 模板一致):
# [Core Action] — [Target Domain]
## Problem Statement
[What problem does this solve? Who has it?]
## Core Feature
[What should the system do? Focus on behavior, not implementation]
## Target Users
[Who will use this? What's their goal?]
## User Flows
1. [Primary flow from user perspective]
2. [Alternative flows if applicable]
## Data Requirements
- [What data the feature needs to work with]
- [Any data relationships]
## Success Criteria
- [IMP] [Testable criterion that requires code/implementation]
- [SEF] [Side-effect criterion - automatic consequence]
- [EXT] [External verification criterion]
## Non-Goals
- **Feature X**: [Brief explanation why excluded]
- **Feature Y**: [Brief explanation why excluded]
## Negative Requirements
- REQ-NR001: The system SHALL NOT [security/data integrity constraint]
## [NEEDS CLARIFICATION] (max 3)
- [Specific question that significantly impacts scope]
阶段 5:输出优化后的提示词
将完整的优化提示词放在标记为 optimized-prompt 的围栏代码块中:
```optimized-prompt
[Full optimized prompt content]
---
## EARS Syntax Reference
Use EARS (Easy Approach to Requirements Syntax) for requirements:
| Form | Pattern | Example |
|------|---------|---------|
| **Event-driven** | `WHEN <event> THEN the system SHALL <action>` | `WHEN the user clicks "Submit" THEN the system SHALL validate the form data` |
| **State-driven** | `WHEN <system state> THEN the system SHALL <action>` | `WHEN the session expires THEN the system SHALL clear user data` |
| **Generic** | `The system SHALL <action>` | `The system SHALL encrypt all stored passwords with bcrypt` |
| **Feature** | `IF <feature> THEN the system SHALL <action>` | `IF multi-factor auth is enabled THEN the system SHALL require second factor` |
| **Negative** | `IF <unwanted condition> THEN the system SHALL NOT <action>` | `IF SQL input detected THEN the system SHALL reject with 400` |
Mandatory keywords: **SHALL**, **WILL**, **MAY**
Forbidden words: "robust", "intuitive", "fast", "scalable", "efficient", "user-friendly"
---
## Acceptance Criteria Taxonomy
Every success criterion MUST be tagged:
| Tag | Meaning | Generates Tasks? |
|-----|---------|------------------|
| `[IMP]` | Requires new code, configuration, or explicit behavior | **YES** |
| `[SEF]` | Natural automatic consequence of an `[IMP]` criterion | NO (verify in e2e) |
| `[EXT]` | Verified by external tools or user observation | NO (e2e checkpoint) |
**60% Rule**: At least 60% of criteria should be `[IMP]`.
---
## Prompt Templates by Category
### Authentication & User Management
```optimized-prompt
# Add [Feature] — User Management
## Problem Statement
[Describe the problem users face without this feature]
## Core Feature
The system SHALL [describe what the feature does, focus on behavior]
## Target Users
- **Primary**: [main user type]
- **Secondary**: [other affected users]
## User Flows
1. **Primary Flow**: [Step by step from user perspective]
2. **Alternative Flow**: [If applicable]
## Data Requirements
- User entity: [fields]
- [Other entities involved]
## Success Criteria
- [IMP] [Criterion 1 — testable outcome requiring code]
- [IMP] [Criterion 2]
- [SEF] [Criterion 3 — automatic consequence]
- [EXT] [Criterion 4 — verified externally]
## Non-Goals
- **Social Login**: No OAuth providers (Google, GitHub, etc.)
- **Password Reset**: Not included in this specification
- **Two-Factor Auth**: Not included in this specification
## Negative Requirements
- REQ-NR001: The system SHALL NOT store passwords in plain text; it SHALL use bcrypt with cost factor ≥12
- REQ-NR002: The system SHALL NOT expose user existence through login error messages
API 与后端功能
# [Feature Name] — API Layer
## Problem Statement
[What integration need or capability gap exists]
## Core Feature
The system SHALL provide [describe the API behavior]
## Target Users
- **Primary**: [API consumers]
- **Secondary**: [administrators]
## User Flows
1. **Happy Path**: [Request → Validation → Response]
2. **Error Path**: [Invalid input → Error response]
## API Contract
- Endpoint: [path and method]
- Input: [what the API receives]
- Output: [what the API returns]
- Error cases: [failure modes with codes]
## Data Model
- [Entities involved]
- [Relationships]
## Success Criteria
- [IMP] [Criterion 1]
- [IMP] [Criterion 2]
- [SEF] [Criterion 3]
## Non-Goals
- **GraphQL**: REST only
- **Async Processing**: Synchronous only
- **Caching**: Not included
## Negative Requirements
- REQ-NR001: IF user input is used in SQL query THEN the system SHALL NOT concatenate directly
- REQ-NR002: The system SHALL NOT expose internal error details to clients
UI 与前端功能
# [Feature Name] — User Interface
## Problem Statement
[What user experience gap exists]
## Core Feature
The user SHALL be able to [describe user action and system response]
## Target Users
- **Primary**: [end users]
- **Secondary**: [admin users if applicable]
## User Flows
1. **Entry**: [How user accesses this feature]
2. **Interaction**: [Primary user action]
3. **Outcome**: [Result user sees]
4. **Error**: [Error handling for invalid input]
## UI Requirements
- Layout: [description]
- Components: [key UI elements]
- Feedback: [success/error/loading states]
## Responsive Behavior
- Desktop: [behavior]
- Mobile: [behavior]
## Success Criteria
- [IMP] [Criterion 1 — visible behavior]
- [IMP] [Criterion 2]
- [IMP] [Criterion 3]
- [SEF] [Criterion 4 — automatic]
## Non-Goals
- **Real-time Updates**: No WebSocket or SSE
- **Offline Mode**: Not included
- **Accessibility Features**: [specific exclusions]
## Negative Requirements
- REQ-NR001: The system SHALL NOT display raw error messages to users
- REQ-NR002: The system SHALL NOT allow XSS through user input fields
数据与处理功能
# [Feature Name] — Data Processing
## Problem Statement
[What data challenge exists]
## Core Feature
The system SHALL [describe data transformation/processing behavior]
## Target Users
- **Primary**: [who benefits]
- **Secondary**: [who monitors]
## User Flows
1. **Data Input**: [Source and format]
2. **Processing**: [Transformation steps]
3. **Output**: [Result destination and format]
## Data Quality
- Validation: [rules]
- Error handling: [for bad data]
## Performance Constraints
- Volume: [expected data size]
- Latency: [expected processing time]
## Success Criteria
- [IMP] [Criterion 1]
- [IMP] [Criterion 2]
- [EXT] [Criterion 3 — external verification]
## Non-Goals
- **Real-time Processing**: Batch only
- **Data Export**: Not included
- **Backup/Restore**: Not included
## Negative Requirements
- REQ-NR001: The system SHALL NOT lose data on processing failure
- REQ-NR002: The system SHALL NOT process unbounded data without pagination
示例
示例 1:简单想法 → 优化后
输入:
Add user authentication
输出:
# Add User Authentication — Authentication Layer
## Problem Statement
Users cannot securely access the system. They need a way to prove their identity and access their personalized content.
## Core Feature
The system SHALL provide email/password authentication that allows users to:
- Register with a valid email address and secure password
- Log in with registered credentials
- Maintain an authenticated session across requests
- Log out to terminate their session
## Target Users
- **Primary**: End users who need to access personalized features
- **Secondary**: Administrators who manage user accounts
## User Flows
1. **Registration**: User enters email → receives confirmation → sets password → account created
2. **Login**: User enters credentials → validated → session established → redirected to dashboard
3. **Logout**: User clicks logout → session terminated → redirected to login page
## Data Requirements
- User entity: email, hashed_password, created_at, updated_at
- Session entity: user_id, token, expiration
## Success Criteria
- [IMP] Users can register with email/password
- [IMP] Users can log in with valid credentials
- [IMP] Invalid credentials show generic error message
- [IMP] Users can log out
- [IMP] Session persists across page navigation
- [IMP] Expired sessions require re-login
## Non-Goals
- **Social Login**: No OAuth providers (Google, GitHub, etc.)
- **Password Reset**: Not included in this specification
- **Two-Factor Authentication**: Not included in this specification
## Negative Requirements
- REQ-NR001: The system SHALL NOT store passwords in plain text; it SHALL use bcrypt with cost factor ≥12
- REQ-NR002: The system SHALL NOT expose user existence through login error messages; it SHALL use generic "invalid credentials" for both cases
- REQ-NR003: The system SHALL NOT allow weak passwords (minimum 8 characters, mixed case, number)
示例 2:模糊想法 → 结构化
输入:
Better search for products
输出:
# Improve Product Search — Product Discovery
## Problem Statement
Users cannot find products they are looking for using the current search. Results are not relevant, don't match user intent, and sorting is not useful.
## Core Feature
The system SHALL provide enhanced product search that allows users to:
- Search products by name, description, and category
- Receive results ranked by relevance to search terms
- Filter results by category, price range, and availability
- Sort results by relevance, price, or newest
## Target Users
- **Primary**: Shoppers looking for specific products
- **Secondary**: Browsers exploring product catalog
## User Flows
1. **Direct Search**: User enters search terms → results displayed → user selects product
2. **Filtered Search**: User enters terms → applies filters → refined results → user selects product
3. **Empty Results**: User enters terms → no results → suggestion displayed
## Search Behavior
- Minimum 2 characters to trigger search
- Partial word matching for product names
- Search across: product name, description, category name, tags
- Results limited to 50 per page with pagination
## Filtering Options
- Category: single or multiple selection
- Price range: min/max with validation
- Availability: in-stock only toggle
## Sorting Options
- Relevance (default): based on search term match score
- Price: low-to-high or high-to-low
- Newest: by creation date descending
## Success Criteria
- [IMP] Search returns products matching the query terms
- [IMP] Search supports partial word matching
- [IMP] Category filter limits results to selected category
- [IMP] Price range filter shows products within min/max bounds
- [IMP] Results can be sorted by relevance, price, or date
- [IMP] Pagination allows navigation through large result sets
- [IMP] Empty search shows appropriate message with suggestions
## Non-Goals
- **Autocomplete**: Not included in this specification
- **Search Analytics**: Not included in this specification
- **Personalized Results**: Results are the same for all users
- **Image Search**: Not included in this specification
## Negative Requirements
- REQ-NR001: The system SHALL NOT expose product inventory details in search results unless explicitly needed
- REQ-NR002: The system SHALL NOT allow SQL injection through search terms; it SHALL sanitize all input
- REQ-NR003: The system SHALL NOT return results beyond configured pagination limits per request
示例 3:技术想法 → 功能描述
输入:
Implement Redis caching for API responses
输出:
# Implement API Response Caching — Performance Optimization
## Problem Statement
The API is slow for frequently requested data. Repeated requests for the same resources consume unnecessary server resources and increase response times for users.
## Core Feature
The system SHALL cache frequently accessed API responses to reduce response times and server load:
- Cache GET requests for defined intervals
- Return cached responses when data hasn't changed
- Invalidate cache when underlying data changes
- Provide cache statistics for monitoring
## Target Users
- **Primary**: API consumers (frontend applications, mobile apps)
- **Secondary**: System administrators monitoring performance
## Cache Behavior
- Cache key based on request URL and parameters
- Default TTL: 5 minutes (configurable per endpoint)
- Cache stores: response body, status code, headers
- Cache miss: fetch from source, store, return
## Invalidation Rules
- Cache invalidated when source data is modified via POST/PUT/PATCH/DELETE
- Manual invalidation available via admin endpoint
- Bulk invalidation by cache key pattern
## Success Criteria
- [IMP] Cached requests return within 50ms
- [IMP] Cache hit rate visible in metrics
- [IMP] Manual cache invalidation works
- [IMP] Automatic invalidation on data changes
- [IMP] Cache can be disabled per request via header
- [SEF] Cache reduces database load for repeated requests
- [EXT] Response time improvement measurable via APM
## Non-Goals
- **Distributed Cache**: Single Redis instance only
- **Cache Warming**: Not included
- **Cache Partitioning**: Not included
- **Multi-Tenant Isolation**: Not included in this specification
## Negative Requirements
- REQ-NR001: The system SHALL NOT cache responses containing user-specific data
- REQ-NR002: The system SHALL NOT serve stale cache beyond configured TTL
- REQ-NR003: The system SHALL NOT expose cache internals in API responses
- REQ-NR004: IF cache connection fails THEN the system SHALL fall back to direct database access without error
与脑暴的集成
优化后的提示词应直接用于 /specs.brainstorm:
# Copy the optimized prompt and use it with brainstorm
/specs.brainstorm [paste optimized prompt here]
工作流
Raw Idea → brainstorm-prompt-optimizer → Optimized Prompt → /specs.brainstorm → Functional Spec → /specs.spec-to-tasks → Tasks
约束
- 仅输出优化后的提示词——不要提供分析或建议
- 如果输入是 Bug 修复或修改请求,请勿优化 → 转交给
specs.change-spec - 如果输入过于模糊,无法有效优化,请提出一个澄清问题
- 聚焦于 WHAT(行为),而非 HOW(实现方式)
- 包含明确的非目标部分(至少 3 项),以防止范围蔓延
- 包含否定性需求(至少 2 项),用于安全性/完整性约束
- 使用 EARS 语法(SHALL/WILL/MAY)编写需求
- 为每项验收标准添加
[IMP]、[SEF]或[EXT]标签 - 最多使用 3 个
[NEEDS CLARIFICATION]标记
相关命令和技能
| 组件 | 适用场景 |
|---|---|
/specs.brainstorm | 优化后,运行 brainstorm 以创建规范 |
/specs.spec-to-tasks | 将规范转换为可执行任务 |
specs-change-spec | 用于 Bug 修复或增量变更(非新功能) |
specs-brainstorm | 功能规范模板参考 |
评论
支持 Markdown