Skip to content

直接复制使用现成提示词,解决"不知道跟 Claude 说什么"的问题。本页收集了 50+ 条 Claude Code 提示词,按发现、设计、构建、发布、运维五个阶段分组,每条附带使用场景、工作原理和下一步建议。勾选需要连接的 MCP 服务器或 GitHub CLI 后即可运行。

Claude Code 提示词库:按任务场景速查命令和模板

这些提示词来自 Anthropic 官方指南:包括常见工作流最佳实践Anthropic 团队使用 Claude Code 的记录。每一条都是起点而非脚本。点击展开「为什么有效」可以查看背后的模式,方便你举一反三。

发现阶段 (Discover)

了解代码库结构、追踪变更历史、定位问题。

新手入门:快速了解代码库

适用角色:所有开发者

提示词

give me an overview of this codebase: architecture, key directories, and how the pieces connect

说明:描述你想知道什么,而不是指定读哪些文件。Claude 会自行探索项目并返回整体总结。

下一步:运行 /init 设置 CLAUDE.md,让 Claude 每次会话都记住这些信息。

来源常见工作流


解释不熟悉的代码

适用角色:所有开发者

提示词(替换 {path}{format}):

explain what {path} does and how data flows through it. write it up as {format}

示例:{path} = src/scheduler/queue.ts{format} = an HTML page with a diagram, then open it in my browser

说明:指定文件和输出格式(HTML 页面、图表、要点列表等)。

下一步:设置输出样式,让 Claude 持续使用你喜欢的方式解释。

来源常见工作流


查找某个行为发生在哪里

适用角色:所有开发者

提示词(替换 {behavior}):

where do we {behavior}?

示例:{behavior} = validate uploaded file types

说明:按行为搜索,而不是按文件名。即使不知道文件名或目录也能生效。

来源常见工作流


删除前检查哪些代码依赖它

适用角色:所有开发者

提示词(替换 {target}):

what would break if I deleted {target}?

示例:{target} = the retryWithBackoff helper

说明:删除前先问。Claude 会列出调用者和下游影响,告诉你这是一行清理还是需要协调的变更。

来源常见工作流


追踪代码的演化历史

适用角色:所有开发者

提示词(替换 {path}):

look through the commit history of {path} and summarize how it evolved and why

示例:{path} = internal/auth/session.go

说明:当问题是「为什么」,而不是「是什么」时,指向提交历史。Claude 会读取日志和 blame,解释当前实现背后的决策。

来源最佳实践


开始前评估变更范围

适用角色:PM、设计师

提示词(替换 {change}):

which files would I need to touch to {change}?

示例:{change} = add a dark mode toggle to settings

说明:在提交路线图之前先评估工作量。返回的文件列表告诉你这是单个组件还是跨切面变更。

来源Anthropic 团队实践


向代码库提产品问题

适用角色:PM

提示词(替换 {role}{action}):

I am a {role}. walk me through what happens when a user {action}, from the UI down to the result

示例:{role} = PM{action} = clicks Export to PDF

说明:说明你的角色,Claude 会根据这个级别给出答案,无需你读源代码。

下一步:设置输出样式,让答案始终保持在合适深度。

来源Anthropic 团队实践

设计阶段 (Design)

规划多文件变更、编写规格说明、梳理边缘案例。

计划多文件变更(先不碰代码)

适用角色:PM、设计师

提示词(替换 {target}{goal}):

plan how to refactor the {target} to {goal}. list the files you would change, but don't edit anything yet

示例:{target} = payment module{goal} = support multiple currencies

说明:要求「先不动手」将探索与修改分开。按 Shift+Tab 进入计划模式可以默认先出计划。

来源常见工作流


通过访谈编写规格说明

适用角色:PM

提示词(替换 {feature}):

I want to build {feature}. interview me about implementation, UX, edge cases, and tradeoffs until we have covered everything, then write the spec to SPEC.md

