← cd ..

我怎麼讓 Claude Code 記住所有事

·22 min·EN
claude-codeagenticautomationdevtools

第 47 個 Session:我崩潰的那次

晚上十一點,禮拜二。我在 debug 我維護的五個 Go microservice 之一的 403 error。Claude Code 幫我追 DynamoDB logs 追了二十分鐘。進展不錯。

然後它跑了這個:

# Claude 實際跑的命令:
go test -short ./handler/admin/...
# 在: ~/code/api-gateway/     ← 錯的 REPO
# 應該在: ~/code/auth-service/

錯的 repo。錯的 test 命令。這個服務用的是 make test-unit,不是 go test。Claude 在一個完全不相干的 codebase 裡自信滿滿地改檔案,我又多花了三個命令才發現。

我收拾殘局,糾正 Claude,繼續工作。隔天早上,新 session,同一個 bug——Claude 又打開錯的 repo。它不記得昨晚。不記得修正。什麼都不記得。

那一刻我決定了:每一個沒存下來的修正,就是一個你會再犯的修正。

讓我動手的數據

六個月後,我跑了一次所有 Claude Code sessions 的分析。我那時已經造好的 insights tool 可以跑這些數據:

錯誤類別次數例子
錯的 repo 或目錄137從 service-B checkout 改到 service-A 的 code
錯的資料來源48用 staging profile query production table
Scope creep31修 V3 bug 碰到 V1 handler
淺層分析29只看 git log 不看實際 source file

137 次。同一類錯誤,一百三十七次。不是因為 Claude 不好——是因為每個 session 都從零開始。就像那個每天早上都問你「等一下,staging 的 database 是哪一個?」的同事,只是他每天早上都問到永遠。

所以我造了一個系統讓它停。花了六個月迭代,我要把每個檔案都秀給你看。

架構:你的 AI 的神經系統

完整的 setup 長這樣:

~/.claude/
├── settings.json              ← 神經系統(hooks 接線)

├── rules/                     ← Tier 1: 行為護欄
│   ├── agent-behavior.md      #   自動存檔協議、知識路由
│   ├── error-recovery.md      #   反思協議、重試預算
│   ├── grader-pipeline.md     #   每個服務的品質關卡
│   └── workflow-discipline.md #   Worktree-first、branch 命名

├── projects/*/memory/         ← Tier 2: 修正 & 專案事實
│   ├── MEMORY.md              #   索引(每個 session 都載入)
│   └── *.md                   #   個別 memory 檔案

├── skills/                    ← Tier 3: 可重用流程
│   ├── SKILL_INDEX.md         #   觸發條件索引
│   └── */SKILL.md             #   15+ 個 skill 檔案

├── scripts/                   ← 25 個 bash scripts(執行層)
│   ├── guard-*.sh             #   5 個 PreToolUse guards
│   ├── detect-*.sh            #   修正 & 變更偵測
│   ├── post-stop-*.sh         #   Session 結束反思
│   ├── nudge-learn.sh         #   定期學習提醒
│   └── pre-compact-*.sh       #   Context 壓縮復原

└── tools/                     ← 跨 session 搜尋
    ├── recall_index.py        #   JSONL → SQLite FTS5 indexer
    └── recall_search.py       #   BM25 搜尋 + recency boost

每一層載入時機不同:

Tier何時載入存什麼例子
Rules碰到符合 path pattern 的檔案時「永遠/永遠不要」的行為規則"永遠不要 commit 到 master"
Memory每個 session 啟動修正、專案事實、偏好"DynamoDB 前綴是 stg- 不是 staging-"
Skills按需透過 trigger matching有精確命令的多步驟流程"怎麼部署 auth-service 到 staging"

但架構圖解釋不了為什麼這個 work。秘密在 hooks 裡。

神經系統:settings.json

這是最重要的一個檔案。它把 25 個 bash scripts 接到 6 個 lifecycle events。Claude 的每一個動作都經過這個神經系統:

