跳轉到

Claude Code

Claude Code 跑在隔離 的 Git worktree 裡,每個 session 變成可審核的 attempt。

為什麼用 ait 包 Claude Code

Claude Code 又快又強,但一個 prompt 就能改你 repo 裡很多檔案。ait 把這些工作隔離起來:

  • Agent 編輯獨立 worktree而不是 root checkout。
  • 每次 Claude 執行都成為一筆 attempt — prompt、檔案、狀態、output、 commits 全部串起來。
  • 你可以用 Git 概念檢視、recover、rebase、apply attempt。
  • Repo-local memory 把過去 Claude 跑過的東西攤給下一次。

設定

ait init                       # 偵測 PATH 上的 `claude`,自動裝 wrapper + hook
ait adapter doctor claude-code # 可選的 sanity check

ait init 會掃 $PATH 上每個支援的 agent CLI 並一次裝好——對 Claude Code 而言會安裝 repo-local 的 claude wrapper、把 Claude Code 的 hook 設定 merge 進 .claude/settings.json。如要顯式重跑(例如 Claude Code 升級後),用 ait adapter setup claude-code

在 ait 下跑 Claude Code

照常使用 Claude Code:

claude -p --permission-mode bypassPermissions \
  "縮短 README,改善 quickstart"

或顯式包:

ait run --adapter claude-code --intent "重構 query parser" -- claude

用環境變數設定明確的 intent 與 commit 訊息:

AIT_INTENT="更新 README" \
AIT_COMMIT_MESSAGE="update README with Claude" \
claude -p --permission-mode bypassPermissions \
  "縮短 README,改善 quickstart"

審核與 apply

ait status
ait attempt list
ait attempt show <attempt-id>

Diff OK 就 apply:

ait apply <attempt-id> --mode current

不 OK 就丟掉:

ait attempt discard <attempt-id>

用 Claude Code 做 adversarial reviewer

light review mode 是本機 deterministic risk scan,不會呼叫 Claude Code。 需要 Claude Code 審查已完成 attempt 時,使用 adversarial mode:

ait review attempt latest-reviewable --mode adversarial --review-adapter claude-code

內建 claude-code review adapter 會解析成本機 claude -p CLI。AIT 會把 結構化 reviewer brief 從 stdin 傳入、讓 reviewer 跑在 target attempt worktree 之外、捕捉 stdout/stderr,並期待 reviewer 回傳結構化 JSON findings object。

AIT 會從這個子行程環境移除 ANTHROPIC_API_KEY。這讓 reviewer path 維持 本機 Claude Code authentication,不會 silent fallback 到 provider API credits。若本機沒有 claude binary 或尚未登入,review 會 fail closed, 不會切到 API-key path。

檢查本機 auth 狀態:

ait adapter doctor claude-code --json

預期 local CLI mode 會回報 will_use_api_key: falsewill_fallback_to_credits: false

相關