oliverweissl/context-garden / skills/weeder
weeder
VerifiedMeasure and reduce a Skill's token footprint (always-loaded description + on-trigger SKILL.md body) without regressing routing accuracy or losing instructions. Use when a SKILL.md feels oversized, repeats rules, or has a vague description that might mis-route.
| File | Kind | Size |
|---|---|---|
| .gitignore | other | 32 B |
| SKILL.md | skill md | 3.1 KB |
| agents/weeder.md | markdown | 1.2 KB |
| bin/weederexecutable | script | 292 B |
| references/classification.md | markdown | 4.9 KB |
| references/llm-assist.md | markdown | 2.1 KB |
| references/routing-heuristic.md | markdown | 4.1 KB |
| scripts/cg_mode.py | script | 5.4 KB |
| scripts/we_apply_suggestion.py | script | 5.7 KB |
| scripts/we_audit.py | script | 5.6 KB |
| scripts/we_config.py | script | 2.5 KB |
| scripts/we_constraints.py | script | 5.1 KB |
| scripts/we_dupes.py | script | 6.1 KB |
| scripts/we_filler.py | script | 4.9 KB |
| scripts/we_optimize.py | script | 4.3 KB |
| scripts/we_parse.py | script | 5.0 KB |
| scripts/we_routing.py | script | 4.5 KB |
| scripts/we_suggest.py | script | 3.8 KB |
| scripts/we_text.py | script | 2.1 KB |
| scripts/we_tokens.py | script | 4.1 KB |
| scripts/weeder.pyexecutable | script | 12.0 KB |
| tests/fixtures/answer_lot.json | config | 875 B |
| tests/fixtures/filler_sentences.json | config | 2.6 KB |
| tests/fixtures/routing_examples.json | config | 489 B |
| tests/smoke_test.shexecutable | script | 14.3 KB |
scripts/we_routing.py
View on GitHub"""Lexical PROXY for "would a model pick this skill for this prompt": good for
catching before/after regressions, not for borderline cases (confirm those
with a real agent). See references/routing-heuristic.md.
"""
from __future__ import annotations
import re
_STOPWORDS = {
"the",
"a",
"an",
"in",
"on",
"of",
"to",
"for",
"and",
"or",
"is",
"are",
"this",
"that",
"with",
"when",
"please",
"need",
"want",
"use",
"using",
"help",
"me",
"my",
"it",
"be",
"at",
"by",
"from",
"you",
"your",
"i",
"can",
"would",
"like",
"some",
"any",
}
_WORD_RE = re.compile(r"[A-Za-z_][A-Za-z0-9_]*")
_CAMEL_RE = re.compile(r"[A-Z]?[a-z0-9]+|[A-Z]+(?=[A-Z]|$)")
def _split_identifier(token: str) -> list[str]:
return [m.lower() for m in _CAMEL_RE.findall(token) if m]
# Below this, a best match is too weak to count as a trigger -- matters
# most with no --competing descriptions, where anything nonzero would
# otherwise "win" by default.
MIN_SCORE = 0.2
def _stem(word: str) -> str:
"""Light suffix stripping so "files"/"file", "deleting"/"delete"
match; not a real stemmer (see routing-heuristic.md)."""
for suffix, min_len in (("ing", 6), ("ed", 5), ("es", 5), ("s", 4)):
if word.endswith(suffix) and len(word) >= min_len and not word.endswith("ss"):
word = word[: -len(suffix)]
break
return word.rstrip("e") if len(word) > 4 else word
def extract_keywords(text: str) -> set[str]:
words = _WORD_RE.findall(text or "")
out = set()
for w in words:
out.add(w.lower())
out.update(_split_identifier(w))
return {_stem(w) for w in out if len(w) > 1 and w not in _STOPWORDS}
def relevance_score(description: str, prompt: str) -> float:
"""Fraction of the prompt's keywords the description contains (not Jaccard,
so a longer description isn't penalised)."""
desc_kw = extract_keywords(description)
prompt_kw = extract_keywords(prompt)
if not desc_kw or not prompt_kw:
return 0.0
return len(desc_kw & prompt_kw) / len(prompt_kw)
def predict_trigger(
descriptions: dict[str, str], prompt: str
) -> tuple[str | None, dict[str, float]]:
"""`descriptions`: {skill_name: description_text}, at minimum the
skill under test plus any --competing descriptions supplied. Returns
(winning_skill_name_or_None, all_scores). None if the best score is
below MIN_SCORE (nothing matched meaningfully)."""
scores = {name: relevance_score(desc, prompt) for name, desc in descriptions.items()}
if not scores:
return None, scores
best = max(scores, key=lambda k: scores[k])
if scores[best] < MIN_SCORE:
return None, scores
return best, scores
def evaluate_routing(
skill_name: str, skill_description: str, examples: dict, competing: dict[str, str] | None = None
) -> dict:
"""`examples`: {"positive": [prompt, ...], "negative": [prompt, ...],
"ambiguous": [{"prompt":, "expected": "trigger"|"no_trigger"|"either"}]}."""
competing = competing or {}
all_descriptions = {skill_name: skill_description, **competing}
results = []
for prompt in examples.get("positive", []):
best, scores = predict_trigger(all_descriptions, prompt)
results.append(_row(prompt, "positive", "trigger", best, scores, best == skill_name))
for prompt in examples.get("negative", []):
best, scores = predict_trigger(all_descriptions, prompt)
results.append(_row(prompt, "negative", "no_trigger", best, scores, best != skill_name))
for item in examples.get("ambiguous", []):
prompt, expected = item["prompt"], item.get("expected", "either")
best, scores = predict_trigger(all_descriptions, prompt)
if expected == "either":
correct = True
elif expected == "trigger":
correct = best == skill_name
else:
correct = best != skill_name
results.append(_row(prompt, "ambiguous", expected, best, scores, correct))
n = len(results)
accuracy = (sum(r["correct"] for r in results) / n) if n else None
return {"accuracy": accuracy, "n": n, "results": results}
def _row(prompt, kind, expected, predicted, scores, correct) -> dict:
return {
"prompt": prompt,
"kind": kind,
"expected": expected,
"predicted": predicted,
"correct": bool(correct),
"top_scores": dict(sorted(scores.items(), key=lambda kv: -kv[1])[:3]),
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |