跳转到内容

提示词模式

可记忆的命名模式,用于与 Claude Code 的高效交互。这些模式来源于社区最佳实践,帮助你更有效地沟通。


通过建立上下文和标准来设定质量期望。

模式: “Implement as if you were a [角色] at [高标准公司/场景]”

# 高质量代码
Implement this authentication system as if you were
a senior security engineer at a major bank.
# 生产就绪
Review this code as if preparing for a SOC2 audit.
# 性能优先
Optimize this function as if it will handle
10,000 requests per second.

通过添加明确限制来强制创造性解决方案。

模式: “Solve this [with constraint X] [without using Y]”

# 依赖约束
Implement this feature without adding any new dependencies.
# 规模约束
Solve this in under 50 lines of code.
# 时间约束(执行)
This must complete in under 100ms.
# 简洁约束
Use only standard library functions.

强制在实现之前进行规划。

模式: “Before implementing, explain your approach in [N] sentences”

Before writing code, explain in 2-3 sentences
how you'll approach this.

通过让 Claude 提问来协作调试。

模式: “I’m stuck on [X]. Ask me questions to help me figure it out.”

# 调试
I'm stuck on why this test is failing.
Ask me questions to help diagnose the issue.
# 设计
I can't decide on the right architecture.
Ask me questions about my requirements.
# 问题理解
I don't fully understand what I need to build.
Ask clarifying questions.

通过验证逐步构建复杂功能。

模式: “Let’s build this incrementally. Start with [最小版本], then we’ll add [功能].”

Build the user registration incrementally:
1. First: Basic form that saves to database
2. Then: Email validation
3. Then: Password strength requirements
4. Finally: Email verification flow
Show me step 1 first.

定义明确的范围,防止过度工程化。

模式: “Only modify [X]. Don’t touch [Y].”

# 文件范围
Only modify auth.ts. Don't change any other files.
# 函数范围
Fix just the calculateTotal function.
Don't refactor surrounding code.
# 功能范围
Add the logout button only.
Don't add session management or remember-me features.

不同场景适合不同的模式组合:

场景模式组合
关键功能As If + 先解释 + 渐进式
快速修复约束 + 边界
调试会话橡皮鸭 + 渐进式
架构决策先解释 + As If
重构边界 + 渐进式 + 约束

应避免的提示词反模式:

反模式问题更好的方式
”Make it perfect”标准未定义使用 “As If” 模式指定具体上下文
”Fix everything”范围爆炸使用 “边界” 模式
”Just do it”缺乏验证使用 “先解释” 模式
”Make it fast”约束模糊指定具体:“under 100ms”
过度详细描述上下文污染仅聚焦相关约束

新手起步

“先解释”“边界” 模式开始。它们最简单且效果最直接。

日常开发

渐进式 模式是日常功能开发的默认选择,配合 约束 模式保持简洁。

疑难调试

橡皮鸭 模式帮助你理清思路,让 Claude 引导你发现问题根源。

关键系统

对安全或性能关键的系统,组合使用 As If + 先解释 + 渐进式