Fix fleet-auditor SkillBloat: measure frontmatter only, not full SKILL.md (fixes #16)#17
Merged
alexgreensh merged 1 commit intoApr 8, 2026
Conversation
SkillBloat was measuring the full SKILL.md file per skill, inflating the reported skill overhead by ~19x and producing false high-severity findings (e.g. $136/mo skill_bloat on a fleet where /context shows the real overhead is ~$7/mo). Claude Code only loads each skill's YAML frontmatter (name + description) into the session at startup. SKILL.md bodies are loaded on demand when the user invokes the skill via the Skill tool. Fix: add `_estimate_skill_frontmatter_tokens()` that parses and measures only the frontmatter block. Falls back to the documented 100-token default if no frontmatter is present. Verified on a 41-skill fleet: - Before: 75,578 tokens total (avg 1,843/skill) - After: 4,011 tokens total (avg 97/skill) - Matches Claude Code's own /context output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #16.
fleet-auditor'sSkillBloatdetector was over-counting skill token overhead by ~19x. It measures the fullSKILL.mdfile per skill, but Claude Code only loads the YAML frontmatter (name+description) into the session at startup.SKILL.mdbodies load on demand when the user invokes the skill via the Skill tool.On a 41-skill fleet this produced a false HIGH-severity
$136/mo skill_bloatfinding that's really closer to ~$7/mo, drowning out real waste patterns (empty heartbeats, abandoned sessions).Change
_estimate_skill_frontmatter_tokens(skill_md)helper that parses the file, extracts the YAML frontmatter block (content between the first two---markers), and estimates tokens for just that block.100(the documented average from the detector's own description) if the file has no frontmatter or can't be read.estimate_tokens_from_file(skill_md)with the new helper inClaudeCodeAdapter.parse_config.Verification
Tested on a 41-skill Claude Code install. Cross-checked against
/contextoutput.linkedin)freqtrade-setup)The post-fix distribution matches what Claude Code's own
/contextcommand reports (skills shown as 4-139 tokens each in the context breakdown). The 100-token fallback aligns with the detector's own description string ("~100 tokens each"atfleet.py:749).Impact on
skill_bloatfindingsOn the same 41-skill fleet:
41 skills loaded (75,578 tokens overhead per API call),monthly_waste_usd: 136.0441 skills loaded (4,011 tokens overhead per API call),monthly_waste_usd: ~7.22This is the correct order of magnitude. Users will now see the real top waste source (empty heartbeats) instead of spending hours archiving skills for negligible savings.
Notes
estimate_tokens_from_textalready existed inshared.py— I just added it to the existing import line.🤖 Generated with Claude Code