README.md

skill-prerequisite-check #

Auto-load skill prerequisites as additional context.

When a skill declares a prerequisite via any of the supported markers or list forms, this plugin resolves each reference and injects the contents into the next turn as additionalContext. No more silently skipping the "Read gws-shared/SKILL.md first" instruction that every gws-* skill declares.

How it works #

Registered as a PostToolUse hook on the Skill tool. On every invocation a Go binary launched by scripts/skill-prerequisite-check.sh reads tool_input.skill, resolves it through the registered-skills index to the on-disk SKILL.md, scans that file for prerequisite markers, and emits the combined bodies as additionalContext.

The hook does not consult tool_response.content. As of Claude Code 2.1.x the Skill tool response is {"success":true,"commandName":"<id>"} with no skill body; the body arrives as a separate user-role message the hook never sees. Reading the on-disk SKILL.md keyed on tool_input.skill is the only reliable source.

The binary lives at cmd/skill-prerequisite-check/ in the marketplace repo. The launcher prefers a nix-installed binary on $PATH, falling back to a checksum-verified download of the release artifact.

Supported markers #

Each marker is matched case-insensitively and tolerates surrounding markdown (blockquote prefixes, bold wrapping).

Inline markers:

  • Depends on:
  • MUST READ
  • PREREQUISITE: / Prerequisite:
  • Read first:
  • Requires:
  • See also:

List introducers (own line, followed by bullets):

  • ## Prerequisites (any markdown heading level)
  • Depends on:
  • Prerequisites: / prerequisites:
  • Requires:
  • See also:

A line with non-whitespace content after the marker is treated as inline. A line with only the marker introduces a list that runs until the first blank or non-bullet line.

Reference formats #

Each inline remainder or bullet body is scanned for the first reference it contains, in priority order:

  1. Markdown link: [label](ref)
  2. Backtick-wrapped: `ref`
  3. First non-whitespace token

Resolution #

A path-shaped ref (absolute, contains /, or ends in .md, .txt, .json, .yml, .yaml) resolves against the SKILL.md's own directory. A ref is rejected as unsafe unless its resolved path sits under a known skills root: ~/.claude/skills/ or any install path from ~/.claude/plugins/installed_plugins.json. An unsafe ref emits an UNSAFE PREREQUISITE (path) notice listing the declared ref (never the resolved path), and the file is not read. A safe ref that reads successfully is emitted under a Prerequisite: separator; a safe ref that cannot be read emits a MISSING PREREQUISITE (file) notice instead.

Containment uses filepath.Rel against each root rather than HasPrefix, so a sibling whose name starts with a root path (e.g. /plugins/p-evil vs /plugins/p) is still rejected.

A bare identifier (tdd, gh-security:secure-by-design) is looked up in the registered-skills index. The index enumerates ~/.claude/skills/*/SKILL.md and every install path listed in ~/.claude/plugins/installed_plugins.json. Matching runs exact-then-substring on the short name (and on the plugin prefix if given). A single hit loads the SKILL.md body. Zero hits emits a MISSING PREREQUISITE (skill) notice. Multiple hits emits an ambiguity notice listing the candidates so the next turn can pick one explicitly.

Resolved bodies and notices are concatenated with --- Prerequisite: <ref> --- separators, deduped by raw ref text, and written as hookSpecificOutput.additionalContext.

Installation #

/plugin install skill-prerequisite-check@jcmuller-plugins

Tests #

Behavior coverage lives in Go and runs via the nix devshell:

go test ./cmd/skill-prerequisite-check/... ./internal/skillindex/...

The bats suite is a launcher smoke test only:

bats tests/skill-prerequisite-check.bats