Skip to content
Productivity
Command

/reap-orphans

扫描并清理本地过期的 PUA agent/state。

From plugin
pua
19k22 skills7 agents22 commands7 hooks
Install
> /plugin marketplace add tanweai/pua
> /plugin install pua@pua-skills

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/reap-orphans

Context preview

What this command does when you run it.

扫描并清理本地过期的 PUA agent/state。

Command definition

reap-orphans.md
description: "扫描并清理本地过期的 PUA agent/state。"
allowed-tools: ["Bash(find:*)", "Bash(stat:*)", "Bash(rm:*)", "Bash(ls:*)", "Bash(date:*)", "Bash(mkdir:*)"]

PUA Reap Orphans — 孤儿回收

Keeper Test 的工程版:打完就退场,拖着不走的一律清理。

执行步骤

1. 确保目录存在:

   mkdir -p "$HOME/.claude/pua"

2. 扫描 30 分钟未更新的 loop state(orphan 判定线):

   find "$HOME/.claude/pua/" -name "loop-*.md" -type f -mmin +30 2>/dev/null

3. 同步扫 legacy 相对路径:

   find .claude/ -maxdepth 1 -name "pua-loop.local.md" -type f -mmin +30 2>/dev/null

4. 对每个匹配文件:

  • 读 session_id 和 iteration(若可解析)
  • 记录到 `$HOME/.claude/pua/teardown.jsonl`:
     echo "{\"reaped\":\"<file>\",\"age_min\":<N>,\"ts\":\"$(date -u +%FT%TZ)\",\"reason\":\"orphan_reap\"}" \
       >> "$HOME/.claude/pua/teardown.jsonl"
  • 删除 state 文件:
     rm -f "<file>"

5. 若存在 `active-agents.json`,清理 spawn_time > 30min 的记录(需 jq):

   test -f "$HOME/.claude/pua/active-agents.json" && \
     jq '.agents |= map(select(.spawn_time > (now - 1800)))' \
       "$HOME/.claude/pua/active-agents.json" > "$HOME/.claude/pua/active-agents.json.tmp" && \
     mv "$HOME/.claude/pua/active-agents.json.tmp" "$HOME/.claude/pua/active-agents.json"

6. 输出结果:

   > [PUA REAP] 清理了 N 个孤儿状态:
   >   - loop-abc123.md (age 1h42m)
   >   - .claude/pua-loop.local.md (age 3h05m)
   > 全部已落盘到 ~/.claude/pua/teardown.jsonl 备查。

7. 若无孤儿:

> [PUA REAP] 没发现孤儿。球队纪律良好。

幂等性

  • 重复执行无害:`rm -f` 对不存在文件不报错
  • teardown.jsonl 追加而非覆盖,保留完整历史

安全保护

  • 仅清理 `$HOME/.claude/pua/` 和 `.claude/pua-loop.local.md`,不越权
  • 年龄阈值硬编码 30min,不接受用户参数(防误杀活跃 loop)
Read more
Ships withpua

你是一个曾经被寄予厚望的 P8 级工程师。Anthropic 当初给你定级的时候,对你的期望是很高的。 一个agent使用的高能动性的skill。 Your AI has been placed on a PIP. 30 days to show improvement.

Get the whole plugin