提示词库

软件开发提示词

用于规划变更、审查代码、编写测试和调试的提示词,经过结构化设计,让助手返回你可以检查的成果。

提示词是英文的,即它们的编写和测试所用的语言。这些页面上的说明和指引已翻译。

  • planning
  • architecture
  • code
100/100 · 163 token

变更的实施计划

把功能需求和相关代码变成一份有序的计划,包含文件、风险和测试。

适用场景: 在开始一项涉及多个文件的变更之前,想先把步骤和风险写下来时。

prompt
You are a senior software engineer planning a change to an existing codebase.

## Task
Produce an ordered plan for the requested change, based only on the code provided below.

## Requirements
- List the steps in the order they must be done.
- Name the file and function each step changes.
- State one risk for every step that changes existing behavior.
- List the tests that must pass before the change is complete.
- Use the phrase "not shown in the code provided" where the code does not contain what a step needs.

## Output format
Return markdown with four sections: Summary (2 sentences), Steps (numbered list), Risks (bulleted list), and Tests (bulleted list).

## Input
<request>
{{request}}
</request>

<code>
{{code}}
</code>

变量

{{request}}
你想要的变更,用你自己的话描述。
{{code}}
这项变更涉及的文件或函数。

示例输入

request: Add rate limiting to the login endpoint, 5 attempts per minute per IP.
code: the login route handler and the existing middleware file.

示例输出

## Summary
Add a per-IP limiter as middleware on POST /login. Existing middleware order is kept.

## Steps
1. middleware/rateLimit.ts: add createLimiter(max, windowMs)...
2. routes/auth.ts, loginRouter: apply the limiter before validateBody...

## Risks
- Step 2: requests behind a shared proxy share one IP...

## Tests
- 6th attempt within a minute returns 429...

仅为示意:为展示预期的形式而编写,并非由模型生成。

  • debugging
  • errors
  • code
100/100 · 162 token

根据错误做根因分析

从堆栈跟踪及其周围的代码出发,得出一份按可能性排序的原因清单,以及用于确认每个原因的检查。

适用场景: 你有错误信息和代码,但还不知道原因,想要可以按顺序验证的假设时。

prompt
You are a senior software engineer debugging a production error.

## Task
Identify the most likely root causes of the error below, using the stack trace and the code provided.

## Requirements
- Rank at most 3 causes from most to least likely.
- Quote the line of code each cause depends on.
- Give one check for each cause that confirms or rules it out.
- Do not propose a fix for a cause until its check is stated.
- Write "cannot be determined from the input" for anything the trace and code do not show.

## Output format
Return a markdown table with the columns Rank, Cause, Evidence, and Check, followed by one paragraph naming the cause to test first.

## Input
<error>
{{error}}
</error>

<code>
{{code}}
</code>

变量

{{error}}
错误信息和堆栈跟踪。
{{code}}
跟踪中提到的函数。

示例输入

error: TypeError: Cannot read properties of undefined (reading 'id') at getOrder (orders.js:42)
code: the getOrder function and its caller.

示例输出

| Rank | Cause | Evidence | Check |
|---|---|---|---|
| 1 | `user` is undefined when the session expired | `const id = req.user.id` (line 42) | Log `req.user` for a request with an expired cookie |

Test cause 1 first: it is the only path where `req.user` is unset.

仅为示意:为展示预期的形式而编写,并非由模型生成。

改成你的

修改需求以符合你的标准,然后检查结果。提示词分析器会在你输入时重新评分,优化器会在不丢失任何需求的前提下去掉冗词,安全扫描器会在你发送给模型之前标出密钥和个人数据。

更多类别