写意

Command Palette

Search for a command to run...

真言·提示词指南Prompt Guide

三个来源,一样标准:官学(Claude Code 官方 52 条,按场景分类)、撷英(网络经典,条条署名)、心法(本站主理人的自用真言)。直接复制即可使用。

官学·Claude Code 官方Claude Code Official

Anthropic 官方提示词库完整收录,按场景分类。用词经过官方打磨,适合作为标准起手式。

初探·入门第一次接触代码库时该问什么Getting Started

刚拿到一个陌生代码库,先别急着改。用这几条让 AI 带你摸清架构、关键目录和模块关系,建立全局认知再动手。

第一次接触代码库时该问什么从这里开始
在新存储库中定位Get codebase overview
give me an overview of this codebase: architecture, key directories, and how the pieces connect

给我一份代码库总览:架构、关键目录,以及各部分的连接方式。

为什么有效:说出你想要答案的方式

参详·理解搞懂不熟悉的代码与改动的影响Understanding

遇到看不懂的代码或拿不准的改动,让 AI 解释原理、梳理调用链、评估影响范围,避免瞎改引出新 bug。

搞懂不熟悉的代码与改动的影响
解释不熟悉的代码Explain unfamiliar code
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 页面并在浏览器打开。

为什么有效:给它工件

搞懂不熟悉的代码与改动的影响从这里开始
找到某事发生的地方Find where something happens
where do we validate uploaded file types?

我们在哪里校验上传文件的类型?

为什么有效:描述结果,而不是步骤

搞懂不熟悉的代码与改动的影响
在删除前检查什么会破坏Check what would break before deleting
what would break if I deleted the retryWithBackoff helper?

如果我删掉 retryWithBackoff 这个辅助函数,什么会坏掉?

为什么有效:描述结果,而不是步骤

搞懂不熟悉的代码与改动的影响
追踪代码如何演变Trace how code evolved
look through the commit history of internal/auth/session.go and summarize how it evolved and why

翻看 internal/auth/session.go 的提交历史,总结它如何演变、为何演变。

为什么有效:给它工件

搞懂不熟悉的代码与改动的影响
在开始前确定更改的范围Scope a change before starting
which files would I need to touch to add a dark mode toggle to settings?

要加一个深色模式开关到设置页,我需要改哪些文件?

为什么有效:描述结果,而不是步骤

搞懂不熟悉的代码与改动的影响
向代码库提出产品问题Ask the codebase a product question
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 multi-file changes before touching code
plan how to refactor the payment module to support multiple currencies. list the files you would change, but don't edit anything yet

规划如何重构支付模块以支持多币种。列出要改的文件,但先别动手改。

为什么有效:描述结果,而不是步骤

动手前先规划范围、对齐需求
通过采访起草规范Draft a spec via interview
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。

为什么有效:说出你想要答案的方式

动手前先规划范围、对齐需求
将会议转变为工单Turn meeting notes into tickets
read @meeting-notes.md and write up the action items, then create a Linear ticket for each with acceptance criteria

读 @meeting-notes.md,整理出行动项,并为每项创建一个带验收标准的 Linear 工单。

为什么有效:给它工件

动手前先规划范围、对齐需求
在构建前映射边界情况Map edge cases before building
list the error states, empty states, and edge cases for the file upload flow that the design needs to cover

列出文件上传流程的错误态、空态和边界情况,供设计覆盖。

为什么有效:说明可测量的目标

塑形·原型把设计稿变成可点击的原型Prototyping

有设计稿或想法时,让 AI 快速搭出能点的雏形。先验证交互对不对,再投入细节开发。

把设计稿变成可点击的原型
将模型转变为工作原型Turn a mockup into a working prototype
here is a mockup. build a working prototype I can click through, matching the layout and states shown

这是一张设计稿。做一个可以点击走通的原型,匹配图中的布局与各种状态。

为什么有效:给它工件

把设计稿变成可点击的原型
从屏幕截图实现并自检Implement from screenshot and self-check
implement this design, then take a screenshot of the result, compare it to the original, and fix any differences

实现这个设计,然后截图对比原图,修掉所有差异。

为什么有效:给它一种检查自己工作的方式

铸就·实现编写与补全功能代码Implementation

真正写功能代码、补全全新模块时的提示词。把「要什么」讲清楚,AI 就能产出可运行的初版。

编写与补全功能代码
遵循现有模式Follow an existing pattern
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 处理器。

为什么有效:指向参考

编写与补全功能代码
为未记录的代码生成文档Document undocumented code
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 small, well-defined feature
add a /health endpoint that returns the app version and uptime

加一个 /health 接口,返回应用版本与运行时长。

