fix(hooks): stop auto-injecting the meta-skill on SessionStart (#569)

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.
This commit is contained in:
Santhi Prakash committed 2026-09-15 19:21:06 +00:00
1 parent be4e44a9fb
commit a598aab8d6
5 files changed
+9 -18

No files matched your search

+1 -1
View File
@@ -81,7 +81,7 @@ We don't accept translations of the documentation (README, `docs/`) or of skills
## Testing Hooks
The session-start hook (`hooks/session-start.sh`) injects the `using-agent-skills` meta-skill into every new Claude Code session. A regression test at `hooks/session-start-test.sh` validates the hook's JSON payload — both when `jq` is available and when it isn't.
The session-start script (`hooks/session-start.sh`) injects the `using-agent-skills` meta-skill when wired into a host's `SessionStart` hook. The Claude Code plugin does not register it — Claude Code routes skills natively, and always-on injection would create two routers for the same task (see [docs/getting-started.md](docs/getting-started.md)); the script remains for hosts without native skill routing. A regression test at `hooks/session-start-test.sh` validates the script's JSON payload — both when `jq` is available and when it isn't.
Run it before opening any PR that touches:
+1 -1
View File
@@ -32,4 +32,4 @@ After install, invoke a skill in Codex chat with `@` (e.g. `@spec-driven-develop
- `.agents/plugins/marketplace.json` — marketplace entry declaring the repo root (`./`) as the plugin source.
- `skills/<name>/SKILL.md` — unchanged. Codex and Claude Code share the same `name` + `description` frontmatter format, so one file serves both platforms.
Slash commands in `.claude/commands/`, personas in `agents/`, and the lifecycle hook under `hooks/` stay Claude Code-specific. On Codex, invoke the underlying skill directly instead of the slash command (e.g. `@spec-driven-development` instead of `/spec`).
Slash commands in `.claude/commands/` and personas in `agents/` stay Claude Code-specific. The `SessionStart` script under `hooks/` is a standalone helper for hosts without native skill routing and is not wired by either plugin. On Codex, invoke the underlying skill directly instead of the slash command (e.g. `@spec-driven-development` instead of `/spec`).
+1 -1
View File
@@ -93,7 +93,7 @@ To enable these, ensure you have the relevant MCP extensions installed in your G
Gemini CLI supports session lifecycle hooks. You can use these to automatically inject context or run validation scripts at the start of a session.
To replicate the `agent-skills` experience from other tools, you can configure a `SessionStart` hook that reminds you of the available skills or loads a meta-skill.
To replicate the `agent-skills` experience from other tools, you can configure a `SessionStart` hook that reminds you of the available skills or loads a meta-skill. `hooks/session-start.sh` in this repo is a ready-made script for that: it prints the `using-agent-skills` meta-skill as a standard `SessionStart` JSON envelope on stdout.
### Explicit Context Loading
-14
View File
@@ -1,14 +0,0 @@
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "SCRIPT=\"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh\"; [ -f \"$SCRIPT\" ] || SCRIPT=\"${CLAUDE_PROJECT_DIR}/.claude/hooks/session-start.sh\"; [ -f \"$SCRIPT\" ]&& bash \"$SCRIPT\" || true"
}
]
}
]
}
}
+6 -1
View File
@@ -1,6 +1,11 @@
#!/bin/bash
# agent-skills session start hook
# Injects the using-agent-skills meta-skill into every new session
# 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": "..."}}