Awesome-omni-skill context-guard
Installs opt-in Claude Code hooks that detect stale AI context files (CLAUDE.md, AGENTS.md, GEMINI.md, etc.) and remind developers to update them. Includes post-commit drift detection, structural change reminders, and a quality rule. Claude Code only — hooks do not work in OpenCode, Codex CLI, or other tools.
git clone https://github.com/diegosouzapw/awesome-omni-skill
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/ai-agents/context-guard" ~/.claude/skills/diegosouzapw-awesome-omni-skill-context-guard && rm -rf "$T"
skills/ai-agents/context-guard/SKILL.mdContext Guard
What It Does
Context Guard adds two PostToolUse hooks and one quality rule to a project. The hooks detect when AI context files (CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules, copilot-instructions.md, .windsurfrules, .clinerules) are out of date and nudge the developer to update them.
Claude Code only. These hooks use Claude Code's hook system (PostToolUse events,
.claude/settings.json configuration). OpenCode, Codex CLI, Cursor, Windsurf, Cline, and Gemini CLI do not support Claude Code hooks. The quality rule (.claude/rules/context-quality.md) is also Claude Code-specific.
Cross-tool features like skills (
.claude/skills/) and AGENTS.md work in OpenCode and Codex CLI without Context Guard.
Components
Hook: context-drift-check.sh
- Event: PostToolUse on
(filters forBash
commands)git commit - Fires: After a successful git commit
- Checks:
- Compares each context file's last-modified commit vs the most recent source-code commit
- Detects broken file-path references inside context files
- Flags when
orpackage.json
changed more recently than context filespyproject.toml
- Output: Lists stale files and recommends
, or stays silent if everything is current/ai-context audit - Throttle: Max once per hour via
timestamp.git/.context-guard-last-check
Hook: context-structural-change.sh
- Event: PostToolUse on
Write|Edit - Fires: After creating or editing structural files (commands, skills, agents, rules, manifests, config)
- Reminds: Which context files may need updating based on the type of change
- File patterns:
→ AGENTS.md, CLAUDE.md, llms.txtcommands/*.md
→ AGENTS.md, CLAUDE.md, llms.txt.claude/skills/*/SKILL.md
→ AGENTS.md.claude/agents/*.md
→ CLAUDE.md, AGENTS.md.claude/rules/*.md
,package.json
, config files → all context filespyproject.toml
Rule: context-quality.md
Auto-loaded every session. Establishes cross-file consistency, path verification, version accuracy, command accuracy, and a sync-points table mapping project changes to context files.
Installation
The
/context-guard install command:
- Copies hook scripts to
in the target project.claude/hooks/ - Merges hook configuration into
.claude/settings.json - Copies the quality rule to
.claude/rules/context-quality.md - Makes hook scripts executable
Settings.json Configuration
{ "hooks": { "PostToolUse": [ { "matcher": "Bash", "hooks": [{ "type": "command", "command": ".claude/hooks/context-drift-check.sh" }] }, { "matcher": "Write|Edit", "hooks": [{ "type": "command", "command": ".claude/hooks/context-structural-change.sh" }] } ] } }
Uninstallation
The
/context-guard uninstall command removes the hook scripts, settings.json entries, and the quality rule.
Customisation
Throttle Interval
Edit
context-drift-check.sh line with 3600 (seconds) to change the check interval. Set to 0 to check on every commit.
File Patterns
Edit
context-structural-change.sh case statement to add or remove structural file patterns.
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Hooks not firing | Scripts not executable | |
| No output after commit | Throttle active | Delete to reset |
| "jq: command not found" | jq not installed | Install jq: or |
| Hook errors in logs | Wrong project directory | Check is set correctly |