Skip to content

Prevent silent SKILL.md routing degradation from frontmatter truncation #92

Closed

Description

@choo121600

Background

Claude Code applies two truncation limits to SKILL.md frontmatter when building the skill listing shown to the model:

  1. Per-skill limit: description + when_to_use is truncated at 1,536 characters.

“the combined description and when_to_use text is truncated at 1,536 characters in the skill listing to reduce context usage.” — docs

https://code.claude.com/docs/en/skills#frontmatter-reference

  1. Aggregate limit: the total skill listing budget scales dynamically at 1% of the context window, with a fallback of 8,000 characters.

“The budget scales dynamically at 1% of the context window, with a fallback of 8,000 characters.” — docs

https://code.claude.com/docs/en/skills#skill-descriptions-are-cut-short

When these limits are exceeded, descriptions are silently truncated.

This is risky because the trigger keywords and routing cues the model relies on can disappear without warning, causing skills to mis-route or fail to activate entirely.

Current state of this repository

Measured against the 17 SKILL.md files currently under .claude/skills/:

Skill desc + when_to_use
pr-management-code-review 1,704 (168 chars over limit)
setup-steward 1,400
setup-isolated-setup-install 1,292
security-issue-fix 1,249
security-cve-allocate 1,197
… 12 more all under 1,200
Aggregate (post per-skill cap) 18,586

Effective aggregate budgets:

  • Sonnet (200k context): 8,000-char fallback budget → currently ~2.3× over
  • Opus 4.7 (1M context): ~10,000-char dynamic budget (1%) → currently ~1.9× over

Adopters using additional plugin skills increase this even further.

Impact

  • The end of pr-management-code-review frontmatter — including the triage vs. code-review routing distinction — is already being truncated.
  • Aggregate truncation order is not user-controllable, so as the catalog grows, any skill’s trigger keywords may silently disappear.
Image

This can gradually degrade routing reliability in ways that are difficult to diagnose.

Proposal

  1. Audit all SKILL.md files and move expository content out of frontmatter into the document body.

    Keep only:

    • concise trigger phrases
    • routing cues
    • high-signal task descriptions

    Move:

    • rationale
    • implementation notes
    • long examples
    • “distinct from X” explanations
    • criteria source paths
    • sub-step descriptions
  2. Target budgets:

    • keep each description + when_to_use under ~400 chars
    • keep repository aggregate under 5,000 chars

    This provides headroom even for Sonnet adopters and downstream plugin ecosystems.

  3. Add a CI check (or pre-commit hook) that fails when:

    • any skill exceeds the 1,536-char per-skill limit
    • aggregate post-truncation catalog exceeds 8,000 chars
  4. Document these limits in AGENTS.md so future skill authors are aware of the constraints.