示例:{feature} = per-workspace rate limits

说明:让 Claude 像采访一样问你结构化的问题,直到需求完整,然后写入文件。

下一步:将问题保存为 /spec 技能,每次写 spec 都走同样的流程。

来源最佳实践


把会议记录变成工单

适用角色:PM、设计师

提示词(替换 {input}{tracker}):

read {input} and write up the action items, then create a {tracker} ticket for each with acceptance criteria

示例:{input} = @meeting-notes.md{tracker} = Linear

说明:跳过转录步骤,Claude 直接从非结构化输入中提取 action item,通过 MCP 写入你的跟踪系统。

下一步:保存为 /tickets 技能。

来源Anthropic 团队实践(需要连接工单系统)


构建前梳理边缘案例

适用角色:设计师、PM

提示词(替换 {feature}):

list the error states, empty states, and edge cases for {feature} that the design needs to cover

示例:{feature} = the file upload flow

说明:询问「缺少什么」而不是「有什么」。Claude 会列出快乐路径设计容易忽略的错误、空数据和边界状态。

来源Anthropic 团队实践


将线框图变成可运行原型

适用角色:设计师、PM、市场

提示词(粘贴线框图后发送):

here is a mockup. build a working prototype I can click through, matching the layout and states shown

说明:可点击的原型能回答静态线框图回答不了的问题。把工作代码交给工程师,而不是在文档里解释交互。

来源Anthropic 团队实践


根据截图实现并自检

适用角色:设计师

提示词(粘贴设计图后发送):

implement this design, then take a screenshot of the result, compare it to the original, and fix any differences

说明:Claude 会渲染、对比原始图片并迭代,无需你指出每个差距。

下一步:使用 /goal 让 Claude 持续迭代直到截图匹配。

来源最佳实践(需要浏览器渲染能力:Desktop 应用内置,终端需安装 Chrome 扩展或 Playwright MCP)

构建阶段 (Build)

实现功能、生成文档、编写测试、重构、代码审查、纠正方向。

模仿已有模式

适用角色:所有开发者

提示词(替换 {example}{new}):

look at how {example} is implemented to understand the pattern, then build {new} the same way

示例:{example} = the GitHub webhook handler{new} = a Stripe webhook handler

说明:指向你喜欢的代码。没有参考时 Claude 使用通用最佳实践;有参考时它匹配代码库实际使用的约定。

下一步:让 Claude 把遵循的模式写入 CLAUDE.md,后续会话无需参考也能保持一致。

来源最佳实践


为无文档代码生成文档

适用角色:文档作者

提示词(替换 {scope}{format}):

find {scope} without {format} comments and add them, matching the style already used in the file

示例:{scope} = the public functions in src/auth/{format} = JSDoc

说明:指定范围和格式,Claude 找到缺失的注释并匹配已有风格。

来源常见工作流


添加一个精确定义的小功能

适用角色:所有开发者

提示词(替换 {endpoint}{payload}):

add a {endpoint} endpoint that returns {payload}

示例:{endpoint} = /health{payload} = the app version and uptime

说明:说明输入和输出,而不是如何构建。Claude 找到类似代码所在位置,在旁边添加。

来源常见工作流


从头构建内部小工具

适用角色:PM、设计师、市场、文档

提示词(替换 {tool}):

create a {tool} using HTML, CSS, and vanilla JavaScript, then open it in my browser

示例:{tool} = drag-and-drop Kanban board with three columns

说明:不需要项目、框架或构建步骤。描述工具后 Claude 会打开浏览器让你看到它立即工作。

来源Anthropic 团队实践


从头到尾处理一个 Issue

适用角色:所有开发者

提示词(替换 {issue}):

read issue #{issue}, implement the fix, and run the tests

示例:{issue} = 312

说明:给出 Issue 编号,不需要总结。Claude 自己阅读完整工单,甚至会验证变更后才报告。

来源常见工作流(需要 GitHub CLI 认证或 GitHub 作为 MCP 连接器)


