context-monitor

context-monitor is a skill for Claude Code from guihai24/openskills. It costs 217 tokens per session (1,394 once invoked), scanned B, original, MIT.

A Claude Code status-bar tool that shows how much of the conversation context has been used. Context is the amount of conversation and tool information the model can still work with before the limit is reached.

In plain words
What is it for?
Installing and maintaining a status-bar display for context usage, including percentage, token counts, warning colors, and safe handling of usage data.
Why use it?
It warns you before the conversation becomes too large to continue comfortably. This gives you time to run /compact, which shortens the conversation history.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths; mentions Claude Code; built for openclaw.

Good fit Installing and maintaining a status-bar display for context usage, including percentage, token counts, warning colors, and safe handling of usage data.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/guihai24/openskills/context-monitor
Install

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.

Any agent
npx skills add guihai24/openskills --skill context-monitor
Clone the repo
git clone --depth 1 https://github.com/guihai24/openskills

Made for: Claude Code.

Wrote 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.

agentmods badge for context-monitor

README.md
[![agentmods](https://agentmods.dev/badge/skills/guihai24/openskills/context-monitor/github.svg)](https://agentmods.dev/skills/guihai24/openskills/context-monitor)
Your own site
<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.

agentmods 80×15 button for context-monitor

Your own site · 80×15
<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>
Per session 217 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,394 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 12d ago against content hash 0c7b31cbd592, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

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.

The scan reads SKILL.md. This mod also ships 3 executable files (scripts/install.sh, scripts/statusline-context.py, scripts/uninstall.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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 字段
skills/context-monitor/SKILL.md · 90 lines

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 给状态栏加一个实时计量条,让你在变黄、变红时就主动下手。

安装

前置:python3jq

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。三个容易踩的坑,脚本都处理了——这也是它存在的价值:

  1. 跳过全 0 的合成消息:API 出错会在 transcript 末尾留下一条 <synthetic> 全 0 usage 消息。天真地取"最后一条 usage"会读到 0、误显示 0%。脚本跳过 token 全 0 的消息。

  2. /compact 边界(最隐蔽)/compact 会追加一条带 compactMetadata 的消息,其中 postTokens 是压缩后的真实大小——但这条消息本身没有 usage。若只取"最后一条 usage",会穿透到压缩之前的旧值,表现为"compact 完了百分比还是不降"。脚本的规则是:反向遍历时,compact 边界(postTokens)和真实 usage 谁先遇到用谁——于是 compact 后的空窗期显示 postTokens(已压缩),等你发新消息后自动切换到含工具/系统提示开销的真实值。

  3. 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

Read the full file on GitHub · 90 lines

Files

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.

Changes

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.

  1. 12d ago First seen · 90 lines · 217 tokens per session scan B 0c7b31cbd592

Subscribe to this mod's changes

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.

Related

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.

garrytan/gbrain · 52 tokens

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.…

mem0ai/mem0 · 273 tokens

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…

danielmiessler/LifeOS · 196 tokens

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.

opensquilla/opensquilla · 44 tokens

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…

shiwenwen/hope-agent · 115 tokens

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.

GanyuanRan/Aegis · 45 tokens