@cleocode/skills 2026.5.83 → 2026.5.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/package.json +1 -1
  2. package/skills/_shared/__tests__/lifecycle-protocol-reconcile.test.ts +112 -0
  3. package/skills/_shared/__tests__/loom-adr-links.test.ts +163 -0
  4. package/skills/_shared/__tests__/loom-stage-coverage.test.ts +167 -0
  5. package/skills/ct-adr-recorder/SKILL.md +92 -0
  6. package/skills/ct-adr-recorder/__tests__/skill-adr-recorder.test.ts +65 -0
  7. package/skills/ct-consensus-voter/SKILL.md +14 -0
  8. package/skills/ct-contribution/SKILL.md +80 -0
  9. package/skills/ct-docs-lookup/SKILL.md +116 -1
  10. package/skills/ct-docs-lookup/references/ctx7-workflow.md +198 -0
  11. package/skills/ct-docs-lookup/references/library-id-resolution.md +217 -0
  12. package/skills/ct-docs-lookup/references/version-specific-docs.md +220 -0
  13. package/skills/ct-docs-review/SKILL.md +133 -1
  14. package/skills/ct-docs-review/__tests__/skill-docs-review.test.ts +53 -0
  15. package/skills/ct-docs-review/references/inline-comment-patterns.md +268 -0
  16. package/skills/ct-docs-review/references/pr-review-mode.md +270 -0
  17. package/skills/ct-docs-review/references/style-violations.md +341 -0
  18. package/skills/ct-docs-write/SKILL.md +157 -1
  19. package/skills/ct-docs-write/__tests__/skill-docs-write.test.ts +55 -0
  20. package/skills/ct-docs-write/references/audience-targeting.md +305 -0
  21. package/skills/ct-docs-write/references/cleo-style-guide.md +234 -0
  22. package/skills/ct-docs-write/references/markdown-patterns.md +329 -0
  23. package/skills/ct-documentor/SKILL.md +11 -0
  24. package/skills/ct-documentor/references/anti-patterns.md +216 -0
  25. package/skills/ct-documentor/references/chain-orchestration.md +194 -0
  26. package/skills/ct-documentor/references/doc-types-and-templates.md +301 -0
  27. package/skills/ct-documentor/references/style-coordination.md +195 -0
  28. package/skills/ct-epic-architect/SKILL.md +15 -0
  29. package/skills/ct-ivt-looper/SKILL.md +32 -0
  30. package/skills/ct-release-orchestrator/SKILL.md +16 -0
  31. package/skills/ct-research-agent/SKILL.md +24 -0
  32. package/skills/ct-research-agent/references/anti-patterns.md +154 -0
  33. package/skills/ct-research-agent/references/citation-and-evidence.md +140 -0
  34. package/skills/ct-research-agent/references/source-strategy.md +116 -0
  35. package/skills/ct-research-agent/references/triggers-and-routing.md +93 -0
  36. package/skills/ct-skill-validator/SKILL.md +19 -0
  37. package/skills/ct-skill-validator/scripts/check_depth.py +306 -0
  38. package/skills/ct-spec-writer/SKILL.md +86 -1
  39. package/skills/ct-spec-writer/__tests__/skill-spec-writer.test.ts +60 -0
  40. package/skills/ct-spec-writer/references/anti-patterns.md +176 -0
  41. package/skills/ct-spec-writer/references/rfc2119-language.md +138 -0
  42. package/skills/ct-spec-writer/references/spec-templates.md +233 -0
  43. package/skills/ct-spec-writer/references/traceability-matrix.md +145 -0
  44. package/skills/ct-task-executor/SKILL.md +25 -0
  45. package/skills/ct-task-executor/references/acceptance-criteria-mapping.md +163 -0
  46. package/skills/ct-task-executor/references/anti-patterns.md +201 -0
  47. package/skills/ct-task-executor/references/common-failures.md +193 -0
  48. package/skills/ct-task-executor/references/evidence-and-gates.md +179 -0
  49. package/skills/ct-task-executor/references/implementation-patterns.md +160 -0
  50. package/skills/ct-validator/SKILL.md +44 -0
  51. package/skills/ct-validator/references/anti-patterns.md +194 -0
  52. package/skills/ct-validator/references/compliance-reports.md +199 -0
  53. package/skills/ct-validator/references/schema-checking.md +191 -0
  54. package/skills/ct-validator/references/validation-modes.md +185 -0
  55. package/skills/manifest.json +82 -16
@@ -11,6 +11,10 @@ tier: 3
11
11
  core: false
12
12
  category: meta
13
13
  protocol: contribution
14
+ loomStage: contribution
15
+ adrRefs:
16
+ - ADR-015
17
+ - ADR-053
14
18
  dependencies: []
15
19
  sharedResources:
16
20
  - subagent-protocol-base
@@ -519,3 +523,79 @@ jq -s '[.[] | select(.epicId == "T2204")] | .[0]' .cleo/contributions/CONTRIBUTI
519
523
  | [contribution.schema.json](../../schemas/contribution.schema.json) | **Authoritative** for JSON Schema |
520
524
  | [CONTRIBUTION-PROTOCOL-GUIDE.md](../../docs/guides/CONTRIBUTION-PROTOCOL-GUIDE.md) | Usage guide with examples |
521
525
  | [CONSENSUS-FRAMEWORK-SPEC.md](../../docs/specs/CONSENSUS-FRAMEWORK-SPEC.md) | Consensus voting thresholds |
526
+
527
+ ---
528
+
529
+ ## LOOM Stage Binding (T9670)
530
+
531
+ `ct-contribution` is bound to LOOM lifecycle stage **`contribution`** — the terminal node of the RCASD-IVTR+C pipeline. Use this skill to formalize an Epic's contribution back to canon after its work has converged.
532
+
533
+ ### Stage-Transition Contract
534
+
535
+ The contribution stage is entered from one of two upstream stages depending on the Epic's `kind`:
536
+
537
+ | Upstream stage | Epic kind | Entry condition |
538
+ |---|---|---|
539
+ | **`release`** | most epics (work, bug, experiment) | Release tag pushed; release manifest recorded |
540
+ | **`testing`** | epics whose `kind` is `release` or that gate on IVTR | IVT loop converged; `ivtLoopConverged: true` recorded |
541
+ | **`specification`** | spec-only epics (no code) | Specification accepted; HITL signoff recorded |
542
+
543
+ ```
544
+ research → consensus → architecture_decision → specification → decomposition
545
+ ↓
546
+ implementation
547
+ ↓
548
+ validation
549
+ ↓
550
+ testing ← (some epics return here)
551
+ ↓
552
+ release
553
+ ↓
554
+ contribution ← (this skill)
555
+ ```
556
+
557
+ The transition is enforced by the playbook runtime defined in **ADR-053**. The runtime is a deterministic state machine; `contribution` is its terminal accepting state. Once entered, the Epic is closed in canon.
558
+
559
+ ### Acceptance-Gate Evidence
560
+
561
+ The contribution stage's completion gate is satisfied by emitting **at least one** of the following ADR-051 evidence atoms, recorded via `cleo verify <epicId> --gate contribution --evidence "<atoms>"`:
562
+
563
+ | Atom kind | Format | Meaning |
564
+ |---|---|---|
565
+ | `decision:` | `decision:D-<slug>` | A BRAIN decision id that records the contribution outcome. |
566
+ | `files:` | `files:path/a.md,path/b.md` | A list of contribution-format JSON / markdown deliverables produced by `/contribution submit`. |
567
+ | `note:` | `note:<freeform>` | Owner-attested closure rationale; preferred when the contribution is non-textual (e.g. a tag push referenced by SHA in the note). |
568
+
569
+ Example:
570
+
571
+ ```bash
572
+ cleo verify T9568 --gate contribution \
573
+ --evidence "decision:D-loom-coverage-001;files:.cleo/contributions/T9568-final.json"
574
+ cleo complete T9568
575
+ ```
576
+
577
+ The gate validator (ADR-051 §2.4) rejects an empty evidence string with `E_EVIDENCE_MISSING`. Stale evidence (modified files after `verify` but before `complete`) fails with `E_EVIDENCE_STALE`.
578
+
579
+ ### Open Follow-Up
580
+
581
+ A future ADR dedicated to the contribution stage's lifecycle gates (covering automated rollup signals from `cleo saga rollup`, multi-Epic contribution aggregation, and the contribution → "saga close" promotion path) is on the roadmap. File via:
582
+
583
+ ```bash
584
+ cleo add --kind work --type task --severity P2 \
585
+ --title "T-LOOM-GAP-ADR-CONTRIBUTION: dedicated ADR for contribution stage gates" \
586
+ --relates T9670 \
587
+ --acceptance "ADR drafted under .cleo/adrs/|Cross-referenced from ct-contribution SKILL.md|Validator gate updated"
588
+ ```
589
+
590
+ Until that ADR lands, contribution gates derive from ADR-015 (multi-contributor architecture) and ADR-053 (playbook runtime) — both already referenced in this skill's `adrRefs`.
591
+
592
+ ---
593
+
594
+ ## See also / References
595
+
596
+ This skill binds to the **contribution** LOOM lifecycle stage (the final stage of the RCASD-IVTR+C pipeline). Governing ADRs:
597
+
598
+ - [ADR-015 — multi-contributor architecture](../../../../.cleo/adrs/ADR-015-multi-contributor-architecture.md) — defines the multi-contributor consensus mechanics that this stage formalizes for an Epic's downstream return path.
599
+ - [ADR-053 — playbook runtime](../../../../.cleo/adrs/ADR-053-playbook-runtime.md) — defines the lifecycle state machine; contribution is its terminal node.
600
+
601
+ LOOM coverage matrix: [docs/skills/loom-coverage-matrix.md](../../../../docs/skills/loom-coverage-matrix.md).
@@ -63,4 +63,119 @@ Incorporate the fetched documentation into your response:
63
63
 
64
64
  - **Be specific**: Pass the user's full question as the query for better results
65
65
  - **Version awareness**: When users mention versions ("Next.js 15", "React 19"), use version-specific library IDs if available from the resolution step
66
- - **Prefer official sources**: When multiple matches exist, prefer official/primary packages over community forks
66
+ - **Prefer official sources**: When multiple matches exist, prefer official/primary packages over community forks
67
+
68
+ ## Why Context7 (not training data)
69
+
70
+ The user's global rule is explicit: prefer Context7 over training data for any
71
+ library, framework, SDK, API, CLI tool, or cloud service — even well-known ones
72
+ like React, Next.js, Prisma, Express, Tailwind, Django, or Spring Boot. This
73
+ includes API syntax, configuration, version migration, library-specific
74
+ debugging, setup instructions, and CLI tool usage. Use even when you think
75
+ you know the answer; training data may not reflect recent changes.
76
+
77
+ ## Three-Command Budget
78
+
79
+ The user rules cap a docs lookup at three CLI invocations per question. The
80
+ budget fits the standard workflow:
81
+
82
+ 1. `npx ctx7@latest library "<name>" "<question>"` — one call to resolve.
83
+ 2. `npx ctx7@latest docs <id> "<question>"` — one call to fetch.
84
+ 3. (Optional) `npx ctx7@latest docs <id> "<question>" --research` — one
85
+ retry with sandboxed agents pulling source + web search.
86
+
87
+ Going over budget is a signal: the library name is wrong, the question
88
+ is too broad, or Context7 doesn't cover this library. In any of those
89
+ cases, refine before retrying — don't burn more calls.
90
+
91
+ ## When NOT to Use This Skill
92
+
93
+ The user rules explicitly exclude these from docs-lookup:
94
+
95
+ - **Refactoring** — re-shaping existing code; no library lookup needed.
96
+ - **Scripts written from scratch** — general programming, not library API.
97
+ - **Debugging business logic** — use codebase tools (Grep, GitNexus), not
98
+ external docs.
99
+ - **Code review** — quality assessment, not library reference.
100
+ - **General programming concepts** — pure CS questions; training data is fine.
101
+
102
+ Use docs-lookup ONLY for: API syntax, configuration questions, version
103
+ migration issues, library-specific debugging, setup instructions, and CLI
104
+ tool usage.
105
+
106
+ ## Authentication and Quotas
107
+
108
+ The `ctx7` CLI runs anonymously with a limited free quota. When quota
109
+ exhausts:
110
+
111
+ ```text
112
+ Error: Quota exceeded.
113
+ Run `npx ctx7@latest login` for higher limits.
114
+ Or set CONTEXT7_API_KEY env var with your key.
115
+ ```
116
+
117
+ Surface the error to the user (or include in `needs_followup`). NEVER
118
+ silently fall back to training data — that violates the skill's contract.
119
+
120
+ ## Sensitive Data
121
+
122
+ Queries to Context7 are logged on the Context7 side. Never include:
123
+
124
+ - API keys, tokens, passwords
125
+ - Internal hostnames or URLs
126
+ - Customer-identifying data
127
+ - Source code excerpts from private repos
128
+
129
+ Use generic phrasing. If the actual API call needs a specific value,
130
+ describe it abstractly ("how do I authenticate with an API key" instead
131
+ of "use API key sk_live_abc123 to...").
132
+
133
+ ## Multi-Library Composition
134
+
135
+ A single question may touch multiple libraries — common in modern stacks
136
+ (SvelteKit + Better-Auth + Drizzle, Next.js + Prisma + Tailwind, etc.).
137
+ Resolve each library independently with the right version pin, then
138
+ synthesize.
139
+
140
+ The three-command budget applies per-library; a question spanning
141
+ three libraries gets nine commands. Stay focused — fetch the specific
142
+ integration point each time, not the entire library surface.
143
+
144
+ ## Citing Versions in Answers
145
+
146
+ Every code example produced from a version-pinned fetch MUST cite the
147
+ version. The reader copies the code and runs it; when their version
148
+ differs, the citation is the first thing they check.
149
+
150
+ ```markdown
151
+ Use `defineRelations` (Drizzle ORM v1.0.0-beta and later):
152
+
153
+ ```typescript
154
+ import { defineRelations } from "drizzle-orm";
155
+ // ...
156
+ ```
157
+ ```
158
+
159
+ Without the version note, the reader who is on Drizzle 0.x will be
160
+ confused when the import fails.
161
+
162
+ ## Common Failure Modes
163
+
164
+ | Symptom | Cause | Fix |
165
+ |---------|-------|-----|
166
+ | "Library not found" | Wrong name format | Use official punctuation: "Next.js" not "nextjs" |
167
+ | Stale answer | No version pin | Detect installed version from lockfile, pin |
168
+ | Generic answer when specifics needed | Vague query | Pass full question text, not single words |
169
+ | Quota exceeded | Anonymous over-use | `ctx7 login` or set `CONTEXT7_API_KEY` |
170
+ | Hallucinated API | Skipped Context7 | Always run Step 1+2 before answering library questions |
171
+ | Wrong fork picked | Took top result blindly | Read descriptions; prefer official org |
172
+
173
+ ---
174
+
175
+ ## See references/
176
+
177
+ Progressive disclosure — load on demand only:
178
+
179
+ - `references/ctx7-workflow.md` — two-step loop, query formatting, research mode, budget
180
+ - `references/library-id-resolution.md` — signals for picking the right ID; disambiguation procedure
181
+ - `references/version-specific-docs.md` — version pinning, migrations, deprecations, drift detection
@@ -0,0 +1,198 @@
1
+ # ctx7 Workflow
2
+
3
+ `ct-docs-lookup` is the CLEO-side wrapper around the `ctx7` CLI. The
4
+ underlying contract is set in the user's global rules
5
+ (`~/.claude/rules/context7.md`) and the project's `MCP_Context7.md`.
6
+ This reference codifies the workflow with concrete examples and
7
+ recovery procedures.
8
+
9
+ ## Why Context7
10
+
11
+ The skill's purpose statement is direct: when the user asks about a
12
+ library, framework, or needs code examples, fetch current documentation
13
+ instead of relying on training data. Training data is stale — the
14
+ project's user rules say so explicitly.
15
+
16
+ This applies even when you think you know the answer. API surfaces of
17
+ React, Next.js, Prisma, Tailwind, Drizzle, Svelte, Supabase, and friends
18
+ move faster than any model's cutoff. Verify against current docs.
19
+
20
+ ## The Two-Step Loop
21
+
22
+ The ctx7 CLI is shipped as `npx ctx7@latest`. The workflow is two calls.
23
+
24
+ ```bash
25
+ # Step 1 — resolve the official library ID
26
+ npx ctx7@latest library "<library-name>" "<user-question>"
27
+
28
+ # Step 2 — fetch docs for the resolved ID
29
+ npx ctx7@latest docs <libraryId> "<user-question>"
30
+ ```
31
+
32
+ The output of Step 1 is a list of candidate library IDs in the form
33
+ `/org/project`. Pick the best match (see `library-id-resolution.md` for
34
+ the heuristics) and pass it to Step 2.
35
+
36
+ ## Step 1: Library Resolution
37
+
38
+ Use the official library name with proper punctuation:
39
+
40
+ | ❌ Wrong | ✅ Correct |
41
+ |----------|------------|
42
+ | `"nextjs"` | `"Next.js"` |
43
+ | `"customerio"` | `"Customer.io"` |
44
+ | `"threejs"` | `"Three.js"` |
45
+ | `"reactdom"` | `"React DOM"` |
46
+ | `"vuejs"` | `"Vue.js"` |
47
+ | `"tailwindcss"` | `"Tailwind CSS"` |
48
+
49
+ The library name matches what the project documents itself as. When
50
+ unsure, search the project's GitHub README for the official name.
51
+
52
+ Pass the user's full question as the second arg — specific queries
53
+ return better matches than single words.
54
+
55
+ ```bash
56
+ # GOOD
57
+ npx ctx7@latest library "Drizzle ORM" "how do I define relations in v1"
58
+
59
+ # BAD — too generic, ranks poorly
60
+ npx ctx7@latest library "drizzle" "relations"
61
+ ```
62
+
63
+ ## Step 1 Output Interpretation
64
+
65
+ The CLI returns candidates with several signals — pick by:
66
+
67
+ 1. **Exact name match.** "Next.js" should resolve to `/vercel/next.js`
68
+ over `/some-fork/next.js-clone`.
69
+ 2. **Source reputation.** Look for High or Medium source labels.
70
+ 3. **Code snippet count.** More snippets = better-indexed library.
71
+ 4. **Benchmark score.** Higher is better; reflects retrieval quality.
72
+
73
+ If the top candidate doesn't match exactly what the user asked for —
74
+ e.g., they said "Next.js 15" and the top candidate is generic — try
75
+ again with refined terms or version-specific names.
76
+
77
+ ## Step 2: Docs Fetch
78
+
79
+ Once you have the library ID:
80
+
81
+ ```bash
82
+ npx ctx7@latest docs /vercel/next.js "how do I configure middleware to inject auth headers"
83
+ ```
84
+
85
+ The output is documentation excerpts with citations. Use these directly
86
+ in your answer — they are current, sourced, and citable.
87
+
88
+ ## Version-Specific Docs
89
+
90
+ When the user names a version, use the version-specific form:
91
+
92
+ ```bash
93
+ # General
94
+ npx ctx7@latest docs /vercel/next.js "..."
95
+
96
+ # Pinned to v14.3.0
97
+ npx ctx7@latest docs /vercel/next.js/v14.3.0 "..."
98
+
99
+ # Pinned to v15 (latest 15.x)
100
+ npx ctx7@latest docs /vercel/next.js/v15 "..."
101
+ ```
102
+
103
+ The Step 1 output enumerates available versions. Pick the version
104
+ matching the project's actual installed version (check
105
+ `package.json` / `Cargo.toml` / `requirements.txt`).
106
+
107
+ ## Research Mode (Fallback)
108
+
109
+ If the default fetch doesn't satisfy the question, retry with
110
+ `--research`:
111
+
112
+ ```bash
113
+ npx ctx7@latest docs /vercel/next.js "..." --research
114
+ ```
115
+
116
+ This launches sandboxed agents that git-pull the actual source repos
117
+ plus live web search, then synthesizes a fresh answer. More costly
118
+ (longer, more tokens), so use only when:
119
+
120
+ - Default fetch returned a generic answer when specifics were needed.
121
+ - The question references a recent change that may not be indexed yet.
122
+ - The user explicitly asked for research-grade depth.
123
+
124
+ ## Auth and Quotas
125
+
126
+ The `ctx7` CLI runs anonymously by default with limited quota. When
127
+ quota is exhausted:
128
+
129
+ ```bash
130
+ # Error message will be something like:
131
+ # Error: Quota exceeded. Run `npx ctx7@latest login` or set CONTEXT7_API_KEY
132
+ ```
133
+
134
+ Instruct the user (or surface in `needs_followup`) to either:
135
+ - Run `npx ctx7@latest login` (one-time browser auth)
136
+ - Set `CONTEXT7_API_KEY` env var with their key
137
+
138
+ Do NOT silently fall back to training data — that violates the skill's
139
+ contract. The whole point is current docs, not stale recall.
140
+
141
+ ## Budget Discipline
142
+
143
+ The user rules cap the workflow at "no more than 3 commands per
144
+ question". For most lookups this is plenty:
145
+ - 1 call: library resolution
146
+ - 1 call: docs fetch
147
+ - 1 call (optional): retry with `--research` if needed
148
+
149
+ Going over budget signals one of:
150
+ - Wrong library name (refine and retry)
151
+ - Question too broad (narrow the question first)
152
+ - Genuine library mismatch (Context7 doesn't cover this library — use
153
+ web search via WebSearch/WebFetch as alternative)
154
+
155
+ ## Sensitive Data
156
+
157
+ Never include API keys, passwords, credentials, or internal URLs in
158
+ queries. The query is logged on the Context7 side.
159
+
160
+ ```bash
161
+ # WRONG
162
+ npx ctx7@latest docs /supabase/supabase "use API key sk_live_abc123 to..."
163
+
164
+ # RIGHT
165
+ npx ctx7@latest docs /supabase/supabase "how do I authenticate the client with an API key"
166
+ ```
167
+
168
+ ## End-to-End Example
169
+
170
+ ```bash
171
+ # User asked: "How do I do streaming server actions in Next.js 15?"
172
+
173
+ # Step 1 — resolve
174
+ $ npx ctx7@latest library "Next.js" "How do I do streaming server actions in Next.js 15?"
175
+ > /vercel/next.js/v15 (benchmark 0.87, snippets 1240, source: High)
176
+ > /vercel/next.js (benchmark 0.85, snippets 5230, source: High)
177
+ > ...
178
+
179
+ # Step 2 — fetch (use version-pinned ID)
180
+ $ npx ctx7@latest docs /vercel/next.js/v15 "How do I do streaming server actions in Next.js 15?"
181
+ > [docs excerpt with streaming example, citation]
182
+
183
+ # Compose answer using the fetched docs, citing version
184
+ ```
185
+
186
+ ## When NOT to Use This Skill
187
+
188
+ See `library-id-resolution.md` for the boundary with debugging tasks,
189
+ and `version-specific-docs.md` for when the answer doesn't depend on
190
+ a specific library. Quick summary:
191
+
192
+ - ❌ Don't use for refactoring (no library lookup needed)
193
+ - ❌ Don't use for scripts written from scratch
194
+ - ❌ Don't use for debugging business logic (use codebase tools)
195
+ - ❌ Don't use for code review
196
+ - ❌ Don't use for general programming concepts
197
+ - ✅ Use for API syntax, configuration, version migration, library-specific
198
+ debugging, setup instructions, CLI tool usage
@@ -0,0 +1,217 @@
1
+ # Library ID Resolution
2
+
3
+ The Context7 library catalog uses `/org/project` IDs. Picking the right
4
+ ID is the difference between fetching authoritative docs and fetching
5
+ a community fork's stale README. This reference codifies the
6
+ disambiguation heuristics with concrete examples.
7
+
8
+ ## ID Anatomy
9
+
10
+ ```
11
+ /vercel/next.js
12
+ └org─┘ └proj─┘
13
+
14
+ /vercel/next.js/v14.3.0
15
+ └org─┘ └proj─┘ └version┘
16
+ ```
17
+
18
+ - The `org` is typically the GitHub org or the company name.
19
+ - The `project` is the official package name.
20
+ - The optional `version` is a tag or release branch.
21
+
22
+ ## Resolution Output Format
23
+
24
+ A typical Step 1 (`ctx7 library`) output:
25
+
26
+ ```text
27
+ Top matches for "Next.js" against query "configure middleware":
28
+
29
+ 1. /vercel/next.js
30
+ - Source: High
31
+ - Description: The React Framework for the Web.
32
+ - Code snippets: 5230
33
+ - Benchmark: 0.85
34
+
35
+ 2. /vercel/next.js/v15
36
+ - Source: High
37
+ - Description: Next.js v15 release line.
38
+ - Code snippets: 1240
39
+ - Benchmark: 0.87
40
+
41
+ 3. /community/next-with-foo
42
+ - Source: Medium
43
+ - Description: Next.js + Foo starter template.
44
+ - Code snippets: 87
45
+ - Benchmark: 0.42
46
+
47
+ 4. /old-org/nextjs-legacy
48
+ - Source: Low
49
+ - Description: Pre-app-router Next.js patterns.
50
+ - Code snippets: 412
51
+ - Benchmark: 0.39
52
+ ```
53
+
54
+ Five signals to weigh.
55
+
56
+ ## Signal 1: Exact Name Match
57
+
58
+ The user said "Next.js". Candidates 1 and 2 are exact matches; 3 is
59
+ "next-with-foo" (a derivative); 4 is "nextjs-legacy" (suffixed).
60
+
61
+ Prefer the canonical name. The derivative or suffixed projects are
62
+ appropriate ONLY when the user explicitly named them.
63
+
64
+ ## Signal 2: Source Reputation
65
+
66
+ `High` > `Medium` > `Low`. Source reputation reflects how authoritative
67
+ Context7 considers the project. Official org-owned repos are High.
68
+ Community forks are typically Medium. Abandoned or low-quality projects
69
+ are Low.
70
+
71
+ When multiple High candidates exist, look further. When the only
72
+ High candidate is the obvious one, pick it.
73
+
74
+ ## Signal 3: Code Snippet Count
75
+
76
+ More snippets = better-indexed library = higher chance of finding the
77
+ exact API the user asked about. The unversioned ID usually has higher
78
+ snippet counts than version-pinned IDs because it aggregates across
79
+ versions.
80
+
81
+ For general questions, prefer unversioned IDs. For version-specific
82
+ questions, accept the lower snippet count of the pinned ID.
83
+
84
+ ## Signal 4: Benchmark Score
85
+
86
+ The benchmark is a retrieval-quality measure produced by Context7 —
87
+ higher means the candidate library has good documentation that
88
+ indexes well. Use as a tiebreaker only.
89
+
90
+ In the example above, candidate 2 has a slightly higher benchmark
91
+ (0.87) than candidate 1 (0.85) because v15-specific queries score
92
+ better against the pinned slice. For a v15-specific question, prefer
93
+ candidate 2.
94
+
95
+ ## Signal 5: Query Alignment
96
+
97
+ The user's query in Step 1 affects ranking. If the query mentioned
98
+ "middleware", candidates whose docs cover middleware will rank higher.
99
+ This is why passing the FULL user question (not a single word) yields
100
+ better resolution.
101
+
102
+ ## Common Pitfalls
103
+
104
+ ### Pitfall: Picking the version-pinned ID for a general question
105
+
106
+ The user asked "What does Next.js do?" — a general question.
107
+
108
+ - ❌ Pick `/vercel/next.js/v15` — too narrow; misses cross-version context.
109
+ - ✅ Pick `/vercel/next.js` — covers the whole project.
110
+
111
+ ### Pitfall: Picking the unversioned ID for a version-specific question
112
+
113
+ The user asked "How do I migrate from Next.js 14 to 15?"
114
+
115
+ - ❌ Pick `/vercel/next.js` — might return mixed-version docs.
116
+ - ✅ Pick `/vercel/next.js/v15` — gets the migration guide for 15.
117
+ - ✅ Better: pick `/vercel/next.js/v15` for "to" and `/vercel/next.js/v14`
118
+ for "from", and run two fetches.
119
+
120
+ ### Pitfall: Picking the community fork when the user wants the official
121
+
122
+ The user asked "How do I use Tailwind utilities?"
123
+
124
+ - ❌ Pick `/some-community/tailwind-with-extras` — not what they meant.
125
+ - ✅ Pick `/tailwindlabs/tailwindcss` — the official.
126
+
127
+ Community forks rank LOW on the "what user meant" axis even when they
128
+ rank high on other signals. Default to the official.
129
+
130
+ ### Pitfall: Picking the highest snippet count regardless of relevance
131
+
132
+ The user asked about Vue 3 composition API.
133
+
134
+ - ❌ Pick `/vuejs/vue` (high snippet count, but it's the Vue 2 line).
135
+ - ✅ Pick `/vuejs/core` or `/vuejs/vue-next` (Vue 3).
136
+
137
+ Always read the description, not just the count. Old projects accumulate
138
+ snippets because they've been around longer — they may no longer be
139
+ current.
140
+
141
+ ## Disambiguation Procedure
142
+
143
+ When two candidates look equally good:
144
+
145
+ 1. **Read the descriptions.** They usually disambiguate.
146
+ 2. **Check the org.** Official org = the project's home; community
147
+ org = derivative.
148
+ 3. **Check the project's GitHub URL** if Context7 includes it. The URL
149
+ matches what the project's README cites.
150
+ 4. **Try both.** Compare the outputs of Step 2 for each candidate. The
151
+ one that better answers the question is the right one.
152
+
153
+ ## When Resolution Fails
154
+
155
+ Sometimes Step 1 returns no good match. The library may not be in
156
+ Context7's catalog, or the name was wrong. Recovery:
157
+
158
+ ```bash
159
+ # Retry with the formal name from the project's GitHub
160
+ npx ctx7@latest library "TanStack Query" "..." # not "react-query"
161
+
162
+ # Retry with the alternative spelling
163
+ npx ctx7@latest library "GitHub Actions" "..." # not "gh-actions"
164
+
165
+ # Retry with a more specific query
166
+ npx ctx7@latest library "Next.js" "App Router middleware in v15"
167
+
168
+ # If all retries fail, fall back to WebSearch / WebFetch
169
+ # (but tell the user the library isn't in Context7's catalog)
170
+ ```
171
+
172
+ ## Version Resolution Specifics
173
+
174
+ When a project has many versions, Step 1's output lists them. Pick by:
175
+
176
+ 1. **Match the project's installed version.** Check `package.json`,
177
+ `Cargo.toml`, `requirements.txt`, etc.
178
+ 2. **If the user named a version, use that.**
179
+ 3. **If neither, use the latest stable (highest version number that
180
+ isn't pre-release).**
181
+
182
+ ```bash
183
+ # Project installed Next.js 14.3.x
184
+ $ jq '.dependencies.next' package.json
185
+ "14.3.0"
186
+
187
+ # Use the pinned version
188
+ npx ctx7@latest docs /vercel/next.js/v14.3.0 "..."
189
+ ```
190
+
191
+ This catches the case where the user asks about behavior that differs
192
+ between versions; using the wrong version pin gives a confidently
193
+ wrong answer.
194
+
195
+ ## Caching
196
+
197
+ Library IDs rarely change. If you resolved `/vercel/next.js/v15` for
198
+ one query, you can re-use it for the next query about the same library
199
+ without running Step 1 again. Just remember to refresh the resolution
200
+ when:
201
+
202
+ - Asking about a different major version.
203
+ - The project's installed version changed.
204
+ - The previous fetch didn't satisfy the question (maybe the wrong ID
205
+ was picked).
206
+
207
+ ## When NOT to Use Library Lookup
208
+
209
+ The user rules are explicit: not for refactoring, scripts-from-scratch,
210
+ business-logic debugging, code review, or general programming concepts.
211
+
212
+ If the question is "how do I structure my repository?" — that is a
213
+ general programming question. Use general knowledge plus codebase
214
+ inspection, not Context7.
215
+
216
+ If the question is "how does Next.js's app router handle parallel
217
+ routes?" — that is a library API question. Use Context7.