1k worktree clean

From OneKeyHQ/app-monorepo · View interactive version

1k worktree clean is an AI agent skill from the GitHub repository OneKeyHQ/app-monorepo. Use when the user wants to audit local git worktrees against origin/x, choose by number or A, and decide whether stale worktree directories, already-merged worktrees, or no-delta worktrees can be cleaned up. Triggers on "worktree clean", "worktree 合并到 x", "检测哪些 worktree 已进 x".

How to use this skill

Skill file

Worktree Clean Check

Use this skill to list local worktrees, surface clean or dirty state, and judge whether selected committed branch code has already landed in origin/x by actual code content, not by merge commits alone.

Rules

Step 1: List Local Worktrees

Run:

rtk proxy bash .skillshare/skills/1k-worktree-clean/scripts/1k-worktree-clean.sh list

Then present the choices to the user and append:

请回复编号,例如 `1`、`2,4` 或 `A`。

List output should include, for each worktree:

Step 2: Sync Remote X

Run:

rtk git fetch origin x

If sandboxing blocks the fetch, request approval and rerun it.

Step 3: Check Selected Worktrees

Run one of:

rtk proxy bash .skillshare/skills/1k-worktree-clean/scripts/1k-worktree-clean.sh check 1
rtk proxy bash .skillshare/skills/1k-worktree-clean/scripts/1k-worktree-clean.sh check 1,3
rtk proxy bash .skillshare/skills/1k-worktree-clean/scripts/1k-worktree-clean.sh check A

Step 4: Surface Cleanup Candidates And Ask

Run the matching cleanup-candidate command with the same selection:

rtk proxy bash .skillshare/skills/1k-worktree-clean/scripts/1k-worktree-clean.sh cleanup-candidates 1
rtk proxy bash .skillshare/skills/1k-worktree-clean/scripts/1k-worktree-clean.sh cleanup-candidates 1,3
rtk proxy bash .skillshare/skills/1k-worktree-clean/scripts/1k-worktree-clean.sh cleanup-candidates A

Then summarize:

If there is at least one cleanup candidate, append:

如需继续清理,请回复:
`stale`:只删残留目录
`merged 2,4`:只删这些可移除且 clean 的 worktree
`all`:两类都清理
`no`:不清理

If there are no cleanup candidates, say so explicitly.

Step 5: Delete Only After Confirmation

If the user confirms cleanup:

rtk git worktree remove <path>
rtk proxy rm -rf <path>

How To Interpret The Result

Output Contract

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.