claude-code - 💡(How to fix) Fix Feature request: declarative `requires:` and `skill-allowlist:` so subagents can lazy-load only the skills they need [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55989Fetched 2026-05-05 06:01:02
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3commented ×1

Error Message

  1. A subagent attempting to invoke a skill not in its closure receives a clear error or a load-on-demand path (implementation detail).

Root Cause

Filing both separately because the surfaces are distinct.

RAW_BUFFERClick to expand / collapse

Problem

When the parent session spawns a subagent (Agent tool, agent-team workflows, etc.), the subagent inherits the parent's full skill registry and tool catalog as context, even when the agent definition's Tools: whitelist is narrow.

This eager broadcast is conservative-by-default — the loader assumes any skill might be invoked transitively — but the cost compounds:

  • The skill-list text is on the order of tens of kilobytes (grows with every new skill the user installs)
  • It is injected on every subagent spawn
  • For workflows that fan out into many parallel subagents (multi-agent forge runs, kickoff discovery waves, parallel test/review passes), this dominates the per-spawn token bill

There is no way for an agent or skill author to tell the loader "this agent only uses these skills" or "this skill only invokes these other skills". The system has no declarative dependency surface, so it cannot lazy-load.

Proposed surface

Add two optional frontmatter fields:

  1. Skill frontmatter gains an optional requires: field listing other skills (e.g. /git:create-pr) and tools (e.g. Bash, Read, AskUserQuestion) the skill genuinely invokes.
  2. Agent frontmatter gains an optional skill-allowlist: field listing which skills the agent is permitted to invoke.

Loader behaviour changes:

  • On subagent spawn, inject only skills listed in skill-allowlist. If the field is absent, fall back to the closure of skills the parent context has actually used in this session (or fall back to current behaviour for backward compatibility — see below).
  • On skill invocation, walk the requires: graph to ensure transitively-needed skills are loaded.
  • Skills NOT in the closure are referenced by name only (no body); the agent can request a load on demand via a tool call or implicit trigger.

Why declarative over discovery

A discovery-based alternative — "the loader scans skill bodies for /namespace:name references and builds the graph automatically" — is appealing but fragile:

  • Skills compose dynamically. An AskUserQuestion branch may invoke different skills based on the user's choice; static analysis cannot resolve which are actually reachable.
  • String-grep for /namespace:name produces false positives in prose, examples, and forbidden-pattern tables. A skill that mentions /git:create-pr only to forbid its direct use would still pull it into the closure.
  • Authors lose control over what counts as a dependency.

Declarative requires: is explicit, reviewable, and enforceable by author-side audit tooling (which is how schema fields are typically validated in skill ecosystems already).

Backward compatibility

  • Skills without requires: keep the current eager-broadcast behaviour. No regression.
  • Agents without skill-allowlist: keep the current full-registry behaviour. No regression.
  • Migration is opt-in. High-traffic skills and agents (those that fan out into many subagents) declare first; the long tail follows over time.

Why this is distinct from a memory-injection hook

A separate request (PreMemoryLoad hook) addresses rule dual-injection from worktree symlink resolution. This request addresses skill / tool catalog eager broadcast at subagent spawn. The two share an architectural family — loader-side cost reduction — but the surfaces and fixes are different:

DimensionMemory-loader hookThis request
What is over-injectedRule filesSkill registry + tool catalog
WhenSession start + every memory refreshEvery subagent spawn
TriggerSymlink → dual realpath resolutionConservative "any skill might be needed" default
Fix shapePre-injection hook + content-hash dedupDeclarative requires: + skill-allowlist: + lazy load

Filing both separately because the surfaces are distinct.

Acceptance criteria

  1. Skill frontmatter requires: field accepts a list of /namespace:name strings and tool names.
  2. Agent frontmatter skill-allowlist: field accepts a list of /namespace:name strings.
  3. On subagent spawn, the loader injects only skills resolvable from skill-allowlist (transitively closed via requires:).
  4. Absence of either field reproduces today's behaviour.
  5. A subagent attempting to invoke a skill not in its closure receives a clear error or a load-on-demand path (implementation detail).

extent analysis

TL;DR

Implementing declarative requires: and skill-allowlist: fields in skill and agent frontmatter can help mitigate the eager broadcast of the full skill registry and tool catalog to subagents.

Guidance

  • Introduce requires: field in skill frontmatter to list invoked skills and tools, enabling the loader to lazy-load transitively needed skills.
  • Add skill-allowlist: field in agent frontmatter to specify permitted skills, allowing the loader to inject only listed skills on subagent spawn.
  • Update the loader to walk the requires: graph for skill invocation and load skills on demand via tool calls or implicit triggers.
  • Ensure backward compatibility by maintaining current behavior for skills and agents without the new fields.

Example

# Skill frontmatter example
requires:
  - /git:create-pr
  - Bash
  - Read

# Agent frontmatter example
skill-allowlist:
  - /git:create-pr
  - /my-skill:my-subskill

Notes

The proposed solution relies on the introduction of new frontmatter fields, which may require updates to existing skills and agents. The requires: and skill-allowlist: fields should be carefully validated to ensure correct functionality.

Recommendation

Apply the proposed workaround by introducing the requires: and skill-allowlist: fields in skill and agent frontmatter, as this approach provides a declarative and explicit way to manage skill dependencies and reduce the eager broadcast of the skill registry and tool catalog.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Feature request: declarative `requires:` and `skill-allowlist:` so subagents can lazy-load only the skills they need [1 comments, 2 participants]