查找并更新全仓库的文案

适用角色:设计师、文档、市场

提示词(替换 {copy}{new}):

find every place we say "{copy}" or a close variant, show me each one in context, then update them all to "{new}". leave tests and the changelog alone

示例:{copy} = Sign up free{new} = Start free trial

说明:要求查找变体(字面搜索可能漏掉),指定跳过测试和历史。你只需审查用户实际看到的文案。

来源Anthropic 团队实践


根据历史示例撰写文档

适用角色:文档、市场、PM

提示词(替换 {examples}{folder}{topic}):

read the {examples} in {folder} to learn the structure and voice, then draft a new one for {topic}

示例:{examples} = privacy impact assessments{folder} = legal/pia/{topic} = the new analytics integration

说明:指向已完成工作的目录,Claude 学习结构和语气,初稿读起来就像你写的。

下一步:将这种语气保存为技能,每次起草都直接应用。

来源:Anthropic 法律团队实践


编写测试、运行并修复失败

适用角色:所有开发者

提示词(替换 {path}):

write tests for {path}, run them, and fix any failures

示例:{path} = app/parsers/feed.py

说明:将写、运行、修复合入一句,Claude 持续迭代而不需要你停下指示。

下一步:运行 /init 让 Claude 自动识别测试命令。

来源常见工作流


测试驱动实现

适用角色:所有开发者

提示词(替换 {feature}):

write tests for {feature} first, then implement it until they pass

示例:{feature} = the password reset flow

说明:测试定义完成条件,Claude 在实现上迭代直到通过。

来源Scaling agentic coding guide


根据覆盖率报告填补测试空白

适用角色:所有开发者

提示词(替换 {report}{target}):

read {report} and add tests for the lowest-covered files until each is above {target}%

示例:{report} = coverage/coverage-summary.json{target} = 80

说明:指向覆盖率报告,Claude 读取实际数字并针对最薄弱的文件编写测试。

下一步:设为目标,让 Claude 持续写入直到覆盖率达标。

来源常见工作流


跨代码库迁移模式

适用角色:所有开发者

提示词(替换 {from}{to}):

migrate everything from {from} to {to}: identify every place that needs to change, then make the changes

示例:{from} = the old logging API{to} = the structured logger

说明:描述旧模式和新模式,要求先识别所有调用点,这样结果中会列出每个位置,你可以检查是否有遗漏。

来源常见工作流


跨语言移植代码

适用角色:所有开发者

提示词(替换 {source}{target}{keep}):

port {source} to {target}, keeping the same {keep}

示例:{source} = this Python module{target} = Rust{keep} = public API and test behavior

说明:说明要保留什么(API、行为),Claude 有了对照检查的契约。

来源Anthropic 团队实践


针对可量化目标优化

适用角色:数据团队

提示词(替换 {target}{metric}{current}{goal}):

optimize {target} to bring {metric} from {current} down to under {goal}

示例:{target} = the search query{metric} = p95 latency{current} = 2s{goal} = 500ms

说明:给出指标和目标,Claude 有了明确的「完成」定义。

下一步:设为 /goal,让 Claude 持续测量并迭代直到命中数字。

来源Scaling agentic coding guide


修复精确的视觉 Bug

适用角色:设计师

提示词(替换 {element}{amount}{container}{viewport}):

the {element} extends {amount} beyond the {container} on {viewport}. fix it.

示例:{element} = login button{amount} = 20px{container} = card border{viewport} = mobile

说明:精确的视觉反馈精确修复。说明元素、测量值和视口。

下一步:添加预览工具以便 Claude 截图验证修复。

来源Scaling agentic coding guide


提交前审查你的更改

适用角色:所有开发者

提示词

review my uncommitted changes and flag anything that looks risky before I commit

说明:在问题还便宜时抓住它。Claude 完整读取更改文件(不仅仅是 diff 行),能发现快速自检遗漏的问题。

下一步:运行 /review 用一个命令完成同样检查。

来源常见工作流


审查拉取请求

适用角色:所有开发者

提示词(替换 {pr}):

review PR #{pr} and summarize what changed, then list any concerns

示例:{pr} = 247

说明:Claude 结合整个代码库上下文审查,不只 diff。它能发现纯 diff 审查遗漏的问题。

下一步:通过 Code Review 功能对每个 PR 自动启用审查。

来源常见工作流(需要 GitHub CLI 认证)


应用基础设施变更前审查

适用角色:安全、运维

提示词(粘贴 Terraform plan 输出后发送):

here is my Terraform plan output. what is this going to do, and is anything here going to cause problems?

说明:Plan 输出密度高、难扫描。粘贴后你得到一份通俗语言总结,了解实际会发生什么。

来源Anthropic 团队实践


用子代理进行安全审查

适用角色:安全

提示词(替换 {path}):

use a subagent to review {path} for security issues and report what it finds

示例:{path} = src/api/

说明子代理在自己的上下文窗口运行审查并返回摘要,不会消耗主会话空间。内置通用子代理无需额外设置即可处理。

下一步:设置一个团队可用的专用安全审查子代理。

来源最佳实践


正式审查前先过一遍内容

适用角色:市场、文档

提示词(替换 {file}{concerns}{reviewer}):

review {file} for {concerns} and list anything I should fix before it goes to {reviewer}

示例:{file} = launch-post.md{concerns} = unsupported claims, missing attributions, and brand-guideline issues{reviewer} = legal

说明:在人工投入时间之前先过一遍。指定要检查的问题范围,修复发现的问题后发送更干净的草稿。

下一步:将检查清单保存为技能,整个团队都能运行。

来源:Anthropic 法律团队实践


纠正错误方向

适用角色:所有开发者

提示词(替换 {feedback}):

that is not right: {feedback}. try a different approach

示例:{feedback} = the function signature needs to stay backward-compatible

说明:说明 Claude 遗漏的约束条件,而不是单纯说「不对」。具体原因让 Claude 在重试时有具体约束去满足,而不是再次猜测。

下一步:按两次 Esc 打开回退菜单,恢复代码和对话,让重试从干净状态开始。

来源最佳实践


缩小变更范围

适用角色:所有开发者

提示词(替换 {scope}):

that is too much. keep only the changes to {scope} and undo your other edits

示例:{scope} = the validation logic in src/forms/

说明:当方向正确但改动过大时,让 Claude 只保留部分更改而不是全部回退。划定边界可以防止小修复变成重构。

来源最佳实践


把一次纠正变成一条规则

适用角色:所有开发者

提示词(替换 {mistake}):

you keep {mistake}. add a rule to CLAUDE.md so this stops happening

示例:{mistake} = using default exports when this project uses named exports

说明:聊天中的纠正不会共享给团队。项目 CLAUDE.md 中的规则一旦提交就共享了,Claude 每次会话都读取。

下一步:打开 /memory 查看 Claude 写入了什么。

来源最佳实践

发布阶段 (Ship)

解决合并冲突、生成提交信息、创建 PR、编写发布说明、CI 工作流。

解决合并冲突

适用角色:所有开发者

提示词

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

说明:让 Claude 从 diff 推导信息,匹配仓库现有的提交风格。

来源常见工作流


从工单创建拉取请求

适用角色:所有开发者

提示词(替换 {tracker}{topic}):

find the {tracker} ticket about {topic} and open a PR that implements it

示例:{tracker} = Linear{topic} = the login timeout

说明:跳过在追踪系统、编辑器和 GitHub 之间的上下文切换。一条提示词完成读取规格、修改代码、打开 PR。

来源常见工作流(需要连接工单系统)


从 Git 历史草拟发布说明

适用角色:PM、文档、市场

提示词(替换 {from}{to}):

compare {from} to {to} and draft release notes grouped by feature, fix, and breaking change

示例:{from} = v2.3.0{to} = v2.4.0

说明:给出两个参考点和所需结构,Claude 读取之间的提交日志并草拟你能编辑的更新日志。

下一步:保存为 /changelog 技能。

来源常见工作流


编写 CI 工作流

适用角色:运维

提示词(替换 {steps}{branch}):

write a GitHub Actions workflow that {steps} on every push to {branch}

示例:{steps} = runs the tests and deploys to staging{branch} = main

说明:描述何时运行、做什么,YAML 自动生成并匹配项目的构建和测试命令。

来源常见工作流

运维阶段 (Operate)

调试、排查事故、分析数据、自动化重复任务。

查找并修复失败的测试

适用角色:所有开发者

提示词(替换 {test}):

the {test} test is failing, find out why and fix it

示例:{test} = UserAuth

说明:描述症状,不需要知道哪个文件有问题。Claude 运行测试看到失败、回溯到源码、修复。

来源常见工作流


调查用户报告的错误

适用角色:运维

提示词(替换 {symptom}{where}):

users are seeing {symptom} on {where}. investigate and tell me what is going on

示例:{symptom} = 500 errors{where} = /api/settings

说明:描述症状和位置,Claude 阅读相关代码路径并追踪可能原因。如有堆栈跟踪或日志可粘贴。

下一步:在运行手册中放入一个预填此提示的深度链接。

来源常见工作流


从根部修复构建错误

适用角色:运维

提示词(粘贴构建错误后发送):

here is a build error. fix the root cause and verify the build succeeds

说明:要求根因分析和验证,防止表面修补只压制错误而不修复。

来源最佳实践


调查生产事故

适用角色:运维、安全

提示词(替换 {symptom}):

{symptom}. check the logs, recent deploys, and config changes, then tell me the most likely cause

示例:{symptom} = the checkout endpoint started returning 500s an hour ago

说明:列举要关联的证据来源,而不是操作步骤。Claude 同时读取日志、git 历史和配置来缩小原因。

下一步:通过 MCP 连接 Sentry 或日志存储。

来源常见工作流


根据控制台截图诊断问题

适用角色:运维、数据

提示词(替换 {console}{resource}):

here is a screenshot of {console}. walk me through why {resource} is failing and give me the exact commands to fix it

示例:{console} = the GCP Kubernetes dashboard{resource} = this pod

说明:云控制台显示问题但没说解决命令。Claude 读取截图后把仪表盘翻译成 kubectl、gcloud 或 aws 命令。

来源Anthropic 团队实践


用自然语言查日志

适用角色:安全、运维、数据

提示词(替换 {events}{scope}{timeframe}):

show me all {events} for {scope} over {timeframe}. write the query, run it, and tell me what stands out

示例:{events} = failed logins{scope} = the auth service{timeframe} = the past 24 hours

说明:提出查询要求,Claude 构建 SQL 或对应的查询语句,对连接的数据源运行并展示查询和结果。

来源:Anthropic 网络安全团队实践(需要连接数据仓库或日志存储)


分析数据文件

适用角色:数据、PM、市场

提示词(替换 {file}{output}):

read {file}, summarize the key patterns, and write the results to {output}

示例:{file} = @reports/q1-signups.csv{output} = an HTML page with charts, then open it in my browser

说明:一次性问题不需要临时脚本。指向项目文件夹中的文件,Claude 直接读取、分析并写入结果。

下一步:通过 MCP 连接数据源,无需导出文件。

来源Anthropic 团队实践


根据性能数据生成变体

适用角色:市场、数据

提示词(替换 {file}{items}{n}{limit}):

read {file}, find the underperforming {items}, and generate {n} new variations that stay under {limit} characters

示例:{file} = @ads-performance.csv{items} = headlines{n} = 20{limit} = 90

说明:一开始就说明约束,确保生成不超限。Claude 读取指标、选择要替换的部分、生成符合限制的替代方案。