// file: ~/.claude/settings.json(真的那個,現在 production 在跑的)
{
  "hooks": {
    "SessionStart": [{
      "matcher": "",
      "hooks": [{
        "type": "command",
        "command": "python3 ~/.claude/tools/recall_index.py; bash ~/.claude/scripts/detect-external-changes.sh; echo \"Branch: $(git branch --show-current) | Uncommitted: $(git status --short | wc -l) files\""
      }]
    }],
    "UserPromptSubmit": [{
      "matcher": "*",
      "hooks": [
        { "type": "command", "command": "bash ~/.claude/scripts/detect-correction.sh" },
        { "type": "command", "command": "bash ~/.claude/scripts/nudge-learn.sh" }
      ]
    }],
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          { "type": "command", "command": "bash ~/.claude/scripts/guard-force-push.sh" },
          { "type": "command", "command": "bash ~/.claude/scripts/guard-dangerous-commands.sh" },
          { "type": "command", "command": "bash ~/.claude/scripts/guard-aws-env.sh" },
          { "type": "command", "command": "bash ~/.claude/scripts/guard-commit-master.sh" }
        ]
      },
      {
        "matcher": "Edit",
        "hooks": [{ "type": "command", "command": "bash ~/.claude/scripts/guard-worktree.sh" }]
      },
      {
        "matcher": "Write",
        "hooks": [{ "type": "command", "command": "bash ~/.claude/scripts/guard-worktree.sh" }]
      }
    ],
    "PostToolUse": [{
      "matcher": "Edit",
      "hooks": [{ "type": "command", "command": "bash ~/.claude/scripts/post-edit-gofmt.sh" }]
    }],
    "Stop": [{
      "matcher": "",
      "hooks": [
        { "type": "command", "command": "bash ~/.claude/scripts/post-stop-reflect.sh" }
      ]
    }]
  }
}

六個事件。每個 Bash 命令過 4 個 guard。每個檔案編輯過 worktree check。每個 session 結束觸發強制反思。每條使用者訊息掃描修正。

這是神經系統。現在讓我展示器官。

Guard Scripts:牙齒

改變一切的領悟:沒有執行力的 rules 只是建議。 我可以在 markdown 裡寫一整天「永遠不要 commit 到 main」。Claude 在凌晨兩點 context 太長的時候還是會做。

Guard scripts 是 bash hooks,在命令執行前攔截。Exit code 0 = 放行,exit code 2 = 擋住。API 簡單到不行。

17 行 script 救了我的 deploy

#!/bin/bash
# file: ~/.claude/scripts/guard-commit-master.sh
INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
[[ -z "$COMMAND" ]] && exit 0

if echo "$COMMAND" | grep -qE 'git\s+commit'; then
    BRANCH=$(git branch --show-current 2>/dev/null)
    if [[ "$BRANCH" == "master" || "$BRANCH" == "main" ]]; then
        echo "BLOCKED: Cannot commit on $BRANCH. Use a worktree branch."
        echo "  Use EnterWorktree with a ticket name (e.g., PROJ-1234-description)."
        exit 2
    fi
fi

exit 0

17 行。從 stdin 讀 JSON,檢查是不是 git commit,檢查 branch。完事。

六個月來,這個 script 默默擋住了意外的 commit 到 protected branches。每一個都可能觸發 CI pipeline、發 Slack alert、叫醒 on-call(有時候是我)。17 行 bash,靜靜地睡著,等你需要它的那一刻。

Worktree 強制器

更兇的一個——擋住 worktree 外的任何 source code 編輯:

#!/bin/bash
# file: ~/.claude/scripts/guard-worktree.sh
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null)

# 允許編輯 .claude/ config
if [[ "$FILE_PATH" == *"/.claude/"* ]]; then
    exit 0
fi

# 允許 home 目錄的 dotfiles(不在 repo 裡)
if [[ "$FILE_PATH" == "$HOME/"* ]] && [[ "$FILE_PATH" != *"/code/"* ]]; then
    exit 0
fi

# 不在 git repo 裡就放行
if ! git rev-parse --is-inside-work-tree &>/dev/null 2>&1; then
    exit 0
fi

# 檢查是不是在 worktree 裡(git-dir 包含 /worktrees/)
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
if [[ "$GIT_DIR" == *"/worktrees/"* ]]; then
    exit 0
fi

echo "BLOCKED: Not in a worktree. Call EnterWorktree before editing source files."
exit 2

每一個 code 改動都走 worktree → feature branch → PR → merge。零例外。

我最愛的那一個:AWS 環境錯配偵測

#!/bin/bash
# file: ~/.claude/scripts/guard-aws-env.sh
INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
[[ -z "$COMMAND" ]] && exit 0

# 擋住 inline credentials
if echo "$COMMAND" | grep -qE 'AWS_SECRET_ACCESS_KEY='; then
    echo "BLOCKED: Inline AWS credentials detected. Use AWS_PROFILE instead."
    exit 2
fi

# 抓 profile/table prefix 不匹配
if echo "$COMMAND" | grep -qE 'dynamodb.*(scan|query|get-item|put-item)'; then
    if echo "$COMMAND" | grep -qE '(PROFILE=stage|--profile stage)' && \
       echo "$COMMAND" | grep -qE '(prod-|prd-)myapp'; then
        echo "BLOCKED: Stage profile but production table name detected."
        echo "  Stage tables use prefix: stg-myapp-"
        exit 2
    fi
    if echo "$COMMAND" | grep -qE '(PROFILE=prod|--profile prod)' && \
       echo "$COMMAND" | grep -q 'stg-myapp'; then
        echo "BLOCKED: Prod profile but staging table name detected."
        exit 2
    fi
fi

exit 0

這個抓的是讓我做惡夢的那類錯誤:用 staging credentials 去 query production 的 DynamoDB table。Claude 會搞混 prefix(stg- vs stage- vs staging-prd- vs prod- vs production-)——老實說,人也會。這個 guard 不管你的意圖,它讀實際的命令、檢查實際的 prefix。

48 次「錯的資料來源」裡面,這個 guard 至少能擋 30 次。我是在另外 18 次之後才造的。(都是這樣——你在事故之後才造 guard,不是之前。)

自動修正迴圈

Guard 防止錯誤。但真正的 magic 在學習迴圈——三個 script 的 pipeline:偵測修正、nudge 學習、強制反思。

Step 1:偵測修正(中英雙語)

我打的每一條訊息都經過這個:

#!/bin/bash
# file: ~/.claude/scripts/detect-correction.sh
# 每個 prompt 都跑——必須快(<200ms)
INPUT=$(cat)
PROMPT=$(echo "$INPUT" | jq -r '.prompt // ""' 2>/dev/null)
[ -z "$PROMPT" ] && exit 0

# 修正 pattern(中文 + 英文)
if echo "$PROMPT" | grep -qiE \
  '不是這|不要這|不要用|不對|錯了|搞錯|你搞|重來|重做|別這樣|wrong|not what I|don.t do that|that.s wrong|stop doing|no[,.].*instead|no[,.].*use'; then

  # 建 marker 讓 Stop hook 知道有修正
  touch ~/.claude/sessions/.correction-detected

  cat << 'JSONEOF'
{"additionalContext": "User correction detected. MANDATORY: After fixing this, save the correction as a feedback memory BEFORE continuing. Include Why and How-to-apply."}
JSONEOF
fi

exit 0

當我說「不對」或「don't do that」或「no, use X instead」——script 偵測到,丟一個 marker file,注入系統訊息叫 Claude 立刻存修正。不是 session 結束時。不是想到的時候。現在。

雙語 pattern 很關鍵。我生氣的時候用中文想(「你搞錯了」比 "you got it wrong" 出來更快),script 兩邊都抓。

Step 2:定期 nudge 學習

每 15 個 prompt:

#!/bin/bash
# file: ~/.claude/scripts/nudge-learn.sh
COUNTER_FILE="$HOME/.claude/sessions/.prompt-counter"
NUDGE_INTERVAL=15

if [[ -f "$COUNTER_FILE" ]]; then
    COUNT=$(cat "$COUNTER_FILE" 2>/dev/null | tr -d ' \n')
    COUNT=$((COUNT + 1))
else
    COUNT=1
fi
echo "$COUNT" > "$COUNTER_FILE"

if [[ $((COUNT % NUDGE_INTERVAL)) -eq 0 ]]; then
    cat << 'JSONEOF'
{"additionalContext": "LEARNING REVIEW (periodic). Check:\n- Stuck? Run /recall — a past session may have the answer.\n- User corrected you? Save to memory.\n- Complex task solved (5+ tool calls)? Save as skill.\nOnly act if something is genuinely worth saving."}
JSONEOF
fi

exit 0

靈感來自 Hermes agent 的 periodic self-reflection 研究。每 15 個 prompt,Claude 收到一個 nudge:「你有學到值得存的東西嗎?」大部分時候答案是沒有。但當答案是——Claude 剛花了 8 個 tool calls 搞清楚 deploy 流程——那個 nudge 就把一次性的發現變成永久的 skill。

(我一開始設每 5 個 prompt。受不了。Claude 會在想事情想到一半的時候跳出來認真地存「user 偏好 tabs 不偏好 spaces」。15 是甜蜜點。)

Step 3:不存不准走

核選項。Session 結束時:

#!/bin/bash
# file: ~/.claude/scripts/post-stop-reflect.sh(簡化版)
INPUT=$(cat)

# 自我閘門:每個 session 只擋一次
GATE_FILE="$HOME/.claude/sessions/.stop-reflected"
if [[ -f "$GATE_FILE" ]]; then
    echo '{"decision": "approve"}'
    exit 0
fi

CORRECTIONS_DETECTED=false
if [[ -f ~/.claude/sessions/.correction-detected ]]; then
    CORRECTIONS_DETECTED=true
    rm -f ~/.claude/sessions/.correction-detected
fi

SUBSTANTIAL=false
TRANSCRIPT=$(echo "$INPUT" | jq -r '.transcript_path // ""' 2>/dev/null)
if [[ -n "$TRANSCRIPT" ]] && [[ -f "$TRANSCRIPT" ]]; then
    SIZE=$(wc -c < "$TRANSCRIPT" 2>/dev/null | tr -d ' ')
    [[ "$SIZE" -gt 30000 ]] && SUBSTANTIAL=true
fi

if [[ "$SUBSTANTIAL" == "true" ]] || [[ "$CORRECTIONS_DETECTED" == "true" ]]; then
    touch "$GATE_FILE"  # 只擋一次
    MSG="MANDATORY SESSION REFLECTION:\n\n"
    if [[ "$CORRECTIONS_DETECTED" == "true" ]]; then
        MSG="${MSG}CORRECTIONS DETECTED — save each as feedback memory NOW.\n\n"
    fi
    MSG="${MSG}1) Reusable patterns? → /learn\n"
    MSG="${MSG}2) Mistakes to prevent? → feedback memory\n"
    MSG="${MSG}3) New user preferences? → user memory\n"

    MSG_ESCAPED=$(echo -e "$MSG" | python3 -c 'import sys,json; print(json.dumps(sys.stdin.read()))')
    echo "{\"decision\": \"block\", \"reason\": \"Save learnings first\", \"systemMessage\": $MSG_ESCAPED}"
else
    echo '{"decision": "approve"}'
fi

你在 session 中糾正了 Claude,session 要結束的時候,這個 hook 擋住出口。不存就不准走。自我閘門(.stop-reflected)確保只擋一次——Claude 反思完就可以正常退出。

這是讓所有東西複利的關鍵。沒有它,修正蒸發。有了它,每一個修正都變成永久記憶。

Tier 1: 在你需要時載入的 Rules

Rules 住在 ~/.claude/rules/,用 path-scoped frontmatter——只在你碰到符合的檔案時啟動:

<!-- file: ~/.claude/rules/agent-behavior.md -->
---
paths:
  - "src/**"
  - "cmd/**"
  - "handler/**"
  - "service/**"
---

## Auto-Save(強制——不是可選的)

不要問 permission。不要跳過。不要推遲到 session 結束。

### 使用者修正 — 立刻存
1. 修好問題
2. **立刻**存修正為 feedback
3. 分類:行為 → rules/、專案事實 → memory/、流程 → skills/
4. 包含 **Why****How to apply**

關鍵字:「不要問 permission」。修正就是強制自動存檔。每次我說「不是那樣」,Claude 建一個 memory entry,包含修正、原因、何時適用。detect-correction script 注入提醒。Stop hook 阻止不存就走。三層 enforcement 保護一個行為。

Reflexion protocol 加了重試預算:

## 任何 Failure,停下來反思

1. **Recall**: "我看過這個嗎?" → 跑 /recall
2. **Diagnose**: "Root cause,不是 symptom。"
3. **Plan**: "什麼改動會修好這個?"
4. **Check**: "我是不是在重複同樣的事期待不同結果?"
5. **Learn**: "值得用 /learn 記下來嗎?"

## 重試預算
- 同一個方法最多 **3 次**。然後換一個。
- **2 種方法都失敗** → 問 user。
- **同一個 failure 出現兩次** → 自動存 feedback memory。

三次然後換。兩次換然後問。同一個 failure 兩次就自動存。沒有無窮迴圈。

Tier 2: 會複利的 Memory

Memory 在 session 開始時載入,每個有結構化的 frontmatter:

<!-- file: memory/blog-quality-feedback.md -->
---
name: blog-quality-feedback
description: 文章必須教,不是摘要。深度不可妥協。
type: feedback
---

Conrad 退回了第一批 blog 文章,說品質太低。

具體問題:
- 太短(4-5 分鐘閱讀)——好的技術文章要 10-20 分鐘
- 太淺——讀起來像 README,不像教學文
- 沒有可行動的 takeaway
- Pseudo-code 不是真的 code

**Why:** Conrad 的品牌是「用深度教學的後端工程師」。淺的文章毀掉信譽。

**How to apply:** 每篇文章發布前必須通過 BLOG_QUALITY.md。

結構:發生什麼為什麼重要怎麼用。「Why」區分了合規和判斷。「不要寫短文」給你合規。「淺的文章毀掉在資深工程師心中的信譽」給你一個會判斷 edge case 的 AI。

Tier 3: 取代 Prompting 的 Skills

確定性的流程:

<!-- file: ~/.claude/skills/deploy-staging/SKILL.md -->
---
name: deploy-staging
description: Build 完成後觸發 staging deployment
allowed-tools: Bash(gh *), Bash(aws *)
model: sonnet
---

# Step 1: 等 Build and Publish 完成
gh run list --workflow "Build and Publish" --branch master --limit 1 \
  --repo my-org/api-gateway \
  --json databaseId,status,conclusion,headSha

# Step 2: 觸發 staging deployment
gh workflow run "Deploy to staging" \
  --repo my-org/api-gateway \
  -f environment=stg

# Step 3: 監控 deployment pipeline
aws codepipeline get-pipeline-state \
  --name myapp-staging-pipeline \
  --profile stage --region us-west-2

/deploy-staging → 同樣的命令、同樣的 repo、同樣的 flags。每一次。15+ 個 skills 涵蓋 deploy、debugging、PR 工作流。Skill 打敗 prompt 因為它是確定性的、可維護的、而且編碼了部落知識。

跨 Session Recall:200ms 搜尋 197 個 Sessions

複利的核心。每個 session transcript 切成 chunks,索引進 SQLite FTS5:

# file: ~/.claude/tools/recall_index.py
CHUNK_TARGET_CHARS = 3000
CHUNK_OVERLAP_CHARS = 500

def chunk_turns(turns: list[dict], target_chars=CHUNK_TARGET_CHARS):
    """把對話切成可搜尋的 chunks。"""
    chunks = []
    current_chunk = []
    current_chars = 0

    for turn in turns:
        text = f"{turn['role'].upper()}: {turn['text']}"

        if current_chars + len(text) > target_chars and current_chunk:
            chunk_text = "\n\n".join(current_chunk)
            chunks.append({
                "content": chunk_text,
                "has_code": bool(re.search(r"```|func |def |class ", chunk_text)),
                "has_error": bool(re.search(
                    r"error|panic|FAIL|nil pointer", chunk_text, re.IGNORECASE
                )),
            })
            # 保留最後一筆作為 overlap
            current_chunk = [current_chunk[-1]] if current_chunk else []
            current_chars = len(current_chunk[0]) if current_chunk else 0

        current_chunk.append(text)
        current_chars += len(text)

    return chunks

搜尋結合 BM25 relevance 和指數 recency decay:

# file: ~/.claude/tools/recall_search.py
def recency_boost(session_date_str: str, half_life_days: float = 30.0) -> float:
    """30 天前的 session 權重 50%。最近的工作更重要。"""
    session_date = datetime.fromisoformat(session_date_str)
    age_days = (datetime.now() - session_date).total_seconds() / 86400
    return 2 ** (-age_days / half_life_days)

# 合計: score = bm25_score * (0.7 + 0.3 * recency)

資料庫:197 sessions · 4,374 chunks · 57.5 MB 可搜尋。

