新模块写好了,却没接上
New module written, never wired in
智能体写了实现功能的文件,却没导入、没注册、没加路由,所以对用户来说这个功能并不存在。
适用于: Claude Code · Cursor · Codex · Copilot agent
症状
diff 里多了一个看起来完整的新文件,但没有任何地方引用它;路由、菜单、处理函数或定时任务从没被执行。
为什么会这样
“接线”的代码在别的文件里(路由表、index、依赖注入容器、cron 表),智能体没打开它们,大型重构里尤其常见。agent-review 把它列为 AR016“孤立的新文件”。
示例
示意。
text+ src/routes/export.ts (new: GET /export handler, 80 lines)
src/routes/index.ts (unchanged: export route never registered)
$ curl -i localhost:3000/export -> 404
复制即用的修复
按你用的智能体挑选文件。规则片段用英文写,放进任何仓库都能用。
规则
Claude Code:加入 CLAUDE.md
CLAUDE.md## New files must be reachable
- For every new file, name the place that imports or registers it, and show that reference in the diff.
- Prove the feature is reachable end to end: hit the route, run the command, or render the page,
and paste the output.
- Remove any new file that nothing uses.
规则
Codex、Copilot 编码智能体等:加入 AGENTS.md
AGENTS.md## New files must be reachable
- For every new file, name the place that imports or registers it, and show that reference in the diff.
- Prove the feature is reachable end to end: hit the route, run the command, or render the page,
and paste the output.
- Remove any new file that nothing uses.
Cursor 规则
Cursor:项目规则
.cursor/rules/orphaned-new-file.mdc---
description: "AgentFails: New module written, never wired in"
alwaysApply: true
---
## New files must be reachable
- For every new file, name the place that imports or registers it, and show that reference in the diff.
- Prove the feature is reachable end to end: hit the route, run the command, or render the page,
and paste the output.
- Remove any new file that nothing uses.
技能
团队共享的 /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">