feat: add skill-guards plugin to enforce fresh execution on every skill invocation#196
feat: add skill-guards plugin to enforce fresh execution on every skill invocation#196JacobPEvans wants to merge 2 commits intomainfrom
Conversation
…ll invocation When skills like /ship or /finalize-pr are called multiple times in a session, Claude shortcuts by assuming prior results are still valid. This adds a three-layer defense: a UserPromptSubmit hook that injects a "FRESH EXECUTION" systemMessage on every /skill-name prompt, and skill-specific state warnings in the 6 highest-value skills naming the async events that make their state stale. (claude)
There was a problem hiding this comment.
Pull request overview
Adds a new skill-guards hook-only plugin to reduce “stale state” behavior by injecting a fresh-execution reminder whenever a user invokes a /skill, plus adds skill-level preamble warnings for commonly re-invoked skills.
Changes:
- Introduces
skill-guardsplugin with aUserPromptSubmithook that detects/skill-nameand emits asystemMessagereminder. - Adds bats coverage for skill detection and false-positive exclusions.
- Adds “State warning” preambles to several high-usage skills and registers the plugin in repo metadata/spellcheck/marketplace.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
skill-guards/scripts/skill-reinvocation-guard.sh |
New UserPromptSubmit hook script that detects skills and injects a fresh-execution systemMessage. |
skill-guards/hooks/hooks.json |
Registers the new hook command with a short timeout. |
skill-guards/.claude-plugin/plugin.json |
Adds plugin manifest for skill-guards v2.3.2. |
skill-guards/README.md |
Documents the plugin’s purpose, installation, and behavior. |
tests/skill-guards/skill-reinvocation-guard/skill-reinvocation-guard.bats |
Adds bats tests for detection, exclusions, and malformed/empty input. |
github-workflows/skills/*/SKILL.md |
Adds state-staleness warning preambles to selected skills. |
git-workflows/skills/*/SKILL.md |
Adds state-staleness warning preambles to selected skills. |
AGENTS.md |
Registers the new plugin in the repo’s plugin list. |
.claude-plugin/marketplace.json |
Adds skill-guards to marketplace inventory with matching version/metadata. |
cspell.json |
Adds “reinvocation” to allowed words. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/skill-guards/skill-reinvocation-guard/skill-reinvocation-guard.bats
Show resolved
Hide resolved
tests/skill-guards/skill-reinvocation-guard/skill-reinvocation-guard.bats
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Code Review
This pull request introduces the skill-guards plugin, which implements a UserPromptSubmit hook to ensure fresh execution of skills by injecting a system message when a skill invocation is detected. It also adds state warnings to several SKILL.md files to remind the model to re-fetch live data. The review feedback focuses on improving the robustness of the skill-reinvocation-guard.sh script, specifically by refining the regex to avoid false positives with filesystem paths, expanding the directory exclusion list, and following shell best practices such as using printf instead of echo.
- Use heredoc (<<<) instead of echo for jq input to avoid backslash/hyphen issues - Use printf instead of echo for all JSON output (shell best practice) - Tighten regex with trailing non-match anchor to prevent partial matches - Add root|sbin to filesystem path exclusion list - Add jq fallback (printf) for systemMessage emission if jq fails - Use jq for JSON construction in test helper to handle special characters (claude)
Summary
Introduces the
skill-guardsplugin, a three-layer defense-in-depth system to ensure Claude re-executes skills from scratch on every invocation instead of reusing stale cached results. This layer injects a "FRESH EXECUTION" systemMessage via UserPromptSubmit hook when a skill is invoked, forcing complete re-evaluation.Changes
skill-guards plugin (
skill-guards/): New plugin with:/skill-name).claude-plugin/marketplace.jsonfor discoverySkill state warnings (6 skills updated):
/ship,/finalize-pr,/resolve-pr-threads,/refresh-repo,/wrap-up,/squash-merge-pr/shipwarns about queued/running workflow jobs;/finalize-prwarns about comment/review state changesConfiguration updates:
AGENTS.md: Added skill-guards to plugin referencecspell.json: Added skill-guards-specific vocabularyTest Plan
/shiptwice → verify systemMessage appears and all steps re-execute/usr/bin/python→ verify no false positive triggerArchitecture
Part of a three-layer defense-in-depth system:
🤖 Generated with Claude Code