mirror of
https://github.com/alirezarezvani/claude-skills.git
synced 2026-11-27 22:48:39 +00:00
* feat: mobile-release, cloud-finops and support-ops plugins Three new plugins for gaps the library had no skill for: - engineering/mobile-release: iOS privacy-manifest and Play release checks, plus a PROCEED/HOLD/HALT staged-rollout gate. - engineering/cloud-finops: FOCUS-export allocation coverage, commitment utilization/coverage/ESR, robust cost anomalies. - business-growth/support-ops: business-hours SLA attainment, Erlang C staffing, ticket deflection finder. Each ships 3 stdlib scripts, 3 cited references, a cs-* agent and commands, mirrors into its domain bundle, trigger and behaviour eval cases with fixtures, and refreshed counters, mirrors and baselines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8KYFKgTBNWHqHJNQWHwnq * feat: trigger tuning, skill-router hooks and eval cases for the new plugins - Descriptions rewritten in user words after held-out trigger evals (cloud-finops 12/24 -> 19/24 positives, 0 near-miss fires). - Skill-router UserPromptSubmit hooks in mobile-release, cloud-finops, support-ops and both bundles; 0 wrong hints across 2,355 eval prompts. - support-ops scoped to interval scheduling; headcount and hiring stay with capacity-planner (the old note wrongly said it had no queueing). - support-ops Report section and mobile-release reason-code rule from behaviour-eval transcripts; behaviour eval prompt names the review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8KYFKgTBNWHqHJNQWHwnq * fix(mobile-release, support-ops): small-sample HALTs, platform check, backlog drain From review on #1153: - rollout_gate: Play thresholds judged on the 95% Wilson lower bound; below --min-users a significant regression or device breach is a HOLD, not a HALT (1 crash among 40 users no longer halts a 1% rollout). - rollout_gate: baseline and release on different platforms exit 3; an Android row without anr_users says ANR was not checked. - staffing_plan: backlog drain spread over the first --drain-hours rows only, at the arrivals' effective AHT (divided by concurrency); footer states one row = one hour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8KYFKgTBNWHqHJNQWHwnq * fix(mobile-release, support-ops): input validation and documented caveats From the second review on #1153: - rollout_gate: inf/NaN counts and out-of-range percentages exit 3; exactly two rows required, matching the docstring; repeated looks across stages and the staged-cohort bias documented. - staffing_plan: non-finite inputs exit 3; staffed is defined as paid agents rostered before shrinkage. - business-growth/CLAUDE.md lists all six skills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L8KYFKgTBNWHqHJNQWHwnq --------- Co-authored-by: Claude <noreply@anthropic.com>
137 lines
4.4 KiB
Python
137 lines
4.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Skill router: a UserPromptSubmit hook that points the model at a skill.
|
|
|
|
Why this exists: the 2026-11 trigger evals found skills that never fire on
|
|
prompts squarely inside their scope. On those prompts no other skill fired
|
|
either; the model answered directly. Two rounds of description rewrites did
|
|
not move them, so wording is not the lever. This hook is.
|
|
|
|
What it does: matches the user's prompt against hand-written, high-precision
|
|
patterns in skill_routes.json (next to this file). On a match it adds one line
|
|
of context naming the skill; on no match it prints nothing. It never blocks a
|
|
prompt and never calls a model.
|
|
|
|
Noise rules:
|
|
* at most one skill per plugin per prompt (highest score wins)
|
|
* each skill is suggested at most once per session
|
|
* prompts that start with "/" are skipped (the user picked a command)
|
|
* fails open: any error means no output, exit 0
|
|
|
|
Disable with SKILL_ROUTER=0 (all plugins) or SKILL_ROUTER_<PLUGIN>=0, where
|
|
<PLUGIN> is the plugin name upper-cased with "-" as "_".
|
|
|
|
Every plugin that ships this hook carries an identical copy of this file;
|
|
scripts/check_skill_router.py keeps the copies in sync.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import re
|
|
import sys
|
|
import tempfile
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
ROUTES = os.path.join(HERE, "skill_routes.json")
|
|
HEAD_TAIL = 1500 # long pastes: look only at the start and the end
|
|
|
|
|
|
def _compile(patterns):
|
|
return [re.compile(p, re.I) for p in patterns or []]
|
|
|
|
|
|
def load_routes(path=ROUTES):
|
|
with open(path, encoding="utf-8") as fh:
|
|
cfg = json.load(fh)
|
|
routes = []
|
|
for r in cfg["routes"]:
|
|
routes.append({
|
|
"skill": r["skill"],
|
|
"why": r["why"],
|
|
"any": _compile(r.get("any")),
|
|
"pairs": [(_compile(a), _compile(b)) for a, b in r.get("pairs", [])],
|
|
"not": _compile(r.get("not")),
|
|
})
|
|
return cfg["plugin"], routes
|
|
|
|
|
|
def _hit(regexes, text):
|
|
return any(rx.search(text) for rx in regexes)
|
|
|
|
|
|
def score(route, text):
|
|
if _hit(route["not"], text):
|
|
return 0
|
|
s = sum(1 for rx in route["any"] if rx.search(text))
|
|
s += sum(1 for a, b in route["pairs"] if _hit(a, text) and _hit(b, text))
|
|
return s
|
|
|
|
|
|
def best_route(routes, prompt):
|
|
text = prompt if len(prompt) <= 2 * HEAD_TAIL else prompt[:HEAD_TAIL] + "\n" + prompt[-HEAD_TAIL:]
|
|
best, best_s = None, 0
|
|
for r in routes:
|
|
s = score(r, text)
|
|
if s > best_s:
|
|
best, best_s = r, s
|
|
return best
|
|
|
|
|
|
def _state_file(session_id, plugin):
|
|
safe = re.sub(r"[^A-Za-z0-9_-]", "", session_id or "nosession")[:80]
|
|
d = os.path.join(tempfile.gettempdir(), "claude-skill-router")
|
|
os.makedirs(d, mode=0o700, exist_ok=True)
|
|
return os.path.join(d, f"{safe}-{plugin}.json")
|
|
|
|
|
|
def already_suggested(session_id, plugin, skill):
|
|
"""Record the suggestion; return True if this session already had it."""
|
|
try:
|
|
path = _state_file(session_id, plugin)
|
|
seen = []
|
|
if os.path.exists(path):
|
|
with open(path, encoding="utf-8") as fh:
|
|
seen = json.load(fh)
|
|
if skill in seen:
|
|
return True
|
|
seen.append(skill)
|
|
with open(path, "w", encoding="utf-8") as fh:
|
|
json.dump(seen, fh)
|
|
except Exception:
|
|
pass
|
|
return False
|
|
|
|
|
|
def main():
|
|
if os.environ.get("SKILL_ROUTER", "1") == "0":
|
|
return 0
|
|
try:
|
|
data = json.load(sys.stdin)
|
|
plugin, routes = load_routes()
|
|
except Exception:
|
|
return 0
|
|
if os.environ.get("SKILL_ROUTER_" + plugin.upper().replace("-", "_"), "1") == "0":
|
|
return 0
|
|
prompt = (data.get("prompt") or "").strip()
|
|
if not prompt or prompt.startswith("/"):
|
|
return 0
|
|
route = best_route(routes, prompt)
|
|
if route is None:
|
|
return 0
|
|
if already_suggested(data.get("session_id", ""), plugin, route["skill"]):
|
|
return 0
|
|
name = f"{plugin}:{route['skill']}"
|
|
msg = (f"Skill hint ({plugin} plugin): this request fits the `{name}` skill "
|
|
f"({route['why']}). Load it with the Skill tool first, before you answer or ask "
|
|
f"for missing input, unless the request is outside that scope or a more specific "
|
|
f"skill fits better.")
|
|
print(json.dumps({"hookSpecificOutput": {
|
|
"hookEventName": "UserPromptSubmit", "additionalContext": msg}}))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
sys.exit(main())
|
|
except Exception:
|
|
sys.exit(0)
|