ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 cskwork

token-weather

在提示列上方繪製單行 context window 預測,顯示已使用 token、12 回合迷你折線圖與上一回合的 token 增量。

cskwork@cskwork

cskwork/claude-code-mods/tree/main/token-weather

已翻譯

關於這個 mod

token-weather

token-weather 是 Claude Code 外掛(2.1.287+),會在提示列正上方加入 context window 的即時單行預測。它顯示狀態指示器(☀ Clear → ↯ Compact soon)、已使用 token、涵蓋最近 12 個回合的迷你折線圖,以及最近一個回合增加的 token 數量。它屬於 cskwork/claude-code-mods marketplace,安裝方式如下:

/plugin marketplace add cskwork/claude-code-mods
/plugin install token-weather@claude-code-mods
/reload-plugins

repository 也記錄 mod 結構(manifest、hooks.json、register.tsx、可選的 types contract、tests),並包含建立新 mod 的工具。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add cskwork/claude-code-mods
claude plugin install token-weather
原文 / README

claude-code-mods

Mods for Claude Code (2.1.287+): plugins of function hooks that observe, rewrite or answer what Claude Code does and draw their own UI. Based on Getting started with Claude Code mods.

Landing page: https://cskwork.github.io/claude-code-mods/

| Mod | What it does | | --- | --- | | token-weather | A one-line forecast of the context window above the prompt: ☀ Clear → ↯ Compact soon, tokens used, a sparkline of the last 12 turns, and how much the last turn added. | | blast-radius | Before a risky Bash command runs (recursive rm, git reset --hard, git clean -f, force push, git branch -D, git stash drop/clear, kubectl delete, SQL DROP/TRUNCATE, migrations), dry-runs what it would touch and asks Proceed or Cancel. Cancel or dismiss denies the call. | | template | Starter mod, not installed: a slash command, a status line entry, a band, and a $.state contract with a test. |

Install

Inside Claude Code:

/plugin marketplace add cskwork/claude-code-mods
/plugin install token-weather@claude-code-mods
/plugin install blast-radius@claude-code-mods
/reload-plugins

Make a new mod

scripts/new-mod.sh my-mod "One line about what it does"
claude --plugin-dir "$PWD/my-mod"     # hot-reloads on every save

The script copies template/, renames it, adds it to .claude-plugin/marketplace.json, then runs claude plugin validate and claude plugin test on it.

A mod is three files plus an optional state contract:

my-mod/
├── .claude-plugin/plugin.json   name, version, description, "types"
├── hooks/hooks.json             { "modules": ["./register.tsx"] }
├── hooks/register.tsx           export const register: Register = on => { ... }
├── types/index.d.ts             PluginState contract for $.state values
└── tests/my-mod.test.ts         claude plugin test my-mod

Rules that bite:

  • Every hook is ($, e, next). Call next(e) to pass on, next({ ...e, x }) to rewrite, return without it to answer.
  • Keep values in $.state (atom / read / update); module variables reset on every hot reload.
  • No Node, no DOM: files, processes, clock and UI go through $. UI elements come from $.ui.resolve(e).
  • Test mocks are hooks too: on('process.run', ($, e) => ({ value: ... })).
  • After the engine loads a mod it writes .claude-plugin/types/ beside it, so tsc -p <mod> type-checks it (gitignored).

Check

for m in token-weather blast-radius template; do claude plugin validate $m && claude plugin test $m; done

其他同名作品

更多類似作品