为什么有效:描述结果,而不是步骤

编写与补全功能代码
从头开始构建一个小的内部工具Build a small internal tool from scratch
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 做一个三列的拖拽看板,并在浏览器打开。

为什么有效:说出你想要答案的方式

编写与补全功能代码
端到端处理问题Handle an issue end to end
read issue #312, implement the fix, and run the tests

读 issue #312,实现修复并运行测试。

为什么有效:给它一种检查自己工作的方式

编写与补全功能代码
在代码库中查找和更新副本Find and update copies across the codebase
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』。别动测试和变更日志。

为什么有效:描述结果,而不是步骤

编写与补全功能代码
从过去的例子起草文档Draft a doc from past examples
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, run them, fix failures
write tests for app/parsers/feed.py, run them, and fix any failures

为 app/parsers/feed.py 写测试,运行并修复失败。

为什么有效:给它一种检查自己工作的方式

用测试保障质量
从测试驱动实现Implement test-first
write tests for the password reset flow first, then implement it until they pass

先为密码重置流程写测试,再实现直到测试通过。

为什么有效:给它一种检查自己工作的方式

用测试保障质量
从覆盖率报告填补空白Fill coverage gaps from report
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 a pattern across the codebase
migrate everything from the old logging API to the structured logger: identify every place that needs to change, then make the changes

把旧的日志 API 全部迁移到结构化日志:先找出所有要改的地方,再改。

为什么有效:给它一种检查自己工作的方式

改善结构而不改变行为
将代码移植到另一种语言Port code to another language
port this Python module to Rust, keeping the same public API and test behavior

把这个 Python 模块移植到 Rust,保持相同的公开 API 与测试行为。

为什么有效:描述结果,而不是步骤

改善结构而不改变行为
针对可测量目标进行优化Optimize against a measurable target
optimize the search query to bring p95 latency from 2s down to under 500ms

优化搜索查询,把 p95 延迟从 2 秒降到 500 毫秒以内。

为什么有效:说明可测量的目标

改善结构而不改变行为
修复精确的视觉错误Fix a precise visual bug
the login button extends 20px beyond the card border on mobile. fix it.

移动端登录按钮超出卡片边框 20px,修掉它。

为什么有效:说明可测量的目标

勘验·审查提交 / 合并前检查质量与风险Review

提交或合并前,让 AI 从安全、性能、可读性多角度挑问题,把风险挡在合入之前。

提交 / 合并前检查质量与风险从这里开始
在提交前审查你的更改Review your changes before committing
review my uncommitted changes and flag anything that looks risky before I commit

审查我尚未提交的改动,在提交前标出任何有风险的地方。

为什么有效:给它一种检查自己工作的方式

提交 / 合并前检查质量与风险
审查拉取请求Review a pull request
review PR #247 and summarize what changed, then list any concerns

审查 PR #247,总结改了什么,再列出所有疑虑。

为什么有效:说出你想要答案的方式

提交 / 合并前检查质量与风险
在应用前审查基础设施更改Review infra changes before applying
here is my Terraform plan output. what is this going to do, and is anything here going to cause problems?

这是我的 Terraform plan 输出。它会做什么?有没有会引发问题的地方?

为什么有效:说出你想要答案的方式

提交 / 合并前检查质量与风险
使用子代理运行安全审查Run a security review with a subagent
use a subagent to review src/api/ for security issues and report what it finds

用子代理审查 src/api/ 的安全问题,并报告发现。

为什么有效:描述结果,而不是步骤

提交 / 合并前检查质量与风险
在正式审查前捕获问题Catch issues before formal review
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 跑偏时怎么把它拉回来,并把正确做法固化成规则或记忆,下次不再犯。

纠正 AI 的偏差并固化成规则
纠正错误的方法Correct the wrong approach
that is not right: the function signature needs to stay backward-compatible. try a different approach

那样不对:函数签名必须保持向后兼容。换一种做法。

为什么有效:描述结果,而不是步骤

纠正 AI 的偏差并固化成规则
缩小更改的范围Narrow the scope of changes
that is too much. keep only the changes to the validation logic in src/forms/ and undo your other edits

太多了。只保留 src/forms/ 里校验逻辑的改动,其它撤销。

为什么有效:描述结果,而不是步骤

纠正 AI 的偏差并固化成规则
将更正转变为规则Turn a correction into a rule
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 merge conflicts
resolve the merge conflicts in this branch and explain what you kept from each side

解决这个分支的合并冲突,并说明你从两侧各自保留了什么。

为什么有效:说出你想要答案的方式

版本控制与协作流程
使用生成的消息提交Commit with a generated message
commit these changes with a message that summarizes what I did

提交这些改动,消息概括我做了什么。

为什么有效:描述结果,而不是步骤

版本控制与协作流程
从工单打开拉取请求Open a PR from a ticket
find the Linear ticket about the login timeout and open a PR that implements it

找到关于登录超时的 Linear 工单,开一个实现它的 PR。

为什么有效:描述结果,而不是步骤

颁行·发布发版说明与持续集成Release

整理发版说明、跑持续集成、准备上线的提示词。让每次发布有迹可循、可回滚。

发版说明与持续集成
从 git 历史起草发布说明Draft release notes from git history
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,起草发布说明,按功能、修复、破坏性变更分组。

为什么有效:描述结果,而不是步骤

发版说明与持续集成
编写 CI 工作流Write a CI workflow
write a GitHub Actions workflow that runs the tests and deploys to staging on every push to main

写一个 GitHub Actions 工作流:每次 push 到 main 都跑测试并部署到预发。

为什么有效:描述结果,而不是步骤

辨症·调试定位并修复失败与报错Debugging

程序失败、报错、行为异常时,让 AI 顺着线索定位根因并给出修复,而不是乱试。

定位并修复失败与报错从这里开始
找到并修复失败的测试Find and fix a failing test
the UserAuth test is failing, find out why and fix it

UserAuth 测试失败了,找出原因并修复。

为什么有效:给它一种检查自己工作的方式

定位并修复失败与报错
调查报告的错误Investigate a reported error
users are seeing 500 errors on /api/settings. investigate and tell me what is going on

用户在 /api/settings 看到 500 错误。排查并告诉我怎么回事。

为什么有效:描述结果,而不是步骤

定位并修复失败与报错
在根处修复构建错误Fix a build error at the root
here is a build error. fix the root cause and verify the build succeeds

这是个构建错误。修复根因并验证构建通过。

为什么有效:给它一种检查自己工作的方式

应劫·事件线上事故排查Incident

线上出事故时的应急提示词:快速定位、止血、复盘,把影响降到最低。

线上事故排查
调查生产事件Investigate a production 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。查日志、近期部署和配置变更,告诉我最可能的原因。

为什么有效:描述结果,而不是步骤

线上事故排查
从控制台屏幕截图诊断Diagnose from a console screenshot
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 为何失败,并给出修复的确切命令。

为什么有效:给它工件

线上事故排查
用纯英文查询日志Query logs in plain English
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 分析数据、生成报表或批量产出变体内容。把重复的数据活交给它。

分析数据并生成变体
分析数据文件Analyze a data file
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 页面并在浏览器打开。

为什么有效:说出你想要答案的方式

分析数据并生成变体
从性能数据生成变体Generate variants from performance data
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 在合适时机自动触发,省下重复劳动。

把重复动作沉淀为技能 / 钩子
将重复任务转变为技能Turn a recurring task into a skill
create a /ship skill for this project that runs the linter and tests, then drafts a commit message

为这个项目创建一个 /ship 技能:跑 lint 和测试,然后起草提交信息。

为什么有效:描述结果,而不是步骤

把重复动作沉淀为技能 / 钩子
为重复行为添加钩子Add a hook for repetitive behavior
write a hook that runs prettier after every edit to a .ts or .tsx file

写一个钩子:每次编辑 .ts / .tsx 文件后自动跑 prettier。

为什么有效:描述结果,而不是步骤

把重复动作沉淀为技能 / 钩子
使用 MCP 连接工具Connect a tool via MCP
set up the Sentry MCP server so you can read my error reports directly

接入 Sentry 的 MCP 服务,这样你能直接读我的错误报告。

为什么有效:描述结果,而不是步骤

把重复动作沉淀为技能 / 钩子
捕获下次要记住的内容Capture what to remember next time
summarize what we did this session and suggest what to add to CLAUDE.md

总结本次会话做了什么,并建议该往 CLAUDE.md 里加什么。

为什么有效:描述结果,而不是步骤

撷英·来自网络From the Web

从官方教程与经典文献里采撷的提示词,条条署名出处。宁缺毋滥,只收经得起复用的。

纠正 AI 的偏差并固化成规则
元提示:让 AI 替你写提示词Metaprompt
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

纠正 AI 的偏差并固化成规则
先提问,再动手Ask Questions First
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

搞懂不熟悉的代码与改动的影响
一步一步思考Zero-shot Chain-of-Thought
请一步一步思考,再给出最终答案。(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

本站主理人在实战中磨出来的自用真言,附使用心得。整理中,敬请期待。

整理中,敬请期待——有好真言也欢迎推荐。