No slash command · from tea-rags
Internal recipe for code-gen skills that extracts battle-tested code templates via a three-level locality cascade (subdomain, infra prefix, project-wide). Called by data-driven-generation and dinopowers skills. Returns templates, locality, and diagnostics.
Ships in tea-rags. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Internal recipe for code-gen skills: battle-tested template for code about to be written, via three-level locality cascade.
Not a callee without the marker: THIS prompt lacks [invoked by …] (user
says "execute the plan" / "start the task") → caller's flow runs (executor guard
first), not this recipe; markers never carry over between requests.
Handoff = run the recipe now. Prompt [invoked by <caller> …] carrying
behaviorQuery= / positiveIds= / positiveCode= → you are this recipe, not
the caller: its own steps (guard, DDG, chain) stay with it. Target dir without
pathPatternL1 → L1 = **/<target dir>/**. First call = L1 below:
semantic_search (find_similar when ids/code), path=<working dir>,
rerank: "proven", pathPattern: <L1>.
Caller passes:
| Input | Required | Notes |
|---|---|---|
positiveIds | one-of | Chunk IDs from prior cascade results |
positiveCode | one-of | Raw code snippet(s) (embedded on the fly by find_similar) |
behaviorQuery | one-of | NL query if no chunk/code is available |
pathPatternL1 | yes | From explore PG-OUTPUT (deepest subdomain target) |
limit | no | Default 10 |
At least one of positiveIds / positiveCode / behaviorQuery MUST be
present. Else return
{ templates: [], locality: "none", diagnostics: ["no input"] }.
Every call: project=<alias> + path=<working dir>. treeState row = pre-edit
copy → never template; current body via find_symbol. Lag / drift ≠ licence to
leave tea-rags (core); own checkout changedFiles > 0 → incremental
index_codebase, subagent / linked worktree → never reindex. →
tea-rags://guide/freshness.
L1 pathPattern = pathPatternL1 (deepest subdomain)
L2 pathPattern = infra prefix + first semantic segment (broader domain)
L3 pathPattern = null (project-wide)
L2 derivation. Split L1 segments: leading run from skip-vocabulary = infra prefix (NOT counted, KEPT in glob); rest = semantic tail. L2 = glob cut after first semantic segment. Semantic tail ≤ 1 segment → L2 = L1, skip L2 step entirely.
Skip-vocabulary (infra/layer prefixes): app, src, lib, core, packages,
internal, domains; Rails layers: services, models, controllers,
jobs, workers, mailers, concerns, graphql, serializers,
presenters, decorators, operations, interactors, policies.
**/domains/trajectory/git/rerank/derived-signals/** → prefix
[domains], semantic [trajectory, git, rerank, derived-signals] → L2 =
**/domains/trajectory/**.**/app/services/crm/accounts/** → prefix [app, services], semantic
[crm, accounts] → L2 = **/app/services/crm/** (NOT **/app/services/** —
layer-wide L2 = degenerate L3).**/app/services/billing/** → semantic [billing], 1 segment → skip L2.**/domains/explore/strategies/new-feature/** → prefix [domains],
semantic [explore, strategies, new-feature] = 3 segments → L2 =
**/domains/explore/**. Count tail segments one by one; never skip L2 on a
tail ≥ 2.**/domains/explore/** / **/some-new-area/** → semantic tail 1 segment
→ skip L2: cascade L1 → L3, never a parent glob.**/chunker/hooks/** → no prefix, semantic [chunker, hooks] → L2 =
**/chunker/** (2 segments is NOT too shallow — L1 always runs).**/language/ruby/chunking/** → no prefix, semantic
[language, ruby, chunking] → L2 = **/language/**.For each level in [L1, L2, L3]:
find_similar (only behaviorQuery → semantic_search / hybrid_search):
rerank: "proven" + level: "chunk" (proven is file-level; keep chunk
results)filter: { presets: "battleTested" } — ANDs w/ pathPatternpathPattern: <level> (omit for L3)limit: <input limit, default 10>positiveIds | positiveCode | query: behaviorQueryRelax-on-empty: 0 results → re-run once w/
filter: { presets: "production" }, record
"no battle-tested reference found; widened to production code" in
diagnostics. Never return empty silently while relax possible.
Quality gate over overlay labels:
ideal_count = chunks where
commitCount label is "low" or "typical", ANDageDays label is "old" or "legacy", ANDbugFixRate label is "healthy"ideal_count ≥ 2 → return top result + locality. Stop.ideal_count == 1 AND lone ideal's
payload.codegraph.symbols.file.isHub == true → level accepted,
templates[0] = lone ideal (NOT top-by-score). Stop. Hub = usage-proof
(fanIn > p95). No codegraph.symbols in payload → branch inert.Reject filter (always): exclude bugFixRate "critical" OR (ageDays
"recent" AND commitCount "low").
No qualifying chunk → next level.
All levels fail → diagnostics carries BOTH lines, verbatim:
"no battle-tested reference found; widened to production code" (every relax
that ran) + "no proven templates for <input> in this project";
locality: "none" (caller falls back: scratch, ask user).
{
templates: [
{
chunkId,
path,
level: "L1" | "L2" | "L3",
labels: { commitCount, ageDays, bugFixRate, blameContributorCount, ... },
blameDominantAuthor,
},
...
],
locality: "L1" | "L2" | "L3" | "none",
diagnostics: [<per-level fail reasons>],
}
Caller reads templates[0]; locality → usage:
L1 → exact subdomain. blameDominantAuthor → style + review routing.L2 → sibling subdomain. blameDominantAuthor reviews technique, not code.L3 → project-wide. Technique only; verify architectural fit before verbatim
adoption.none → caller generates from scratch, tells user to scrutinize.Return empty templates immediately if:
positiveIds / positiveCode / behaviorQueryWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub artk0de/tearags-mcp --plugin tea-rags17 skills in this plugin
/analytics-rerankPick tea-rags rerank preset, build `{custom: {...}}` weight set, or compose analytics-driven search (ownership, tech-debt, hotspots, code-review, security-audit, fragile-silo). Invoke on intent like "rank by ownership", "find tech debt", "hotspot scan", "code review of recent changes", "security audit of auth code", "code that looks stable but breaks a lot", "custom weights for impact analysis". NOT for project health scan needing cross-preset overlap — use `tea-rags:risk-assessment`. NOT for debug root-cause — use `tea-rags:bug-hunt`. NOT for filter shape — use `tea-rags:filter-building`./architecture-diagnosticsDiagnose structural violations for an explicit architecture audit, an explicit invocation of this skill, or structural refactoring. Assess dependency/layer violations, coupling and move candidates. Not for context gathering, code overviews, behavior or contract questions, or routine feature work. Risk/health uses risk-assessment; failures use bug-hunt; plain cycles use find_cycles./bug-huntFind source of concrete failure — rank historically buggy code (high bugFixRate + churn) AND freshly changed never-fixed code (committed or still uncommitted) against symptom. Triggers on "debug X", "why does Y fail", "test fails", "stack trace says Z", "find bugs in X", "found a bug in X — show / compare Y", "suspects in X and Y — search both", a search hit with bugFixRate / ageDays labels ("proceed?", "проверь там"), "where is error 'X' in code", "где в коде строка / упоминается 'X'", "when did error 'X' appear in git history", "когда появилась ошибка 'X'", "read the whole file" / "прочитай весь файл" of a search hit, "падает". NOT for code history without an error string or failure ("when did X change", "посмотри через git" alone) — core routing answers it. NOT for code health scanning without bug intent — use risk-assessment for that./data-driven-generationDecide HOW to write or change code by inspecting git signals on neighbors — classifies task mode (CREATE / EXTEND / MODIFY), pulls strategy and templates from proven low-churn implementations, reuses existing shared helpers. Triggers on "implement function X", "add method to class Y", "write a helper for Z", "modify function X", "change behavior of Y", "напиши функцию", "добавь метод", "поправь метод", "измени поведение", "overlay labels → strategy?", a hotfix with location + fix named (cause known → not bug-hunt). NOT for discovery — use tea-rags:explore. NOT for pure rename/extract; a file MOVE still routes here./exploreUse for questions about existing code behavior, usages, structure, examples, or explicit pre-change context that need investigation. Not bug symptoms, implementation-plan authoring, or broad code-health audits./filter-buildingBuild tea-rags filter beyond `pathPattern`. Invoke whenever reasoning before a tea-rags search includes a SCOPE: domain, language, author, time window, ticket, prod-vs-test split, directory exclusion. User names scope ("in the X domain", "Ruby code", "Alice's work", "modified this week", "for ticket RAGS-142", "production code"), rarely says "filter". Maps scope to typed filter params, `level`, `pathPattern` negation, or raw `filter`. E.g. "tests of AuthService" → `testFile: "only"`. NOT for picking rerank preset — use `tea-rags:analytics-rerank`. NOT for general exploration — use `tea-rags:explore`.Other plugins' skills for the same job