真言·提示词指南Prompt Guide
三个来源,一样标准:官学(Claude Code 官方 52 条,按场景分类)、撷英(网络经典,条条署名)、心法(本站主理人的自用真言)。直接复制即可使用。
官学·Claude Code 官方Claude Code Official
Anthropic 官方提示词库完整收录,按场景分类。用词经过官方打磨,适合作为标准起手式。
初探·入门第一次接触代码库时该问什么Getting Started
刚拿到一个陌生代码库,先别急着改。用这几条让 AI 带你摸清架构、关键目录和模块关系,建立全局认知再动手。
give me an overview of this codebase: architecture, key directories, and how the pieces connect给我一份代码库总览:架构、关键目录,以及各部分的连接方式。
为什么有效:说出你想要答案的方式
参详·理解搞懂不熟悉的代码与改动的影响Understanding
遇到看不懂的代码或拿不准的改动,让 AI 解释原理、梳理调用链、评估影响范围,避免瞎改引出新 bug。
explain what src/scheduler/queue.ts does and how data flows through it. write it up as an HTML page with a diagram, then open it in my browser解释 src/scheduler/queue.ts 的作用与数据流向,写成带图的 HTML 页面并在浏览器打开。
为什么有效:给它工件
where do we validate uploaded file types?我们在哪里校验上传文件的类型?
为什么有效:描述结果,而不是步骤
what would break if I deleted the retryWithBackoff helper?如果我删掉 retryWithBackoff 这个辅助函数,什么会坏掉?
为什么有效:描述结果,而不是步骤
look through the commit history of internal/auth/session.go and summarize how it evolved and why翻看 internal/auth/session.go 的提交历史,总结它如何演变、为何演变。
为什么有效:给它工件
which files would I need to touch to add a dark mode toggle to settings?要加一个深色模式开关到设置页,我需要改哪些文件?
为什么有效:描述结果,而不是步骤
I am a PM. walk me through what happens when a user clicks Export to PDF, from the UI down to the result我是产品经理。带我从 UI 一路走到结果,讲清楚用户点『导出 PDF』时发生了什么。
为什么有效:说出你想要答案的方式
谋定·计划动手前先规划范围、对齐需求Planning
动手前先和 AI 对齐要做什么、做到什么程度。把需求拆成可执行的步骤,再开始写,少走弯路。
plan how to refactor the payment module to support multiple currencies. list the files you would change, but don't edit anything yet规划如何重构支付模块以支持多币种。列出要改的文件,但先别动手改。
为什么有效:描述结果,而不是步骤
I want to build per-workspace rate limits. interview me about implementation, UX, edge cases, and tradeoffs until we have covered everything, then write the spec to SPEC.md我想做按工作区的速率限制。就实现、UX、边界情况和权衡采访我,覆盖全面后把规范写入 SPEC.md。
为什么有效:说出你想要答案的方式
read @meeting-notes.md and write up the action items, then create a Linear ticket for each with acceptance criteria读 @meeting-notes.md,整理出行动项,并为每项创建一个带验收标准的 Linear 工单。
为什么有效:给它工件
list the error states, empty states, and edge cases for the file upload flow that the design needs to cover列出文件上传流程的错误态、空态和边界情况,供设计覆盖。
为什么有效:说明可测量的目标
塑形·原型把设计稿变成可点击的原型Prototyping
有设计稿或想法时,让 AI 快速搭出能点的雏形。先验证交互对不对,再投入细节开发。
here is a mockup. build a working prototype I can click through, matching the layout and states shown这是一张设计稿。做一个可以点击走通的原型,匹配图中的布局与各种状态。
为什么有效:给它工件
implement this design, then take a screenshot of the result, compare it to the original, and fix any differences实现这个设计,然后截图对比原图,修掉所有差异。
为什么有效:给它一种检查自己工作的方式
铸就·实现编写与补全功能代码Implementation
真正写功能代码、补全全新模块时的提示词。把「要什么」讲清楚,AI 就能产出可运行的初版。
look at how the GitHub webhook handler is implemented to understand the pattern, then build a Stripe webhook handler the same way先看 GitHub webhook 处理器是怎么实现的,理解其模式,再用同样方式写一个 Stripe webhook 处理器。
为什么有效:指向参考
find the public functions in src/auth/ without JSDoc comments and add them, matching the style already used in the file找出 src/auth/ 里没有 JSDoc 的公开函数并补上,风格与文件现有写法一致。
为什么有效:指向参考
add a /health endpoint that returns the app version and uptime加一个 /health 接口,返回应用版本与运行时长。
为什么有效:描述结果,而不是步骤
create a drag-and-drop Kanban board with three columns using HTML, CSS, and vanilla JavaScript, then open it in my browser用 HTML、CSS 和原生 JS 做一个三列的拖拽看板,并在浏览器打开。
为什么有效:说出你想要答案的方式
read issue #312, implement the fix, and run the tests读 issue #312,实现修复并运行测试。
为什么有效:给它一种检查自己工作的方式
find every place we say "Sign up free" or a close variant, show me each one in context, then update them all to "Start free trial". leave tests and the changelog alone找出所有写『Sign up free』或近似文案的地方,逐处展示上下文,再统一改成『Start free trial』。别动测试和变更日志。
为什么有效:描述结果,而不是步骤
read the privacy impact assessments in legal/pia/ to learn the structure and voice, then draft a new one for the new analytics integration读 legal/pia/ 下的隐私影响评估,学习其结构与语气,再为新的分析集成起草一份。
为什么有效:指向参考
试炼·测试用测试保障质量Testing
让 AI 补单元测试、写边界用例、跑通关键路径。用测试兜住质量,改起来才敢动手。
write tests for app/parsers/feed.py, run them, and fix any failures为 app/parsers/feed.py 写测试,运行并修复失败。
为什么有效:给它一种检查自己工作的方式
write tests for the password reset flow first, then implement it until they pass先为密码重置流程写测试,再实现直到测试通过。
为什么有效:给它一种检查自己工作的方式
read coverage/coverage-summary.json and add tests for the lowest-covered files until each is above 80%读 coverage/coverage-summary.json,为覆盖率最低的文件补测试,直到每个都高于 80%。
为什么有效:说明可测量的目标
易筋·重构改善结构而不改变行为Refactoring
不改对外行为、只改善内部结构的提示词。让 AI 理顺重复代码、拆清职责,代码更好维护。
migrate everything from the old logging API to the structured logger: identify every place that needs to change, then make the changes把旧的日志 API 全部迁移到结构化日志:先找出所有要改的地方,再改。
为什么有效:给它一种检查自己工作的方式
port this Python module to Rust, keeping the same public API and test behavior把这个 Python 模块移植到 Rust,保持相同的公开 API 与测试行为。
为什么有效:描述结果,而不是步骤
optimize the search query to bring p95 latency from 2s down to under 500ms优化搜索查询,把 p95 延迟从 2 秒降到 500 毫秒以内。
为什么有效:说明可测量的目标
the login button extends 20px beyond the card border on mobile. fix it.移动端登录按钮超出卡片边框 20px,修掉它。
为什么有效:说明可测量的目标
勘验·审查提交 / 合并前检查质量与风险Review
提交或合并前,让 AI 从安全、性能、可读性多角度挑问题,把风险挡在合入之前。
review my uncommitted changes and flag anything that looks risky before I commit审查我尚未提交的改动,在提交前标出任何有风险的地方。
为什么有效:给它一种检查自己工作的方式
review PR #247 and summarize what changed, then list any concerns审查 PR #247,总结改了什么,再列出所有疑虑。
为什么有效:说出你想要答案的方式
here is my Terraform plan output. what is this going to do, and is anything here going to cause problems?这是我的 Terraform plan 输出。它会做什么?有没有会引发问题的地方?
为什么有效:说出你想要答案的方式
use a subagent to review src/api/ for security issues and report what it finds用子代理审查 src/api/ 的安全问题,并报告发现。
为什么有效:描述结果,而不是步骤
review launch-post.md for unsupported claims, missing attributions, and brand-guideline issues and list anything I should fix before it goes to legal审查 launch-post.md,找出无依据的说法、缺失的署名和品牌规范问题,列出在送法务前该修的内容。
为什么有效:描述结果,而不是步骤
驯化·引导纠正 AI 的偏差并固化成规则Guidance
AI 跑偏时怎么把它拉回来,并把正确做法固化成规则或记忆,下次不再犯。
that is not right: the function signature needs to stay backward-compatible. try a different approach那样不对:函数签名必须保持向后兼容。换一种做法。
为什么有效:描述结果,而不是步骤
that is too much. keep only the changes to the validation logic in src/forms/ and undo your other edits太多了。只保留 src/forms/ 里校验逻辑的改动,其它撤销。
为什么有效:描述结果,而不是步骤
you keep using default exports when this project uses named exports. add a rule to CLAUDE.md so this stops happening你一直用默认导出,但本项目用命名导出。把这条规则写进 CLAUDE.md,避免再犯。
为什么有效:指向参考
留痕·Git版本控制与协作流程Git
提交、分支、合并、写提交说明等版本控制操作。让 AI 按规范管好协作历史。
resolve the merge conflicts in this branch and explain what you kept from each side解决这个分支的合并冲突,并说明你从两侧各自保留了什么。
为什么有效:说出你想要答案的方式
commit these changes with a message that summarizes what I did提交这些改动,消息概括我做了什么。
为什么有效:描述结果,而不是步骤
find the Linear ticket about the login timeout and open a PR that implements it找到关于登录超时的 Linear 工单,开一个实现它的 PR。
为什么有效:描述结果,而不是步骤
颁行·发布发版说明与持续集成Release
整理发版说明、跑持续集成、准备上线的提示词。让每次发布有迹可循、可回滚。
compare v2.3.0 to v2.4.0 and draft release notes grouped by feature, fix, and breaking change对比 v2.3.0 与 v2.4.0,起草发布说明,按功能、修复、破坏性变更分组。
为什么有效:描述结果,而不是步骤
write a GitHub Actions workflow that runs the tests and deploys to staging on every push to main写一个 GitHub Actions 工作流:每次 push 到 main 都跑测试并部署到预发。
为什么有效:描述结果,而不是步骤
辨症·调试定位并修复失败与报错Debugging
程序失败、报错、行为异常时,让 AI 顺着线索定位根因并给出修复,而不是乱试。
the UserAuth test is failing, find out why and fix itUserAuth 测试失败了,找出原因并修复。
为什么有效:给它一种检查自己工作的方式
users are seeing 500 errors on /api/settings. investigate and tell me what is going on用户在 /api/settings 看到 500 错误。排查并告诉我怎么回事。
为什么有效:描述结果,而不是步骤
here is a build error. fix the root cause and verify the build succeeds这是个构建错误。修复根因并验证构建通过。
为什么有效:给它一种检查自己工作的方式
应劫·事件线上事故排查Incident
线上出事故时的应急提示词:快速定位、止血、复盘,把影响降到最低。
the checkout endpoint started returning 500s an hour ago. check the logs, recent deploys, and config changes, then tell me the most likely cause结算接口一小时前开始返回 500。查日志、近期部署和配置变更,告诉我最可能的原因。
为什么有效:描述结果,而不是步骤
here is a screenshot of the GCP Kubernetes dashboard. walk me through why this pod is failing and give me the exact commands to fix it这是 GCP Kubernetes 控制台截图。带我搞清楚这个 pod 为何失败,并给出修复的确切命令。
为什么有效:给它工件
show me all failed logins for the auth service over the past 24 hours. write the query, run it, and tell me what stands out显示认证服务过去 24 小时所有失败登录。写出查询、运行它,并告诉我哪里异常。
为什么有效:说出你想要答案的方式
演数·数据分析数据并生成变体Data
让 AI 分析数据、生成报表或批量产出变体内容。把重复的数据活交给它。
read @reports/q1-signups.csv, summarize the key patterns, and write the results to an HTML page with charts, then open it in my browser读 @reports/q1-signups.csv,总结关键模式,把结果写成带图表的 HTML 页面并在浏览器打开。
为什么有效:说出你想要答案的方式
read @ads-performance.csv, find the underperforming headlines, and generate 20 new variations that stay under 90 characters读 @ads-performance.csv,找出表现差的标题,生成 20 条 90 字符以内的新变体。
为什么有效:说明可测量的目标
自运·自动化把重复动作沉淀为技能 / 钩子Automation
把反复做的事沉淀成技能、钩子或脚本,让 AI 在合适时机自动触发,省下重复劳动。
create a /ship skill for this project that runs the linter and tests, then drafts a commit message为这个项目创建一个 /ship 技能:跑 lint 和测试,然后起草提交信息。
为什么有效:描述结果,而不是步骤
write a hook that runs prettier after every edit to a .ts or .tsx file写一个钩子:每次编辑 .ts / .tsx 文件后自动跑 prettier。
为什么有效:描述结果,而不是步骤
set up the Sentry MCP server so you can read my error reports directly接入 Sentry 的 MCP 服务,这样你能直接读我的错误报告。
为什么有效:描述结果,而不是步骤
summarize what we did this session and suggest what to add to CLAUDE.md总结本次会话做了什么,并建议该往 CLAUDE.md 里加什么。
为什么有效:描述结果,而不是步骤
撷英·来自网络From the Web
从官方教程与经典文献里采撷的提示词,条条署名出处。宁缺毋滥,只收经得起复用的。
You are a prompt engineer. Based on my task description below, craft a high-quality prompt for me: clarify the goal, the audience, the output format and the constraints, then output the final prompt only.
我的任务:<在此描述你的任务>转写简化版:让 AI 充当提示词工程师,替你把任务描述打磨成结构化提示词;完整原文见来源。
为什么有效:写好提示词本身就是一门手艺,把它交给专门的「提示词工程师」角色,往往比自己硬凑更快。
来源:Anthropic 提示词工程互动教程(Metaprompt)· github.com/anthropics/prompt-eng-interactive-tutorial
Before implementing, ask me up to 5 clarifying questions about requirements that are ambiguous or missing. Wait for my answers before writing any code.
需求:<在此描述你的需求>转写自 Anthropic 教程中的提问模式:让 AI 先把需求里的模糊点问清楚。
为什么有效:需求的坑在动手前填最便宜——五连问能逼出你没写进需求里的隐含假设。
来源:Anthropic 提示词工程互动教程 · github.com/anthropics/prompt-eng-interactive-tutorial
请一步一步思考,再给出最终答案。(Let's think step by step.)在任意任务后追加这句,能明显提升推理类任务的准确率。
为什么有效:把「直接给答案」变成「展示推理过程」,模型的中间步骤会自己纠错。出自 Kojima et al. 2022 论文级别的发现。
来源:Kojima et al., Large Language Models are Zero-Shot Reasoners (2022) · arxiv.org/abs/2205.11916
心法·我的真言My Prompts
本站主理人在实战中磨出来的自用真言,附使用心得。整理中,敬请期待。