Skip to content

feat: add UserPromptSubmit hook for context-related skill activation#15

Merged
Nathan Schram (nathanschram) merged 2 commits intomainfrom
fix/ai-context-nl-triggering
Mar 15, 2026
Merged

feat: add UserPromptSubmit hook for context-related skill activation#15
Nathan Schram (nathanschram) merged 2 commits intomainfrom
fix/ai-context-nl-triggering

Conversation

@nathanschram
Copy link
Member

@nathanschram Nathan Schram (nathanschram) commented Mar 15, 2026

Summary

  • Adds context-forced-eval.sh — a new UserPromptSubmit hook that keyword-gates context-related prompts and injects skill evaluation instructions, improving NL trigger activation for ContextDocs skills
  • Updates Context Guard install/uninstall/status to include the new hook and UserPromptSubmit event
  • Adds CODEOWNERS, .gitignore for dev artifacts, and _typos.toml entry for hook regex patterns
  • Full test coverage: 51 new test cases (Section 7) covering slash commands, NL keywords, non-matching prompts, Untether gating, and case insensitivity — total now 116/116

Files changed

File Change
hooks/context-forced-eval.sh New hook script (keyword-gated UserPromptSubmit)
.claude/hooks/context-forced-eval.sh Installed copy
.claude/skills/context-guard/SKILL.md Documents new hook + UserPromptSubmit settings
AGENTS.md Hook count 6→7, lists new hook
CHANGELOG.md Unreleased section with 3 fixes
commands/context-guard.md Install/uninstall/status updated
llms.txt New hook entry
scripts/update-installed-hooks.sh Deploys new hook + patches settings.json
tests/test-hooks.sh 51 new tests (Section 7)
.github/CODEOWNERS Repository ownership
.gitignore Excludes dev artifacts
_typos.toml Allows promot partial match

Test plan

  • bash tests/test-hooks.sh — 116/116 pass
  • bash tests/check-token-budgets.sh — 0 warnings
  • bash tests/validate-llms-txt.sh — 0 errors

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added automatic evaluation of user prompts for context-related keywords with intelligent skill recommendations.
  • Bug Fixes

    • Fixed false positives in context detection for infrastructure files.
    • Improved context skill trigger reliability for stale file scenarios.
    • Synchronized skill descriptions across all documentation.
  • Tests

    • Added comprehensive test coverage for context evaluation feature.

Add "out-of-date", "refresh stale CLAUDE.md", and "move MEMORY.md"
trigger phrases to disambiguate ai-context from context-verify when
users ask about updating or fixing context files vs just checking them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds context-forced-eval.sh — a keyword-gated UserPromptSubmit hook that
injects skill evaluation instructions when prompts match context-related
keywords or slash commands. Skips silently on unrelated prompts and in
Untether sessions.

Includes full test coverage (Section 7), CODEOWNERS, gitignore for dev
artifacts, and documentation updates across AGENTS.md, SKILL.md,
context-guard command, llms.txt, and the update-installed-hooks script.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nathanschram Nathan Schram (nathanschram) merged commit 98c3106 into main Mar 15, 2026
8 of 9 checks passed
@nathanschram Nathan Schram (nathanschram) deleted the fix/ai-context-nl-triggering branch March 15, 2026 02:31
@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4904b60f-317b-43af-a9c3-2e235400d63a

📥 Commits

Reviewing files that changed from the base of the PR and between 0cb4ed1 and 1edd664.

📒 Files selected for processing (13)
  • .claude/hooks/context-forced-eval.sh
  • .claude/skills/ai-context/SKILL.md
  • .claude/skills/context-guard/SKILL.md
  • .github/CODEOWNERS
  • .gitignore
  • AGENTS.md
  • CHANGELOG.md
  • _typos.toml
  • commands/context-guard.md
  • hooks/context-forced-eval.sh
  • llms.txt
  • scripts/update-installed-hooks.sh
  • tests/test-hooks.sh

📝 Walkthrough

Walkthrough

A new UserPromptSubmit hook is introduced that activates on user prompts to detect context-related keywords and inject skill evaluation context. Hook registration, installation logic, tests, and documentation are updated across the codebase. Skill descriptions clarify scope for ai-context and context-guard.

Changes

Cohort / File(s) Summary
Hook Script Implementation
.claude/hooks/context-forced-eval.sh, hooks/context-forced-eval.sh
New Bash hook script that detects context keywords via exact slash-command prefixes (/ai-context, /context-guard, /context-verify) or regex patterns. Outputs JSON with skill evaluation context if matched, empty object otherwise. Early-exits in Untether sessions.
Installation & Configuration
scripts/update-installed-hooks.sh, commands/context-guard.md
Updates installation scripts to register context-forced-eval.sh in Tier 1 hooks and add UserPromptSubmit entry to settings.json. Adds detection logic and warnings for missing UserPromptSubmit hook during installation/uninstall flows.
Skill Descriptions
.claude/skills/ai-context/SKILL.md, .claude/skills/context-guard/SKILL.md
Expands ai-context skill description to clarify scope: added emphasis on updating/fixing out-of-date context, refreshing files, and promoting patterns. Adds context-guard documentation for the new UserPromptSubmit hook integration.
Project Documentation
AGENTS.md, CHANGELOG.md, llms.txt
Updates hook count from 6 to 7 in AGENTS.md. Adds Context Forced Eval Hook entry to llms.txt manifest. CHANGELOG documents three documentation-related fixes including improved skill descriptions and context guard reliability.
Environment & Metadata
.github/CODEOWNERS, .gitignore, _typos.toml
Adds CODEOWNERS entry routing all paths to core team. Expands .gitignore with three new directories (ai-context-workspace/, incoming/, tests/activation-results/). Adds regex partial match entry promot for promotion-related spell checking.
Test Coverage
tests/test-hooks.sh
Adds new Section 7 test suite for context-forced-eval.sh covering slash-commands, NL keywords, non-matching prompts, gate logic, and cleanup. Includes duplicate test section (appears twice). Updates header comment to reference 7 ContextDocs hooks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 With twitching nose and keywords keen,
Our hook-eval hops the prompt scene,
Context detected, skills aligned—
The finest guidance, smartly designed!

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ai-context-nl-triggering
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant