Anthropic 官方提供了经过验证的提示词模式库,核心原则是"描述结果而非步骤"和"给 Claude 自检方法",这些模式可直接用于 Claude Opus 4.7 的日常开发任务。
适合的任务:API 开发、数据库迁移、性能优化、错误调试、文档生成、功能实现
不适合的任务:需要极度精确控制的底层系统编程;官方模式更适合中高层抽象任务
适用的模型版本:Claude Opus 4.7
适用的客户端、Agent 或 API:Claude API、Claude Code
推荐的推理档位和参数:复杂任务用 xhigh,一般任务用 high
❌ 错误方式:
"打开 src/api/routes.ts,在第 42 行添加 rate limiting 中间件,
然后修改 config.ts 添加配置项..."
✅ 正确方式:
"为公共 API 添加速率限制,确保现有测试仍然通过"原理:让 Claude 自己找到正确的文件和位置,而不是手动指定每一步。
❌ 错误方式:
"实现用户认证功能"
✅ 正确方式:
"实现用户认证功能,运行测试验证所有用例通过,
然后尝试用无效 token 调用 API 确认被拒绝"原理:要求 Claude 在同一提示中运行、测试、比较或验证,让它迭代而不是停在一次尝试后。
API 开发:
add rate limiting to the public API and make sure existing tests still pass数据库迁移:
write the migration, run it against the dev database,
and confirm the schema matches功能实现:
add a settings page that follows the same layout as the profile page性能优化:
get the bundle size under 200KB and show me what you removed错误调试:
why is the build failing? @build.log文档生成:
explain how the payment retry logic works as an HTML page with a diagram,
then open it in my browser# 1. 创建 skill 目录
mkdir -p .claude/skills/api-rate-limit
# 2. 创建 SKILL.md
cat > .claude/skills/api-rate-limit/SKILL.md << 'EOF'
---
name: api-rate-limit
description: 为 API 端点添加速率限制,包含配置和测试
---
# API 速率限制
## 步骤
1. 检查当前的 API 路由结构
2. 添加速率限制中间件
3. 配置限制参数(请求数/时间窗口)
4. 确保现有测试通过
5. 添加新的测试用例验证限制生效
## 验证
- 运行 `npm test` 确保所有测试通过
- 手动测试超过限制的请求被拒绝
EOF# CLAUDE.md
## 项目约定
- 所有 API 端点必须有速率限制
- 使用 express-rate-limit 包
- 限制:100 请求/15分钟/IP
- 测试必须覆盖正常请求和被限制的请求
## 常见模式
- 添加新功能时,总是先检查现有测试
- 性能优化后,必须对比优化前后的指标
- 错误调试时,先复现问题再修复从官方提示词库选择一个与你的任务匹配的模式
根据你的项目上下文调整提示词(替换具体功能名称、文件路径等)
在提示词中包含验证步骤(运行测试、检查输出、对比预期)
如果效果好,将提示词保存为 skill 供团队复用
在 CLAUDE.md 中记录有效的模式和约定
对于重复任务,使用已验证的 skill 而不是重新编写提示词
官方文档明确指出这些模式"基于发布的 Anthropic 资源"
提示词库包含常见工作流、最佳实践、团队使用案例
文档强调两个核心原则:
"描述结果而非步骤" - 让 Claude 找到文件
"给 Claude 自检方法" - 要求运行、测试、比较或验证
官方建议将有效的提示词保存为 skill,记录约定到 CLAUDE.md
文档提到 plan mode 用于大型或高风险变更,在编辑前显示文件列表
这些模式适用于大多数中高层抽象任务
底层系统编程或需要极度精确控制的任务可能需要更详细的步骤
提示词效果取决于 Claude Opus 4.7 的理解能力和项目上下文
不是所有任务都适合"描述结果"模式,某些复杂任务可能需要分步指导
skill 和 CLAUDE.md 需要团队维护和更新
官方文档:"The prompts above share a few patterns. Recognizing them helps you adapt any prompt here to your own task. Describe the outcome, not the steps. Say what you want and let Claude find the files."
"Give it a way to check its own work. Ask for run, test, compare, or verify in the same prompt so Claude iterates instead of stopping after one attempt."
Claude Opus 4.7