﻿---
title: "提示默认写四件套"
summary: "Goal、Context、Constraints、Done when。四件事写全，Codex 少猜、更好审。"
category: prompt
level: starter
surfaces: [cli, app, ide]
tags: ["提示", "Done when", "@文件"]
canonical: /tips/four-part-prompt/
---

# 提示默认写四件套

Goal、Context、Constraints、Done when。四件事写全，Codex 少猜、更好审。

一个可复用的提示骨架：

```text
Goal: 把结算失败时的重试改成指数退避
Context: @src/billing/retry.ts，昨天的 CI 日志，相关 issue
Constraints: 不要改公共 API；不要动迁移；沿用现有日志字段
Done when: pnpm test -- retry 通过，并且失败三次后不再立即重试
```

- **Goal** 写结果，少写手段
- **Context** 用 `@` 点名文件、目录、报错，而不是「你自己看吧」
- **Constraints** 写架构、安全、禁止事项
- **Done when** 必须可验证：测试、行为变化、bug 不再复现

没有「完成条件」时，质量门只剩你自己。

## 来源

- [OpenAI · Best practices](https://developers.openai.com/codex/learn/best-practices)
