plan-archive

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/plan-archive — 歸檔已完成的 Plan

/plan-archive — Archive Completed Plans

plans/active/
中已完成的 plan 移至
plans/completed/
,並補上驗證結果。
ECC 資源感知: 若有可用的 code-reviewer agent,可輔助驗證 plan 中的實作結果。

Move completed plans in
plans/active/
to
plans/completed/
and add verification results.
ECC Resource Awareness: If a usable code-reviewer agent is available, it can assist in verifying the implementation results in the plan.

Step 1:找出要歸檔的 Plan

Step 1: Locate the Plan to Archive

如果有傳入引數(檔名或路徑),直接使用。 否則,列出
plans/active/
下的所有
.md
bash
ls plans/active/*.md 2>/dev/null
若有多個,依 mtime 排序,問使用者選哪一個。 若只有一個,直接用。 若目錄不存在或空,輸出「找不到待歸檔的 plan」並結束。

If an argument (filename or path) is passed in, use it directly. Otherwise, list all
.md
files under
plans/active/
:
bash
ls plans/active/*.md 2>/dev/null
If there are multiple files, sort them by mtime and ask the user which one to select. If there is only one, use it directly. If the directory does not exist or is empty, output "No plan to be archived found" and exit.

Step 2:讀取 Plan 內容

Step 2: Read Plan Content

讀取目標 plan 檔案,確認:
  • 是否有
    ## Phase
    ## Step
    段落(實作步驟)
  • 是否有
    ## 驗證
    ## Verification
    段落
  • 是否有
    ## Industry & Standards Reference
    段落

Read the target plan file and confirm:
  • Whether there is a
    ## Phase
    or
    ## Step
    section (implementation steps)
  • Whether there is a
    ## 驗證
    or
    ## Verification
    section
  • Whether there is a
    ## Industry & Standards Reference
    section

Step 3:補充驗證結果

Step 3: Supplement Verification Results

在 plan 檔案頂部(緊接
---
frontmatter 後)加上:
markdown
**狀態:✅ 完成(YYYY-MM-DD)**
再追加或更新
## 驗證結果
段落,填入:
  • 測試通過數(若有)
  • 實際執行結果(對照 plan 中的「預期」)
  • 業界/學術參照落實情況 — 對照 plan 的 Industry & Standards Reference,確認各項參照是否已實際應用
  • 任何偏差或補充說明

Add the following at the top of the plan file (right after the
---
frontmatter):
markdown
**Status: ✅ Completed (YYYY-MM-DD)**
Then add or update the
## Verification Results
section, fill in:
  • Number of passed tests (if any)
  • Actual execution results (compared with "expectations" in the plan)
  • Implementation status of industry/academic references — compare with the Industry & Standards Reference of the plan to confirm whether each reference has been actually applied
  • Any deviations or supplementary explanations

Step 4:移動檔案

Step 4: Move the File

bash
mkdir -p plans/completed
mv plans/active/<filename>.md plans/completed/<filename>.md
確認移動成功後輸出:
✅ 已歸檔:plans/completed/<filename>.md

bash
mkdir -p plans/completed
mv plans/active/<filename>.md plans/completed/<filename>.md
After confirming the move is successful, output:
✅ Archived: plans/completed/<filename>.md

自動化(Hook 設定)

Automation (Hook Configuration)

若希望每次
ExitPlanMode
自動將 plan 存至
plans/active/
, 可設定 PostToolUse hook:
If you want to automatically save the plan to
plans/active/
after each
ExitPlanMode
, you can configure the PostToolUse hook:

1. 建立 hook script

1. Create the hook script

~/.claude/hooks/save-plan-on-exit.sh
bash
#!/bin/bash
~/.claude/hooks/save-plan-on-exit.sh
:
bash
#!/bin/bash

PostToolUse hook for ExitPlanMode

PostToolUse hook for ExitPlanMode

Reads JSON from stdin, copies plan file to project's plans/active/

Reads JSON from stdin, copies plan file to project's plans/active/

INPUT=$(cat)
INPUT=$(cat)

Extract plan_file path from tool response

Extract plan_file path from tool response

PLAN_FILE=$(echo "$INPUT" | python3 -c " import sys, json try: d = json.load(sys.stdin) # ExitPlanMode tool_response may contain the plan file path resp = d.get('tool_response', d) print(resp.get('plan_file', resp.get('planFile', ''))) except Exception: print('') " 2>/dev/null)
if [ -z "$PLAN_FILE" ] || [ ! -f "$PLAN_FILE" ]; then exit 0 fi
PLAN_FILE=$(echo "$INPUT" | python3 -c " import sys, json try: d = json.load(sys.stdin) # ExitPlanMode tool_response may contain the plan file path resp = d.get('tool_response', d) print(resp.get('plan_file', resp.get('planFile', ''))) except Exception: print('') " 2>/dev/null)
if [ -z "$PLAN_FILE" ] || [ ! -f "$PLAN_FILE" ]; then exit 0 fi

Only act if we're inside a git repo with a plans/ directory pattern

Only act if we're inside a git repo with a plans/ directory pattern

if [ ! -f "$(pwd)/.git/HEAD" ] && [ ! -d "$(pwd)/.git" ]; then exit 0 fi
DEST_DIR="$(pwd)/plans/active" mkdir -p "$DEST_DIR"
SLUG=$(basename "$PLAN_FILE") cp "$PLAN_FILE" "$DEST_DIR/$SLUG" echo "[plan-archive] Plan saved to plans/active/$SLUG" >&2

```bash
chmod +x ~/.claude/hooks/save-plan-on-exit.sh
if [ ! -f "$(pwd)/.git/HEAD" ] && [ ! -d "$(pwd)/.git" ]; then exit 0 fi
DEST_DIR="$(pwd)/plans/active" mkdir -p "$DEST_DIR"
SLUG=$(basename "$PLAN_FILE") cp "$PLAN_FILE" "$DEST_DIR/$SLUG" echo "[plan-archive] Plan saved to plans/active/$SLUG" >&2

```bash
chmod +x ~/.claude/hooks/save-plan-on-exit.sh

2. 設定
~/.claude/settings.json

2. Configure
~/.claude/settings.json

json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "ExitPlanMode",
        "hooks": [
          {
            "type": "command",
            "command": "bash ~/.claude/hooks/save-plan-on-exit.sh"
          }
        ]
      }
    ]
  }
}
json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "ExitPlanMode",
        "hooks": [
          {
            "type": "command",
            "command": "bash ~/.claude/hooks/save-plan-on-exit.sh"
          }
        ]
      }
    ]
  }
}

3. Rule(搭配使用)

3. Rule (for combined use)

在專案
CLAUDE.md
加入,確保 Claude 在實作完成後主動呼叫
/plan-archive
markdown
undefined
Add to the project's
CLAUDE.md
to ensure that Claude actively calls
/plan-archive
after the implementation is completed:
markdown
undefined

Commit 前知識沉澱清單

Knowledge Precipitation Checklist Before Commit

  1. 歸檔 plan — 若本次工作有對應的 plan,實作完成後執行
    /plan-archive
    plans/active/<name>.md
    移至
    plans/completed/
    ,補上驗證結果

---
  1. Archive plan — If there is a corresponding plan for this work, execute
    /plan-archive
    after the implementation is completed Move
    plans/active/<name>.md
    to
    plans/completed/
    , add verification results

---

目錄規範

Directory Specification

plans/
├── active/       # 進行中(Hook 自動存入 / /plan 手動建立)
├── completed/    # 已實作完成(/plan-archive 歸檔)
└── archived/     # 長期封存(不再參考的舊 plan)
plans/
├── active/       # In progress (automatically saved by Hook / manually created via /plan)
├── completed/    # Implemented and completed (archived via /plan-archive)
└── archived/     # Long-term archived (old plans no longer referenced)