By bryantchi
Token-efficiency rules, skill routing, enforcement hooks, and cross-platform AGENTS.md generation for sustainable long-term Claude Code use.
Run the memory + routing health audit; report stale entries, duplicate slugs, missing/unrouted skills
Generate CLAUDE.md / AGENTS.md / GEMINI.md from claude-sustain rules into the current project
Show claude-sustain's active rules, skill routing, memory backend, and (when available) session token tally
Opt-in pull of latest claude-sustain rules from GitHub; user reviews diff and writes to overrides.json (plugin dir is never modified)
Walk through stale or conflicting memory entries and routing-table drift. Use when the user runs /sustain:audit, asks "is my memory store healthy?", or before a major release of personal rules.
Search persistent memory across mempalace MCP, claude-mem MCP, and the structured filesystem fallback. Use when the user asks "how did we solve X before?", "what did we decide about Y?", or anything that implies recalling prior-conversation context.
Decide whether and where to persist a learning. Use at phase boundaries when something seems worth long-term memory — a rule, a non-obvious decision, an external resource, or a project-state change. Picks the right wing (feedback / project / reference / user) and routes through the user's active memory backend.
Run the 6-question phase-end checklist when a logical phase completes (after a feature, before a context switch, or when the Stop hook prompts you). Use to surface skipped Iron Rules, missed memory writes, and overdue /compact opportunities.
Interpret session token statistics and recommend the next move — /compact, delegate to a subagent, switch to a smaller model, or stop and persist learnings. Use after `/sustain:status`, when the session feels long, or when context-window pressure is showing up in degraded responses.
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
給 Claude Code 用的 Token 節省規則 + Skill 路由 + 自動提醒 + 記憶子系統 + 跨平台 AGENTS.md 產生器。讓 AI 用得久、用得省、用得好。
長期跟 AI 配合寫程式,會發現自己一直在重複交代同一件事:「不要讀整個檔案」「subagent 要寫字數上限」「重複改用 perl 不要一個個編輯」⋯這些規則寫進 CLAUDE.md 會被忽略,貼在每次對話又煩。
更深的問題是:
claude-sustain 是為了解決這四件事做的 plugin。
裝完 plugin 之後預設行為跟 v0.5 一樣(不開硬閘、不推訊息)。三件新功能都是 opt-in。
1. Lookup 自動建議便宜模型(已開、零設定)
你叫 Claude「找出 src/ 下所有 console.log」→ PreToolUse 看到是查找型 prompt → systemMessage 提醒 Claude 加 model: "haiku"。
2. Iron-2 hard-gate(subagent 沒寫字數上限就擋)
cp examples/strict.json ~/.claude/sustain/strict.json
# 編輯把 ironGate 改成 true
之後 Task 漏掉「≤ 800 字」「不受字數限制」就會被 Claude Code 直接拒絕。已預列 OMC / superpowers 常見模板的 bypass pattern。
3. 長 session 跑完推訊息
cp examples/notify.json ~/.claude/sustain/notify.json
# 把 webhook URL 換成你的 Slack/Discord/Telegram
session token 超過 100k 或時間超過 10 分鐘就推。網路掛掉永不擋 Stop。
/sustain:status 隨時查目前哪些開、哪些關。
規則層(rules/spec.json 是唯一真相)
強制層(hooks 自動提醒)
SessionStart 注入規則 primer + 偵測 memory backend + 過濾 skill routingUserPromptSubmit 偵測「逐個 / 仔細 / 全部 / thoroughly」等鐵律 1 觸發詞PreToolUse 攔截 Task subagent 沒寫字數上限的呼叫Stop 印階段六問 + token 統計 + 寫 telemetry log記憶層(多 backend 抽象)
memory-write-router / memory-search-bridge / audit-memory觀測層
~/.claude/sustain/telemetry/<日期>.jsonl/sustain:status 顯示當下 + 7 日移動平均token-budget-coach skill 解讀數字、建議 /compact / 切 subagent / 換模型自我修護
/sustain:audit 掃 memory(>90 天沒動的 / slug 太相近的重複 / 抽出 URL 給你檢查)+ skill routing(spec 列了沒裝的 / 裝了沒列的)跨平台
spec.json 產出 CLAUDE.md / AGENTS.md / GEMINI.md/sustain:export 寫進任何專案目錄AGENTS.md symlink 到 CLAUDE.md,讓 Codex CLI / Gemini CLI 等吃 AGENTS.md 的工具直接能讀/plugin marketplace add BryantChi/claude-sustain
/plugin install claude-sustain@claude-sustain
完整重啟 Claude Code(/clear 不夠 — 要 CLI 退出再重開)。新 session 應該看到:
[claude-sustain v0.6.1] active — 4 Iron Rules + 6-question phase check + N/M skill routes · memory: <backend> 一行從本機 clone 安裝:
/plugin marketplace add /path/to/claude-sustain
/plugin install claude-sustain@claude-sustain
| 指令 | 用途 |
|---|---|
/sustain:status | 看當前規則、routing 涵蓋、memory backend、session token、7 日移動平均、建議下一步 |
/sustain:audit | Memory + routing 健診。只報告、永不自動刪 |
/sustain:export | 把 CLAUDE.md / AGENTS.md / GEMINI.md 寫進指定目錄 |
/sustain:update-rules | 從 GitHub 拉最新 spec、diff 給你看、寫進 ~/.claude/sustain/overrides.json(永不動 plugin 目錄) |
| Skill | 觸發場景 |
|---|---|
token-rules-primer | 重新建立鐵律 + R1–R5 的記憶 |
phase-self-check | 走完 6 問 checklist |
memory-write-router | 決定要不要存、存哪 |
memory-search-bridge | 「以前怎麼做的」回想 |
token-budget-coach | 解讀 token 統計、建議下一步 |
audit-memory | 走完 audit 報告的可行動項目 |
編輯 ~/.claude/sustain/overrides.json(你自己建立,plugin 永遠不會動它)。內容是 spec.json 的子集,依 id 對齊合併:改一條規則不用重列整張表。
範例 — 客製化 R1.3 的描述:
{
"details": {
"R1": {
"rules": [
{ "id": "R1.3", "text": "檔案 > 500 行:只讀相關段落,別整檔。" }
]
}
}
}
升級 plugin(/plugin update 或 /sustain:update-rules)時,bundled 規則會更新但你的 overrides 不會被蓋掉。
預設 v0.5 warn-only 行為不變。要把 Iron-2 升級成擋下來的硬閘,建立 ~/.claude/sustain/strict.json:
{
"ironGate": true,
"bypassPatterns": ["#bypass-iron2"]
}
開啟後,Task prompt 缺字數上限或 escape clause 會直接被 Claude Code 擋掉(permissionDecision=deny)。bypassPatterns 給內部信任模板留逃生口。
範例設定:examples/strict.json — 已預先列出 oh-my-claudecode / superpowers Explore agent 等常見模板的 pattern。
⚠️ 與 oh-my-claudecode 共存:先保持
ironGate: false跑 1 週收 telemetry,看哪些 OMC dispatch 被警告,再把它們加進bypassPatterns,最後才開硬閘。直接開會把 OMC 大半功能擋掉。
長 session 跑完想被推訊息?建立 ~/.claude/sustain/notify.json:
npx claudepluginhub bryantchi/claude-sustain --plugin claude-sustainConsult multiple AI coding agents (Gemini, OpenAI, Grok, Perplexity, plus codex and antigravity CLIs when installed) to get diverse perspectives on coding problems
Comprehensive skill pack with 66 specialized skills for full-stack developers: 12 language experts (Python, TypeScript, Go, Rust, C++, Swift, Kotlin, C#, PHP, Java, SQL, JavaScript), 10 backend frameworks, 6 frontend/mobile, plus infrastructure, DevOps, security, and testing. Features progressive disclosure architecture for 50% faster loading.
Upstash Context7 MCP server for up-to-date documentation lookup. Pull version-specific documentation and code examples directly from source repositories into your LLM context.
Comprehensive startup business analysis with market sizing (TAM/SAM/SOM), financial modeling, team planning, and strategic research
v9.44.1 — Patch release for Gemini environment/version detection and qwen auth gating. Run /octo:setup.
Permanent coding companion for Claude Code — survives any update. MCP-based terminal pet with ASCII art, stats, reactions, and personality.