Skip to content

PR Context Cache

Owner Agent: Raana Consumers: /maigo:review step 1

Why this skill exists

/maigo:review 的第一步是 Raana 抓 PR context。「re-review」(同一個 PR 改完再跑一次) 時這些資料幾乎沒變——重抓只是浪費時間。第一次 fetch 後 cache 到 .maigo/review-rubric.md 開頭的機讀區段,re-review 偵測同 source 且 diff sha 未變 → 直接還原,跳過全部 gh / git 重抓。

怎麼跑

機械流程由 script 代勞(cache 偵測 / 驗證 / fetch / truncate / 寫檔一條龍):

python3 "${CLAUDE_PLUGIN_ROOT:-.}/scripts/pr_context_cache.py" <source> \
    [--rubric .maigo/review-rubric.md] [--base main]
  • <source>:GitHub PR URL / PR 編號(需要 gh CLI)、本地 branch 名、或 commit range
  • 在 maigo repo 自身工作時,直接 python3 scripts/pr_context_cache.py 即可

stdout 第一行是 cache_hit: true|false,其後是 cache 區段全文—— 含 Source / PR number / Title / Body(截 500 行)/ Linked issues / CI status / Diff stat / Diff sha / Full diff(截 2000 行)。

行為摘要

  • cache hit(Source 相同且 diff sha256 未變)→ 印出快取區段,不碰網路(除了重算 sha 的那次 diff)
  • cache miss → 重抓全部欄位,寫回 rubric 開頭 <!-- pr-context-cache:start v1 --><!-- pr-context-cache:end --> 區段 (無檔案 → 建立;無區段 → prepend;有舊區段 → 整段取代)

Fallback

script 跑不起來(找不到路徑、無 gh CLI、git 失敗 → exit 1 + stderr)→ Raana 回退手動抓:依 /maigo:review step 1 列的 gh pr view / gh pr diff / gh pr checks(或 git diff / git log)指令直接 fetch,不寫 cache。

What this skill does NOT cover

  • review-rubric.md 其餘內容(rubric 本身由 Tomori 撰寫)
  • 評估 diff 是否有問題(那是 Soyo 的工作)
  • 決定要 review 哪個 target(caller 傳進來)
  • 非 review 流程的 PR context 抓取(如 /maigo:describe-pr 不走這個 skill)