agentleFS
wisterx-specwisterx-spec/agent-rails/.agents/skills/scan-dead-routes/SKILL.md

scan-dead-routes

Skill2 starsChanged 7 months agoMITView on GitHub

扫描路由配置与页面文件的一致性,找出幽灵路由(配置有文件不存在)和孤儿页面(文件存在配置无注册)

The file

Files
SKILL.md

Scan Dead Routes Skill

单独调用:/scan-dead-routes 在工作流中调用:由 slim 工作流 Phase 2 自动触发


执行步骤

Step 1:探测路由配置文件

按优先级自动探测:

  1. {{FRONTEND_PATH}}/router.tsx / router.ts
  2. {{FRONTEND_PATH}}/routes.tsx / routes.ts
  3. {{FRONTEND_PATH}}/App.tsx(React Router inline 定义)
  4. app/ 目录(Next.js / Remix 文件路由)
  5. src/router/index.ts(Vue Router)

若用户提供 router_file_hint 参数则直接使用。

Step 2:提取路由 → 组件映射

从路由配置中提取所有 component: XxxPage 或 import('./pages/XxxPage') 引用,建立 路由路径 → 组件文件 映射表。

Step 3:检查幽灵路由(路由有,文件不存在)

对每个路由的组件引用,检查对应文件是否存在。

Step 4:检查孤儿页面(文件有,路由无注册)

列出 pages/(views/)目录下所有文件,检查是否被任何路由引用。排除:

  • _layout.tsx、_app.tsx 等框架约定文件
  • .slimignore 中豁免的路径
  • index.tsx(通常是目录入口)

输出格式

## 死路由扫描结果

### 幽灵路由(路由配置存在,但组件文件不存在)
| 路由路径 | 引用的组件 | 建议操作 |
|---------|---------|---------|
| /old-feature | OldFeaturePage | 从路由配置中移除 |

### 孤儿页面(页面文件存在,但未注册到路由)
| 文件路径 | 最后修改 | 建议操作 |
|---------|---------|---------|
| src/pages/ExperimentPage.tsx | 2024-02-10 | 确认是否废弃 |

无问题时输出:✅ 路由配置与页面文件一致,无死路由

约束

  • NEVER 自动修改路由配置或删除页面文件
  • MUST 排除框架约定文件(_layout, _app 等)
  • 对于文件路由(Next.js/Nuxt)项目,路由由目录结构决定,无需对比配置文件——跳过 Step 2,仅执行 Step 4 的孤儿页面检测

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.