做错了功能

桩代码冒充“已完成”

A stub shipped as "done"

智能体说功能做完了,但某个函数体其实是 `pass`、`return null` 或 `throw new Error("not implemented")`。

适用于: Claude Code · Cursor · Codex · Copilot agent

症状

总结里写着“完成”。界面或接口都有了,但背后的核心函数是占位符、TODO,或者返回写死的值。

为什么会这样

智能体习惯先搭骨架再填肉。会话一长或遇到难点,骨架就留下来了,最后的总结描述的是计划而不是代码。agent-review 把它列为 AR035“实现不完整”;Agentic SDLC 手册里也有相关的“快做完了”陷阱。

示例

摘自 agent-review 分类(AR035)。

python
def refund(order):
    """Issue a full refund to the customer."""
    pass  # placeholder; not what the diff claims

复制即用的修复

按你用的智能体挑选文件。规则片段用英文写,放进任何仓库都能用。

规则

Claude Code:加入 CLAUDE.md

CLAUDE.md
## No placeholders in "done" work
- Never report a task complete while any changed code contains `pass`, `TODO`, `FIXME`,
  `not implemented`, or a hard-coded return standing in for real logic.
- If you cannot finish a part, say so in the first line of your reply and list exactly what is stubbed.
- Before saying done, search the diff: `git diff | grep -nE "TODO|FIXME|not implemented|pass$"`.
规则

Codex、Copilot 编码智能体等:加入 AGENTS.md

AGENTS.md
## No placeholders in "done" work
- Never report a task complete while any changed code contains `pass`, `TODO`, `FIXME`,
  `not implemented`, or a hard-coded return standing in for real logic.
- If you cannot finish a part, say so in the first line of your reply and list exactly what is stubbed.
- Before saying done, search the diff: `git diff | grep -nE "TODO|FIXME|not implemented|pass$"`.
Cursor 规则

Cursor:项目规则

.cursor/rules/placeholder-shipped-as-done.mdc
---
description: "AgentFails: A stub shipped as 'done'"
alwaysApply: true
---

## No placeholders in "done" work
- Never report a task complete while any changed code contains `pass`, `TODO`, `FIXME`,
  `not implemented`, or a hard-coded return standing in for real logic.
- If you cannot finish a part, say so in the first line of your reply and list exactly what is stubbed.
- Before saying done, search the diff: `git diff | grep -nE "TODO|FIXME|not implemented|pass$"`.
CI / 脚本

CI 步骤:diff 中新增占位符则失败

.github/workflows/no-placeholders.yml
name: no-placeholders
on: pull_request
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - name: Fail on new placeholders
        run: |
          if git diff "origin/${{ github.base_ref }}...HEAD" -U0 | grep -E '^\+' \
             | grep -nE 'TODO|FIXME|not implemented|NotImplementedError|^\+\s*pass\s*$'; then
            echo "Placeholder code added. Finish it or open a tracked issue."; exit 1
          fi
技能

团队共享的 /verify 技能(Claude Code)

把它提交进仓库,让整个团队(以及每个智能体会话)跑同一套检查。把命令换成你项目里真实的命令。

.claude/skills/verify/SKILL.md
---
name: verify
description: Verify the current change before calling it done. Use before every commit, PR, or "done" message.
---

# Verify

Run every step and paste the real output. Never summarize a step you did not run.

1. **Scope**: run `git diff --stat` and `git status --short`. For every changed file, say which part
   of the request needs it. Any file you cannot justify gets reverted, or listed under
   "Unrequested changes" for the user to decide.
2. **Build and types**: `npm run build` (or the project's build command).
3. **Tests**: `npm test`. Report pass/fail counts. If a test was edited, skipped or deleted,
   say so explicitly with the reason.
4. **Behavior**: exercise the changed behavior once for real (a curl, a CLI run, a screenshot)
   and show what happened.
5. **Report** in this format:
   - Requested: <one line>
   - Changed files: <list, each with its reason>
   - Checks run: <command -> result>
   - Not done / unsure: <list, or "none">

来源与致谢

相关条目

每周翻车

每周一个真实的智能体翻车案例和它的修复。免费、简短、不刷屏。