Skip to content

Enforce skill invocation via UserPromptSubmit routing hook #154

Description

@vivek7405

Problem

Agent Skills (webjs-file-issue, webjs-start-work, webjs-list-todos, use-railway) are model-invoked: they fire only when the model judges a request to match their triggers, and that judgement can be wrong. In one session a "can we add prefetch, verify in the remix repo, let me know if we can" request was treated as pure research, so the webjs-file-issue workflow was skipped and code investigation began with no tracked issue. Skill descriptions and AGENTS.md prose are advisory; only a hook is deterministic, the same way block-prose-punctuation.sh enforces the em-dash rule.

Design / approach

Add a UserPromptSubmit hook (.claude/hooks/route-skills.sh) that runs on every prompt and, from the prompt TEXT (not model judgement):

  1. Keyword routes the prompt against each skill's documented triggers and, for each hit, injects a high-priority directive naming the skill to invoke via the Skill tool BEFORE other work.
  2. Always injects a generic standing policy: before acting, check the available skills and invoke any whose purpose matches, because skills encode required workflow. This is generic across ALL skills, not a rule about filing GitHub issues specifically. It also covers the research-becomes-build case keyword routing can miss.

Verified mechanics against the Claude Code hooks reference: a hook CANNOT force a Skill tool-call; the strongest deterministic lever is UserPromptSubmit additionalContext injected as a system reminder. So keyword cases are deterministic; genuinely-ambiguous prompts lean on the always-injected policy. Honest ceiling, documented as such.

Wired into .claude/settings.json alongside the existing PreToolUse / PostToolUse hooks. Lives in the repo .claude/ so every agent on webjs gets it (personal ~/.claude/skills already shadow project skills, so the skills themselves are not duplicated into the repo).

Acceptance criteria

  • UserPromptSubmit hook routes file-issue / start-work / list-todos / railway trigger phrases to the right skill
  • Standing skill policy is injected on every prompt, including ones with no keyword match
  • Hook emits valid hookSpecificOutput.additionalContext JSON and exits 0 (never blocks a prompt)
  • Registered in .claude/settings.json; merged config is valid JSON
  • AGENTS.md documents the hook in the agent-config table
  • Tests cover the routing decisions (each skill's triggers + the no-match standing-only case)

Activity

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions