tidy-up

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tidy Up

整理清理

Reclaim space and remove leftover local clutter without wrecking active work. Parse the first token as a command when it matches the table; otherwise map clear intent. Default with no useful target is
scan
(inventory + proposed cleanup), not blind delete.
回收空间并清理残留的本地杂物,同时不破坏正在进行的工作。当第一个标记匹配下表中的命令时,将其解析为对应命令;否则根据明确意图映射。无明确目标时默认执行
scan
(清点 + 提议清理方案),而非盲目删除。

Operating contract

操作契约

Shared by every DecisionNerd/dev-skills skill. Canonical copy:
handbook/concepts/14-operating-contract.md
.
  • Define done first. Before using tools, write the finish line in one or two lines: the acceptance criteria (existing issue AC, BDD scenarios, tests, or contract when they exist; otherwise propose them and say where they should live) and the evidence that will prove them. Re-check it before reporting done. Never report done on work you did not verify.
  • Requested scope sets the finish line. A question ("is it ready?", "why is it broken?", "what next?") ends with the answer and a
    Next:
    line naming the exact next invoke. An outcome request ("fix", "finish", "land", "#42") continues through the chain (diagnose → fix → test → check-readiness → merge-it) until the outcome or a real blocker. Do not end a turn with "Do you want me to…?" for in-scope, in-repo work.
  • Stop only for real blockers. Stop and ask only when you cannot continue without the user, or before: deleting data or unmerged work, force-push or history rewrite, changing anything outside this repository (GitHub objects, deployments, live data, production or paid resources, external services), or leaving the requested scope, unless the user's request already named that exact action. Keep the harness's permission prompts for risky commands. Otherwise keep going and put status notes in the same message as the next action.
  • Ask well, once. For a genuine question use the harness's structured question tool when it has one (Claude Code:
    AskUserQuestion
    ; Codex:
    request_user_input
    when the current mode supports it) with concrete options; otherwise plain text with numbered options. Treat the answer as settled; do not re-open earlier verdicts, plans, or answers unless asked.
  • Fan out when work is parallel. Use subagents for independent reads (repo survey, evidence gathering, per-option research, per-area audits) and for independent verification (a reviewer that did not write the change). Writes stay single-owner per path set and sequential. Brief every child with goal, done-when, constraints, must-not, and return shape; verify each child's result before consolidating. Use Claude Code's
    Workflow
    tool only for orchestration across many subagents that truly needs it; it is expensive.
  • Pick the model tier per child; defer to routing config. If the harness or user config already routes subagents (Claude Code
    CLAUDE_CODE_SUBAGENT_MODEL
    or a CLAUDE.md rule; Codex
    agents.default_subagent_model
    or a role's
    agents.<name>.config_file
    ; Cursor a custom subagent's
    model:
    frontmatter), follow it and do not pass a model. Otherwise: mechanical search or inventory → fast/cheap (Claude Code
    haiku
    ); implementation and evidence gathering → mid (
    sonnet
    ); planning, review, adversarial verification → top (
    opus
    or
    fable
    ). In Claude Code set it with the
    Agent
    tool
    model
    param or agent frontmatter
    model:
    ; in Codex pass a spawn model or set
    model
    in the role's config file; in Cursor set
    model:
    (default
    inherit
    ) in
    .cursor/agents/*.md
    . Where the harness cannot choose, children inherit the parent model or the harness picks one (Cursor's built-in Explore/Bash/Browser subagents pick per subtask); say which in the status note.
  • Keep a checklist on long runs. For more than about five steps or work that crosses skills, keep
    TASKS.md
    at the repo root and tick items as they finish. Do not commit it unless the repo already tracks one.
  • Close every run with three headings.
    Blocked on me
    (the one genuine question or blocker, else "none");
    Changed
    (files, commits, GitHub objects, deploys, else "nothing");
    Found
    (evidence, verdict, and
    Next: <exact invoke>
    ).
所有 DecisionNerd/dev-skills 技能共享此规范。官方版本:
handbook/concepts/14-operating-contract.md
。
  • 先定义完成标准。 使用工具前,用一两行写明完成线:验收标准(若存在现有 issue 的 AC、BDD 场景、测试或契约则沿用;否则提出标准并说明应存放的位置)以及证明完成的证据。报告完成前重新核对。未经验证的工作绝不能报告为已完成。
  • 请求范围决定完成线。 问题类请求(“准备好了吗?”、“为什么坏了?”、“下一步是什么?”)以答案和一行
    Next:
    结尾,其中写明确切的下一步调用。结果类请求(“修复”、“完成”、“上线”、“#42”)需贯穿整个流程链(诊断 → 修复 → 测试 → 就绪检查 → 合并)直到达成结果或遇到真正的阻塞。对于范围内的仓库内工作,不要以“你需要我…吗?”结束一轮回复。
  • 仅因真正的阻塞停止。 仅在以下情况停止并询问用户:没有用户输入就无法继续;或在执行以下操作前:删除数据或未合并的工作、强制推送或历史重写、修改本仓库外的任何内容(GitHub 对象、部署、线上数据、生产或付费资源、外部服务)、超出请求范围——除非用户的请求已明确指定该操作。保留运行框架对风险命令的权限提示。否则继续执行,并将状态说明与下一步操作放在同一条消息中。
  • 一次问清楚。 对于真实问题,若运行框架提供结构化提问工具(Claude Code:
    AskUserQuestion
    ;Codex:当前模式支持时用
    request_user_input
    ),则使用该工具并给出具体选项;否则使用带编号选项的纯文本。将答案视为最终决定;除非用户要求,否则不要重新讨论之前的结论、计划或答案。
  • 并行工作时拆分任务。 对于独立读取类工作(仓库调研、证据收集、逐选项研究、分领域审计)和独立验证类工作(未编写变更的评审者),使用子 Agent。写入操作按路径集保持单一负责人且顺序执行。向每个子 Agent 说明目标、完成条件、约束、禁止事项和返回格式;合并前验证每个子 Agent 的结果。仅在确实需要编排大量子 Agent 时使用 Claude Code 的
    Workflow
    工具;该工具成本较高。
  • 为每个子 Agent 选择模型等级;遵循路由配置。 若运行框架或用户配置已为子 Agent 配置路由(Claude Code 的
    CLAUDE_CODE_SUBAGENT_MODEL
    或 CLAUDE.md 规则;Codex 的
    agents.default_subagent_model
    或角色的
    agents.<name>.config_file
    ;Cursor 自定义子 Agent 的
    model:
    前置元数据),则遵循该配置,不要传递模型参数。否则:机械搜索或清点 → 快速/低成本(Claude Code
    haiku
    );实现和证据收集 → 中等(
    sonnet
    );规划、评审、对抗性验证 → 顶级(
    opus
    或
    fable
    )。在 Claude Code 中通过
    Agent
    工具的
    model
    参数或 Agent 前置元数据的
    model:
    设置;在 Codex 中传递生成模型或在角色配置文件中设置
    model
    ;在 Cursor 中在
    .cursor/agents/*.md
    里设置
    model:
    (默认
    inherit
    )。若运行框架无法选择,子 Agent 继承父模型或由运行框架选择(Cursor 内置的 Explore/Bash/Browser 子 Agent 会按子任务选择);在状态说明中注明使用的模型。
  • 长时间运行时保留检查清单。 对于超过约五个步骤或跨技能的工作,在仓库根目录保留
    TASKS.md
    ,完成一项勾选一项。除非仓库已跟踪该文件,否则不要提交它。
  • 每次运行结束时给出三个标题。
    Blocked on me
    (一个真实问题或阻塞项,没有则为“none”);
    Changed
    (文件、提交、GitHub 对象、部署,没有则为“nothing”);
    Found
    (证据、结论,以及
    Next: <确切的调用内容>
    )。

Commands

命令

CommandWhat it does
scan
/
plan
/
dry-run
Inventory clutter; estimate size; propose deletions (no deletes)
workspaces
/
worktrees
Remove dangling / merged / abandoned git worktrees and empty workspace dirs
artifacts
/
build
Remove stale build outputs (
dist
,
build
,
.next
,
site
,
coverage
, etc.)
caches
Clear regenerable caches (tool/package caches in-repo; ask before global home caches)
branches
Prune stale local branches (merged / gone remote); never delete unmerged without approval
deep
Broader pass: workspaces + artifacts + caches + safe branch prune (still gated)
all
Same as
deep
for the current repo (or named path); still inventory → approve → delete
help
/
library
List commands
Aliases:
clean
/
cleanup
/
prune
→ map to the narrowest fitting command, or
scan
if unclear.
Target: repo root (default cwd), monorepo package path, or explicit directory.
命令功能
scan
/
plan
/
dry-run
清点杂物;估算大小;提议删除方案(不执行删除)
workspaces
/
worktrees
移除悬空/已合并/已废弃的 git worktree 以及空的工作区目录
artifacts
/
build
移除过期的构建输出(
dist
、
build
、
.next
、
site
、
coverage
等)
caches
清理可再生缓存(仓库内的工具/包缓存;清理全局主目录缓存前需询问)
branches
修剪过期的本地分支(已合并/远程已删除);未经批准绝不能删除未合并的分支
deep
更全面的清理:工作区 + 构建产物 + 缓存 + 安全分支修剪(仍需审批)
all
对当前仓库(或指定路径)执行与
deep
相同的操作;仍遵循 清点 → 审批 → 删除 流程
help
/
library
列出所有命令
别名:
clean
/
cleanup
/
prune
→ 映射到最匹配的窄范围命令,若不明确则映射为
scan
。
目标:仓库根目录(默认当前工作目录)、monorepo 包路径或显式指定的目录。

Routing

路由规则

  1. No argument / vague “tidy up”: run
    scan
    , then ask one structured multi-select question: which buckets to apply (workspaces / artifacts / caches / branches / deep), showing estimated sizes and risk level for each. Use the harness's structured question tool when available; otherwise plain text with numbered options.
  2. First word is a command: run it; remainder is path/scope.
  3. Clear intent (“remove old worktrees”, “clear .next”, “prune merged branches”): map and proceed.
  4. User already ordered exact deletes (“delete these worktrees”, “rm -rf dist and .next”): execute that scope; list what was removed under
    Changed
    .
  1. 无参数 / 模糊的“整理一下”:执行
    scan
    ,然后提出一个结构化的多选问题:要应用哪些清理类别(工作区 / 构建产物 / 缓存 / 分支 / 深度清理),并显示每个类别的估算大小和风险等级。若运行框架提供结构化提问工具则使用该工具;否则使用带编号选项的纯文本。
  2. 第一个词是命令:执行该命令;剩余部分为路径/范围。
  3. 意图明确(“移除旧 worktree”、“清理 .next”、“修剪已合并分支”):映射到对应命令并继续。
  4. 用户已明确要求删除特定内容(“删除这些 worktree”、“rm -rf dist 和 .next”):执行该范围的清理;在
    Changed
    下列出已删除的内容。

Hard safety rules

严格安全规则

Follow references/safety.md. Summary:
  1. Inventory before delete — list paths + sizes + why removable.
  2. Never delete uncommitted changes, active worktree checkouts still in use,
    .env
    / secrets, or non-ignored source.
  3. Prefer project-local cleanups; global caches (
    ~/Library/Caches
    , npm/pnpm/yarn global store, Docker) only when explicitly asked.
  4. Prefer repo scripts (
    npm run clean
    ,
    make clean
    ,
    git worktree prune
    ) over ad-hoc
    rm -rf
    .
  5. No
    git clean -fdx
    unless the user explicitly asks for that exact command after seeing what it would remove.
  6. No force-delete of unmerged branches or worktrees with dirty status without explicit approval.
  7. After deletes, report what was removed and approximate space reclaimed under
    Changed
    .
  8. Single owner, no fan-out for deletes. Destructive commands run sequentially in the parent; no subagent fan-out for delete steps.
遵循 references/safety.md。摘要如下:
  1. 删除前先清点 — 列出路径 + 大小 + 可删除的原因。
  2. 绝不能删除 未提交的变更、仍在使用的活动 worktree 检出、
    .env
    / 密钥文件,或未被忽略的源码。
  3. 优先进行项目本地清理;仅在用户明确要求时才清理全局缓存(
    ~/Library/Caches
    、npm/pnpm/yarn 全局存储、Docker)。
  4. 优先使用仓库脚本(
    npm run clean
    、
    make clean
    、
    git worktree prune
    ),而非临时的
    rm -rf
    。
  5. 除非用户在看到
    git clean -fdx
    会删除的内容后明确要求执行该命令,否则不得使用。
  6. 未经明确批准,不得强制删除未合并的分支或有未提交变更的 worktree。
  7. 删除完成后,在
    Changed
    下报告已删除的内容和回收的大致空间。
  8. 删除操作单一负责人,不拆分任务。 破坏性命令在父 Agent 中顺序执行;删除步骤不得使用子 Agent 拆分执行。

Default flow (
scan
→ apply)

默认流程(
scan
→ 执行)

  1. Detect stack (git, node, python, rust, docker, turbo, etc.) and ignore rules.
  2. Inventory candidates (see references/targets.md).
  3. Present a table: path | kind | size | risk | command that would clean it.
  4. Ask which buckets to apply (or run the named command if already chosen).
  5. Execute (single-owner; no subagent fan-out for delete steps); re-scan briefly.
  6. Close with three headings:
    Blocked on me
    (any high-risk item still awaiting approval),
    Changed
    (paths removed, approximate space reclaimed),
    Found
    (what remains; Next:
    <next invoke if applicable>
    ).
  1. 检测技术栈(git、node、python、rust、docker、turbo 等)和忽略规则。
  2. 清点待清理候选项(参见 references/targets.md)。
  3. 展示表格:路径 | 类型 | 大小 | 风险 | 对应的清理命令。
  4. 询问要应用哪些清理类别(若已选定则执行指定命令)。
  5. 执行(单一负责人;删除步骤不使用子 Agent 拆分);简要重新扫描。
  6. 以三个标题结束:
    Blocked on me
    (仍待审批的高风险项)、
    Changed
    (已删除的路径、回收的大致空间)、
    Found
    (剩余内容;Next:
    <如适用,填写下一步调用>
    )。

Command notes

命令说明

workspaces
/
worktrees

workspaces
/
worktrees

  • git worktree list --porcelain
    ; prune with
    git worktree prune
    for missing dirs.
  • Remove worktrees whose branch is merged/deleted and working tree is clean — after approval.
  • Drop empty leftover dirs from agent/cloud worktrees when safe.
  • If a worktree is dirty or has an open PR tip, report and skip unless user forces.
  • 执行
    git worktree list --porcelain
    ;对缺失的目录使用
    git worktree prune
    修剪。
  • 经批准后,删除分支已合并/已删除且工作树干净的 worktree。
  • 安全情况下,删除 Agent/云 worktree 残留的空目录。
  • 若 worktree 有未提交变更或对应未关闭的 PR 顶端,需报告并跳过,除非用户强制删除。

artifacts
/
build

artifacts
/
build

  • Remove ignored build outputs that regenerate:
    dist
    ,
    build
    ,
    out
    ,
    site
    ,
    .next
    ,
    .nuxt
    ,
    .output
    ,
    coverage
    ,
    *.tsbuildinfo
    , Storybook static, etc.
  • Respect monorepos: clean packages in scope only.
  • Prefer
    git clean -fdX -- <paths>
    (ignored only) over deleting tracked files.
  • 删除可重新生成的、被忽略的构建输出:
    dist
    、
    build
    、
    out
    、
    site
    、
    .next
    、
    .nuxt
    、
    .output
    、
    coverage
    、
    *.tsbuildinfo
    、Storybook 静态文件等。
  • 遵循 monorepo 结构:仅清理范围内的包。
  • 优先使用
    git clean -fdX -- <paths>
    (仅清理被忽略的文件),而非删除已跟踪的文件。

caches

caches

  • In-repo:
    .turbo
    ,
    .cache
    ,
    .parcel-cache
    ,
    .vite
    ,
    __pycache__
    ,
    .pytest_cache
    ,
    .mypy_cache
    ,
    .ruff_cache
    ,
    .eslintcache
    , native build caches when ignored.
  • Package managers: local
    node_modules/.cache
    ; ask before
    pnpm store prune
    / npm cache verify-delete / global Homebrew caches.
  • Do not delete
    node_modules
    unless the user asked (
    deep
    may propose it, not auto-run).
  • 仓库内缓存:
    .turbo
    、
    .cache
    、
    .parcel-cache
    、
    .vite
    、
    __pycache__
    、
    .pytest_cache
    、
    .mypy_cache
    、
    .ruff_cache
    、
    .eslintcache
    ,以及被忽略的原生构建缓存。
  • 包管理器:本地
    node_modules/.cache
    ;执行
    pnpm store prune
    / npm 缓存验证删除 / 全局 Homebrew 缓存前需询问。
  • 不得删除
    node_modules
    ,除非用户要求(
    deep
    命令可以提议删除,但不会自动执行)。

branches

branches

  • Fetch/prune remotes when network ok:
    git fetch --prune
    .
  • List merged locals and
    gone
    upstreams; delete only after listing.
  • Keep: current branch, default branch, branches the user names as keepers.
  • 网络正常时获取/修剪远程分支:
    git fetch --prune
    。
  • 列出已合并的本地分支和远程已删除的上游分支;仅在列出后才删除。
  • 保留:当前分支、默认分支、用户指定保留的分支。

deep
/
all

deep
/
all

Run scan across all buckets, then apply approved buckets in order: workspaces → artifacts → caches → branches. Stop and ask if any high-risk item appears (Docker system prune, whole
node_modules
, unmerged branch).
对所有类别执行扫描,然后按顺序应用已批准的类别:工作区 → 构建产物 → 缓存 → 分支。若出现任何高风险项(Docker system prune、整个
node_modules
、未合并分支),停止并询问用户。

Related skills

相关技能

  • Agent thrash left junk mid-run:
    agents slap
    first, then
    tidy-up
  • Code structure cleanup (not disk clutter):
    refactor-it
  • Situational awareness before cleaning:
    recon
  • Agent 运行中途产生大量垃圾:先执行
    agents slap
    ,再执行
    tidy-up
  • 代码结构清理(非磁盘杂物):
    refactor-it
  • 清理前的态势感知:
    recon

Grounding

参考依据

This skill’s TTPs are grounded in current engineering baselines (DORA, GitHub Docs, Fowler/Beck, Google SRE & SWE book, OpenTelemetry, OWASP LLM / NIST AI RMF, Diátaxis — see handbook
sources.md
).
Inventory before delete (safe ops hygiene). Reclaim regenerable clutter and merged branches; never confuse tidy with deleting secrets or unmerged work.
Handbook card:
handbook/practices/tidy-up.md
.
本技能的 TTPs 基于当前工程基线(DORA、GitHub Docs、Fowler/Beck、Google SRE 与 SWE 书籍、OpenTelemetry、OWASP LLM / NIST AI RMF、Diátaxis —— 参见手册
sources.md
)。
删除前先清点(安全操作规范)。回收可再生的杂物和已合并分支;绝不能将整理与删除密钥或未合并工作混为一谈。
手册卡片:
handbook/practices/tidy-up.md
。