agentleFS
yuan-ai-cloudyuan-ai-cloud/yuanliaofan-harness/skills/cleanup/SKILL.md

cleanup

Skill1 starsChanged 32 days agoApache-2.0View on GitHub

废旧代码清理审计。重构落地后、版本切分前、分支合并前使用。扫描 @deprecated 标记、向下兼容导出、re-export 壳、孤儿文件/导出,判断是否可以安全删除。Examples:"v0.79 拆包后 shared-db 还有多少残留"、"这个旧 harness 文件夹能不能整体删"。与 drift-check 互补:一个查死重,一个查违规。不适用于:MUST/NEVER 违规审计(转 drift-check)、运行时 bug(走 incident 或线内排查)。

84 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use you-might-not-need-a-callback, you-might-not-need-a-memo and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • bibektimilsina00Skill

    you-might-not-need-a-callback

    Analyze and fix useCallback anti-patterns in your code

    Also in 3 projects that use this

  • bibektimilsina00Skill

    you-might-not-need-a-memo

    Analyze and fix useMemo/React.memo anti-patterns in your code

    Also in 3 projects that use this

  • Scylla23Skill

    redo

    Re-run the last routed task one model tier up (haiku → sonnet → opus → fable). User-invoked escalation when the previous result missed. Pass --dry-run to preview without running.

    Also in 3 projects that use this

  • SocialKit-APISkill

    video-transcripts

    Extract transcripts from social videos through SocialKit across YouTube, TikTok, Instagram, Facebook, X/Twitter, LinkedIn, and direct video file URLs. Use when the user asks to transcribe, get captions or subtitles, pull the spoken text, or read what a video says, including one video or many at once. Returns full text plus timestamped segments. Not for posting, private accounts, or unrelated website scraping.

    Also in 3 projects that use this

  • SentrySkill

    db-migrate

    Create database migrations using Drizzle Kit. Use when adding/modifying tables, columns, or indexes. Ensures schema.ts and migrations stay in sync.

    Also in 3 projects that use this

  • AnasX7Skill

    improve

    Survey any codebase as a senior advisor and produce prioritized, self-contained implementation plans for OTHER models/agents to execute. Strictly read-only on source code — never implements, fixes, or refactors anything itself. Use when asked to audit a codebase, find improvement opportunities (bugs, security, performance, test coverage, tech debt, migrations, DX), suggest features or where to take the project next (roadmap, product direction), or generate handoff plans for another agent to implement.

    Also in 5 projects that use this

  • +3 more from bibektimilsina00

The file

Files
SKILL.md

废旧代码清理

定位

回答"这段代码还有人需要吗?" 与 drift-check(回答"是否违反规则")方法论互补——drift-check 查规则违反,cleanup 查消费者消失。

典型触发时机:多轮重构后、版本切分前、分支合并前、老猿说"代码有点臃肿了"。

消费者判定优先用缘分引擎(MUST)

"还有没有消费者"是符号图反查问题——每个候选符号用 yuanfen-impact(或 yuanfen-exploring 查 inbound Call 边)查上游。grep 会漏:

  • re-export 链:export * from './legacy' 后 grep 符号名在消费者文件里找不到
  • path alias:@/domains/... 让文本匹配不到
  • method 调用:instance.method() 中 method 的名字被其他类复用,grep 大量误报

引擎走 Call / Import / Extends 边,跨 alias + re-export 解析到源头。只有引擎报 0 消费者的符号才进"安全删"档;grep 补位仅用于字符串动态消费(字符串拼接 import、配置文件路径、CLI 注册)。

检查什么

1. @deprecated 符号

  • 找所有 @deprecated 注释标记的 export(函数/类/类型/常量/文件级)
  • 对每个符号追溯所有消费者:
    • 仅 @deprecated 自己内部引用 / 文档引用 → 安全删
    • 仍有真实消费者 → 记录消费者清单 + 数量,标 需讨论

2. 向下兼容导出(backward-compat shims)

  • grep 注释里出现 "向下兼容" / "backward" / "legacy" / "兼容旧" / "@deprecated" / "保留此" 的导出
  • 核对注释里声称的"消费者"是否还存在
  • 注意重构中常见模式:export const applyXxx = createXxx(DEFAULT_MAP) — 如果工厂版本已被所有消费者采用,绑定版本可删

3. re-export 壳文件

  • 只有 export { ... } from '...' / export * from '...' 的文件,无新增逻辑
  • 评估能否让消费者直接 import 源头
  • 例外:作为包对外 API 边界的 index.ts 不算壳(它存在的意义是定义公共接口)

4. 孤儿文件/导出

  • 全仓库 grep 某个 export 名,0 消费者 → 候选删除
  • 警惕动态消费:
    • 字符串拼接 import(import('./' + name))
    • 配置文件里的字符串路径
    • CLI 注册(bin 字段、package.json scripts)
    • 测试 fixture / generator 目录

5. 长期 TODO/FIXME(可选)

  • 扫描 TODO / FIXME / XXX / HACK 注释
  • 结合 git blame 看作者和时间,超过 1 个版本未跟进的 → 标"可能已废"

判定分层

每个发现分为两档,决定处置方式:

档位信号处置
安全删0 消费者 / 消费者仅在同个 deprecated 范围内 / 注释里声称的消费者已不存在直接删除,跑 tsc 验证
需讨论有外部消费者 / 动态消费疑虑 / 消费者也是 @deprecated 但还没到删除时机列消费者,让老猿决定迁移路径或保留理由

输出格式

## Cleanup Report — [日期]

### 安全删 (N 处)
- `path/to/file.ts:Symbol` — 理由(例:@deprecated 3 个月,grep 0 消费者)

### 需讨论 (N 处)
- `path/to/file.ts:Symbol`
  - 消费者: `consumer-a.ts`, `consumer-b.ts` (N 处)
  - 建议: 迁移 / 保留(附理由)/ 降级标记

### 无发现 (N/M 类)
- re-export 壳文件: 未发现

### 处置建议
- 安全删部分: 是否批准一键清理?
- 需讨论部分: 逐条对齐

安全纪律

  • NEVER 直接删除,所有变更 MUST 经老猿确认
  • 删除前 MUST 跑 tsc + 所在包的测试
  • 跨包重命名/删除 MUST 跑全仓 tsc,不能只信单包绿
  • 动态消费疑虑一律进"需讨论"——宁可保守
  • 删除的同时清理对应的 @deprecated 注释/文档引用/memory 里过期的提醒
  • 删除目录或目录内全部文件后 MUST 跑 docker compose build <affected-service> 验证 Dockerfile 不漂移(v0.84 教训 L-084-05):

    本地 dev 走 pnpm dev 不过 Dockerfile build 路径,不会暴露 Dockerfile 中遗留的 COPY <已删目录> 等死代码。只有 docker compose build 才暴露。

    实证:0d82f14 cleanup 删了 apps/yuanai-cms/scripts/ 内的 v082 一次性 backfill 脚本,但 Dockerfile 里 COPY /app/apps/yuanai-cms/scripts ./apps/yuanai-cms/scripts 没同步删除。空目录被 turbo prune 剥掉,builder stage 该路径不存在。直到 v0.84 deploy 跑 deploy-beta yuanai-cms 才撞 "not found"。

    Cleanup checklist 增项:

    • grep 所有 Dockerfile* 文件,搜 "<被删目录名>" 或 "<被删文件路径前缀>" 是否还有残留 COPY / RUN / VOLUME 引用
    • 涉及目录删除时 MUST 跑 docker compose build <service> 验证 image 构建成功
    • 同时检查 .dockerignore 是否需要清理对应条目

design-system v2 清理(v0.90 起,v2 迁移窗口内分批执行)

v0.90 引入 design-tokens v1 兼容层 + admin-layout 老路径。版本号仅为历史标记(原 v0.91/v0.92 计划已顺延),以下按 v2 迁移进度分批执行:

  • v0.91 deprecated 警告期:
    • packages/design-tokens/css/variables.css(v1 兼容入口)所有 alias 加 @deprecated 注释
    • packages/design-tokens/tailwind/preset.js(v1 兼容入口)同上
    • packages/design-tokens/themes/index.ts v1 ThemeKey API 加 @deprecated
    • @shared-components/admin-layout 包 README 标 deprecated
    • ESLint 启用 bg-gray-* / 老 bg-background text-foreground warn(非 error)
  • v0.92 删除期:
    • 删 packages/design-tokens/css/variables.css(v1 alias 入口),caller 改 variables-v2.css
    • 删 packages/design-tokens/tailwind/preset.js,caller 改 preset-v2
    • 删 packages/design-tokens/themes/index.ts v1 API,caller 改 ts/themes
    • 删 admin-layout 4 个布局组件 AdminLayout/Header/Sidebar/Content(v1.08 7c096242;包保留 MarkdownEditor/useDynamicMenu 等活符号,非整包删)
    • 删 apps/youcai/src/components/shell/(youcai 全切 AppShell)
    • grep import.*admin-layout、import.*youcai/src/components/shell 应 0 处
  • v0.92 grep checklist(cleanup 跑前先扫一遍):
    • var(--color-bg-primary) / var(--color-text-foreground) 等 v1 CSS var 名 0 处
    • bg-background / bg-muted / text-foreground / border-border 等 v1 Tailwind class 0 处
    • applyTheme('love') / applyTheme('health') v1 legacy key 0 处
    • from '@design-tokens'(主入口)的 ThemeKey import 0 处

详细引用 docs/specs/archive/v0.90/v0.90-rfc-01-design-tokens-v2.md §六 v1 兼容层 和 RFC-02 §5.3 admin-layout 命运。

与其他 skill 的关系

  • drift-check: 静态规则匹配(是否违反 MUST/NEVER)。cleanup 关注代码图(是否还在被用)。两者常在重构完成后一起跑。
  • reflect(version 模式): 版本级回顾,cleanup 是 reflect 可能派生的行动项之一。
  • review: 代码审查可能发现清理机会,但 review 主要看"新代码写得对不对",不全量扫存量。

参考文件

不定义新规则。仅在必要时参考:

  • CLAUDE.md — "Don't add half-finished implementations" / "NEVER backwards-compat hacks" 等通用原则
  • 工作日志中标注的遗留条目(如归档工作日志的"已知问题"段)

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.