sinapse-ai 9.3.0 → 9.4.0

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 (192) hide show
  1. package/.claude/CLAUDE.md +56 -343
  2. package/.claude/rules/agent-authority.md +6 -0
  3. package/.claude/rules/agent-handoff.md +5 -0
  4. package/.claude/rules/cross-squad-routing.md +5 -0
  5. package/.claude/rules/hook-governance.md +6 -0
  6. package/.claude/rules/mcp-usage.md +3 -1
  7. package/.claude/rules/safe-collaboration.md +10 -0
  8. package/.claude/rules/security-data-protection.md +9 -0
  9. package/.claude/rules/squad-awareness.md +3 -1
  10. package/.claude/rules/tool-examples.md +6 -0
  11. package/.claude/rules/workflow-execution.md +7 -0
  12. package/.codex/agents/analyst.md +253 -72
  13. package/.codex/agents/architect.md +455 -68
  14. package/.codex/agents/data-engineer.md +492 -106
  15. package/.codex/agents/developer.md +560 -0
  16. package/.codex/agents/devops.md +518 -69
  17. package/.codex/agents/product-lead.md +335 -0
  18. package/.codex/agents/project-lead.md +377 -0
  19. package/.codex/agents/quality-gate.md +449 -0
  20. package/.codex/agents/sinapse-orqx.md +9 -7
  21. package/.codex/agents/sprint-lead.md +287 -0
  22. package/.codex/agents/squad-creator.md +344 -0
  23. package/.codex/agents/ux-design-expert.md +495 -0
  24. package/.codex/delegation-matrix.json +756 -44
  25. package/.codex/handoff-packet.schema.json +30 -6
  26. package/.sinapse-ai/data/entity-registry.yaml +175 -363
  27. package/.sinapse-ai/data/registry-update-log.jsonl +16 -0
  28. package/.sinapse-ai/development/agents/analyst.md +90 -0
  29. package/.sinapse-ai/development/agents/architect.md +73 -0
  30. package/.sinapse-ai/development/agents/developer.md +69 -0
  31. package/.sinapse-ai/development/agents/devops.md +117 -0
  32. package/.sinapse-ai/development/agents/quality-gate.md +85 -0
  33. package/.sinapse-ai/development/checklists/agent-quality-gate.md +27 -0
  34. package/.sinapse-ai/development/checklists/brownfield-compatibility-checklist.md +20 -0
  35. package/.sinapse-ai/development/checklists/code-review-checklist.md +106 -0
  36. package/.sinapse-ai/development/checklists/issue-triage-checklist.md +9 -0
  37. package/.sinapse-ai/development/checklists/memory-audit-checklist.md +16 -0
  38. package/.sinapse-ai/development/checklists/pr-quality-checklist.md +72 -0
  39. package/.sinapse-ai/development/checklists/security-deployment-checklist.md +54 -0
  40. package/.sinapse-ai/development/checklists/self-critique-checklist.md +19 -1
  41. package/.sinapse-ai/development/skills/debug.md +57 -0
  42. package/.sinapse-ai/development/skills/fast-review.md +69 -0
  43. package/.sinapse-ai/development/skills/research-synthesis.md +77 -0
  44. package/.sinapse-ai/development/skills/security-scan.md +73 -0
  45. package/.sinapse-ai/development/skills/verify.md +53 -0
  46. package/.sinapse-ai/development/templates/squad/agent-template.md +17 -4
  47. package/.sinapse-ai/development/templates/squad/checklist-template.md +13 -5
  48. package/.sinapse-ai/development/templates/squad/task-template.md +7 -0
  49. package/.sinapse-ai/development/templates/squad/workflow-template.yaml +7 -0
  50. package/.sinapse-ai/development/workflows/fast-track.yaml +87 -0
  51. package/.sinapse-ai/infrastructure/scripts/validate-codex-delegation.js +3 -1
  52. package/.sinapse-ai/install-manifest.yaml +71 -35
  53. package/docs/codex-integration-process.md +22 -0
  54. package/docs/codex-parity-program.md +27 -0
  55. package/docs/ide-integration.md +36 -0
  56. package/package.json +1 -1
  57. package/squads/claude-code-mastery/knowledge-base/claude-code-internals-reference.md +927 -0
  58. package/squads/squad-brand/knowledge-base/archetype-brand-mapping.md +12 -1
  59. package/squads/squad-brand/knowledge-base/brand-activism-cultural-branding.md +216 -0
  60. package/squads/squad-brand/knowledge-base/brand-audit-criteria.md +58 -0
  61. package/squads/squad-brand/knowledge-base/brand-digital-strategy.md +188 -0
  62. package/squads/squad-brand/knowledge-base/brand-legal-ip.md +222 -0
  63. package/squads/squad-brand/knowledge-base/brand-naming-framework.md +163 -0
  64. package/squads/squad-brand/knowledge-base/branding-master-reference.md +1001 -0
  65. package/squads/squad-brand/knowledge-base/color-psychology.md +25 -12
  66. package/squads/squad-brand/knowledge-base/employer-personal-branding.md +206 -0
  67. package/squads/squad-brand/knowledge-base/routing-catalog.md +34 -0
  68. package/squads/squad-brand/knowledge-base/sonic-branding-principles.md +6 -1
  69. package/squads/squad-brand/knowledge-base/typography-personality.md +34 -0
  70. package/squads/squad-claude/knowledge-base/context-window-optimization.md +334 -0
  71. package/squads/squad-claude/knowledge-base/knowledge-architecture-reference.md +403 -0
  72. package/squads/squad-claude/knowledge-base/memory-systems-reference.md +412 -0
  73. package/squads/squad-claude/knowledge-base/obsidian-claude-integration.md +423 -0
  74. package/squads/squad-claude/knowledge-base/retrieval-augmented-generation.md +320 -0
  75. package/squads/squad-claude/knowledge-base/skill-creation-patterns.md +380 -0
  76. package/squads/squad-claude/knowledge-base/swarm-orchestration-patterns.md +411 -0
  77. package/squads/squad-cloning/knowledge-base/clone-quality-assurance.md +211 -0
  78. package/squads/squad-cloning/knowledge-base/confidence-scoring.md +51 -0
  79. package/squads/squad-cloning/knowledge-base/cross-squad-deployment.md +47 -0
  80. package/squads/squad-cloning/knowledge-base/ethical-guidelines.md +237 -0
  81. package/squads/squad-cloning/knowledge-base/knowledge-graph-for-clones.md +295 -0
  82. package/squads/squad-cloning/knowledge-base/memory-architecture-for-clones.md +229 -0
  83. package/squads/squad-cloning/knowledge-base/multi-agent-deployment-patterns.md +320 -0
  84. package/squads/squad-cloning/knowledge-base/skill-standard-for-clones.md +262 -0
  85. package/squads/squad-cloning/knowledge-base/sop-extraction-guide.md +243 -0
  86. package/squads/squad-commercial/knowledge-base/account-based-selling.md +206 -0
  87. package/squads/squad-commercial/knowledge-base/ai-as-competitive-infrastructure.md +14 -0
  88. package/squads/squad-commercial/knowledge-base/ai-in-sales.md +199 -0
  89. package/squads/squad-commercial/knowledge-base/brazilian-sales-context.md +195 -0
  90. package/squads/squad-commercial/knowledge-base/customer-success-operations.md +83 -2
  91. package/squads/squad-commercial/knowledge-base/prospecting-pipeline-generation.md +69 -0
  92. package/squads/squad-commercial/knowledge-base/sales-enablement-playbook.md +260 -0
  93. package/squads/squad-commercial/knowledge-base/sales-methodology-comparison.md +185 -0
  94. package/squads/squad-commercial/knowledge-base/sales-revenue-master-reference.md +1123 -0
  95. package/squads/squad-content/knowledge-base/brazilian-content-context.md +176 -0
  96. package/squads/squad-content/knowledge-base/competitor-analysis-methods.md +40 -1
  97. package/squads/squad-content/knowledge-base/content-architecture-taxonomy.md +206 -0
  98. package/squads/squad-content/knowledge-base/content-formats-encyclopedia.md +58 -1
  99. package/squads/squad-content/knowledge-base/content-references-bibliography.md +130 -0
  100. package/squads/squad-content/knowledge-base/content-strategy-master-reference.md +1097 -0
  101. package/squads/squad-content/knowledge-base/content-tech-stack.md +150 -0
  102. package/squads/squad-content/knowledge-base/copywriting-formulas-library.md +188 -0
  103. package/squads/squad-content/knowledge-base/email-newsletter-strategy.md +161 -0
  104. package/squads/squad-content/knowledge-base/platform-algorithm-intelligence.md +86 -1
  105. package/squads/squad-content/knowledge-base/social-algorithms-master-reference.md +1007 -0
  106. package/squads/squad-content/knowledge-base/video-audio-content-playbook.md +218 -0
  107. package/squads/squad-copy/knowledge-base/ai-copy-production.md +254 -0
  108. package/squads/squad-copy/knowledge-base/brazilian-copywriting-context.md +242 -0
  109. package/squads/squad-copy/knowledge-base/email-copywriting-system.md +299 -0
  110. package/squads/squad-copy/knowledge-base/landing-page-copy-architecture.md +267 -0
  111. package/squads/squad-copy/knowledge-base/power-words-catalog.md +205 -0
  112. package/squads/squad-copy/knowledge-base/seo-copywriting.md +255 -0
  113. package/squads/squad-copy/knowledge-base/video-script-copywriting.md +239 -0
  114. package/squads/squad-council/knowledge-base/brand-strategy-models.md +193 -0
  115. package/squads/squad-council/knowledge-base/growth-strategy-models.md +267 -0
  116. package/squads/squad-council/knowledge-base/innovation-disruption-frameworks.md +193 -0
  117. package/squads/squad-council/knowledge-base/market-analysis-frameworks.md +240 -0
  118. package/squads/squad-council/knowledge-base/organizational-leadership-models.md +212 -0
  119. package/squads/squad-council/knowledge-base/sales-strategy-models.md +215 -0
  120. package/squads/squad-courses/knowledge-base/course-launch-strategy.md +251 -0
  121. package/squads/squad-courses/knowledge-base/domain-advocacia-curriculum.md +385 -0
  122. package/squads/squad-courses/knowledge-base/domain-contabilidade-curriculum.md +266 -0
  123. package/squads/squad-courses/knowledge-base/platform-comparison.md +68 -0
  124. package/squads/squad-courses/knowledge-base/video-production-guide.md +70 -0
  125. package/squads/squad-cybersecurity/knowledge-base/cloud-security-reference.md +363 -0
  126. package/squads/squad-cybersecurity/knowledge-base/compliance-frameworks.md +273 -0
  127. package/squads/squad-cybersecurity/knowledge-base/database-security.md +438 -0
  128. package/squads/squad-cybersecurity/knowledge-base/incident-response-playbook.md +420 -0
  129. package/squads/squad-cybersecurity/knowledge-base/network-security-reference.md +477 -0
  130. package/squads/squad-cybersecurity/knowledge-base/penetration-testing-methodology.md +350 -0
  131. package/squads/squad-cybersecurity/knowledge-base/vulnerability-management.md +349 -0
  132. package/squads/squad-design/knowledge-base/brazilian-design-context.md +223 -0
  133. package/squads/squad-design/knowledge-base/component-api-patterns.md +208 -4
  134. package/squads/squad-design/knowledge-base/design-system-master-reference.md +1302 -0
  135. package/squads/squad-design/knowledge-base/design-systems-frameworks.md +91 -1
  136. package/squads/squad-design/knowledge-base/responsive-modern-css.md +96 -4
  137. package/squads/squad-design/knowledge-base/wcag-aria-reference.md +117 -5
  138. package/squads/squad-design/knowledge-base/web-performance-reference.md +127 -4
  139. package/squads/squad-finance/knowledge-base/brazilian-taxation.md +263 -0
  140. package/squads/squad-finance/knowledge-base/contabilidade-master-reference.md +998 -0
  141. package/squads/squad-finance/knowledge-base/finance-master-reference.md +946 -0
  142. package/squads/squad-finance/knowledge-base/financial-reporting-analysis.md +316 -0
  143. package/squads/squad-finance/knowledge-base/fintech-brazilian-context.md +242 -0
  144. package/squads/squad-finance/knowledge-base/fpa-planning-frameworks.md +286 -0
  145. package/squads/squad-finance/knowledge-base/ma-and-transactions.md +285 -0
  146. package/squads/squad-finance/knowledge-base/risk-management.md +233 -0
  147. package/squads/squad-finance/knowledge-base/startups-venture-capital.md +337 -0
  148. package/squads/squad-growth/knowledge-base/ai-growth-playbook.md +216 -0
  149. package/squads/squad-growth/knowledge-base/attribution-models.md +78 -0
  150. package/squads/squad-growth/knowledge-base/brazilian-growth-context.md +208 -0
  151. package/squads/squad-growth/knowledge-base/community-led-growth.md +175 -0
  152. package/squads/squad-growth/knowledge-base/content-marketing-flywheel.md +190 -0
  153. package/squads/squad-growth/knowledge-base/email-lifecycle-framework.md +192 -0
  154. package/squads/squad-growth/knowledge-base/growth-frameworks-catalog.md +82 -0
  155. package/squads/squad-growth/knowledge-base/growth-master-reference.md +1168 -0
  156. package/squads/squad-growth/knowledge-base/routing-catalog.md +53 -11
  157. package/squads/squad-paidmedia/knowledge-base/audiences-segmentation-deep.md +285 -0
  158. package/squads/squad-paidmedia/knowledge-base/creative-strategy-deep.md +294 -0
  159. package/squads/squad-paidmedia/knowledge-base/google-ads-account-architecture.md +87 -0
  160. package/squads/squad-paidmedia/knowledge-base/meta-ads-campaign-architecture.md +76 -0
  161. package/squads/squad-paidmedia/knowledge-base/paid-media-metrics-reference.md +117 -0
  162. package/squads/squad-paidmedia/knowledge-base/paid-traffic-master-reference.md +1308 -0
  163. package/squads/squad-paidmedia/knowledge-base/routing-catalog.md +95 -18
  164. package/squads/squad-paidmedia/knowledge-base/traffic-masters-frameworks.md +71 -0
  165. package/squads/squad-product/knowledge-base/brazilian-product-context.md +284 -0
  166. package/squads/squad-product/knowledge-base/discovery-methodology-playbook.md +141 -0
  167. package/squads/squad-product/knowledge-base/pm-frameworks-reference.md +125 -9
  168. package/squads/squad-product/knowledge-base/product-analytics-formulas.md +72 -0
  169. package/squads/squad-product/knowledge-base/product-led-growth-reference.md +155 -13
  170. package/squads/squad-product/knowledge-base/product-market-fit-framework.md +222 -0
  171. package/squads/squad-product/knowledge-base/routing-catalog.md +32 -0
  172. package/squads/squad-research/knowledge-base/agentic-second-brain-reference.md +591 -0
  173. package/squads/squad-research/knowledge-base/ai-augmented-research.md +212 -0
  174. package/squads/squad-research/knowledge-base/brazilian-market-research-sources.md +197 -0
  175. package/squads/squad-research/knowledge-base/community-platforms-reference.md +786 -0
  176. package/squads/squad-research/knowledge-base/community-research-methods.md +194 -0
  177. package/squads/squad-research/knowledge-base/mixed-methods-research-design.md +168 -0
  178. package/squads/squad-research/knowledge-base/network-effects-analysis.md +192 -0
  179. package/squads/squad-research/knowledge-base/qualitative-research-deep-methods.md +202 -0
  180. package/squads/squad-research/knowledge-base/quantitative-research-methods.md +208 -0
  181. package/squads/squad-research/knowledge-base/research-frameworks-encyclopedia.md +40 -0
  182. package/squads/squad-research/knowledge-base/research-synthesis-frameworks.md +223 -0
  183. package/squads/squad-storytelling/knowledge-base/brand-mythology-framework.md +236 -0
  184. package/squads/squad-storytelling/knowledge-base/brazilian-storytelling-context.md +237 -0
  185. package/squads/squad-storytelling/knowledge-base/data-storytelling.md +232 -0
  186. package/squads/squad-storytelling/knowledge-base/improv-storytelling.md +226 -0
  187. package/squads/squad-storytelling/knowledge-base/persuasion-narrative-techniques.md +269 -0
  188. package/squads/squad-storytelling/knowledge-base/social-movement-narratives.md +191 -0
  189. package/squads/squad-storytelling/knowledge-base/video-storytelling.md +252 -0
  190. package/squads/claude-code-mastery/data/swarm-orchestration-patterns.yaml +0 -378
  191. package/squads/squad-animations/knowledge-base/framer-motion-complete-reference.md +0 -710
  192. package/squads/squad-animations/knowledge-base/web-animations-api-view-transitions.md +0 -478
@@ -0,0 +1,320 @@
1
+ # Retrieval-Augmented Generation (RAG)
2
+
3
+ > BM25+embeddings+graph hybrid retrieval, chunking strategies, and production RAG patterns. Based on MS-009 research (April 2026).
4
+
5
+ ---
6
+
7
+ ## RAG Fundamentals
8
+
9
+ **RAG (Retrieval-Augmented Generation):** Augmenting LLM responses with retrieved external knowledge, rather than relying solely on model training data.
10
+
11
+ **Why RAG matters for agents:**
12
+ - Grounds responses in verified, current information
13
+ - Prevents hallucination by anchoring to source documents
14
+ - Enables access to knowledge beyond training cutoff
15
+ - Allows agents to operate over private/proprietary knowledge bases
16
+ - Reduces fine-tuning costs (context engineering instead)
17
+
18
+ **Patrick Lewis et al. (Facebook AI Research, 2020):** The foundational paper establishing RAG as a paradigm. "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks."
19
+
20
+ ---
21
+
22
+ ## The 2026 Production Standard: Hybrid Search
23
+
24
+ Single-modality retrieval is no longer production-grade. The standard is hybrid:
25
+
26
+ ```
27
+ [User Query]
28
+
29
+ ├── BM25 (keyword search) ──────────────────┐
30
+ │ │
31
+ ├── Dense Embeddings (semantic) ────────────┤
32
+ │ │
33
+ └── Knowledge Graph (structured) ──────────┤
34
+
35
+ Reciprocal Rank Fusion (RRF)
36
+
37
+ Cross-Encoder Reranking
38
+
39
+ Final Top-N to LLM
40
+ ```
41
+
42
+ **Why each component:**
43
+
44
+ | Component | Strengths | Weaknesses |
45
+ |-----------|----------|------------|
46
+ | BM25 | Exact matches, product codes, legal terms, acronyms | Misses semantic similarity |
47
+ | Dense embeddings | Semantic similarity, paraphrase matching | Misses exact terms |
48
+ | Knowledge graph | Structural relationships, entity chains | Misses unstructured content |
49
+
50
+ **Hybrid reduces errors by 35-60% vs pure semantic retrieval.**
51
+
52
+ ---
53
+
54
+ ## BM25 (Best Match 25)
55
+
56
+ The gold standard for keyword-based retrieval, still essential in 2026.
57
+
58
+ **Scoring formula:**
59
+ ```
60
+ BM25(d, q) = Σ IDF(qi) × [f(qi,d) × (k1+1)] / [f(qi,d) + k1×(1-b+b×|d|/avgdl)]
61
+ ```
62
+
63
+ Where:
64
+ - `IDF(qi)` — inverse document frequency of term qi
65
+ - `f(qi,d)` — frequency of term qi in document d
66
+ - `k1` — term saturation (typically 1.2-2.0)
67
+ - `b` — length normalization (typically 0.75)
68
+ - `avgdl` — average document length
69
+
70
+ **Best for:** Product codes, UUIDs, unique identifiers, technical terms, proper nouns, legal/medical terminology.
71
+
72
+ ---
73
+
74
+ ## Dense Embeddings
75
+
76
+ **How they work:** Documents and queries converted to high-dimensional vectors. Similar meanings → nearby in vector space → retrieved together.
77
+
78
+ **Embedding models (2026):**
79
+
80
+ | Model | Dimensions | Strengths |
81
+ |-------|-----------|----------|
82
+ | text-embedding-3-large (OpenAI) | 3,072 | General purpose, MTEB SOTA |
83
+ | voyage-3 (Anthropic) | 1,024 | Claude-optimized, multilingual |
84
+ | cohere-embed-v3 | 1,024 | Classification, search |
85
+ | e5-large-v2 (free) | 1,024 | Open-source quality |
86
+ | bge-m3 (free) | 1,024 | Multi-lingual, long-context |
87
+
88
+ **Selection guidance:**
89
+ - Production with Anthropic stack: Voyage-3
90
+ - Cost-sensitive: bge-m3 (self-hosted)
91
+ - Multilingual: bge-m3 or voyage-3
92
+
93
+ ---
94
+
95
+ ## Reciprocal Rank Fusion (RRF)
96
+
97
+ Merges rankings from multiple retrieval systems without requiring score normalization.
98
+
99
+ **Formula:**
100
+ ```
101
+ RRF(d) = Σ 1 / (k + rank_i(d))
102
+ ```
103
+
104
+ Where `k` = 60 (standard), `rank_i(d)` = rank of document d in retrieval system i.
105
+
106
+ **Why RRF works:** A document appearing in top-5 across multiple retrieval types gets a massive score boost. Captures "universal relevance."
107
+
108
+ **Alternative: Learned merging** — train a small model to weight retrieval sources based on query type. Better for domain-specific applications with training data.
109
+
110
+ ---
111
+
112
+ ## Cross-Encoder Reranking
113
+
114
+ Two-stage retrieval architecture:
115
+
116
+ **Stage 1 (Bi-encoder):** Fast approximate search — retrieves top-K candidates using embeddings.
117
+
118
+ **Stage 2 (Cross-encoder):** Slow, precise scoring — reads query + document together for more accurate relevance.
119
+
120
+ ```
121
+ [Query] + [Document 1] → Score: 0.92
122
+ [Query] + [Document 2] → Score: 0.87
123
+ [Query] + [Document 3] → Score: 0.71
124
+ ```
125
+
126
+ **Models:** `cross-encoder/ms-marco-MiniLM-L-6-v2` (open-source), Cohere Rerank (API).
127
+
128
+ **When to use:** When top-K from bi-encoder stage contains irrelevant results that hurt LLM response quality.
129
+
130
+ ---
131
+
132
+ ## Chunking Strategies
133
+
134
+ How documents are split for indexing. Critical for retrieval quality.
135
+
136
+ ### Chunking Methods
137
+
138
+ | Method | Description | Best For |
139
+ |--------|-------------|---------|
140
+ | **Fixed-size** | Split every N characters/tokens | Baseline, simple docs |
141
+ | **Sentence-based** | Split at sentence boundaries | Prose text |
142
+ | **Semantic** | Split at topic changes (detected by LLM/embeddings) | Complex documents |
143
+ | **Recursive** | Try paragraphs → sentences → words | Variable-length content |
144
+ | **Document-aware** | Respect markdown headers, code blocks | Technical docs, KB files |
145
+ | **Parent-child** | Store full section + child chunks | Knowledge retrieval |
146
+
147
+ ### Parent-Child Chunking (Recommended for KB)
148
+
149
+ ```
150
+ Parent chunk: Full section (e.g., "## Memory Architecture")
151
+ → Stored for retrieval (full context)
152
+
153
+ Child chunks: Individual paragraphs within section
154
+ → Used for search (narrow matches)
155
+ → When matched, return parent chunk (full context)
156
+ ```
157
+
158
+ **Why:** Narrow chunks retrieve more precisely; full sections provide sufficient context for LLM.
159
+
160
+ ### Chunk Size Guidelines
161
+
162
+ | Content Type | Recommended Size | Overlap |
163
+ |-------------|-----------------|---------|
164
+ | Technical documentation | 512-1024 tokens | 10-20% |
165
+ | Conversational notes | 256-512 tokens | 5-10% |
166
+ | Code snippets | 256-512 tokens | 0% (no overlap) |
167
+ | Legal/formal documents | 1024-2048 tokens | 15-20% |
168
+ | Research papers | 512-1024 tokens | 10-15% |
169
+
170
+ **Key rule:** Each chunk should be **semantically self-contained** — understandable without surrounding context.
171
+
172
+ ---
173
+
174
+ ## GraphRAG (Microsoft Research + Production)
175
+
176
+ ### What GraphRAG Adds
177
+
178
+ Standard RAG: "What do these chunks say?"
179
+ GraphRAG: "What do ENTITIES and their RELATIONSHIPS say?"
180
+
181
+ **Two query modes:**
182
+ - **Local query:** Specific fact lookup about known entities
183
+ - **Global query:** Theme/pattern questions across entire corpus
184
+
185
+ ### LazyGraphRAG (2026 Innovation)
186
+
187
+ Full GraphRAG requires expensive upfront indexing (extract all entities and relationships).
188
+
189
+ **LazyGraphRAG:** Defers expensive analysis to query time.
190
+ - Index cost: ~0.1% of full GraphRAG
191
+ - Quality: Comparable for global queries
192
+ - Trade-off: Higher latency per query
193
+
194
+ **Use when:** Cost of upfront indexing prohibitive; data changes frequently.
195
+
196
+ ---
197
+
198
+ ## Agentic RAG
199
+
200
+ State of the art — agents that **plan, retrieve, reason, critique, and refine** in loops.
201
+
202
+ ### Agentic RAG Loop
203
+
204
+ ```
205
+ [Question]
206
+
207
+ [Decompose into sub-questions]
208
+
209
+ For each sub-question:
210
+ [Query formulation] → refined search terms
211
+ [Retrieval] → top-K results
212
+ [Relevance check] → is this actually useful?
213
+ [Gap detection] → what's missing?
214
+ If insufficient → reformulate query and retry (max N)
215
+
216
+ [Cross-reference all findings]
217
+ [Identify convergences and contradictions]
218
+ [Synthesize into coherent answer]
219
+ [Verify citations are accurate]
220
+
221
+ [Final response with citations]
222
+ ```
223
+
224
+ **Survey:** arXiv 2501.09136 — "Agentic RAG" as formal research area.
225
+
226
+ ### SINAPSE Research Pipeline (analogous)
227
+
228
+ ```
229
+ @analyst receives research request
230
+ → Decompose into sub-questions
231
+ → For each: search vault + web + papers
232
+ → Extract claims and assess credibility
233
+ → Cross-reference sources
234
+ → Synthesize structured output
235
+ → Deposit results in vault (audit trail)
236
+ ```
237
+
238
+ ---
239
+
240
+ ## RAG Evaluation
241
+
242
+ ### Core Metrics
243
+
244
+ | Metric | What It Measures | Target |
245
+ |--------|-----------------|--------|
246
+ | Retrieval Precision | % retrieved chunks actually relevant | > 70% |
247
+ | Retrieval Recall | % relevant chunks retrieved | > 60% |
248
+ | Answer Faithfulness | Answer grounded in retrieved context | > 90% |
249
+ | Answer Relevance | Answer addresses the question | > 85% |
250
+ | Context Relevance | Retrieved context relevant to question | > 70% |
251
+ | Latency P95 | Time to first token | < 3s |
252
+
253
+ ### RAGAS Framework
254
+
255
+ Open-source RAG evaluation (Exploding Topics, 2023):
256
+ ```python
257
+ from ragas import evaluate
258
+ from ragas.metrics import faithfulness, answer_relevancy, context_precision
259
+
260
+ results = evaluate(
261
+ dataset=test_cases,
262
+ metrics=[faithfulness, answer_relevancy, context_precision]
263
+ )
264
+ ```
265
+
266
+ ### Common Failure Modes
267
+
268
+ | Failure | Cause | Fix |
269
+ |---------|-------|-----|
270
+ | Hallucination | LLM ignores retrieved context | Better prompting: "Based ONLY on context" |
271
+ | Retrieved wrong content | Poor chunking or embedding quality | Improve chunking, upgrade embeddings |
272
+ | Missing relevant content | Incomplete retrieval | Hybrid search, increase top-K |
273
+ | Context too long | Too many chunks retrieved | Cross-encoder reranking, reduce K |
274
+ | Outdated information | Stale index | Index update schedule |
275
+
276
+ ---
277
+
278
+ ## RAG for SINAPSE Knowledge Base
279
+
280
+ ### Current Knowledge Flow
281
+
282
+ ```
283
+ User query → Claude Code
284
+ → (no automated retrieval)
285
+ → Claude reads KB files manually when needed
286
+ ```
287
+
288
+ ### Recommended Enhancement
289
+
290
+ ```
291
+ User query → SINAPSE agent
292
+ → Query formulation
293
+ → Hybrid search over KB + stories + architecture docs
294
+ → Top-N relevant chunks
295
+ → Grounded response with KB citations
296
+ ```
297
+
298
+ ### Implementation Approach
299
+
300
+ 1. **Index KB files:** Embed all KB files (*.md in knowledge-base/)
301
+ 2. **Index stories:** Embed active stories (docs/stories/)
302
+ 3. **Index architecture docs:** Embed docs/architecture/
303
+ 4. **Search API:** Expose search endpoint via MCP server
304
+ 5. **Agent integration:** Add `*search-kb` skill that agents call when needing reference
305
+
306
+ ### Chunking KB Files
307
+
308
+ KB files are structured markdown. Use document-aware chunking:
309
+
310
+ ```python
311
+ # Split at H2 headers (##)
312
+ # Keep H1 context in each chunk as prefix
313
+ # Minimum chunk: 100 tokens
314
+ # Maximum chunk: 1500 tokens
315
+ # Overlap: 10% between consecutive sections
316
+ ```
317
+
318
+ Each chunk prefixed with: `{file_name} > {h1_title} > {h2_section}`
319
+
320
+ Example: `memory-systems-reference.md > Memory Frameworks Comparison > Letta (MemGPT)`
@@ -0,0 +1,380 @@
1
+ # Skill Creation Patterns
2
+
3
+ > Complete guide to the Agent Skills ecosystem. Based on skills-ecosystem-analysis research (April 2026). 1,060+ skills catalogued, 33 platforms supporting the format.
4
+
5
+ ---
6
+
7
+ ## The Agent Skills Standard
8
+
9
+ ### What Skills Are
10
+
11
+ Skills are **portable, on-demand capability packages** that teach agents how to accomplish domain-specific tasks. Not tools (which provide programmatic access) — skills are **knowledge and workflow instructions** that agents load when needed.
12
+
13
+ **The key difference:**
14
+ | Concept | What it is | When to use |
15
+ |---------|-----------|-------------|
16
+ | **Skill** | Instructions + resources teaching the agent a workflow | Agent needs domain expertise or methodology |
17
+ | **MCP Tool** | Server exposing programmatic actions via protocol | Agent needs API/DB/external service access |
18
+ | **Hook** | Script intercepting lifecycle events | Enforcement, validation, automation |
19
+ | **CLAUDE.md** | Global project instructions | Conventions, rules, project context |
20
+
21
+ ### Format Standard (agentskills.io)
22
+
23
+ The `SKILL.md` format is supported by **33 platforms** (April 2026), including Claude Code, Codex, Gemini CLI, Cursor, VS Code, GitHub Copilot, and 27+ others.
24
+
25
+ **Key principle:** Write once, run anywhere.
26
+
27
+ ---
28
+
29
+ ## SKILL.md File Format
30
+
31
+ ### Directory Structure
32
+
33
+ ```
34
+ skill-name/
35
+ SKILL.md # REQUIRED: metadata + instructions
36
+ scripts/ # Optional: executable scripts
37
+ references/ # Optional: supplementary documentation
38
+ assets/ # Optional: templates, static resources
39
+ LICENSE.txt # Optional: license
40
+ ```
41
+
42
+ **Rule:** Folder name MUST match the `name` field in frontmatter.
43
+
44
+ ### Frontmatter Specification
45
+
46
+ | Field | Required | Constraints | Description |
47
+ |-------|----------|-------------|-------------|
48
+ | `name` | Yes | Max 64 chars, lowercase + hyphens, no consecutive hyphens | Unique identifier |
49
+ | `description` | Yes | Max 1024 chars | What it does AND when to use it |
50
+ | `license` | No | License name or file reference | Distribution terms |
51
+ | `compatibility` | No | Max 500 chars | Environment requirements |
52
+ | `metadata` | No | `map<string, string>` | Arbitrary key-value pairs |
53
+ | `allowed-tools` | No | Experimental | Pre-approved tools list |
54
+
55
+ **Minimal example:**
56
+ ```yaml
57
+ ---
58
+ name: pdf-processing
59
+ description: Extract PDF text, fill forms, merge files. Use when handling PDFs.
60
+ ---
61
+ ```
62
+
63
+ **Complete example:**
64
+ ```yaml
65
+ ---
66
+ name: security-audit
67
+ description: |
68
+ Audit code for security vulnerabilities including injection flaws,
69
+ auth issues, and secret exposure. Use when reviewing PR diffs,
70
+ new features, or when user mentions security review.
71
+ license: Apache-2.0
72
+ compatibility: Requires Python 3.12+
73
+ metadata:
74
+ author: squad-claude
75
+ version: "1.0"
76
+ category: security
77
+ allowed-tools: Read Grep Glob Bash(git diff *)
78
+ ---
79
+ ```
80
+
81
+ ### Progressive Disclosure (3 levels)
82
+
83
+ The most critical architectural pattern in the skill system:
84
+
85
+ | Level | What loads | When | Ideal size |
86
+ |-------|-----------|------|-----------|
87
+ | 1. Metadata | `name` + `description` | Always (startup) | ~100 tokens |
88
+ | 2. Instructions | Full SKILL.md body | When skill is activated | < 5,000 tokens (~500 lines) |
89
+ | 3. Resources | Files in scripts/, references/, assets/ | On-demand | Unlimited |
90
+
91
+ **Critical rule: Keep SKILL.md under 500 lines.** Move detailed reference material to separate files.
92
+
93
+ ---
94
+
95
+ ## Quality Patterns
96
+
97
+ ### Writing Effective Descriptions
98
+
99
+ The description is NOT just documentation — it's the **primary activation mechanism**. Agents use descriptions to decide when to invoke skills.
100
+
101
+ **Anti-pattern (vague):**
102
+ ```yaml
103
+ description: "Helps with code review"
104
+ ```
105
+
106
+ **Best practice (specific + trigger keywords):**
107
+ ```yaml
108
+ description: |
109
+ Review code changes for security vulnerabilities, logic errors, and style violations.
110
+ Use when: reviewing PRs, auditing new features, after implementing auth/payment code,
111
+ or when user asks for code review, security check, or audit.
112
+ ```
113
+
114
+ **Anthropic recommendation:** Make descriptions "a bit pushy" to counter the tendency of under-triggering. Include specific keywords users might say.
115
+
116
+ ### Instruction Principles
117
+
118
+ 1. **Imperative, not declarative** — "Do X" not "X should be done"
119
+ 2. **Concrete examples** — Every skill should have input/output examples
120
+ 3. **Decision trees** — Complex skills need explicit when/when-not-to-use branches
121
+ 4. **Reference templates** — Link to templates in sub-folders, don't inline everything
122
+ 5. **No inventions** — Skills teach existing patterns, not invented ones
123
+ 6. **Scripts as black boxes** — Scripts in `scripts/` should be called with `--help` first, not read inline
124
+
125
+ ### Decision Tree Pattern
126
+
127
+ ```markdown
128
+ ## When to Use This Skill
129
+
130
+ Use this skill when:
131
+ - User mentions "security review", "audit", "vulnerability"
132
+ - PR contains changes to auth, payments, or user data
133
+ - New API endpoints are being added
134
+
135
+ Do NOT use when:
136
+ - Simple read-only changes (cosmetic, docs)
137
+ - Test-only changes
138
+ - User explicitly asks for implementation help (not review)
139
+
140
+ ## Decision Process
141
+
142
+ 1. Read the diff/changed files
143
+ 2. Check for [high-risk patterns]:
144
+ - SQL string concatenation → BLOCK, flag injection risk
145
+ - Hardcoded credentials → BLOCK, flag secret exposure
146
+ - Missing input validation → WARN, suggest Zod schema
147
+ - RLS disabled → BLOCK, flag security regression
148
+ 3. Summarize findings by severity: CRITICAL / HIGH / MEDIUM / LOW
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Official Anthropic Skills (17 skills)
154
+
155
+ ### Plugin: document-skills (source-available)
156
+
157
+ | Skill | Capability |
158
+ |-------|-----------|
159
+ | `docx` | Word document creation/editing with tracked changes |
160
+ | `pdf` | Full PDF manipulation (extract, merge, fill forms) |
161
+ | `pptx` | PowerPoint creation/editing |
162
+ | `xlsx` | Excel creation/editing with formulas and charts |
163
+
164
+ ### Plugin: example-skills (Apache 2.0)
165
+
166
+ | Skill | Capability |
167
+ |-------|-----------|
168
+ | `algorithmic-art` | Generative art with p5.js and seeded randomness |
169
+ | `brand-guidelines` | Anthropic visual identity application |
170
+ | `canvas-design` | Visual design in PNG/PDF |
171
+ | `doc-coauthoring` | Document co-authoring |
172
+ | `frontend-design` | Production-grade interfaces without "AI slop" |
173
+ | `internal-comms` | Internal communications (status reports, newsletters) |
174
+ | `mcp-builder` | Guide for creating MCP servers |
175
+ | `skill-creator` | Meta-skill for creating new skills |
176
+ | `slack-gif-creator` | Animated GIFs optimized for Slack |
177
+ | `theme-factory` | Visual theme creation |
178
+ | `web-artifacts-builder` | Interactive HTML artifacts |
179
+ | `webapp-testing` | Web app testing with Playwright |
180
+
181
+ ### Plugin: claude-api
182
+
183
+ | Skill | Capability |
184
+ |-------|-----------|
185
+ | `claude-api` | Claude API documentation and SDK (Python, TS, Java, Go, Ruby, C#, PHP) |
186
+
187
+ ---
188
+
189
+ ## Ecosystem Numbers (April 2026)
190
+
191
+ | Metric | Value |
192
+ |--------|-------|
193
+ | Skills catalogued (VoltAgent/awesome-agent-skills) | 1,060+ |
194
+ | Dev teams contributing | 38+ |
195
+ | Categories | 11+ |
196
+ | Official vendor skills | 307 |
197
+ | Community skills | 144+ |
198
+ | Platforms supporting SKILL.md format | 33 |
199
+ | obra/superpowers stars | 134,347 |
200
+ | anthropics/skills stars | 110,197 |
201
+
202
+ ### Quality Distribution
203
+
204
+ | Tier | Description | Estimated % |
205
+ |------|-------------|-------------|
206
+ | S-tier | Official Anthropic + Trail of Bits + Superpowers | ~5% |
207
+ | A-tier | Official vendors (Vercel, Netlify, Expo, Microsoft) | ~15% |
208
+ | B-tier | Strong community (documented, tested) | ~25% |
209
+ | C-tier | Basic community (functional, no polish) | ~35% |
210
+ | D-tier | Low-effort / AI-generated bulk | ~20% |
211
+
212
+ ---
213
+
214
+ ## obra/superpowers Framework
215
+
216
+ The dominant community reference with 134K stars — not just skills, but a complete development methodology.
217
+
218
+ ### 14 Skills Included
219
+
220
+ - `brainstorming` — Structured ideation
221
+ - `dispatching-parallel-agents` — Parallel agent orchestration
222
+ - `executing-plans` — Implementation plan execution
223
+ - `finishing-a-development-branch` — Branch finalization
224
+ - `receiving-code-review` — Code review reception
225
+ - `requesting-code-review` — Code review solicitation
226
+ - `subagent-driven-development` — Development with subagents
227
+ - `systematic-debugging` — Systematic debug process
228
+ - `test-driven-development` — TDD workflow
229
+ - `using-git-worktrees` — Worktrees for parallelism
230
+ - `verification-before-completion` — Pre-delivery verification
231
+ - `writing-plans` — Implementation plan writing
232
+ - `writing-skills` — Meta-skill for creating skills
233
+ - `using-superpowers` — Framework usage guide
234
+
235
+ ### Methodology (5 steps)
236
+
237
+ 1. Understand what user wants (spec)
238
+ 2. Show spec in digestible chunks
239
+ 3. Create implementation plan for "enthusiastic junior engineer"
240
+ 4. Subagent-driven development (one agent per task)
241
+ 5. Two-stage review (spec compliance + code quality)
242
+
243
+ ---
244
+
245
+ ## Skills for SINAPSE Squad-Claude
246
+
247
+ ### Existing Skills to Build
248
+
249
+ | Skill | Priority | Description |
250
+ |-------|----------|-------------|
251
+ | `claude-code-audit` | High | Audit CC configuration, hooks, settings |
252
+ | `sinapse-setup` | High | Initialize SINAPSE in a new project |
253
+ | `agent-persona-creation` | High | Create new agent .md files |
254
+ | `hooks-architecture` | Medium | Design and implement hook systems |
255
+ | `mcp-server-setup` | Medium | Configure and test MCP servers |
256
+ | `context-optimization` | Medium | Analyze and reduce context window usage |
257
+ | `skill-creation` | High | Meta-skill — create new SINAPSE skills |
258
+ | `squad-publishing` | Low | Package and publish squads |
259
+
260
+ ### Skill Template for SINAPSE
261
+
262
+ ```yaml
263
+ ---
264
+ name: {skill-name}
265
+ description: |
266
+ {What it does in 1-2 sentences}.
267
+ Use when: {specific trigger conditions — include keywords users say}.
268
+ license: Apache-2.0
269
+ metadata:
270
+ author: squad-claude
271
+ version: "1.0"
272
+ category: {claude-code|configuration|agent|workflow}
273
+ allowed-tools: {space-separated list or omit}
274
+ ---
275
+
276
+ ## Purpose
277
+
278
+ {Brief purpose statement}
279
+
280
+ ## Prerequisites
281
+
282
+ - {Requirement 1}
283
+ - {Requirement 2}
284
+
285
+ ## When to Use
286
+
287
+ Use this skill when:
288
+ - {Trigger condition 1}
289
+ - {Trigger condition 2}
290
+
291
+ Do NOT use when:
292
+ - {Anti-trigger 1}
293
+
294
+ ## Process
295
+
296
+ 1. **{Step 1}**
297
+ {Instructions}
298
+
299
+ 2. **{Step 2}**
300
+ {Instructions}
301
+
302
+ ## Outputs
303
+
304
+ - `{file/artifact}` — {description}
305
+
306
+ ## Common Issues
307
+
308
+ | Issue | Cause | Fix |
309
+ |-------|-------|-----|
310
+ | {issue} | {cause} | {fix} |
311
+ ```
312
+
313
+ ---
314
+
315
+ ## Plugin Distribution System
316
+
317
+ ### Plugin Manifest (marketplace.json)
318
+
319
+ ```json
320
+ {
321
+ "name": "sinapse-claude-skills",
322
+ "plugins": [
323
+ {
324
+ "name": "development-workflow",
325
+ "description": "Skills for Claude Code configuration and SINAPSE workflows",
326
+ "source": "./",
327
+ "strict": false,
328
+ "skills": [
329
+ "./skills/claude-code-audit",
330
+ "./skills/sinapse-setup",
331
+ "./skills/agent-persona-creation"
332
+ ]
333
+ }
334
+ ]
335
+ }
336
+ ```
337
+
338
+ ### Installation
339
+
340
+ ```bash
341
+ /plugin marketplace add sinapse-ai/squad-claude-skills
342
+ /plugin install development-workflow@sinapse-claude-skills
343
+ ```
344
+
345
+ ### Namespacing
346
+
347
+ Skills from plugins receive prefix: `plugin-name:skill-name`
348
+
349
+ Example: `sinapse-claude:claude-code-audit`
350
+
351
+ ---
352
+
353
+ ## Platform Compatibility Matrix
354
+
355
+ | Platform | Support | Notes |
356
+ |----------|---------|-------|
357
+ | Claude Code | Full | Native marketplace |
358
+ | Codex | Full | `.codex/skills/` directory |
359
+ | Gemini CLI | Full | Standard SKILL.md |
360
+ | Cursor | Full | Marketplace |
361
+ | VS Code | Full | Extension integration |
362
+ | GitHub Copilot | Full | Instruction-based |
363
+ | OpenCode | Full | Fetch + install |
364
+ | OpenHands | Full | Cloud platform |
365
+ | Spring AI | Native | Framework integration |
366
+ | 25+ others | Full | Via agentskills.io spec |
367
+
368
+ ---
369
+
370
+ ## Anti-Patterns
371
+
372
+ | Anti-pattern | Problem | Fix |
373
+ |-------------|---------|-----|
374
+ | Vague description | Skill never triggers | Add specific keywords + trigger conditions |
375
+ | SKILL.md > 500 lines | Context pollution | Move details to `references/` subfolder |
376
+ | Scripts inlined in SKILL.md | Unmanageable | Put in `scripts/`, call with `--help` first |
377
+ | Inventing workflows | No grounding | Only document validated, existing patterns |
378
+ | Single monolithic skill | Hard to maintain | Split into focused single-responsibility skills |
379
+ | No examples | Agents misuse skill | Include concrete input/output examples |
380
+ | Hardcoded paths | Portability failures | Use relative paths and env vars |