You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compress skill files via progressive disclosure to cut token/context cost (help wanted) #1106
The skill files are large and get loaded into the agent's context on every /graphify invocation, burning tokens on material that isn't needed for the task at hand. Current sizes:
Every one carries the full extraction spec, per-language node-ID rules, embedded Python snippets, and troubleshooting inline. On smaller-context agents this is a real squeeze (see also #984 "too much context"), and it inflates token cost for simple queries that never touch most of that content.
Ask (help wanted)
Compress / restructure the skill files via progressive disclosure so the always-loaded core stays minimal:
Keep skill.md lean — the trigger, the high-level workflow, and routing. Target a fraction of the current size.
Move the heavy reference material into separate files loaded on demand:
the extraction JSON spec + node-ID format rules
per-language extraction details
platform-specific setup / troubleshooting
Move embedded Python snippets out of the always-loaded path into referenced script files.
Because the bulk is duplicated across all 14 platform variants, a shared-fragment / templated-generation approach would cut both context size and the maintenance burden of keeping 14 files in sync.
Constraints
Node-ID format rules and the extraction JSON contract must stay byte-accurate after the split — these are load-bearing (a wrong stem/format silently creates ghost-duplicate nodes). Don't paraphrase them during the move.
Verify the on-demand references actually resolve on each platform's loader (Claude Code skills, Codex, OpenCode, etc.) before/after.
Related: #1045 (same underlying request from a user). Filing this as a tracked, scoped help-wanted task.
Happy to take this on. Here's the design I propose:
Shared-fragment generator. Add skill_src/ (a lean core.md body plus per-platform delta files for the frontmatter description, the /graphify vs $graphify token, and install paths) and a build script that generates all 14 skill-*.md. Generated files stay committed. CI regenerates and diffs to catch drift. This kills the 14-files-in-sync manually burden.
Progressive disclosure. Lean SKILL.md (target ~250 lines: trigger, workflow overview, routing). Heavy material moves to shared, on-demand reference/ files: extraction-spec.md (JSON contract plus node-ID rule), languages.md, commands.md (query/path/explain/add/update/cluster-only/watch), and troubleshooting.md, plus bash/python heredocs pulled out into scripts/.
Install change_copy_skill_file currently copies a single file to SKILL.md. Progressive disclosure will need the reference/ and scripts/ files next to it, so I would change install to copy the whole skill directory. Reference files will be platform-agnostic, so they're stored once and copied into each platform's skill dir alongside the generated SKILL.md. I'd verify against each loader (Claude Code, Codex, OpenCode, and so on) that sibling-file reads resolve.
Byte-accuracy guardrail. Node-ID rule plus JSON contract move verbatim into extraction-spec.md, pinned by a test (extends test_file_node_id_spec.py) so they can never be paraphrased.
Questions
OK with install copying a directory instead of a single file?
Prefer I land Claude-only first as a reviewable reference impl, then roll out the other 13, or do all 14 in one PR?
Any platform loaders you know won't follow sibling-file references (so those are kept self-contained)?
@TPAteeq great proposal. We dug into this from our end too — sharing findings + answers so you don't repeat the work.
Answers to your 3 questions:
Directory copy — yes. Two gotchas: package-data needs globs (reference/*.md, scripts/*) and they must actually land in the wheel; and uninstall currently unlink()s a single file then rmdirs parents — with a dir it would orphan reference//scripts/ and fail on non-empty dirs, so switch to shutil.rmtree. That uninstall logic is duplicated in ~4 places (main + vscode/antigravity/kiro), all need it. Write SKILL.md last for crash-safety.
Claude-only first — strongly. Only true skill loaders benefit from progressive disclosure; rolling 13 at once multiplies unverified sibling-ref risk.
Loaders that won't follow sibling refs → keep self-contained: Cursor rules, Codex AGENTS.md, OpenClaw, Kiro steering, Devin/windsurf, Antigravity rules. Treat any loader as self-contained until verified.
Findings worth knowing:
Don't split by "scripts vs prose" — split by command. ~half the code-fenced content isn't runnable scripts; it's the extraction subagent prompt template + JSON schema + the byte-exact node-ID spec (skill.md Step 3, ~284 lines) — load-bearing instructions the agent must read, not heredocs you can externalize. We mapped a lossless route-by-command split: lean ~80-line SKILL.md + reference/{extract,update,query,add,watch}.md (verbatim slices). A /graphify query then loads ~184 lines vs 1156 (~84% cut); fresh extract ~32%. That's where the real per-invocation win is.
The 14 variants have drifted, and ~8 are stale with real bugs — they carry ~56 bare-path refs (Path('.graphify_detect.json') instead of graphify-out/... → FileNotFoundError in the final step) + ~40 missing encoding= that skill.md already fixed. So make skill.md the generator's source of truth — regenerating is also a correctness fix, not just dedup.
Byte-accuracy guardrail: pin the node-ID examples against the code (_file_node_id/_file_stem), not a frozen string — extend tests/test_file_node_id_spec.py. Otherwise doc and code can drift together.
Shipped in 0.8.29 via #1121. The per-host SKILL.md is now a lean core (~615 lines, down from ~1156) that carries the full default code-build pipeline inline and links to an on-demand references/ sidecar (extraction-spec, query, update, exports, transcribe, github-and-merge, add-watch, hooks). An agent reads a reference only when that path is actually taken, so a normal build pulls none of them. The references are byte-identical slices of the old monolith, enforced by CI guards (--audit-coverage, --monolith-roundtrip, --always-on-roundtrip), so nothing is lost. Applied across 18 hosts. Thanks for raising this.
Activity
TPAteeq commentedon Jun 2, 2026
Skill restructure proposal
Happy to take this on. Here's the design I propose:
Shared-fragment generator. Add
skill_src/(a leancore.mdbody plus per-platform delta files for the frontmatter description, the/graphifyvs$graphifytoken, and install paths) and a build script that generates all 14skill-*.md. Generated files stay committed. CI regenerates and diffs to catch drift. This kills the 14-files-in-sync manually burden.Progressive disclosure. Lean
SKILL.md(target ~250 lines: trigger, workflow overview, routing). Heavy material moves to shared, on-demandreference/files:extraction-spec.md(JSON contract plus node-ID rule),languages.md,commands.md(query/path/explain/add/update/cluster-only/watch), andtroubleshooting.md, plus bash/python heredocs pulled out intoscripts/.Install change
_copy_skill_filecurrently copies a single file toSKILL.md. Progressive disclosure will need thereference/andscripts/files next to it, so I would change install to copy the whole skill directory. Reference files will be platform-agnostic, so they're stored once and copied into each platform's skill dir alongside the generatedSKILL.md. I'd verify against each loader (Claude Code, Codex, OpenCode, and so on) that sibling-file reads resolve.Byte-accuracy guardrail. Node-ID rule plus JSON contract move verbatim into
extraction-spec.md, pinned by a test (extendstest_file_node_id_spec.py) so they can never be paraphrased.Questions
@safishamsi
safishamsi commentedon Jun 2, 2026
@TPAteeq great proposal. We dug into this from our end too — sharing findings + answers so you don't repeat the work.
Answers to your 3 questions:
reference/*.md,scripts/*) and they must actually land in the wheel; and uninstall currentlyunlink()s a single file then rmdirs parents — with a dir it would orphanreference//scripts/and fail on non-empty dirs, so switch toshutil.rmtree. That uninstall logic is duplicated in ~4 places (main + vscode/antigravity/kiro), all need it. WriteSKILL.mdlast for crash-safety.AGENTS.md, OpenClaw, Kiro steering, Devin/windsurf, Antigravity rules. Treat any loader as self-contained until verified.Findings worth knowing:
Don't split by "scripts vs prose" — split by command. ~half the code-fenced content isn't runnable scripts; it's the extraction subagent prompt template + JSON schema + the byte-exact node-ID spec (skill.md Step 3, ~284 lines) — load-bearing instructions the agent must read, not heredocs you can externalize. We mapped a lossless route-by-command split: lean ~80-line
SKILL.md+reference/{extract,update,query,add,watch}.md(verbatim slices). A/graphify querythen loads ~184 lines vs 1156 (~84% cut); fresh extract ~32%. That's where the real per-invocation win is.The 14 variants have drifted, and ~8 are stale with real bugs — they carry ~56 bare-path refs (
Path('.graphify_detect.json')instead ofgraphify-out/...→ FileNotFoundError in the final step) + ~40 missingencoding=thatskill.mdalready fixed. So make skill.md the generator's source of truth — regenerating is also a correctness fix, not just dedup.Byte-accuracy guardrail: pin the node-ID examples against the code (
_file_node_id/_file_stem), not a frozen string — extendtests/test_file_node_id_spec.py. Otherwise doc and code can drift together.Preserve the query-first layers: the skill
descriptionclause, thePreToolUsehook, and theAGENTS.md/rules sections enforce "use the graph, don't grep." They live mostly outside the skill body, so the split won't break them — but keep thedescriptionverbatim and add a test asserting it. (Separately filed Agent bypasses the graph by Read-ing files: PreToolUse hook only catches Bash grep, not the Read tool (help wanted) #1114 for a real gap there.)Happy to review the Claude-first PR when it's up.
feat(skills): progressive-disclosure split for all platforms (generat…
safishamsi commentedon Jun 2, 2026
Shipped in 0.8.29 via #1121. The per-host
SKILL.mdis now a lean core (~615 lines, down from ~1156) that carries the full default code-build pipeline inline and links to an on-demandreferences/sidecar (extraction-spec, query, update, exports, transcribe, github-and-merge, add-watch, hooks). An agent reads a reference only when that path is actually taken, so a normal build pulls none of them. The references are byte-identical slices of the old monolith, enforced by CI guards (--audit-coverage,--monolith-roundtrip,--always-on-roundtrip), so nothing is lost. Applied across 18 hosts. Thanks for raising this.feat(skills): progressive-disclosure split for all platforms (generat…