Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add guihai24/openskills --skill context-monitorgit clone --depth 1 https://github.com/guihai24/openskillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/guihai24/openskills/context-monitor)<a href="https://agentmods.dev/skills/guihai24/openskills/context-monitor"><img src="https://agentmods.dev/badge/skills/guihai24/openskills/context-monitor/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/guihai24/openskills/context-monitor"><img src="https://agentmods.dev/badge/skills/guihai24/openskills/context-monitor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00217 | $0.01394 |
| Opus 5.5 | $0.00087 | $0.00558 |
| Sonnet 5.5 | $0.00043 | $0.00279 |
| Haiku 4.5 | $0.00022 | $0.00139 |
Grade B, and why
context-monitor scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Reads agent configuration directoriesmediumAgent snooping
.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.
~/.claude/settings.json # 增量加了一个 statusLine 字段 How it starts
The opening of the file, as written. The whole thing — 90 lines — stays where its author put it; the contents beside it link to each section on GitHub.
context-monitor — Claude Code 上下文用量状态栏
在状态栏实时显示 context 占用,绿/黄/红三档预警,避免会话中途突然爆 context 来不及 /compact。
Opus 4.8 ██░░░░░░░░ 18% (180k/1000k)
为什么需要它
Claude Code 有 autocompact 兜底,但你看不见 context 逼近的过程——往往是"突然报超限"才发现,这时已经来不及主动 /compact。这个 skill 给状态栏加一个实时计量条,让你在变黄、变红时就主动下手。
安装
前置:python3、jq。
bash ~/.claude/skills/context-monitor/scripts/install.sh
做的事:把脚本复制到 ~/.claude/context-monitor/、用 jq 增量写入 settings.json 的 statusLine 字段(其余配置原样不动,改前自动备份 settings.json.bak.<时间戳>)、最后自检脚本可运行。
安装后下次状态栏刷新(发一条消息或重启 Claude Code)即生效。之后改脚本本身无需重启——statusLine 每次刷新都重新执行脚本。
装到 OpenClaw 或自定义目录:
CLAUDE_HOME=~/.openclaw bash .../install.sh(前提是该 harness 支持 statusLine)。
显示含义
<模型名> <进度条> <百分比> (<已用>/<上限>),颜色三档:
- 🟢 绿
<60%充裕 🟡 黄60–85%留意,可准备 /compact 🔴 红≥85%该 /compact 了
工作原理(及三个关键坑)
脚本从 stdin 读取 Claude Code 传入的会话信息(含 transcript_path),反向扫描 transcript 取最近一次的 context 占用 = input_tokens + cache_read_input_tokens + cache_creation_input_tokens。三个容易踩的坑,脚本都处理了——这也是它存在的价值:
-
跳过全 0 的合成消息:API 出错会在 transcript 末尾留下一条
<synthetic>全 0 usage 消息。天真地取"最后一条 usage"会读到 0、误显示 0%。脚本跳过 token 全 0 的消息。 -
/compact 边界(最隐蔽):
/compact会追加一条带compactMetadata的消息,其中postTokens是压缩后的真实大小——但这条消息本身没有 usage。若只取"最后一条 usage",会穿透到压缩之前的旧值,表现为"compact 完了百分比还是不降"。脚本的规则是:反向遍历时,compact 边界(postTokens)和真实 usage 谁先遇到用谁——于是 compact 后的空窗期显示postTokens(已压缩),等你发新消息后自动切换到含工具/系统提示开销的真实值。 -
1M vs 200k 上限:Opus 1M context 模型上限 100 万 token,其余 20 万。脚本按 statusLine 传入的 model id 是否含
1m自动判断;可用环境变量CLAUDE_CTX_LIMIT强制覆盖。
自定义
- 上限:
export CLAUDE_CTX_LIMIT=1000000,或改脚本context_limit()的默认值 - 颜色阈值:改脚本里
pct >= 85/pct >= 60两个数 - 进度条长度:改脚本
bar_len
文件结构
~/.claude/context-monitor/statusline-context.py # statusLine 调用的脚本
~/.claude/settings.json # 增量加了一个 statusLine 字段
~/.claude/settings.json.bak.<时间戳> # 改动前的自动备份
卸载
bash ~/.claude/skills/context-monitor/scripts/uninstall.sh
What ships with it
3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2mo ago First seen · 90 lines · 217 tokens per session scan B 0c7b31cbd592
context-monitor is a skill published in the GitHub repository guihai24/openskills (2 stars, last pushed 1mo ago), licensed MIT. It adds 217 tokens to every session and 1,394 once invoked, about $0.0009 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
context-monitor compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| context-monitorguihai24/openskills | Skill | 2 | 1mo ago | MIT | B | 217 | Claude Code |
| knowledge-ingestopenclaw/openclaw | Skill | 394k | today | MIT | A | 80 | Claude Code, Codex |
| mem0-oss-to-platformmem0ai/mem0 | Skill | 69k | yesterday | Apache-2.0 | A | 217 | Claude Code, Codex |
| forgetasgeirtj/system_prompts_leaks | Skill | 71k | yesterday | CC0-1.0 | A | 0 | Claude Code, Codex |
| Cortexdanielmiessler/LifeOS | Skill | 20k | 2d ago | MIT | A | 184 | Claude Code |
| memoryopensquilla/opensquilla | Skill | 7.1k | yesterday | Apache-2.0 | A | 44 | Claude Code, Codex |
| ha-data-storesshiwenwen/hope-agent | Skill | 1.9k | yesterday | MIT | A | 115 | Claude Code, Codex |