context-guard

A command that installs, removes, or reports on hooks that watch whether AI context files are still current.

In plain words
What is it for?
Use it to install advisory checks, enable strict commit protection, remove the hooks, or view their status.
Why use it?
It reminds you to update instructions after important project changes and can block commits when those updates are missing.

Command

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.

agentmods
npx agentmods add commands/littlebearapps/contextdocs/context-guard
Clone the repo
git clone --depth 1 https://github.com/littlebearapps/contextdocs
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,770 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00021 $0.01770
Opus 5 $0.00010 $0.00885
Sonnet 5 $0.00004 $0.00354
Haiku 4.5 $0.00002 $0.00177

Measured yesterday against content hash 5a09ea177219, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context-guard scanned grade A with 0 findings 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 yesterday.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/context-guard.md · 115 lines

How it starts

The opening of the file, as written. The whole thing — 115 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/context-guard

Install opt-in hooks that detect stale AI context files, remind you to update them, and prevent content filter errors when generating standard OSS files. Claude Code only — these hooks use Claude Code's PreToolUse, PostToolUse, and Stop hook system, which is not supported by OpenCode, Codex CLI, or other AI coding tools.

Context Guard has two enforcement tiers:

  • Tier 1 — Nudge (default): Advisory. A Stop hook suggests updating context docs before the session ends. Claude can still stop if context docs genuinely don't need changes.
  • Tier 2 — Guard (opt-in): Blocking. A PreToolUse hook blocks git commit when structural files are staged without context doc updates.

Behaviour

  1. Load the context-guard skill for reference
  2. Execute the requested action: install, install strict, uninstall, or status

Arguments

  • install: Install Context Guard (Tier 1) into the current project:

    1. Create .claude/hooks/ directory if it does not exist
    2. Copy context-drift-check.sh, context-structural-change.sh, content-filter-guard.sh, context-guard-stop.sh, context-session-start.sh, and context-forced-eval.sh from the plugin's hooks/ directory to .claude/hooks/
    3. Make the scripts executable (chmod +x)
    4. Create .claude/agents/ directory if it does not exist
    5. Copy context-updater.md from the plugin's .claude/agents/ directory to .claude/agents/context-updater.md
    6. Merge PreToolUse, PostToolUse, SessionStart, UserPromptSubmit, and Stop hook entries into .claude/settings.json (create the file if needed; if entries already exist, append without overwriting). Use if: "Bash(git commit*)" for context-drift-check.sh so it only fires after git commit (Claude Code v2.1.85+); older versions fall back to the in-script substring guard.
    7. Copy context-quality.md to .claude/rules/context-quality.md (create directory if needed)
    8. Report what was installed
  • install strict: Install Context Guard (Tier 1 + Tier 2) into the current project:

    1. Perform all steps from install above
    2. Additionally copy context-commit-guard.sh from the plugin's hooks/ directory to .claude/hooks/
    3. Add a PreToolUse hook entry for context-commit-guard.sh to .claude/settings.json using if: "Bash(git commit*)" so it only fires on git commit (v2.1.85+); older Claude Code versions fall back to the in-script guard
    4. Report what was installed, noting Tier 2 is active

Read the full file on GitHub · 115 lines

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. yesterday First seen · 115 lines · 21 tokens per session scan A 5a09ea177219

Subscribe to this mod's changes

context-guard is a command published in the GitHub repository littlebearapps/contextdocs (5 stars, last pushed 1mo ago), licensed MIT. It adds 21 tokens to every session and 1,770 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.