Skip to content

refactor: rename context-guard to context-usage #15555

Closed

Description

@kyle-sexton

Problem

Rename the context-guard plugin to context-usage, completely. The new name says what the plugin reports, which is how much of the context window a session is using. "Guard" describes one behavior, the zone gate, not the concern.

When this is done:

  • no current-state reference to the old name remains in this repository or its companion repositories;
  • every lane runs context-usage@melodic-software;
  • the runtime directory ~/.claude/context-guard/ and the MCP tool mcp__context-guard__status are gone, replaced by ~/.claude/context-usage/ and mcp__context-usage__status;
  • no saved setting or operator file is left under the old name.

This is the largest of the five renames. Locations were taken on main at 606fdf680205dc1f7039aab0531ea6043b5ed85f. Line numbers move, so find each location by its quote or by grep.

Why

Q107 and Q133 are the owner's decisions to rename five plugins after their concern rather than their tool or current behavior: typos-format to spelling, ruff-format to python-format, biome-format to javascript-format, context-guard to context-usage, and rate-limit-guard to rate-limits.

  • Owner, 2026-11-11: "We do need to decouple ... low coupling, high cohesion".
  • Owner, 2026-11-12: "we need to make sure everything's migrated: nothing cosmetic, nothing left behind. For rename, it needs to be a complete rename, and nothing left over with the old name."

Under the 2026-11-12 decision:

  • Every item a previous rename treated as optional is required.
  • The runtime directory and the MCP tool rename as well.
  • Saved option values and operator files are migrated, not reset. #15372 sets the precedent for the changelog fragment's form only.

The playbook rule "no deprecation shim, alias, or pointer to the old name" (docs/migration-playbook.md, rename section) still holds. One-time migration code that moves data and then deletes it is not an alias. List each such line in the PR with its removal condition.

Scope in this repository

Identity

  • git mv plugins/context-guard plugins/context-usage.
  • .claude-plugin/marketplace.json: the entry's name and source. The plugin is also a tag on the plugin-quality entry; change the tag too.
  • plugin.json: name, and the keys below.
  • Commands: /context-guard:setup and its other skill commands become /context-usage:…. The install id becomes context-usage@melodic-software.

Option keys and environment variables

Old key New key
context_guard_hooks_enabled context_usage_hooks_enabled
context_guard_band context_usage_band
context_guard_toast context_usage_toast

These keep their names because they carry no plugin name: model_notices, zone_report_mode, zone_line_data. That follows #15372, which renamed only the key that carried the renamed name.

Each variable follows its key: CLAUDE_PLUGIN_OPTION_CONTEXT_GUARD_* becomes CLAUDE_PLUGIN_OPTION_CONTEXT_USAGE_*. The hook::check_enabled "CONTEXT_GUARD…" calls and the test variables follow the same way.

Runtime contracts

  • Directory. ~/.claude/context-guard/ becomes ~/.claude/context-usage/. It holds:

    • context/<session_id>.json, the snapshot;
    • context/<session_id>.compacted, the PostCompact marker;
    • zones.json, an operator file that setup apply writes;
    • cache-line.mjs, which setup apply cache-line copies there.

    The directory name is the CONTRACT_DIR = 'context-guard' literal in hooks/register.tsx. reference/reader-contract.md owns the documented paths.

  • MCP tool. mcp__context-guard__status becomes mcp__context-usage__status with no code change: the tool registers as name: 'status', and the server name comes from the plugin name. Update every caller and every mention:

    • the plugin's own README.md, reference/reader-contract.md, reference/cloud-headless-capture.md, scripts/check-mod-load.sh and its test, skills/setup/SKILL.md, hooks/context-guard.test.ts, and the su-check-six-option-rows-read-only eval (case.yaml, samples/module-row.json);
    • plugins/session-flow/skills/keep-going/SKILL.md, plugins/session-flow/skills/workflow/SKILL.md, plugins/session-flow/skills/workflow/context/continuation.md and plugins/session-flow/skills/workflow/evals/evals.json;
    • plugins/planning/skills/interview/context/routing.md;
    • plugins/plugin-quality/skills/setup/SKILL.md;
    • plugins/harness-ops/skills/lanes/SKILL.md;
    • plugins/harness-ops/skills/audit-mod-posture/scripts/mod-posture.test.sh, which uses the long form mcp__plugin_context-guard_context-guard__status.

    No allowed-tools: or settings allow rule names the tool, in this repository, dotfiles or any org settings.json. Grep again before closing.

  • Mod literals in hooks/register.tsx that the directory move does not change:

    • CONTRACT_DIR;
    • the PREFIX transcript prefix;
    • $.command.register({ name: 'context-guard' }), the /context-guard slash command, which becomes /context-usage;
    • the command.run matcher;
    • the README URL.
  • Readers outside the plugin. All of them must read the new path:

    • lib/context-zone.sh, two $HOME/.claude/context-guard/... lines, and its vendored copy plugins/plugin-quality/scripts/context-zone.sh;
    • lib/context-zone.fixtures.mjs and plugins/plugin-quality/scripts/context-zone.fixtures.mjs;
    • the session-flow and planning skills above, which go through the MCP tool or the snapshot;
    • the dotfiles statusline (see Companion changes).

Files whose names carry the old name

  • hooks/context-guard.test.ts becomes hooks/context-usage.test.ts.
  • .claude/skills/control-claude-code-plugins/features/context-guard/ becomes features/context-usage/.
  • Grep the moved tree for any other file name containing the old name; git ls-files | grep -i -e context-guard -e context_guard must print nothing.

References inside the moved directory (about 58 files)

plugin.json, hooks/register.tsx (16 or more lines), hooks/context-guard.test.ts, hooks/post-compact-mark.sh, hooks/payload.sh, hooks/hooks.json, reference/reader-contract.md, reference/cloud-headless-capture.md, scripts/context-zone.sh, scripts/cache-line.mjs, scripts/check-mod-load.sh, scripts/context-zone.fixtures.mjs, lib/write-snapshot.mjs (vendored), skills/setup/SKILL.md, the evals, and README.md.

The README's #published-zone-for-status-lines anchor is linked from dotfiles. Keep the anchor text stable, or update the dotfiles link in the paired PR. The CHANGELOG.md title line and released sections change too (see "Owner ruling on released history" below).

References outside the moved directory (about 87 files)

  • Other plugins' code:
    • plugins/plugin-quality/scripts/context-zone.sh (vendored from lib/context-zone.sh) and context-zone.fixtures.mjs;
    • plugins/plugin-quality/.claude-plugin/plugin.json, where both the description and a keyword name the plugin;
    • plugins/plugin-quality/probes/audit.json, plugins/plugin-quality/probes/report.json;
    • plugins/context-budget/probes/audit.json, plugins/context-budget/skills/audit/reference/levers.json;
    • plugins/harness-ops/skills/lanes/scripts/lane-launcher.sh, a comment it shares with rate-limit-guard;
    • plugins/rate-limit-guard/lib/write-snapshot.mjs (vendored).
  • Other plugins' prose (24 files):
    • plugin-quality: README.md, skills/audit/SKILL.md, skills/setup/SKILL.md, skills/audit/reference/evidence-packet.md.
    • session-flow: keep-going/SKILL.md, workflow/SKILL.md, workflow/context/continuation.md, orchestrate/SKILL.md, running-retro/SKILL.md, handoff/SKILL.md.
    • planning: interview/context/routing.md, and design/reference/type-discipline/typescript.md, which cites plugins/context-guard/hooks/zone.ts and register.tsx by path.
    • context-budget: README.md, skills/audit/SKILL.md, skills/audit/reference/report.md.
    • docs-hygiene: skills/rename-references/context/patterns.md and triage.md use context-guard as the hyphen-superstring example. Change the example to context-usage. It still contains context, so the examples keep working; re-read each one after the edit.
    • harness-ops: skills/lanes/SKILL.md, skills/audit-skill-visibility/reference/usage-counters.md.
    • Others: implementation/skills/implement-dispatch/SKILL.md, source-control/skills/worktree/SKILL.md, autonomy/reference/prerequisite-resolution.md, rate-limit-guard/README.md and rate-limit-guard/skills/setup/SKILL.md.
  • docs/ (25 files):
    • ADRs 0018, 0028, 0052 and 0093. In ADR 0093, rename the dated review headings too and change the current-state carve-out paths. ADRs 0004 and 0048 hold dated history: rename each line too, per the owner ruling below.
    • Contracts:
      • hook-telemetry/README.md;
      • the description fields of hook-telemetry/data/post-compact-mark.schema.json and zone-crossing-inject.schema.json (their $id URLs carry no plugin name);
      • hook-budget, hook-observability, config-cascade and retired-conventions.
    • docs/conventions/bugs.yaml, which holds the glob plugins/context-guard/scripts/*.sh.
    • Other docs: docs/glossary.md, docs/finding-your-unknowns.md, docs/plugin-philosophy.md, docs/cursor-compatibility.md.
    • Upstream records that name the plugin in a current disposition: docs/upstream/aihero-course.md, docs/upstream/claude-code.md, docs/upstream/claude-dev-sonnet-5-5-blog.md, docs/upstream/mattpocock-skills.md, docs/upstream/platform-claude-com-prompting-claude-fable-5-2.md, docs/upstream/typesafe-jev.md.
  • .github/: .github/scripts/pr-unblock/adjudicate-feedback.test.mjs uses dependencies: ["context-guard"] as a fixture value. Rename it.
  • Tests:
    • plugins/plugin-quality/scripts/context-zone.test.sh (24 lines);
    • plugins/plugin-quality/scripts/zones-inline-drift.test.sh (see Traps);
    • plugins/harness-ops/hooks/hook-failure-audit.test.sh. Its lines were copied from real error records naming plugins/context-guard/hooks/zone-gate.sh. Rewrite them with the new path; they are fixtures, not a record;
    • plugins/harness-ops/skills/audit-mod-posture/scripts/mod-posture.test.sh;
    • plugins/harness-ops/skills/control-claude-code/driver/driver.test.mjs;
    • eval prompts in session-flow workflow and keep-going, planning interview, implementation implement-dispatch, plugin-quality audit and setup, harness-ops audit-skill-visibility, and docs-hygiene rename-references;
    • plugins/session-flow/scripts/tests/test_workflow_continuation_rule.py, which pins a sentence in continuation.md, so change the two together;
    • plugins/rate-limit-guard/hooks/rate-limit-guard.test.ts, one line.
  • Root and scripts:
    • lib/context-zone.sh, lib/context-zone.fixtures.mjs, lib/write-snapshot.mjs;
    • scripts/cross-plugin-source-registry.txt (four lines), scripts/affected-tests-no-suite.txt;
    • the control skill SKILL.md row;
    • the sorted lists: scripts/shared-copies.txt (several lines), scripts/em-dash-purged-paths.txt, scripts/fragment-plugins.txt, scripts/suite-seconds.txt. Moving the entry means re-sorting each list.

Generated files: regenerate, never hand-edit

  • docs/catalog.md: node scripts/generate-catalog.mjs.
  • The cheat sheet: node scripts/generate-cheatsheet.mjs.
  • docs/architecture/landscape.json: plugins/architecture/skills/map-landscape/scripts/landscape-record.sh.
  • Vendored copies (lib/context-zone.sh, lib/write-snapshot.mjs and the others in scripts/shared-copies.txt): scripts/sync-shared-copies.sh.

Traps: do not run a blind sed

  • Silent drift skip. plugins/plugin-quality/scripts/zones-inline-drift.test.sh hard-codes ../../context-guard/reference/reader-contract.md and prints SKIP when that path is missing. If the path is not updated, the drift lane goes inert without failing. Update it, and confirm the test reports PASS, not SKIP.
  • The rate-limit-guard plugin names this one. Change these in this PR, keeping rate-limit-guard's own name, which changes in the rate-limits issue:
    • plugins/rate-limit-guard/README.md;
    • plugins/rate-limit-guard/skills/setup/SKILL.md;
    • plugins/rate-limit-guard/lib/write-snapshot.mjs, through scripts/sync-shared-copies.sh;
    • rate-limit-guard.test.ts.
  • Directory-only hits. post-compact-mark.sh and register.tsx hold the path as a literal string, so a content grep that skips the moved directory misses them.
  • After the git mv, run /docs-hygiene:rename-references context-guard context-usage.

Changelog

  • Run scripts/new-changelog-fragment.sh context-usage major, which writes .changes/context-usage/<slug>.md with bump: major. Write fragments for any other plugin the checks require, such as plugin-quality for its vendored copy and keyword.
  • The fragment names the new id, the new commands, keys, directory and MCP tool, and tells the operator what to re-run if the migration below did not reach their machine. The old-to-new mapping goes in the PR body.
  • Rename the old name in the released CHANGELOG.md sections too. Released-entry body edits follow the in-place correction rule in the header of scripts/check-changelog-parity.sh (Released CHANGELOG entries are being edited in place (#2312 rewrote two lines inside the shipped 0.51.12) — decide whether that is sanctioned #2388): name each edit in the PR body and in the new release entry. --check-preserved watches version headings only; keep every heading and do not change the gate.
  • After merge, confirm the release PR releases context-usage and records nothing under context-guard.

Companion changes in other repositories (each its own paired PR)

Repo Change
melodic-software/dotfiles See below. Required.
others No other org repository names context-guard in current state. Code search found only this repository and dotfiles. Re-grep before closing.

Not edited, with the reason:

dotfiles PR:

  • .chezmoidata/claude.json:
    • In claudeSettings.force.enabledPlugins, replace "context-guard@melodic-software": true with "context-usage@melodic-software": true, in sorted position. This plugin is defaultEnabled: false in the catalog, so it installs only when declared here. Without this edit the new id never installs.
    • force.pluginConfigs has no context-guard entry today. If one exists at build time, move it to the new id under the new key names, values unchanged.
    • Add "context-guard@melodic-software" to claudeSettings.uninstallPlugins.
  • Saved-settings rename map: add context-guard → context-usage with the three key pairs. The map is built in the spelling issue's dotfiles PR. If that has not merged, build it here, the same way.
  • dot_claude/CLAUDE.md.tmpl: change "context-guard names the context zone" to name context-usage. This file renders into the user CLAUDE.md.
  • Statusline:
    • dot_claude/statusline/lib/context-zones.sh: the header lines, CONTEXT_ZONE_SNAPSHOT_DIR="$HOME/.claude/context-guard/context" (which becomes context-usage), and one more mention.
    • dot_claude/statusline/README.md: the fallback note, and the section that links the ccp README URL and its anchor.
    • dot_claude/statusline/tests/context-zones.test.sh (three places) and dot_claude/statusline/tests/bars-default.test.sh.
  • Golden files: regenerate the affected tools/chezmoi-template-lint/golden/*.sha256 with Get-RenderHash.ps1 -Fixture <fixture> and log the regeneration in golden/README.md.
  • Self-Modification: cite Q107/Q133 and the 2026-11-12 quote for the soft-deny on .chezmoidata/claude.json and dot_claude/**.
  • Merge timing: tools/check-plugin-manifest/check.sh passes only after the ccp PR merges. Merge right after it.

Migration: nothing left behind

  1. Installed old id. It is uninstalled on every lane at the next fleet-converge through uninstallPlugins, without --keep-data, so ~/.claude/plugins/data/context-guard-melodic-software/ goes too.

  2. Saved option values: migrate, do not reset. dot_claude/modify_settings.json copies each old-id pluginConfigs value to the new id under its new key, unless that key is already set, then deletes the old entry. The keys that keep their names (model_notices, zone_report_mode, zone_line_data) are copied as they are.

  3. On-disk data under ~/.claude/context-guard/: move it, regenerate the rest, then remove the old directory.

    • zones.json, a custom operator file: move it to ~/.claude/context-usage/zones.json unchanged. It must not reset to the shipped bands.
    • context/*.json snapshots and .compacted markers: per-session state. The new mod writes them fresh. Do not carry them over; they go with the old directory.
    • cache-line.mjs: regenerate it under the new directory, the step setup apply cache-line runs, and repoint any statusLine command that references the old path.
    • Remove ~/.claude/context-guard/.

    Run this unattended on every lane in the dotfiles plugin installer step that already handles uninstallPlugins (.chezmoiscripts/run_after_install-claude-plugins.sh.tmpl and run_install-claude-plugins.ps1.tmpl). For a machine without dotfiles, /context-usage:setup check reports a leftover ~/.claude/context-guard/ as drift and names the fix, and /context-usage:setup apply performs the same move. Both are migration lines, listed in the PR with their removal condition: every lane has converged and the checks below pass.

Acceptance criteria

  • On merged ccp main, git grep -n -i -e 'context-guard' -e 'context_guard' -e 'contextguard' -e 'context guard' returns only the migration lines named in the PR, and the PR lists every remaining hit with its removal condition.
  • The same grep over dotfiles main returns only the uninstallPlugins entry, the rename-map entry, the migration step, and the migration lines listed in its PR.
  • git ls-files | grep -i -e context-guard -e context_guard prints nothing in either repository.
  • These tests pass:
    • plugins/context-usage/hooks/context-usage.test.ts;
    • plugins/context-usage/scripts/check-mod-load.test.sh;
    • plugins/plugin-quality/scripts/context-zone.test.sh;
    • plugins/plugin-quality/scripts/zones-inline-drift.test.sh, reporting PASS and not SKIP;
    • plugins/harness-ops/hooks/hook-failure-audit.test.sh;
    • plugins/harness-ops/skills/audit-mod-posture/scripts/mod-posture.test.sh;
    • plugins/session-flow/scripts/tests/test_workflow_continuation_rule.py;
    • .github/scripts/pr-unblock/adjudicate-feedback.test.mjs.
  • ci-status is green, including the changelog fragment and parity checks and the shared-copies drift check.
  • On the dotfiles PR, after the ccp merge, tools/check-plugin-manifest/check.sh, the golden render check and the statusline tests pass.
  • After both PRs merge and one fleet-converge on a lane:
    • claude plugin list shows context-usage@melodic-software and not context-guard@melodic-software;
    • ~/.claude/context-guard/ does not exist;
    • ~/.claude/context-usage/zones.json holds the lane's previous custom bands, if it had any;
    • a new session lists mcp__context-usage__status and not mcp__context-guard__status;
    • the statusline shows the zone from the new snapshot directory;
    • ~/.claude/settings.json has no context-guard@melodic-software entry under pluginConfigs, and every saved value sits under its new key unchanged.
  • The rendered user CLAUDE.md names context-usage, not context-guard.

Order and dependencies

  • This issue does not depend on the formatter renames. It goes before rate-limits: each plugin's directory and tests name the other, and both touch lane-launcher.sh, harness-ops/skills/lanes/SKILL.md and ADRs 0018, 0052 and 0093. Context-usage goes first because all of its outside readers fail soft and none of them is a loop lane.
  • Merge the ccp PR first, then the dotfiles PR within the same hour.

Open PRs to rebase around

Re-run gh pr list -R melodic-software/claude-code-plugins --state open before starting. These were open at filing time:

  • #15504 adds .changes/ fragments for all five plugins.
  • #15505 edits context-budget, implement-dispatch and plugin-quality audit prose.
  • #15536 edits harness-ops/skills/lanes/SKILL.md and docs/contracts/loop-lane/README.md.

A fragment under .changes/context-guard/ that merges after this rename leaves a fragment for a plugin that no longer exists, and git raises no conflict. Before merging, git mv any such fragment into .changes/context-usage/.

Owner ruling on released history

Owner, 2026-11-12: "I want a clean cutover". Released CHANGELOG sections, ADR text and dated records are renamed to the new name too. The only old-name hits allowed after the rename are the dotfiles uninstallPlugins entry, the rename-map migration entry, and one-time migration lines that must read the old name, each listed in the PR with its removal condition.

Related

  • Owner decisions Q107 and Q133 (2026-11-11), and the 2026-11-12 complete-rename decision.
  • Precedent: #15372.

Activity

  1. self-assigned this
    on Nov 12, 2026
  2. added
    agent-ready
    on Nov 12, 2026
  3. added
    needs-triage
    on Nov 12, 2026
  4. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor

    Size: Large
    Complexity: Medium
    Uncertainty: Known
    Flags: none
    Blocked by: none

    Understood: a complete rename of the context-guard plugin to context-usage. That covers the plugin directory, marketplace entry, option keys and env vars, the ~/.claude/context-guard/ runtime directory, the MCP tool name, outside readers, docs, tests and generated files. It also covers a paired dotfiles PR with settings and on-disk migration. The issue gives the scope, traps, acceptance criteria and owner rulings, so I found nothing missing.

    The work spans about 145 files plus a second repository, so it will probably need splitting into steps.

    I found no open duplicate. #15552, #15553, #15554 and #15556 are the sibling renames, and #15372 is the precedent the issue names.

    Automated triage. A maintainer reviews it.

  5. removed
    needs-triage
    on Nov 12, 2026
  6. melodic-automation-lanes commented on Nov 12, 2026

    @melodic-automation-lanes
    Contributor

    The work-resolve-issue run that agent-ready started ended over 3 hours ago with no report and no pull request. work-unblock removed and added agent-ready back to start a fresh run on main's workflow files. If this run ends the same way, it re-fires the issue again, waiting longer each time.

  7. removed
    agent-ready
    on Nov 12, 2026
  8. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor

    The triage sweep dispatched intake triage for this issue (dispatch 1; 2 runs that reach intake, or 6 dispatches, hand it to a maintainer).

  9. melodic-automation-lanes commented on Nov 14, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane: merged pull request #15633 names it with Refs: after its newest decision or refinement comment, so its work may already be done: close the issue if it is, or post a comment whose first line is **Decision recorded.** saying what is left, which sends it back through intake. Admission takes the issue once each of those is met, when intake triages it again (.github/actions/resolve-config/admission-rules.json).

  10. kyle-sexton commented on Nov 14, 2026

    @kyle-sexton
    MemberAuthor

    Closed by hand after the fleet check on the WSL lane (2026-11-14): context-guard@melodic-software is not installed, context-usage@melodic-software is; no context-guard runtime or data folder exists; every running session was reloaded with /reload-plugins --force. The only old-id hit in user settings is the false entry the dotfiles uninstallPlugins list renders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Work status

confirmed

Priority

medium

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions