From tea-rags
Internal skill for code-gen pipelines that retrieves battle-tested reference code from the project via a three-level locality cascade (subdomain → domain → project-wide). Used by parent skills like tea-rags and dinopowers to find templates for generation or modification.
How this skill is triggered — by the user, by Claude, or both
Slash command
/tea-rags:extract-project-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Internal recipe for code-gen skills. Find battle-tested template in project for
Internal recipe for code-gen skills. Find battle-tested template in project for code you about to write, via three-level locality cascade. Invoked by parent skills; not users directly.
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"] }.
L1 pathPattern = pathPatternL1 (deepest subdomain)
L2 pathPattern = first 2 path segments of L1 (broader domain)
if L1 has ≤ 2 segments → L2 = L1, skip L2 step entirely
L3 pathPattern = null (project-wide)
L2 derivation example.
**/domains/trajectory/git/rerank/derived-signals/** → segments
[domains, trajectory, git, rerank, derived-signals] → L2 =
**/domains/trajectory/**.**/chunker/hooks/** → segments [chunker, hooks] → L2 = L1, skip L2,
jump to L3.For each level in [L1, L2, L3]:
find_similar (or semantic_search / hybrid_search if only
behaviorQuery available) with:
rerank: "proven"pathPattern: <level> (omit for L3)limit: <input limit, default 10>positiveIds | positiveCode | query: behaviorQueryideal_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 annotation. Stop.bugFixRate is "critical" OR (ageDays is "recent" AND
commitCount is "low") excluded from returned top.All three levels fail → return diagnostic
"no proven templates for <input> in this project" so caller falls back
(generate from scratch, ask user, etc.).
Structured object for caller:
{
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] as reference; locality informs how to use
template:
L1 → matches subdomain exactly. Use template's blameDominantAuthor for
style + review routing.L2 → template from sibling subdomain in same broader domain.
blameDominantAuthor reviews technique, not exact code.L3 → template from project at large. blameDominantAuthor reviews technique
only; verify architectural fit before adopting verbatim.none → no template found. Caller generates from scratch and surfaces this to
user so they know to scrutinize result.Return immediately empty templates if:
positiveIds / positiveCode / behaviorQuery providedtea-rags:data-driven-generation Step 2 (TEMPLATE)dinopowers:writing-plans (per code-generation / code-modification Task)dinopowers:executing-plans (per Task during execute)/optimize-skill extract-project-patterns runs baseline cases. Fixture file
evals/cases.json added in follow-up PR (out of scope for initial recipe
landing — see spec Component E).
npx claudepluginhub artk0de/tearags-mcp --plugin tea-ragsInspects git signals on nearby code to select codegen strategy and templates from proven, low-churn implementations before writing new code.
Copies patterns, setup, or structure from another project into the current session. Also supports fix-and-PR mode to submit bug fixes to referenced projects.
Use when building ANY feature within an existing project - search the current codebase for existing patterns, conventions, similar implementations, and established approaches before writing new code