/recall "admin 403 permission denied" → 三週前的 root cause,200ms。不用重新調查。個人版 Stack Overflow,每一個答案都是在你自己的 production 環境驗證過的。

踩的坑(當然有踩)

造這個 harness 本身就是六個月的 debug 冒險。

擋住自己的 Guard。 Worktree guard 一開始擋住 worktree 外的所有檔案——包括 .claude/ config。我花了 20 分鐘搞不懂為什麼 Claude 不能存 memory。/.claude/ 例外?在我把自己鎖在學習系統外面之後加的。

受不了的 Nudge。 nudge-learn.sh 一開始設每 5 個 prompt。Claude 會在想事情到一半的時候跳出來認真地存「user 偏好 tabs 不偏好 spaces」。5 的時候每個小觀察都變 skill。15 是甜蜜點。

Memory 爆量。 第一個月就碰到 10 個檔案的預算。Stop hook 開始唸我,很煩——直到我意識到預算就是 feature。強制合併讓 memory 保持 atomic,不會變成過期事實的墳場。

Stop Hook 無窮迴圈。 早期版本:擋住 → Claude「反思」但沒真的存東西 → 試著停 → 又被擋 → 重複。自我閘門 marker file 是修法:擋一次,之後永遠放行。讓人類判斷反思夠不夠好。

57 MB 而且還在漲。 Recall 資料庫每天長 ~300KB。照這速度一年會到 200MB。我需要 pruning 策略。我還沒有。(如果你造了一個,告訴我。)

前後對比

六個月、197 個 sessions 之後:

指標之前(sessions 1–50)之後(sessions 150–197)
每 session 錯的 repo/目錄~2.7 次~0.1(guard 擋掉其餘的)
Session 啟動設定時間5–10 分鐘 context 設定0 分鐘(memory 自動載入)
「我已經跟你說過了」修正~4 次/session~0.5 次/session
重新調查已解的問題每次都完整 re-debug/recall → 200ms
Deploy 流程手動組命令/deploy-staging 精確命令

系統不完美。Claude 偶爾還是會給我驚喜——對 rules 的創意詮釋。但主導一切的那類錯誤——重複的、可預防的、「我昨天跟你說過了」——基本上消失了。

自己設起來(17 分鐘)

不需要 25 個 scripts。三個檔案就好。

檔案 1:Guard Script(5 分鐘)

#!/bin/bash
# file: ~/.claude/scripts/guard-main.sh
INPUT=$(cat)
CMD=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
[[ -z "$CMD" ]] && exit 0

if echo "$CMD" | grep -qE 'git\s+(commit|push)'; then
    BRANCH=$(git branch --show-current 2>/dev/null)
    if [[ "$BRANCH" == "main" || "$BRANCH" == "master" ]]; then
        echo "BLOCKED: Use a feature branch, not $BRANCH"
        exit 2
    fi
fi
exit 0

檔案 2:在 settings.json 裡接線(2 分鐘)

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "hooks": [{ "type": "command", "command": "bash ~/.claude/scripts/guard-main.sh" }]
    }]
  }
}

檔案 3:你的第一個 Memory(10 分鐘)

<!-- file: ~/.claude/projects/<your-project>/memory/corrections.md -->
---
name: corrections
description: Claude 搞錯需要記住的事
type: feedback
---

## 這個 repo 用 pnpm 不是 npm
**Why:** npm 在我們的 monorepo 造成 lockfile 衝突
**How to apply:** install/add/remove 永遠用 pnpm

## API prefix 是 /api/v2/,不是 /api/v1/
**Why:** v1 在 2024 就 deprecated 了,舊 docs 裡還有
**How to apply:** 所有新 endpoint 和測試 URL 用 /api/v2/

三個檔案。一週內你會感受到差異。

然後迭代

每次你發現自己在糾正 AI,問一個問題:「我怎麼確保這永遠不再發生?」

  • 行為錯誤 → 加一條 rule
  • 錯的事實 → 存一個 memory
  • 重複流程 → 寫一個 skill
  • 危險命令 → 掛一個 guard

一個月後,你的 AI pair programmer 比新進員工更了解你的 codebase。三個月後,比 wiki 更了解你的 deploy pipeline。六個月和 197 個 sessions 之後,它不會再犯同一個錯 137 次了。

它會犯零次。