context-guard is a Claude Code usage mod by melodic-software.
Shows a toast when the session's context crosses into a worse zone, smart, acceptable, or dumb, and can draw the zone and percent in a row above the prompt.
It runs inside the Claude Code process. The side panel is only what the author's README names. Read the repo before you install, or run claude plugin validate on the plugin folder.
Version
1.1.4
License
MIT
Repo stars
28
Last change
2026-10-29
What it can reach
Draws in the session
Reads usage or context figures
Calls another program on this machine
Needs a Claude Code build that can run mods, and Node.js on PATH, installed on its own, for the snapshot writes and the PostCompact marker. The marker and the zone resolver run on Bash, Git Bash on native Windows, and the resolver needs jq. The shipped zones are smart up to 50% used, acceptable up to 75%, and dumb above, combined with token bands for the window, and ~/.claude/context-guard/zones.json can change them. A compacted session counts as dumb. At a crossing, a 4-second toast offers continue, /compact, /clear, or a handoff. Lines to Claude are off by default and need model_notices. The band row is off by default. /context-guard band on turns it on for the session, and /context-guard prints the verdict and figures. Claude can call mcp__context-guard__status for the exact figures. The module writes ~/.claude/context-guard/context/<session_id>.json by running node, and prunes files older than 14 days. No part of the plugin denies a tool call. No run was made in the Desktop app, VS Code, or a cloud session. Install at user scope. The plugin README's own install line names context-guard@<marketplace>.
The marketplace name is melodic-software, the same marketplace as context-budget and display-redaction. This one installs on its own. The repository README gives one install line for every plugin, /plugin install <plugin-name>@melodic-software; this page puts this plugin's name in that line. How full the context is is why this page files it under usage. context-budget draws what the context is made of, by category. token-weather draws a one-line forecast of the context window above the prompt. This one names three zones and tells you once when the session crosses into a worse one, and writes the zone to a file that status lines and other sessions can read.
Demo
Screenshot of the author's GitHub page.
What it hooks into
session.startWhen a session starts
session.endWhen a session ends
session.compactWhen the context is compacted
prompt.submitWhen you send a prompt
session.measureWhen usage is measured
turn.startWhen Claude starts a turn
turn.completeWhen a turn ends
command.runWhen you run its slash command/context-guard
ui.renderDraws into the sessionAbovePrompt
tool.callAround a tool call, where it can hold one
Read from the on() calls in its hook modules. Open its source under Files to check what each one does.
Slash commands 1
/context-guardContext zone status and details; band on or off sets the band row for this session, bare band toggles it