Wrong feature

New module written, never wired in

新模块写好了,却没接上

The agent creates the file that implements the feature but never imports, registers or routes it, so the feature doesn't exist for users.

Applies to: Claude Code · Cursor · Codex · Copilot agent

Symptom

A new file appears in the diff and looks complete. Nothing references it; the route, menu item, handler or job never runs.

Why it happens

Wiring lives in other files (a router, an index, a DI container, a cron table) that the agent didn't open, especially in larger refactors. agent-review lists it as AR016 "Orphaned new file".

Example

Illustrative.

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

Copy-paste fixes

Pick the files for the agents you use. Snippets are in English so they work in any repo.

Rules

Claude Code: add to 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.
Rules

Codex, Copilot coding agent and others: add to 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 rule

Cursor: project rule

.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.
Skill

Shared /verify skill for Claude Code

Commit it to the repo so the whole team (and every agent session) runs the same checks. Replace the commands with your project's real ones.

.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">

Sources and credit

Related patterns

翻车 of the week

One real agent failure and its fix, every week. Free, short, no spam.