Add token-efficient-skill-optimizer - #27
Conversation
Audits and optimizes an existing skill, system prompt, or agent instruction set for token/cost efficiency without degrading quality or safety. What makes it different from generic "make it shorter" advice: - Six honesty labels on every quantitative claim (measured / estimated / projected / cache-dependent / behavior-dependent / reported), enforced by scripts/validate_report.py, which blocks delivery on FAIL. - The audited artifact is treated as untrusted data: instructions embedded in it are recorded as injection findings, never followed. - Safety text is exempt from every removal, merge, and compression rule (R-S1). - 38 rules, each carrying source ids into a 42-source verified research corpus. Hebrew and bilingual handling is explicit: language-suffixed translation files are reported as bilingual_sibling_pairs rather than as duplication to delete, and trigger detection includes Hebrew conditional markers. Includes SKILL_HE.md, metadata.json, and evidence.json (12 claims, each with a primary source URL and snippet). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Welcome to Skills IL! Thanks for your first contribution. Our automated checks are running now:
While you wait, make sure you've reviewed our Contributing Guide. A maintainer will review your PR within 48 hours. |
Markdown resolves base direction per block from the first strong character.
Headings like '### Analyze (ביקורת בלבד)' and list items like '- Apply: ...'
resolved LTR, which mis-renders the Hebrew that follows. Reworded so each
block opens with a Hebrew word ('### מצב Analyze — ...', '- במצב Apply: ...').
Content is unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…nest Every one of the 48 cases asked "given that the skill fired, did it behave?" None asked "should it have fired at all?" That is this package's own R-09 defect class: T-07 flags a missing negative boundary in other people's frontmatter while carrying no case for its own. - T-31..T-36 in tests/cases.jsonl (split 20 -> 26, pool floor 40 -> 46). Each row names a distinct false-fire surface, not one probe reworded: lexical collision on "token" (auth credentials) and on "optimize"/"cost" (runtime rendering, infrastructure spend), the two exclusions named in the description (one-off wording help, authoring a new skill), and subject-matter overlap with no artifact to audit. - Deliberately NO harmful-target row: H-07 owns that behaviour in the sealed holdout, and authoring a development twin after reading it would convert the holdout into training data. - Two mechanical guards, because model-graded cases are blind to the frontmatter clause they depend on. "description states a negative boundary (R-09)" and "description names positive triggers (R-09)" fail the build if an optimization deletes "Do NOT use for..." or the quoted triggers to save ~40 tokens -- the exact edit G-08 exists to flag, now enforced on this package and not only on its targets. Without them all six cases stay green while the behaviour breaks. Mutation-verified, all four: deleting a case, duplicating a prompt, stripping "Do NOT use", stripping the quoted triggers -- each produced the specific expected FAIL. Suite 100 -> 104, gates 10/10. Three names pinned in REQUIRED_TESTS so a rename cannot hollow them out. Honest limit recorded in tests/README.md: these cases test behaviour once the skill is already in context. Whether the host loads it at all is decided upstream from the description and no in-package test can observe it. Prompted by skills-il/developer-tools#27, whose checklist item "verified doesn't trigger on unrelated topics" could not be ticked honestly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The checklist item "verified doesn't trigger on unrelated topics" was left unticked because there was no evidence to point at. There is now. - T-31..T-36 in tests/cases.jsonl (split 20 -> 26). Each row names a distinct false-fire surface: lexical collision on "token" (auth credentials) and on "optimize"/"cost" (runtime rendering, infrastructure spend), the two exclusions named in the description, and subject-matter overlap with no artifact to audit. - Two mechanical guards in run_tests.py, because model-graded cases are blind to the frontmatter clause they depend on: an optimization that deletes "Do NOT use for..." to save ~40 tokens would leave all six cases green while breaking every one of them. - All four assertions mutation-verified; upstream suite 100 -> 104, gates 10/10. Honest limit, recorded in tests/testing-guide.md: these cases test behaviour once the skill is already in context. Whether the host loads it at all is decided upstream from the description and no in-package test can observe it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Closing the loop on the one checklist item I left unticked: verified doesn't trigger on unrelated topics is now backed by evidence rather than a claim, pushed as v1.2.1. Six Two mechanical guards came with them, because the cases alone would be theatre: a model-graded case can't see the frontmatter clause it depends on, so an optimization that deletes One limit I'd rather state than paper over: these cases test behaviour once the skill is already in context. Whether the host loads it at all is decided upstream from the description, and no in-package test can observe that. The guards cover the precondition, not the routing decision — if you have a way to exercise host-level routing on your side, I'd rather use yours. Full detail in the PR description. CI is still waiting on maintainer approval for the workflow runs (first-time fork contributor). |
Description
Adds
token-efficient-skill-optimizer/— a meta-skill that audits and optimizes an existing skill, system prompt, agent instruction set, or workflow for token and cost efficiency, without degrading quality or safety.Seven modes: Analyze (audit only) · Recommend (plan) · Apply (optimize + reviewable diff) · Benchmark (before/after) · Explain · Refresh Evidence · Batch Audit (a whole skills directory).
Why this is not "make your prompt shorter" advice
[measured](needs a data pointer),[estimated],[projected],[cache-dependent],[behavior-dependent],[reported].scripts/validate_report.pyblocks delivery on FAIL. Failed and reverted optimizations get reported, not hidden.R-S1). Grounded in arXiv:2510.22963, where black-box attacks on prompt-compressed agents hit a 0.71 average success rate vs 0.21 for the strongest baseline.Relevance to Israeli / Hebrew skills
Hebrew is under-represented in BPE vocabularies, so the same sentence costs more tokens in Hebrew than in English — which makes token auditing more valuable for a Hebrew-first catalog, not less. Two behaviours are explicit and testable:
measure_tokens.pydetects language-suffixed siblings (X-he.mdbesideX.md) and reports them asbilingual_sibling_pairs, separate fromduplicates— so a bilingual skill is never told to delete its own translation.כאשר,רק,אם,לפני,בעת,במקרה) alongside English and Chinese, so a Hebrew skill's routing text is not mis-scored as prose.Prior results (upstream, reproducible at pinned commits)
Run against three heavily-installed public skills. Token figures are
[estimated](tokenizer proxy with a disclosed ×1.15–1.25 Claude adjustment); byte counts are[measured].improve-codebase-architecture(Matt Pocock)react-best-practices(Vercel)frontend-design(Anthropic)The third row is the one I'd point a reviewer at: the skill reverted its own optimization and reported it. That is the intended behaviour.
Two deltas from upstream, both required by the catalog rules
Documented in a "Distribution note" section inside
SKILL.mdandSKILL_HE.md, so an installed copy explains itself:README.md— the catalog forbids it, soscripts/validate_package.pydrops it from its own C01 inventory.tests/fixtures/is not shipped — those fixtures are deliberately malformed skill packages used as negative test cases. Shipping them would put 11 invalidSKILL.mdfiles into the catalog (and would failvalidate-skill.shwith 7 errors — I checked).scripts/run_tests.pyis included for reference but needs them; the deterministic suite runs from the upstream repo.scripts/validate_package.pyruns fully here.Local verification before opening this PR
Upstream repo (MIT, full harness + research corpus): https://github.com/yosishe/token-efficient-skill-optimizer
Update — v1.2.1: the negative-trigger gap is closed
Your checklist asked for something I couldn't evidence, so I built it rather than ticking the box. All 48 existing cases asked given that the skill fired, did it behave? None asked should it have fired at all? — which is this package's own
R-09defect class, sinceT-07flags exactly that in other people's frontmatter.Six cases (
T-31–T-36), each a distinct false-fire surface, not one probe reworded:T-31T-32T-33T-34T-35T-36Deliberately no harmful-target row.
H-07already owns that behaviour in the sealed holdout; authoring a development twin after reading it would turn the holdout into training data.Two mechanical guards, because the six cases alone would be theatre. Model-graded cases are blind to the thing they depend on — the frontmatter clause that makes not-firing possible. An "optimization" that deletes
Do NOT use for…to save ~40 tokens would leave all six green while breaking every one. Sorun_tests.pynow also assertsdescription states a negative boundary (R-09)anddescription names positive triggers (R-09). That isG-08turned on this package instead of only on its targets.Mutation-verified, since a test that has never failed proves nothing — deleting a case, duplicating a prompt, stripping
Do NOT use, and stripping the quoted triggers each produced the specific expected FAIL:Upstream suite 100 → 104, package gates 10/10, split floors raised (
cases20→26, pool 40→46) so the coverage can't be silently hollowed out, and the three load-bearing names pinned inREQUIRED_TESTSso a rename can't empty them.What this does not verify, stated plainly in
tests/testing-guide.md: these cases test the skill's behaviour once it is already in context. Whether the host loads it at all is decided upstream from thedescription, and no test inside the package can observe that — it needs the agent in the loop. The guards cover the precondition, not the routing decision. If your side has a way to exercise host-level routing, I'd rather use yours than claim mine covers it.I left
README.md's skills table alone — it currently lists 10 of the 31 skill folders, so it doesn't look like it's maintained per-PR. Happy to add a row if you'd like one.Checklist
Quality (human review)
[What] + [When] + [Capabilities]pattern with trigger phrasesTesting (required)
mode-routingcases intests/cases.jsonlare paraphrases ("Why is this agent so expensive to run?", "Cut this skill's cost")negative-triggercasesT-31–T-36intests/cases.jsonl, plus two mechanical guards. Details below.Agent Testing
validate_package.pypasses 10/10 on this exact folder.supported_agentsbecause the skill is plain Markdown + Python with no Claude-specific APIs, but I have not verified it there and would rather say so than claim it.One thing I'd flag rather than let a reviewer find it:
references/measurement.mdstates that tiktoken undercounts Claude tokens by ~15–20%, attributed to Anthropic's token-counting guidance, and that attribution has no URL in the corpus. It is deliberately excluded fromevidence.jsonfor that reason. Happy to either source it properly or soften the wording if you'd prefer.