ai-prompting
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAI Prompting Strategies
AI提示策略
Master the art of communicating with AI coding assistants to get better results faster. These strategies are optimized for spec-driven development but apply broadly to AI collaboration.
掌握与AI编码助手沟通的技巧,更快获得更优结果。这些策略针对规范驱动开发进行了优化,但广泛适用于AI协作场景。
When to Use This Skill
何时使用该技巧
Use these prompting strategies when:
- Working with Claude Code, Cursor, or other AI assistants
- Creating specs through AI collaboration
- Getting inconsistent or low-quality AI responses
- Need to improve AI output accuracy
- Want faster iteration cycles
在以下场景使用这些提示策略:
- 使用Claude Code、Cursor或其他AI助手时
- 通过AI协作创建规范时
- 收到不一致或低质量的AI响应时
- 需要提升AI输出准确性时
- 希望加快迭代周期时
Core Strategies
核心策略
Strategy 1: Context-First Prompting
策略1:以上下文为优先的提示
Always provide sufficient context before making requests.
Poor Approach:
Create requirements for a user profile feature.Better Approach:
I'm working on a web application for a fitness tracking platform. We need to add user profile functionality where users can manage their personal information and fitness goals.
Context:
- Technology: React frontend, Node.js backend
- User base: Health-conscious individuals, age 18-65
- Key constraint: Must comply with GDPR for EU users
- Integration: Will connect with existing authentication system
Please help me create requirements for the user profile feature.Why It Works:
- Provides domain context for better decisions
- Identifies technical constraints early
- Clarifies compliance requirements
- Enables more relevant suggestions
提出请求前,始终提供足够的上下文。
欠佳的方式:
Create requirements for a user profile feature.更优的方式:
I'm working on a web application for a fitness tracking platform. We need to add user profile functionality where users can manage their personal information and fitness goals.
Context:
- Technology: React frontend, Node.js backend
- User base: Health-conscious individuals, age 18-65
- Key constraint: Must comply with GDPR for EU users
- Integration: Will connect with existing authentication system
Please help me create requirements for the user profile feature.为何有效:
- 提供领域上下文,助力更优决策
- 提前明确技术约束
- 阐明合规要求
- 催生更具相关性的建议
Strategy 2: Phased Interaction
策略2:分阶段交互
Work through spec phases sequentially. Complete each phase before moving to the next.
Phase 1 - Requirements:
Let's start with the requirements phase for [feature name].
Current situation: [describe current state]
Problem to solve: [describe the problem]
Users affected: [describe user types]
Success criteria: [how we'll know it works]
Please help me develop comprehensive requirements using the EARS format.Phase 2 - Design (after requirements approved):
Now that we have clear requirements, let's create the technical design.
Requirements summary: [key requirements]
Technical context: [architecture, frameworks, patterns]
Constraints: [performance, scalability, security]
Please propose a technical design that addresses these requirements.Phase 3 - Tasks (after design approved):
With the design finalized, let's break this into implementation tasks.
Design summary: [key components and interactions]
Team context: [team size, skill levels]
Dependencies: [what must be built first]
Please create a sequenced task breakdown for implementation.按规范阶段依次推进,完成每个阶段后再进入下一阶段。
阶段1 - 需求:
Let's start with the requirements phase for [feature name].
Current situation: [describe current state]
Problem to solve: [describe the problem]
Users affected: [describe user types]
Success criteria: [how we'll know it works]
Please help me develop comprehensive requirements using the EARS format.阶段2 - 设计(需求获批后):
Now that we have clear requirements, let's create the technical design.
Requirements summary: [key requirements]
Technical context: [architecture, frameworks, patterns]
Constraints: [performance, scalability, security]
Please propose a technical design that addresses these requirements.阶段3 - 任务(设计获批后):
With the design finalized, let's break this into implementation tasks.
Design summary: [key components and interactions]
Team context: [team size, skill levels]
Dependencies: [what must be built first]
Please create a sequenced task breakdown for implementation.Strategy 3: Iterative Refinement
策略3:迭代优化
Treat spec development as conversation, not single requests.
Initial Request:
Help me define requirements for email notification preferences.Refinement Round 1:
Great start! Let's refine a few areas:
1. For notification frequency, can we add daily digest option?
2. How should we handle changing preferences during pending notifications?
3. Can you elaborate on the unsubscribe requirement for GDPR compliance?Refinement Round 2:
Perfect. Now let's add requirements for:
- Mobile push notifications (in addition to email)
- Notification history (last 30 days)
- Per-notification-type controls (not just global on/off)将规范开发视为对话,而非单次请求。
初始请求:
Help me define requirements for email notification preferences.第一轮优化:
Great start! Let's refine a few areas:
1. For notification frequency, can we add daily digest option?
2. How should we handle changing preferences during pending notifications?
3. Can you elaborate on the unsubscribe requirement for GDPR compliance?第二轮优化:
Perfect. Now let's add requirements for:
- Mobile push notifications (in addition to email)
- Notification history (last 30 days)
- Per-notification-type controls (not just global on/off)Strategy 4: Example-Driven Prompting
策略4:示例驱动的提示
Provide concrete examples of what you want.
For Requirements:
I need acceptance criteria for a file upload feature. Use the EARS format like this example:
Good example from our auth feature:
"WHEN a user enters valid credentials THEN the system SHALL authenticate within 2 seconds"
Avoid vague requirements like:
"System should handle file uploads efficiently"
Focus on specific, testable criteria for:
- File size limits
- Supported file types
- Upload progress indication
- Error handlingFor Design:
Create a component architecture. Follow this existing pattern:
[Reference existing architecture]
Key elements to include:
- Component responsibilities
- Data flow
- API boundaries
- Error handling paths提供你想要的具体示例。
针对需求:
I need acceptance criteria for a file upload feature. Use the EARS format like this example:
Good example from our auth feature:
"WHEN a user enters valid credentials THEN the system SHALL authenticate within 2 seconds"
Avoid vague requirements like:
"System should handle file uploads efficiently"
Focus on specific, testable criteria for:
- File size limits
- Supported file types
- Upload progress indication
- Error handling针对设计:
Create a component architecture. Follow this existing pattern:
[Reference existing architecture]
Key elements to include:
- Component responsibilities
- Data flow
- API boundaries
- Error handling pathsStrategy 5: Constraint-Explicit Prompting
策略5:明确约束的提示
Make all constraints explicit. Don't assume AI knows your limitations.
Design a caching strategy for product catalog data.
Explicit constraints:
- Infrastructure: AWS with Redis, PostgreSQL
- Performance: API response < 200ms for cached data
- Scale: 10,000 products, 1,000 concurrent users
- Budget: Cache cost < $100/month
- Freshness: Updates visible within 5 minutes
- Maintenance: 2-person ops team
Flexibility allowed:
- Cache invalidation strategy (time or event-based)
- Cache key structure (optimize as needed)
- Failover approach (as long as reliable)明确所有约束,不要假设AI知晓你的限制条件。
Design a caching strategy for product catalog data.
Explicit constraints:
- Infrastructure: AWS with Redis, PostgreSQL
- Performance: API response < 200ms for cached data
- Scale: 10,000 products, 1,000 concurrent users
- Budget: Cache cost < $100/month
- Freshness: Updates visible within 5 minutes
- Maintenance: 2-person ops team
Flexibility allowed:
- Cache invalidation strategy (time or event-based)
- Cache key structure (optimize as needed)
- Failover approach (as long as reliable)Strategy 6: Role-Based Prompting
策略6:基于角色的提示
Frame requests from specific perspectives.
Product Owner Perspective:
As a product owner defining checkout requirements:
- Business goals: Reduce cart abandonment
- User value: Smooth, trustworthy purchase experience
- Success metrics: Checkout completion rate > 80%
What requirements should I capture?Technical Lead Perspective:
As tech lead designing a notification system:
- Integrates with existing microservices
- Handles 100k notifications/day with room to grow
- Maintains health if notification service fails
- Aligns with event-driven architecture
What design approach would you recommend?Developer Perspective:
As a mid-level developer implementing this:
- Need clear tasks (2-4 hours each)
- Explicit dependencies between tasks
- Guidance on testing approach
- References to existing code patterns
Can you break down the implementation accordingly?从特定视角提出请求。
产品负责人视角:
As a product owner defining checkout requirements:
- Business goals: Reduce cart abandonment
- User value: Smooth, trustworthy purchase experience
- Success metrics: Checkout completion rate > 80%
What requirements should I capture?技术负责人视角:
As tech lead designing a notification system:
- Integrates with existing microservices
- Handles 100k notifications/day with room to grow
- Maintains health if notification service fails
- Aligns with event-driven architecture
What design approach would you recommend?开发者视角:
As a mid-level developer implementing this:
- Need clear tasks (2-4 hours each)
- Explicit dependencies between tasks
- Guidance on testing approach
- References to existing code patterns
Can you break down the implementation accordingly?Strategy 7: Validation-Oriented Prompting
策略7:面向验证的提示
Build quality checks into your prompts.
After Requirements:
Review these requirements and check:
1. Are all requirements testable and measurable?
2. Have we covered error cases and edge cases?
3. Do any requirements conflict with each other?
4. Are there gaps in the user journey?
5. Do requirements map to all user stories?
Provide a validation summary.After Design:
Validate this design against:
1. Does it address all requirements?
2. Are there single points of failure?
3. What are the performance bottlenecks?
4. How does it handle scale growth?
5. What security concerns exist?
Provide a critical review.在提示中纳入质量检查环节。
需求确定后:
Review these requirements and check:
1. Are all requirements testable and measurable?
2. Have we covered error cases and edge cases?
3. Do any requirements conflict with each other?
4. Are there gaps in the user journey?
5. Do requirements map to all user stories?
Provide a validation summary.设计确定后:
Validate this design against:
1. Does it address all requirements?
2. Are there single points of failure?
3. What are the performance bottlenecks?
4. How does it handle scale growth?
5. What security concerns exist?
Provide a critical review.Strategy 8: Trade-Off Exploration
策略8:权衡探索
Explore options rather than seeking single answers.
We need real-time notifications. Compare these options:
Option A: WebSocket connections
Option B: Server-Sent Events (SSE)
Option C: Long polling
For each, evaluate:
- Implementation complexity
- Browser compatibility
- Server resource usage
- Scalability characteristics
- Maintenance overhead
Present trade-offs in a comparison table.探索多种选项,而非寻求单一答案。
We need real-time notifications. Compare these options:
Option A: WebSocket connections
Option B: Server-Sent Events (SSE)
Option C: Long polling
For each, evaluate:
- Implementation complexity
- Browser compatibility
- Server resource usage
- Scalability characteristics
- Maintenance overhead
Present trade-offs in a comparison table.Phase-Specific Patterns
阶段特定模式
Requirements Phase Patterns
需求阶段模式
User Story Expansion:
I have this user story: [basic story]
Please help me:
1. Expand with detailed acceptance criteria (EARS format)
2. Identify edge cases and error scenarios
3. Define non-functional requirements
4. Suggest validation criteriaCompleteness Check:
Here are my draft requirements: [requirements]
Check for completeness:
- Are all user workflows covered?
- Have we addressed error handling?
- Are there accessibility requirements?
- What about data privacy and security?
- Have we considered mobile vs desktop?用户故事扩展:
I have this user story: [basic story]
Please help me:
1. Expand with detailed acceptance criteria (EARS format)
2. Identify edge cases and error scenarios
3. Define non-functional requirements
4. Suggest validation criteria完整性检查:
Here are my draft requirements: [requirements]
Check for completeness:
- Are all user workflows covered?
- Have we addressed error handling?
- Are there accessibility requirements?
- What about data privacy and security?
- Have we considered mobile vs desktop?Design Phase Patterns
设计阶段模式
Architecture Exploration:
Given these requirements: [summary]
Propose 2-3 different architectural approaches:
1. For each, describe components and interactions
2. List pros and cons
3. Identify risks and mitigations
4. Estimate complexity
Help me compare and choose.Integration Design:
This feature integrates with: [list systems]
Design the integration:
1. Define API contracts
2. Specify data flow and transformation
3. Plan error handling and retries
4. Document assumptions and dependencies架构探索:
Given these requirements: [summary]
Propose 2-3 different architectural approaches:
1. For each, describe components and interactions
2. List pros and cons
3. Identify risks and mitigations
4. Estimate complexity
Help me compare and choose.集成设计:
This feature integrates with: [list systems]
Design the integration:
1. Define API contracts
2. Specify data flow and transformation
3. Plan error handling and retries
4. Document assumptions and dependenciesTasks Phase Patterns
任务阶段模式
Task Sequencing:
Based on this design: [summary]
Create implementation tasks that:
1. Are sequenced to minimize dependencies
2. Enable incremental testing
3. Separate setup, core features, and polish
4. Include testing tasks
5. Range from 2-4 hours eachTask Validation:
Review these tasks: [task list]
Verify:
1. Can each task be completed independently?
2. Are dependencies clearly marked?
3. Do tasks map to design components?
4. Are testing steps included?
5. Is anything missing?任务排序:
Based on this design: [summary]
Create implementation tasks that:
1. Are sequenced to minimize dependencies
2. Enable incremental testing
3. Separate setup, core features, and polish
4. Include testing tasks
5. Range from 2-4 hours each任务验证:
Review these tasks: [task list]
Verify:
1. Can each task be completed independently?
2. Are dependencies clearly marked?
3. Do tasks map to design components?
4. Are testing steps included?
5. Is anything missing?Advanced Techniques
高级技巧
Specification by Example
示例规范
Provide examples of good and bad outputs to calibrate responses.
提供优质和劣质输出的示例,以校准AI响应。
Incremental Context Building
增量上下文构建
Start broad, add detail as AI demonstrates understanding.
从宽泛内容开始,在AI展现理解能力后逐步添加细节。
Meta-Prompting
元提示
Ask AI how to prompt it better for your specific context.
询问AI如何针对你的特定场景给出更优提示。
Comparative Prompting
对比提示
Present multiple versions, ask which is better and why.
呈现多个版本,询问哪个更优及原因。
Common Mistakes
常见错误
- Too little context: AI can't read your mind
- All at once: Work in phases, not giant prompts
- Accept first response: Iterate and refine
- No examples: Show what you want
- Hidden constraints: Make limitations explicit
- Skip validation: Always verify outputs
- 上下文不足: AI无法读取你的想法
- 一次性请求所有内容: 分阶段推进,而非使用冗长提示
- 接受首次响应: 进行迭代和优化
- 未提供示例: 展示你想要的内容
- 隐藏约束: 明确说明限制条件
- 跳过验证: 始终验证输出结果
Quick Reference
快速参考
Starting a spec:
I'm working on [project]. We need [feature].
Context: [tech stack, constraints, users]
Please help me develop [requirements/design/tasks].Refining output:
Good progress. Let's improve:
1. [Specific area to expand]
2. [Missing element to add]
3. [Clarification needed]Validating output:
Review this [document] and identify:
- Missing elements
- Ambiguities
- Conflicts
- Quality issuesExploring options:
Compare these approaches: [options]
Evaluate: [criteria]
Present trade-offs for decision-making.启动规范:
I'm working on [project]. We need [feature].
Context: [tech stack, constraints, users]
Please help me develop [requirements/design/tasks].优化输出:
Good progress. Let's improve:
1. [Specific area to expand]
2. [Missing element to add]
3. [Clarification needed]验证输出:
Review this [document] and identify:
- Missing elements
- Ambiguities
- Conflicts
- Quality issues探索选项:
Compare these approaches: [options]
Evaluate: [criteria]
Present trade-offs for decision-making.