下一步:通过 MCP 连接广告平台,无需导出文件。

来源Anthropic 团队实践


将重复任务保存为技能

适用角色:所有开发者

提示词(替换 {name}{steps}):

create a /{name} skill for this project that {steps}

示例:{name} = ship{steps} = runs the linter and tests, then drafts a commit message

说明:把步骤命名一次,以后就可以当作命令复用。Claude 写入技能,团队成员都能运行。

来源常见工作流


添加钩子以实现重复行为自动化

适用角色:所有开发者

提示词(替换 {action}{event}):

write a hook that {action} after every {event}

示例:{action} = runs prettier{event} = edit to a .ts or .tsx file

说明:钩子让行为自动发生,不需要你记得去要求。描述触发器和动作,Claude 写入钩子配置。

来源最佳实践


用 MCP 连接外部工具

适用角色:所有开发者

提示词(替换 {server}{data}):

set up the {server} MCP server so you can read my {data} directly

示例:{server} = Sentry{data} = error reports

说明:一次连接,省去每次都粘贴数据的麻烦。设置 MCP 后,Claude 在需要时直接读取工具数据。

来源常见工作流


记录下这次会话要记住的内容

适用角色:PM、文档

提示词

summarize what we did this session and suggest what to add to CLAUDE.md

说明:在忘记之前要求总结。Claude 知道这次会话中需要弄清楚什么,并建议写入 CLAUDE.md,让下次会话直接带有上下文。

来源Anthropic 团队实践


这些提示词为什么有效

上面的提示词共享几个模式。认识这些模式能帮助你将任何提示词适配到自己的任务。

描述结果,而不是步骤。 说清楚你想要什么,让 Claude 自己找文件。下面这条提示词没写任何文件路径也能工作:

add rate limiting to the public API and make sure existing tests still pass

给它检查自己工作的方式。 在同一提示词里要求运行、测试、比较或验证,这样 Claude 会迭代而不只是尝试一次。

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

给出素材。 粘贴错误、日志、截图、计划输出直接在提示词里,或者输入 @ 引用文件。Claude 读原始来源,不是你对它的描述。

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

更多模式说明见最佳实践

这些提示词的来源

这些提示词基于已发布的 Anthropic 资源。每张卡片链接到其来源:

关于这些模式的视频演示,请参见 Anthropic Academy 的免费课程 Claude Code in Action

相关资源

本页的提示词是起点。一旦某条适合你的项目,下一步是让它可重复:保存为技能让团队成员都能以 /command 形式运行;将学到的约定记录在CLAUDE.md中,让每次会话都带有上下文而不需要重新学习。对于大型或高风险变更,计划模式会在改动前展示文件列表。

如果你正在团队中推广 Claude Code,请参见管理设置了解托管设置和策略,以及成本和使用了解如何计费。

常见问题

提示词中 {slot} 标记怎么替换?

直接输入实际值。如果使用 Claude Code 复制提示词时,会看到高亮的可编辑区域,填入你的文件路径、功能名称等后复制即可。在终端中也可以手动替换 {path}{behavior} 等占位符。

提示词要求「连接工具」但我的项目只用了 GitHub,需要额外配置吗?

不需要。GitHub 相关提示词(如 work-an-issue-endreview-a-pull-request)需要安装 gh CLI 并认证,或者将 GitHub 添加为 claude.ai 连接器。对于工单系统(Linear、Jira 等)提示词,需要添加对应的 MCP 服务器。其他提示词直接使用代码库内文件。

提示词太多记不住,怎么快速找到需要的?

使用页面顶部的搜索框(在 Web 文档中)输入关键词,或者按标签筛选(理解、计划、构建等)。在 Claude Code 会话中,可以直接描述任务然后加上「用最佳实践完成」,Claude 会匹配本页对应的模式。你也可以将常用提示词保存为技能,用 /your-custom-command 快速触发。