Activity

  1. choo121600 commented on May 7, 2026

    @choo121600
    MemberAuthor

    Our current aggregate frontmatter footprint is also significantly larger than many existing Claude Code plugin ecosystems (for example: oh-my-claude-code, astronomer-agents).

    Image

    As adopters combine multiple skill ecosystems, the probability of silent truncation increases further.

  2. self-assigned this
    on May 7, 2026
  3. added
    family:setup
    kind:perf
    on May 7, 2026
  4. andreahlert commented on May 7, 2026

    @andreahlert
    Contributor

    Awesome work! Noticed this too. been thinking more about the architecture side actually, even considered going hook-based or putting a router subagent in front of the catalog before landing on anything.

    No strong opinion yet on how to fix long term. trim solves the bleeding right now so I'm fine starting there

    One thing tho, I ran the numbers per skill and not all of them should be trimmed the same way. some lose disambiguation cues the model actually leans on to pick between siblings (triage vs code-review kinda thing). a few are fine, a couple need careful cuts, a couple probably need their distinct-from notes pushed into AGENTS.md instead of dropped.

    Full breakdown with token math here: https://gist.github.com/andreahlert/a219b526fd6298f0a81c612c64da5ee0

  5. potiuk commented on May 7, 2026

    @potiuk
    Member

    Fantastic diagnosis... I wonder if we can make some automation to a) detect those cases b) decrease the size c) suggest to split things maybe?

    Maybe there are some repos/ideas out there that cold help :) ?

  6. choo121600 commented on May 8, 2026

    @choo121600
    MemberAuthor
  7. choo121600 commented on May 8, 2026

    @choo121600
    MemberAuthor

    Fantastic diagnosis... I wonder if we can make some automation to a) detect those cases b) decrease the size c) suggest to split things maybe?

    Maybe there are some repos/ideas out there that cold help :) ?

    My impression is that the best path is probably to align more closely with Anthropic’s official SKILL.md guidance.
    https://github.com/anthropics/skills/blob/main/skills/skill-creator/SKILL.md#write-the-skillmd
    Additionally, I think applying #87 could also help quite a bit here.

    For (a) and (b), I think we could build a prek validator hook around those conventions to automatically detect oversized / overly verbose sections and encourage more compact structures.

    For (c), I think we already partially address this through the write-skill skill we adopted from JuliusBrussee/awesome-claude-skills
    It already includes guidance around progressive disclosure and skill splitting:

    https://github.com/apache/airflow-steward/blob/88d3d2ec22b18737445c8df96a975942ab1b5c5d/.claude/skills/write-skill/SKILL.md?plain=1#L132-L147

    So I think the main issue is that many of the problematic skills were created before we introduced those conventions.
    My guess is that improving / migrating the existing skills would already eliminate a large portion of the current truncation risk.

  8. potiuk commented on May 8, 2026

    @potiuk
    Member

    Hmm. Before we dive deeper. ... I wanted to get your thinking on "birds eye" view :)

    I am all for optimising things and using less tokens where we can etc.

    However I am not sure if optimising for current context limitation is what we really want. Historically (Well last few months - but this is the history of "really good" AI) - the context sizes grew dramatically. Fast and what was given as limitation 2 months ago is not even afterthought today.

    Recently Anthropic announce "infinite" context windows - for example https://www.geeky-gadgets.com/claude-s-new-infinite-context-window-model/ where the "compacting" of context is really somethign that happens automatically behind the sceens and there is the "dreaming" phase where your data in long running sessions get re-organized and cleaned and where essentially you will have to stop worrying about "context size" and your session getting worse over time because of that.

    I think it's inevitable it will happen and will work like that - fast.... Is it worth to optimize for that today - if in a month from now we will stop worrying about it ?

    It's more of a philosophical question - I love optimisations and analysis like that and I love to know why and what I see as limitation today..

    But ... will it be a limitation tomorrow ?

  9. choo121600 commented on May 8, 2026

    @choo121600
    MemberAuthor

    Great philosophical question :) and I generally agree that over-optimizing for temporary limits is usually wasted effort.

    That said, I think this issue is less about “today’s context window” and more about always-resident routing metadata.

    A few reasons why I see it differently:

    • Silent routing degradation is already happening today. pr-management-code-review is currently over the per-skill cap, and the truncated section is exactly the “triage vs code-review” disambiguation. That feels more like a correctness bug than a token optimization issue.
    • Skill metadata is always loaded. Unlike the SKILL.md body, the catalog permanently occupies user tokens every turn. Even with future context compaction, larger catalogs still increase cost, latency, and routing noise.
    • Users are also unlikely to use airflow-steward in isolation. In practice, many adopters will combine multiple plugin ecosystems, custom skills, or internal company skills together. A larger catalog footprint on our side increases the likelihood that downstream users hit aggregate catalog limits sooner when combining multiple skill ecosystems.

    I’m less convinced that we should spend time chasing arbitrary goals like “under 5,000 chars” purely for optimization’s sake. That does risk overfitting to today’s constraints.

    So I think a more balanced scope would be:

    • fix active per-skill overflow bugs
    • align frontmatter structure with Anthropic’s official progressive-disclosure guidance
    • move explanatory prose into the body or references
    • add validator guardrails so truncation regressions stay visible

    But avoid turning this into a broad “character shaving” effort unless aggregate size becomes a demonstrated operational problem.

  10. andreahlert commented on May 8, 2026

    @andreahlert
    Contributor

    I fully agree with @potiuk on the future: larger context windows are coming, and fast. Saw anthropic CPO speaking openly about "context windows that feel infinite" when combined with high-quality memory. The direction is clear.

    But, and this is an important but more context in the future does not nullify the truncation bugs that already exist today. Anthropic itself published an [April postmortem] about three separate bugs that degraded Claude Code quality, including one where automatic cleanup of idle-session thinking caused the model to become "forgetful and repetitive".

    And in the official Claude Code repo there is an [open issue (#12054)]where a single getDiagnostics() call returned ~580k tokens and consumed nearly the entire remaining session context, triggering a "context low" error .... showing that the tool still does not manage large context volumes well.

    @choo121600's point feels right to me: this is not optimization for optimization's sake. It is a correctness bug,maybe not a bug, since there is no release yet hahah, the pr-management-code-review skill is already being truncated silently today, and the section being cut is exactly the critical disambiguation ("triage vs code-review"). The model may simply pick the wrong tool with nobody noticing.

    I am +1 for the balanced scope he proposed:

    • Fix the active per-skill overflow bugs (bugs today)
    • Align frontmatter structure with Anthropic's official guidance
    • Move expository prose into the body / references
    • Add validator guardrails so truncation regressions stay visible

    Without turning this into an obsessive character-shaving effort.

    @choo121600, if consensus lands here, do you have bandwidth to lead the implementation? I can help and review the more sensitive cuts.

  11. potiuk commented on May 8, 2026

    @potiuk
    Member

    💯 . Thanks - that was very deliberate and thoughtful :).

    Let's go then

  12. choo121600 commented on May 9, 2026

    @choo121600
    MemberAuthor

    Cool 🙌
    It’s already evening here, so starting tomorrow I’ll proceed roughly in this order:

    1. fix the active overflow bugs
    2. add a validator pre-commit hook to detect truncation regressions
    3. gradually move explanatory prose from frontmatter into the body/references for the remaining skills
  13. potiuk commented on May 9, 2026

    @potiuk
    Member

    Cool :)

  14. choo121600 commented on May 11, 2026

    @choo121600
    MemberAuthor

    We can close this issue and track the remaining work in #118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

family:setupkind:perf

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions