mirror of
https://github.com/addyosmani/agent-skills.git
synced 2026-10-26 15:05:04 +00:00
The plugin's SessionStart hook injected using-agent-skills/SKILL.md as
additionalContext on every session. Claude Code already discovers and
routes skills from their descriptions, so the hook stacks a second
router on the native one — the pattern docs/getting-started.md warns
against ("That creates two routers for the same task"), measured at
~3.5k wasted cache-creation tokens per session in #569.
Delete hooks/hooks.json (the registration; the plugin now ships no
hooks) and keep hooks/session-start.sh as a standalone script for hosts
without native skill routing, matching the fix shape suggested in the
issue. Update the hook header, CONTRIBUTING.md, codex-setup.md, and
gemini-cli-setup.md to match.
34 lines
1.6 KiB
Bash
Executable File
34 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# agent-skills session start hook
|
|
# Injects the using-agent-skills meta-skill into a new session.
|
|
#
|
|
# Not wired by the plugin: hosts that already route skills from their
|
|
# descriptions (Claude Code, Codex CLI) would run a second router on top of
|
|
# the native one — see docs/getting-started.md. Wire this script into a
|
|
# SessionStart hook only on hosts without native skill routing.
|
|
#
|
|
# Every output path must emit the standard SessionStart envelope
|
|
# {"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "..."}}
|
|
# Hosts that validate hook output (Codex CLI, Claude Code) reject other shapes.
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
SKILLS_DIR="$(dirname "$SCRIPT_DIR")/skills"
|
|
META_SKILL="$SKILLS_DIR/using-agent-skills/SKILL.md"
|
|
|
|
if ! command -v jq >/dev/null 2>&1; then
|
|
echo '{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "agent-skills: jq is required for the session-start hook but was not found on PATH. Install jq (e.g. `brew install jq` or `apt-get install jq`) to enable meta-skill injection. Skills remain available individually."}}'
|
|
exit 0
|
|
fi
|
|
|
|
if [ -f "$META_SKILL" ]; then
|
|
CONTENT=$(cat "$META_SKILL")
|
|
# Use jq to properly escape and construct valid JSON
|
|
jq -cn \
|
|
--arg context "agent-skills loaded. Use the skill discovery flowchart to find the right skill for your task.
|
|
|
|
$CONTENT" \
|
|
'{hookSpecificOutput: {hookEventName: "SessionStart", additionalContext: $context}}'
|
|
else
|
|
echo '{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "agent-skills: using-agent-skills meta-skill not found. Skills may still be available individually."}}'
|
|
fi
|