一句话
/goal 让 AI Agent 在闭环中自主完成任务,无需人工逐轮批准。
Anthropic、OpenAI 等主要 AI 公司都在推同一个功能。这不是巧合——/goal 正在从根本上改变我们与 AI Agent 的实时交互方式。
没有 /goal 的问题
以前用 Claude Code/Codex:
- Agent 执行一步 → 等待人类批准 → 人类发提示 → Agent 继续 → 循环
人类是瓶颈。
有了 /goal
/goal create a landing page
Claude 自己完成:研究 → 编码 → 调试 → 返回最终产品。
就像告诉员工完成一个任务,做完再回来汇报。
Claude 自己验证条件是否满足,然后推进到下一步。 这是因为一个 fast、small 的模型在做 gatekeeper,判断条件是否满足。
使用方法
支持:Claude Code CLI、Codex CLI、Hermes agent、Codex desktop app。
Codex Desktop 设置
- Settings → Configuration → goals = true
- Terminal:
codex --approval-mode full-auto /goal [你的目标]
Claude Code
直接启动 CLI,输入 /goal [目标]
Prompt 结构
有效 /goal prompt 需要三个元素:
| 元素 | 说明 | 示例 |
|---|---|---|
| Goal | 任务/目标,一行 | fix every failing test |
| Measurable end state | 定义"完成"长什么样 | until npm test exits 0 |
| Constraints | 必须遵守的规则 | without modifying any file outside /auth |
格式:
/goal [do the work] until [measurable end state] without [constraints that must hold]
真实示例:
/goal fix every failing test until npm test exits 0 without modifying any file outside the /auth directory.
高级 Prompt 结构(复杂项目)
/goal [目标]
Context:
- [项目背景]
- [当前状态]
Success Criteria:
- [可验证的完成标准 1]
- [可验证的完成标准 2]
Constraints:
- [不能做的事 1]
- [不能做的事 2]
Checklist:
- [步骤 1]
- [步骤 2]
- [步骤 3]
用例
研究
/goal research everything recent about the new /goal command
视觉设计
/goal create a cool visual for everything related to the new /goal command
本地文件处理
/goal Improve the README so a new contributor can install, run, test, and understand the project.
/goal Find dead code, unused dependencies, and stale files, then propose what can be safely removed.
/goal Turn the current notes and markdown files into a clean one-page summary document.
编码
/goal Add a dark/light theme toggle to this project, persist the choice in localStorage, update the UI styles to support both themes, and verify it works in the browser.
/goal Add a command palette that can search pages/actions and open with Cmd+K.
Pro Tips
- 一次只能设一个 /goal——明智地使用
- Claude Code 里能看到 token 消耗和进度条
- /goal 适合长期工作,小任务用普通 prompt 就够了
- 搭配 /plan 使用:/goal → /plan → /goal clear
- /pause 暂停,/goal clear 重置
- 不要只把 /goal 用于编码——研究、写作、分析都能用
- 让模型自己设 /goal——它写的 prompt 可能比你更好
- 在 prompt 里提供 checklist
- 给 Agent .md 文件做跟踪
核心洞察
/goal 不是新功能,是新范式:
- 从 copilot 到 autopilot
- 从逐步批准到闭环自主
- 从"告诉我怎么做"到"告诉我做到什么程度"
Agent 不仅能执行任务,还能自己拆解子目标——这是递归自主的起点。