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 | $0.00109 | $0.00697 |
| Sonnet 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 12d 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.
- 12d 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 7d ago), licensed MIT. It adds 217 tokens to every session and 1,394 once invoked, about $0.0011 per session on Opus 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.
Other skills, from other repositories
media-ingest
Ingest video, audio, PDF, book, screenshot, and GitHub repo content into the brain. Multi-format handling with entity extraction and backlink propagation. Covers video-ingest, youtube-ingest, and book-ingest subtypes.
mem0-oss-to-platform
Plan and then execute a migration of a project from the mem0 open-source / self-hosted SDK (the local Memory class) to the mem0 Platform / hosted / managed SDK (the MemoryClient class). Use this whenever a developer wants to move, switch, or migrate their mem0 usage off OSS/self-hosted to the hosted API — e.g.…
Cortex
Operate Cortex, the LifeOS memory system — the typed Knowledge Archive (People, Companies, Ideas, Research with typed related: links) plus recall of prior work sessions, ISAs, and conversations. Search, add, harvest, develop, ingest, distill, graph-navigate, recall. USE WHEN cortex, knowledge, knowledge base, search…
memory
Use when the user asks to remember, recall, forget, update, search, or inspect durable OpenSquilla memory, including profile facts in USER.md and long-term notes in MEMORY.md or memory//.md.
ha-data-stores
Map of Hope Agent's local data stores and safe read-only query workflow. Use when the user asks where Hope Agent stores data, wants to inspect sessions/messages/memory/logs/background jobs/knowledge indexes/settings, asks the model to query local app data, or debugging requires checking persisted state. Trigger…
establishing-project-context
Use when the user asks to establish shared project language, or project work exposes a conflicting, renamed, or deprecated domain term that needs active semantic modeling. Routine small tasks stay on the fast path.