specweave 0.1.9 → 0.3.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 (293) hide show
  1. package/CLAUDE.md +600 -0
  2. package/README.md +245 -81
  3. package/bin/install-all.sh +1 -1
  4. package/bin/install-commands.sh +3 -3
  5. package/bin/specweave.js +39 -9
  6. package/dist/adapters/adapter-base.d.ts +1 -1
  7. package/dist/adapters/adapter-base.d.ts.map +1 -1
  8. package/dist/adapters/adapter-base.js +6 -41
  9. package/dist/adapters/adapter-base.js.map +1 -1
  10. package/dist/adapters/adapter-interface.js +1 -2
  11. package/dist/adapters/adapter-interface.js.map +1 -1
  12. package/dist/adapters/adapter-loader.d.ts +86 -0
  13. package/dist/adapters/adapter-loader.d.ts.map +1 -0
  14. package/dist/adapters/adapter-loader.js +216 -0
  15. package/dist/adapters/adapter-loader.js.map +1 -0
  16. package/dist/adapters/agents-md-generator.d.ts +48 -0
  17. package/dist/adapters/agents-md-generator.d.ts.map +1 -0
  18. package/dist/adapters/agents-md-generator.js +132 -0
  19. package/dist/adapters/agents-md-generator.js.map +1 -0
  20. package/dist/adapters/claude/adapter.d.ts +2 -2
  21. package/dist/adapters/claude/adapter.d.ts.map +1 -1
  22. package/dist/adapters/claude/adapter.js +5 -42
  23. package/dist/adapters/claude/adapter.js.map +1 -1
  24. package/dist/adapters/claude-md-generator.d.ts +78 -0
  25. package/dist/adapters/claude-md-generator.d.ts.map +1 -0
  26. package/dist/adapters/claude-md-generator.js +246 -0
  27. package/dist/adapters/claude-md-generator.js.map +1 -0
  28. package/dist/adapters/codex/adapter.d.ts +50 -0
  29. package/dist/adapters/codex/adapter.d.ts.map +1 -0
  30. package/dist/adapters/codex/adapter.js +316 -0
  31. package/dist/adapters/codex/adapter.js.map +1 -0
  32. package/dist/adapters/copilot/adapter.d.ts +10 -9
  33. package/dist/adapters/copilot/adapter.d.ts.map +1 -1
  34. package/dist/adapters/copilot/adapter.js +35 -100
  35. package/dist/adapters/copilot/adapter.js.map +1 -1
  36. package/dist/adapters/cursor/adapter.d.ts +8 -6
  37. package/dist/adapters/cursor/adapter.d.ts.map +1 -1
  38. package/dist/adapters/cursor/adapter.js +47 -130
  39. package/dist/adapters/cursor/adapter.js.map +1 -1
  40. package/dist/adapters/doc-generator.d.ts +69 -0
  41. package/dist/adapters/doc-generator.d.ts.map +1 -0
  42. package/dist/adapters/doc-generator.js +247 -0
  43. package/dist/adapters/doc-generator.js.map +1 -0
  44. package/dist/adapters/gemini/adapter.d.ts +50 -0
  45. package/dist/adapters/gemini/adapter.d.ts.map +1 -0
  46. package/dist/adapters/gemini/adapter.js +281 -0
  47. package/dist/adapters/gemini/adapter.js.map +1 -0
  48. package/dist/adapters/generic/adapter.d.ts +7 -4
  49. package/dist/adapters/generic/adapter.d.ts.map +1 -1
  50. package/dist/adapters/generic/adapter.js +60 -59
  51. package/dist/adapters/generic/adapter.js.map +1 -1
  52. package/dist/cli/commands/init.d.ts +3 -1
  53. package/dist/cli/commands/init.d.ts.map +1 -1
  54. package/dist/cli/commands/init.js +272 -170
  55. package/dist/cli/commands/init.js.map +1 -1
  56. package/dist/cli/commands/install.d.ts.map +1 -1
  57. package/dist/cli/commands/install.js +22 -58
  58. package/dist/cli/commands/install.js.map +1 -1
  59. package/dist/cli/commands/list.d.ts.map +1 -1
  60. package/dist/cli/commands/list.js +27 -64
  61. package/dist/cli/commands/list.js.map +1 -1
  62. package/dist/core/credentials-manager.d.ts +90 -0
  63. package/dist/core/credentials-manager.d.ts.map +1 -0
  64. package/dist/core/credentials-manager.js +271 -0
  65. package/dist/core/credentials-manager.js.map +1 -0
  66. package/dist/core/project-structure-detector.d.ts +92 -0
  67. package/dist/core/project-structure-detector.d.ts.map +1 -0
  68. package/dist/core/project-structure-detector.js +289 -0
  69. package/dist/core/project-structure-detector.js.map +1 -0
  70. package/dist/core/rfc-generator-v2.d.ts +149 -0
  71. package/dist/core/rfc-generator-v2.d.ts.map +1 -0
  72. package/dist/core/rfc-generator-v2.js +399 -0
  73. package/dist/core/rfc-generator-v2.js.map +1 -0
  74. package/dist/core/rfc-generator.d.ts +147 -0
  75. package/dist/core/rfc-generator.d.ts.map +1 -0
  76. package/dist/core/rfc-generator.js +434 -0
  77. package/dist/core/rfc-generator.js.map +1 -0
  78. package/dist/integrations/ado/ado-client.d.ts +123 -0
  79. package/dist/integrations/ado/ado-client.d.ts.map +1 -0
  80. package/dist/integrations/ado/ado-client.js +398 -0
  81. package/dist/integrations/ado/ado-client.js.map +1 -0
  82. package/dist/integrations/jira/jira-client.d.ts +139 -0
  83. package/dist/integrations/jira/jira-client.d.ts.map +1 -0
  84. package/dist/integrations/jira/jira-client.js +386 -0
  85. package/dist/integrations/jira/jira-client.js.map +1 -0
  86. package/dist/integrations/jira/jira-incremental-mapper.d.ts +75 -0
  87. package/dist/integrations/jira/jira-incremental-mapper.d.ts.map +1 -0
  88. package/dist/integrations/jira/jira-incremental-mapper.js +474 -0
  89. package/dist/integrations/jira/jira-incremental-mapper.js.map +1 -0
  90. package/dist/integrations/jira/jira-mapper.d.ts +105 -0
  91. package/dist/integrations/jira/jira-mapper.d.ts.map +1 -0
  92. package/dist/integrations/jira/jira-mapper.js +494 -0
  93. package/dist/integrations/jira/jira-mapper.js.map +1 -0
  94. package/dist/testing/test-generator.d.ts +117 -0
  95. package/dist/testing/test-generator.d.ts.map +1 -0
  96. package/dist/testing/test-generator.js +370 -0
  97. package/dist/testing/test-generator.js.map +1 -0
  98. package/dist/utils/auto-install.d.ts +3 -0
  99. package/dist/utils/auto-install.d.ts.map +1 -1
  100. package/dist/utils/auto-install.js +16 -82
  101. package/dist/utils/auto-install.js.map +1 -1
  102. package/dist/utils/esm-helpers.d.ts +50 -0
  103. package/dist/utils/esm-helpers.d.ts.map +1 -0
  104. package/dist/utils/esm-helpers.js +57 -0
  105. package/dist/utils/esm-helpers.js.map +1 -0
  106. package/package.json +16 -7
  107. package/src/adapters/README.md +1 -2
  108. package/src/adapters/adapter-base.ts +6 -3
  109. package/src/adapters/adapter-loader.ts +261 -0
  110. package/src/adapters/agents-md-generator.ts +162 -0
  111. package/src/adapters/claude/README.md +6 -14
  112. package/src/adapters/claude/adapter.ts +4 -4
  113. package/src/adapters/claude-md-generator.ts +311 -0
  114. package/src/adapters/codex/README.md +105 -0
  115. package/src/adapters/codex/adapter.ts +333 -0
  116. package/src/adapters/copilot/adapter.ts +36 -65
  117. package/src/adapters/cursor/README.md +0 -2
  118. package/src/adapters/cursor/adapter.ts +46 -92
  119. package/src/adapters/doc-generator.ts +331 -0
  120. package/src/adapters/gemini/README.md +97 -0
  121. package/src/adapters/gemini/adapter.ts +298 -0
  122. package/src/adapters/generic/adapter.ts +61 -57
  123. package/src/adapters/registry.yaml +86 -25
  124. package/src/agents/devops/AGENT.md +16 -18
  125. package/src/agents/docs-writer/AGENT.md +2 -2
  126. package/src/agents/pm/AGENT.md +1 -50
  127. package/src/commands/README.md +134 -111
  128. package/src/commands/{build.md → specweave.do.md} +141 -69
  129. package/src/commands/{done.md → specweave.done.md} +3 -3
  130. package/src/commands/{inc.md → specweave.inc.md} +4 -4
  131. package/src/commands/{increment.md → specweave.increment.md} +143 -76
  132. package/src/commands/specweave.md +430 -0
  133. package/src/commands/specweave.next.md +495 -0
  134. package/src/commands/{progress.md → specweave.progress.md} +12 -12
  135. package/src/commands/specweave.sync-docs.md +665 -0
  136. package/src/commands/specweave.sync-github.md +269 -0
  137. package/src/commands/specweave.sync-jira.md +197 -0
  138. package/src/commands/{validate.md → specweave.validate.md} +4 -4
  139. package/src/hooks/README.md +19 -29
  140. package/src/hooks/post-task-completion.sh +25 -30
  141. package/src/skills/ado-sync/README.md +1 -36
  142. package/src/skills/bmad-method-expert/SKILL.md +1 -3
  143. package/src/skills/brownfield-analyzer/SKILL.md +429 -23
  144. package/src/skills/brownfield-onboarder/SKILL.md +221 -8
  145. package/src/skills/context-loader/SKILL.md +239 -617
  146. package/src/skills/context-optimizer/SKILL.md +0 -30
  147. package/src/skills/github-sync/SKILL.md +1 -19
  148. package/src/skills/increment-planner/SKILL.md +64 -18
  149. package/src/skills/increment-quality-judge/SKILL.md +1 -36
  150. package/src/skills/jira-sync/README.md +1 -38
  151. package/src/skills/role-orchestrator/README.md +1 -22
  152. package/src/skills/role-orchestrator/SKILL.md +1 -59
  153. package/src/skills/skill-router/SKILL.md +0 -18
  154. package/src/skills/spec-kit-expert/SKILL.md +1 -3
  155. package/src/skills/specweave-detector/SKILL.md +225 -275
  156. package/src/skills/task-builder/README.md +1 -7
  157. package/src/templates/AGENTS.md.template +334 -0
  158. package/src/templates/CLAUDE.md.template +131 -298
  159. package/src/templates/README.md.template +115 -23
  160. package/src/templates/environments/minimal/README.md +0 -1
  161. package/INSTALL.md +0 -848
  162. package/SPECWEAVE.md +0 -743
  163. package/src/adapters/copilot/.github/copilot/instructions.md +0 -376
  164. package/src/adapters/cursor/.cursorrules +0 -325
  165. package/src/adapters/generic/SPECWEAVE-MANUAL.md +0 -676
  166. package/src/commands/create-project.md +0 -528
  167. package/src/commands/generate-docs.md +0 -623
  168. package/src/commands/review-docs.md +0 -331
  169. package/src/commands/sync-github.md +0 -115
  170. package/src/skills/ado-sync/test-cases/test-1.yaml +0 -9
  171. package/src/skills/ado-sync/test-cases/test-2.yaml +0 -8
  172. package/src/skills/ado-sync/test-cases/test-3.yaml +0 -9
  173. package/src/skills/bmad-method-expert/test-cases/test-1-placeholder.yaml +0 -12
  174. package/src/skills/bmad-method-expert/test-cases/test-2-placeholder.yaml +0 -12
  175. package/src/skills/bmad-method-expert/test-cases/test-3-placeholder.yaml +0 -12
  176. package/src/skills/brownfield-analyzer/test-cases/test-1-basic-analysis.yaml +0 -48
  177. package/src/skills/brownfield-analyzer/test-cases/test-2-placeholder.yaml +0 -12
  178. package/src/skills/brownfield-analyzer/test-cases/test-3-placeholder.yaml +0 -12
  179. package/src/skills/brownfield-onboarder/test-cases/test-1-placeholder.yaml +0 -12
  180. package/src/skills/brownfield-onboarder/test-cases/test-2-placeholder.yaml +0 -12
  181. package/src/skills/brownfield-onboarder/test-cases/test-3-placeholder.yaml +0 -12
  182. package/src/skills/calendar-system/test-cases/test-1-placeholder.yaml +0 -12
  183. package/src/skills/calendar-system/test-cases/test-2-placeholder.yaml +0 -12
  184. package/src/skills/calendar-system/test-cases/test-3-placeholder.yaml +0 -12
  185. package/src/skills/context-loader/test-cases/test-1-basic-loading.yaml +0 -39
  186. package/src/skills/context-loader/test-cases/test-2-token-budget-exceeded.yaml +0 -44
  187. package/src/skills/context-loader/test-cases/test-3-section-anchors.yaml +0 -45
  188. package/src/skills/context-optimizer/test-cases/test-1-bug-fix-narrow.yaml +0 -97
  189. package/src/skills/context-optimizer/test-cases/test-2-feature-focused.yaml +0 -109
  190. package/src/skills/context-optimizer/test-cases/test-3-architecture-broad.yaml +0 -98
  191. package/src/skills/cost-optimizer/test-cases/test-1-basic-comparison.yaml +0 -75
  192. package/src/skills/cost-optimizer/test-cases/test-2-budget-constraint.yaml +0 -52
  193. package/src/skills/cost-optimizer/test-cases/test-3-scale-requirement.yaml +0 -63
  194. package/src/skills/cost-optimizer/test-results/README.md +0 -46
  195. package/src/skills/design-system-architect/test-cases/test-1-token-structure.yaml +0 -23
  196. package/src/skills/design-system-architect/test-cases/test-2-component-hierarchy.yaml +0 -24
  197. package/src/skills/design-system-architect/test-cases/test-3-accessibility-checklist.yaml +0 -23
  198. package/src/skills/diagrams-architect/test-cases/test-1-c4-context.yaml +0 -13
  199. package/src/skills/diagrams-architect/test-cases/test-2-sequence-diagram.yaml +0 -13
  200. package/src/skills/diagrams-architect/test-cases/test-3-er-diagram.yaml +0 -13
  201. package/src/skills/diagrams-generator/test-cases/test-1.yaml +0 -9
  202. package/src/skills/diagrams-generator/test-cases/test-2.yaml +0 -9
  203. package/src/skills/diagrams-generator/test-cases/test-3.yaml +0 -8
  204. package/src/skills/docs-updater/test-cases/test-1-placeholder.yaml +0 -12
  205. package/src/skills/docs-updater/test-cases/test-2-placeholder.yaml +0 -12
  206. package/src/skills/docs-updater/test-cases/test-3-placeholder.yaml +0 -12
  207. package/src/skills/dotnet-backend/test-cases/test-1-rest-api.yaml +0 -14
  208. package/src/skills/dotnet-backend/test-cases/test-2-authentication.yaml +0 -13
  209. package/src/skills/dotnet-backend/test-cases/test-3-minimal-api.yaml +0 -13
  210. package/src/skills/e2e-playwright/test-cases/TC-001-basic-navigation.yaml +0 -54
  211. package/src/skills/e2e-playwright/test-cases/TC-002-form-interaction.yaml +0 -64
  212. package/src/skills/e2e-playwright/test-cases/TC-003-specweave-integration.yaml +0 -74
  213. package/src/skills/e2e-playwright/test-cases/TC-004-accessibility-check.yaml +0 -98
  214. package/src/skills/figma-designer/test-cases/test-1-design-system.yaml +0 -13
  215. package/src/skills/figma-designer/test-cases/test-2-component-library.yaml +0 -13
  216. package/src/skills/figma-designer/test-cases/test-3-responsive-layout.yaml +0 -13
  217. package/src/skills/figma-implementer/test-cases/test-1-design-to-react.yaml +0 -13
  218. package/src/skills/figma-implementer/test-cases/test-2-storybook.yaml +0 -13
  219. package/src/skills/figma-implementer/test-cases/test-3-design-tokens.yaml +0 -13
  220. package/src/skills/figma-mcp-connector/test-cases/test-1-read-file-desktop.yaml +0 -22
  221. package/src/skills/figma-mcp-connector/test-cases/test-2-read-file-framelink.yaml +0 -21
  222. package/src/skills/figma-mcp-connector/test-cases/test-3-error-handling.yaml +0 -18
  223. package/src/skills/figma-to-code/test-cases/test-1-token-generation.yaml +0 -29
  224. package/src/skills/figma-to-code/test-cases/test-2-component-generation.yaml +0 -27
  225. package/src/skills/figma-to-code/test-cases/test-3-typescript-generation.yaml +0 -28
  226. package/src/skills/frontend/test-cases/test-1-react-component.yaml +0 -13
  227. package/src/skills/frontend/test-cases/test-2-form-validation.yaml +0 -13
  228. package/src/skills/frontend/test-cases/test-3-state-management.yaml +0 -13
  229. package/src/skills/github-sync/test-cases/test-1-placeholder.yaml +0 -12
  230. package/src/skills/github-sync/test-cases/test-2-placeholder.yaml +0 -12
  231. package/src/skills/github-sync/test-cases/test-3-placeholder.yaml +0 -12
  232. package/src/skills/hetzner-provisioner/test-cases/test-1-basic-provision.yaml +0 -71
  233. package/src/skills/hetzner-provisioner/test-cases/test-2-postgres-provision.yaml +0 -85
  234. package/src/skills/hetzner-provisioner/test-cases/test-3-ssl-config.yaml +0 -126
  235. package/src/skills/hetzner-provisioner/test-results/README.md +0 -259
  236. package/src/skills/increment-planner/test-cases/test-1-basic-feature.yaml +0 -27
  237. package/src/skills/increment-planner/test-cases/test-2-complex-feature.yaml +0 -30
  238. package/src/skills/increment-planner/test-cases/test-3-auto-numbering.yaml +0 -24
  239. package/src/skills/increment-quality-judge/test-cases/test-1-good-spec.yaml +0 -95
  240. package/src/skills/increment-quality-judge/test-cases/test-2-poor-spec.yaml +0 -108
  241. package/src/skills/increment-quality-judge/test-cases/test-3-export-suggestions.yaml +0 -87
  242. package/src/skills/jira-sync/test-cases/test-1.yaml +0 -9
  243. package/src/skills/jira-sync/test-cases/test-2.yaml +0 -9
  244. package/src/skills/jira-sync/test-cases/test-3.yaml +0 -10
  245. package/src/skills/nextjs/test-cases/test-1-app-router.yaml +0 -13
  246. package/src/skills/nextjs/test-cases/test-2-server-actions.yaml +0 -13
  247. package/src/skills/nextjs/test-cases/test-3-api-routes.yaml +0 -13
  248. package/src/skills/nodejs-backend/test-cases/test-1-express-api.yaml +0 -13
  249. package/src/skills/nodejs-backend/test-cases/test-2-prisma-orm.yaml +0 -13
  250. package/src/skills/nodejs-backend/test-cases/test-3-authentication.yaml +0 -13
  251. package/src/skills/notification-system/test-cases/test-1-placeholder.yaml +0 -12
  252. package/src/skills/notification-system/test-cases/test-2-placeholder.yaml +0 -12
  253. package/src/skills/notification-system/test-cases/test-3-placeholder.yaml +0 -12
  254. package/src/skills/python-backend/test-cases/test-1-fastapi-crud.yaml +0 -13
  255. package/src/skills/python-backend/test-cases/test-2-sqlalchemy.yaml +0 -13
  256. package/src/skills/python-backend/test-cases/test-3-authentication.yaml +0 -13
  257. package/src/skills/role-orchestrator/test-cases/test-1-simple-product.yaml +0 -98
  258. package/src/skills/role-orchestrator/test-cases/test-2-quality-gate-failure.yaml +0 -73
  259. package/src/skills/role-orchestrator/test-cases/test-3-security-workflow.yaml +0 -121
  260. package/src/skills/role-orchestrator/test-cases/test-4-parallel-execution.yaml +0 -145
  261. package/src/skills/role-orchestrator/test-cases/test-5-feedback-loops.yaml +0 -149
  262. package/src/skills/skill-creator/test-cases/test-1-placeholder.yaml +0 -12
  263. package/src/skills/skill-creator/test-cases/test-2-placeholder.yaml +0 -12
  264. package/src/skills/skill-creator/test-cases/test-3-placeholder.yaml +0 -12
  265. package/src/skills/skill-router/test-cases/test-1-basic-routing.yaml +0 -33
  266. package/src/skills/skill-router/test-cases/test-2-ambiguous-request.yaml +0 -42
  267. package/src/skills/skill-router/test-cases/test-3-nested-orchestration.yaml +0 -50
  268. package/src/skills/spec-driven-brainstorming/test-cases/TC-001-simple-idea-to-design.yaml +0 -148
  269. package/src/skills/spec-driven-brainstorming/test-cases/TC-002-complex-ultrathink-design.yaml +0 -190
  270. package/src/skills/spec-driven-brainstorming/test-cases/TC-003-unclear-requirements-socratic.yaml +0 -233
  271. package/src/skills/spec-driven-debugging/test-cases/TC-001-simple-auth-bug.yaml +0 -212
  272. package/src/skills/spec-driven-debugging/test-cases/TC-002-race-condition-ultrathink.yaml +0 -461
  273. package/src/skills/spec-driven-debugging/test-cases/TC-003-brownfield-missing-spec.yaml +0 -366
  274. package/src/skills/spec-kit-expert/test-cases/test-1-placeholder.yaml +0 -12
  275. package/src/skills/spec-kit-expert/test-cases/test-2-placeholder.yaml +0 -12
  276. package/src/skills/spec-kit-expert/test-cases/test-3-placeholder.yaml +0 -12
  277. package/src/skills/specweave-ado-mapper/test-cases/test-1-export-to-ado.yaml +0 -13
  278. package/src/skills/specweave-ado-mapper/test-cases/test-2-import-from-ado.yaml +0 -13
  279. package/src/skills/specweave-ado-mapper/test-cases/test-3-bidirectional-sync.yaml +0 -13
  280. package/src/skills/specweave-detector/test-cases/test-1-basic-detection.yaml +0 -37
  281. package/src/skills/specweave-detector/test-cases/test-2-missing-config.yaml +0 -37
  282. package/src/skills/specweave-detector/test-cases/test-3-non-specweave-project.yaml +0 -34
  283. package/src/skills/specweave-jira-mapper/test-cases/test-1-export-to-jira.yaml +0 -13
  284. package/src/skills/specweave-jira-mapper/test-cases/test-2-import-from-jira.yaml +0 -13
  285. package/src/skills/specweave-jira-mapper/test-cases/test-3-sync-status.yaml +0 -13
  286. package/src/skills/stripe-integrator/test-cases/test-1-placeholder.yaml +0 -12
  287. package/src/skills/stripe-integrator/test-cases/test-2-placeholder.yaml +0 -12
  288. package/src/skills/stripe-integrator/test-cases/test-3-placeholder.yaml +0 -12
  289. package/src/skills/task-builder/test-cases/test-1-placeholder.yaml +0 -12
  290. package/src/skills/task-builder/test-cases/test-2-placeholder.yaml +0 -12
  291. package/src/skills/task-builder/test-cases/test-3-placeholder.yaml +0 -12
  292. package/src/templates/config.yaml +0 -351
  293. /package/src/commands/{list-increments.md → specweave.list-increments.md} +0 -0
@@ -1,734 +1,356 @@
1
1
  ---
2
2
  name: context-loader
3
- description: Precision context loading system that selectively loads specifications, architecture docs, and ADRs based on context manifests. Achieves 70%+ token reduction by loading only relevant context. Activates automatically when working on features/issues or when user requests "load context for...". Keywords: load context, context manifest, selective loading, specifications, context precision.
3
+ description: Explains how SpecWeave achieves context efficiency through Claude's native progressive disclosure mechanism and sub-agent parallelization. Skills load only when relevant, sub-agents isolate context. Activates when users ask about context loading, token usage, or how SpecWeave scales. Keywords: context loading, progressive disclosure, token efficiency, sub-agents, context management.
4
4
  ---
5
5
 
6
- # Context Loader - Precision Context Loading
6
+ # Context Management in SpecWeave
7
7
 
8
- ## Purpose
8
+ ## Overview
9
9
 
10
- The context-loader is SpecWeave's **precision context loading system** that:
11
- 1. Loads only relevant specifications and documentation (not everything)
12
- 2. Achieves **70%+ token reduction** vs loading full specs
13
- 3. Respects context manifests (`context-manifest.yaml`)
14
- 4. Supports section-level granularity (`#specific-section`)
15
- 5. Enables enterprise-scale specs (500+ pages) without context bloat
16
- 6. Caches loaded context for performance
10
+ SpecWeave achieves efficient context usage through **two native Claude Code mechanisms**:
17
11
 
18
- ## When to Activate
12
+ 1. **Progressive Disclosure** (Skills) - Claude's built-in skill loading system
13
+ 2. **Sub-Agent Parallelization** - Isolated context windows for parallel work
19
14
 
20
- This skill activates when:
21
- - User starts working on a feature (`.specweave/increments/####-name/`)
22
- - User works on an issue (`work/issues/####-name/`)
23
- - User explicitly requests "load context for feature 0003"
24
- - Any skill needs specification context
25
- - specweave-detector detects active work
15
+ **Important**: SpecWeave does NOT use custom context manifests or caching systems. It leverages Claude's native capabilities.
26
16
 
27
- ## Context Manifest Format
17
+ ---
28
18
 
29
- ### Basic Context Manifest
19
+ ## 1. Progressive Disclosure (Skills)
30
20
 
31
- ```yaml
32
- ---
33
- # Context Manifest for Feature 003: Stripe Payment Integration
34
-
35
- # Specification sections to load
36
- spec_sections:
37
- - specifications/modules/payments/overview.md
38
- - specifications/modules/payments/stripe/spec.md
39
- - specifications/modules/payments/stripe/api-contracts.md
40
- - specifications/modules/payments/shared/payment-entities.md
41
-
42
- # Architecture documents to load
43
- architecture:
44
- - .specweave/docs/architecture/system-design.md#payment-flow
45
- - .specweave/docs/architecture/data/database-schema.md#payment-tables
46
- - .specweave/docs/architecture/security/pci-compliance.md
47
-
48
- # Architecture Decision Records to reference
49
- adrs:
50
- - .specweave/docs/decisions/005-payment-provider-choice.md
51
- - .specweave/docs/decisions/012-stripe-webhook-handling.md
52
-
53
- # Context budget (max tokens to load)
54
- max_context_tokens: 10000
55
-
56
- # Priority level
57
- priority: high
58
-
59
- # Auto-refresh context on spec changes
60
- auto_refresh: false
61
-
62
- # Related features
63
- related_features:
64
- - 002-user-subscriptions
65
- - 004-billing-portal
66
-
67
- # Tags for search and categorization
68
- tags:
69
- - payments
70
- - stripe
71
- - pci-compliance
72
- - subscriptions
73
- ---
74
- ```
21
+ ### How It Works
75
22
 
76
- ### Advanced Context Manifest (with filters)
23
+ Claude Code uses a **two-level progressive disclosure system** for skills:
24
+
25
+ #### Level 1: Metadata Only (Always Loaded)
77
26
 
78
27
  ```yaml
79
28
  ---
80
- # Context Manifest with advanced filtering
81
-
82
- spec_sections:
83
- - path: specifications/modules/payments/**/*.md
84
- exclude:
85
- - "**/legacy/**"
86
- - "**/deprecated/**"
87
- sections:
88
- - "#stripe-integration"
89
- - "#webhook-handling"
90
-
91
- architecture:
92
- - path: .specweave/docs/architecture/payments/**/*.md
93
- max_depth: 2 # Don't load deeply nested sections
94
-
95
- adrs:
96
- - path: .specweave/docs/decisions/*.md
97
- filter:
98
- tags: ["payment", "stripe"]
99
-
100
- # Section-level loading
101
- load_sections_only: true
102
-
103
- # Cache settings
104
- cache:
105
- enabled: true
106
- ttl: 3600 # 1 hour
107
-
108
- # Token optimization
109
- optimization:
110
- remove_code_blocks: false # Keep code examples
111
- remove_tables: false
112
- remove_mermaid: false
113
- summarize_long_sections: true # Auto-summarize sections >1000 tokens
29
+ name: nextjs
30
+ description: NextJS 14+ implementation specialist. Creates App Router projects...
114
31
  ---
115
32
  ```
116
33
 
117
- ## Loading Algorithm
118
-
119
- ### Phase 1: Parse Manifest
120
-
121
- ```typescript
122
- interface ContextManifest {
123
- spec_sections: string[];
124
- architecture: string[];
125
- adrs: string[];
126
- max_context_tokens: number;
127
- priority: 'low' | 'medium' | 'high';
128
- auto_refresh: boolean;
129
- related_features?: string[];
130
- tags?: string[];
131
- }
132
-
133
- function parseManifest(manifestPath: string): ContextManifest {
134
- const yaml = readFile(manifestPath);
135
- return parseYAML(yaml);
136
- }
137
- ```
34
+ **What Claude sees initially:**
35
+ - Only the YAML frontmatter (name + description)
36
+ - ~50-100 tokens per skill
37
+ - **All** skills' metadata is visible
38
+ - Claude can decide which skills are relevant
138
39
 
139
- ### Phase 2: Resolve Paths
140
-
141
- ```typescript
142
- function resolvePaths(patterns: string[]): string[] {
143
- const resolved: string[] = [];
144
-
145
- for (const pattern of patterns) {
146
- // Handle glob patterns
147
- if (pattern.includes('*')) {
148
- const files = glob(pattern);
149
- resolved.push(...files);
150
- }
151
-
152
- // Handle section references (#anchor)
153
- else if (pattern.includes('#')) {
154
- const [file, section] = pattern.split('#');
155
- resolved.push({ file, section });
156
- }
157
-
158
- // Handle direct paths
159
- else {
160
- resolved.push({ file: pattern, section: null });
161
- }
162
- }
163
-
164
- return resolved;
165
- }
166
- ```
40
+ #### Level 2: Full Skill Content (Loaded On-Demand)
167
41
 
168
- ### Phase 3: Load Content with Section Filtering
169
-
170
- ```typescript
171
- function loadContent(filePath: string, section?: string): string {
172
- const content = readFile(filePath);
173
-
174
- // If section specified, extract only that section
175
- if (section) {
176
- return extractSection(content, section);
177
- }
178
-
179
- return content;
180
- }
181
-
182
- function extractSection(markdown: string, sectionHeading: string): string {
183
- const lines = markdown.split('\n');
184
- let inSection = false;
185
- let sectionLevel = 0;
186
- const result: string[] = [];
187
-
188
- for (const line of lines) {
189
- // Check if heading
190
- const headingMatch = line.match(/^(#+)\s+(.+)/);
191
-
192
- if (headingMatch) {
193
- const [, hashes, heading] = headingMatch;
194
- const level = hashes.length;
195
-
196
- // Found target section
197
- if (heading.trim() === sectionHeading.replace('#', '').trim()) {
198
- inSection = true;
199
- sectionLevel = level;
200
- result.push(line);
201
- continue;
202
- }
203
-
204
- // End of section (same or higher level heading)
205
- if (inSection && level <= sectionLevel) {
206
- break;
207
- }
208
- }
209
-
210
- if (inSection) {
211
- result.push(line);
212
- }
213
- }
214
-
215
- return result.join('\n');
216
- }
217
- ```
42
+ ```markdown
43
+ # NextJS Skill
218
44
 
219
- ### Phase 4: Token Budget Management
220
-
221
- ```typescript
222
- function enforceTokenBudget(contents: LoadedContent[], maxTokens: number): LoadedContent[] {
223
- let totalTokens = 0;
224
- const result: LoadedContent[] = [];
225
-
226
- // Sort by priority: ADRs > Architecture > Specs
227
- const sorted = sortByPriority(contents);
228
-
229
- for (const content of sorted) {
230
- const tokens = estimateTokens(content.text);
231
-
232
- if (totalTokens + tokens <= maxTokens) {
233
- result.push(content);
234
- totalTokens += tokens;
235
- } else {
236
- // Try to fit summary instead
237
- const summary = summarize(content.text, maxTokens - totalTokens);
238
- if (summary) {
239
- result.push({ ...content, text: summary, summarized: true });
240
- break;
241
- }
242
- }
243
- }
244
-
245
- return result;
246
- }
247
-
248
- function estimateTokens(text: string): number {
249
- // Rough estimate: ~4 characters per token
250
- return Math.ceil(text.length / 4);
251
- }
45
+ [Full documentation, examples, best practices...]
46
+ [Could be 5,000+ tokens]
252
47
  ```
253
48
 
254
- ### Phase 5: Cache Management
255
-
256
- ```typescript
257
- interface CachedContext {
258
- manifestHash: string;
259
- contents: LoadedContent[];
260
- loadedAt: number;
261
- expiresAt: number;
262
- }
263
-
264
- function getCachedContext(manifestPath: string): CachedContext | null {
265
- const cacheKey = manifestHash(manifestPath);
266
- const cached = readCache(`.specweave/cache/context/${cacheKey}.json`);
267
-
268
- if (cached && cached.expiresAt > Date.now()) {
269
- return cached;
270
- }
271
-
272
- return null;
273
- }
274
-
275
- function saveToCache(manifestPath: string, contents: LoadedContent[], ttl: number) {
276
- const cacheKey = manifestHash(manifestPath);
277
- const cache: CachedContext = {
278
- manifestHash: cacheKey,
279
- contents,
280
- loadedAt: Date.now(),
281
- expiresAt: Date.now() + (ttl * 1000)
282
- };
283
-
284
- writeCache(`.specweave/cache/context/${cacheKey}.json`, cache);
285
- }
286
- ```
287
-
288
- ## Loading Workflows
49
+ **What Claude loads:**
50
+ - Full SKILL.md content **only if** skill is relevant to current task
51
+ - Prevents loading 35+ skills (175,000+ tokens) when you only need 2-3
52
+ - **This is the actual mechanism** that saves tokens
289
53
 
290
- ### Workflow 1: Feature Development
54
+ ### Example Workflow
291
55
 
292
56
  ```
293
- User: "Implement feature 003"
294
-
295
- specweave-detector detects feature 003
296
-
297
- context-loader activates
57
+ User: "Create a Next.js authentication page"
298
58
 
299
- Load context-manifest.yaml:
300
- features/003-stripe-payment/context-manifest.yaml
59
+ Claude reviews skill metadata (35 skills × 75 tokens = 2,625 tokens)
301
60
 
302
- Parse manifest:
303
- spec_sections: 4 files
304
- architecture: 3 files (2 with section filters)
305
- adrs: 2 files
306
- max_tokens: 10,000
61
+ Claude determines relevant skills:
62
+ - nextjs (matches "Next.js")
63
+ - frontend (matches "page")
64
+ - (NOT loading: python-backend, devops, hetzner-provisioner, etc.)
307
65
 
308
- Resolve paths:
309
- specifications/modules/payments/overview.md (full)
310
- specifications/modules/payments/stripe/spec.md (full)
311
- ✓ .specweave/docs/architecture/system-design.md#payment-flow (section only)
312
- ...
66
+ Claude loads ONLY relevant skills:
67
+ - nextjs: 5,234 tokens
68
+ - frontend: 3,891 tokens
313
69
 
314
- Load content:
315
- Total: 8,547 tokens (under budget ✓)
316
-
317
- Context loaded:
318
- "Context loaded for Feature 003: Stripe Payment Integration
70
+ Total loaded: 9,125 tokens (vs 175,000+ if loading all skills)
71
+ Token reduction: ~95%
72
+ ```
319
73
 
320
- Loaded 9 documents (8,547 tokens):
321
- ✓ 4 specification files
322
- ✓ 3 architecture documents (2 section-filtered)
323
- ✓ 2 ADRs
74
+ ### References
324
75
 
325
- Token reduction: 73% (vs loading all payment specs: 31,892 tokens)
76
+ - [What are Skills?](https://support.claude.com/en/articles/12512176-what-are-skills)
77
+ - [Agent Skills Engineering](https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills)
326
78
 
327
- Ready to implement!"
328
- ```
79
+ > "Skills work through progressive disclosure—Claude determines which Skills are relevant and loads the information it needs to complete that task, helping to prevent context window overload."
329
80
 
330
- ### Workflow 2: Brownfield Issue
81
+ ---
82
+
83
+ ## 2. Sub-Agent Parallelization
84
+
85
+ ### How It Works
86
+
87
+ Sub-agents in Claude Code have **isolated context windows**:
331
88
 
332
89
  ```
333
- User: Working in work/issues/012-fix-payment-webhook/
334
-
335
- context-loader detects active issue
90
+ Main conversation (100K tokens used)
336
91
 
337
- Load: work/issues/012-fix-payment-webhook/context-manifest.yaml
92
+ Launches 3 sub-agents in parallel
338
93
 
339
- Manifest specifies:
340
- spec_sections:
341
- - specifications/modules/payments/stripe/webhooks.md
342
- architecture:
343
- - .specweave/docs/architecture/webhooks.md
344
- code:
345
- - src/services/stripe-webhook-handler.ts (existing code)
346
-
347
- Load brownfield context:
348
- ✓ Current implementation (src/services/)
349
- ✓ Webhook specification
350
- ✓ Architecture design
351
-
352
- Total: 2,134 tokens
353
-
354
- "Context loaded for Issue 012: Fix Payment Webhook
94
+ ├─ Sub-agent 1: Fresh context (0K tokens used)
95
+ ├─ Sub-agent 2: Fresh context (0K tokens used)
96
+ └─ Sub-agent 3: Fresh context (0K tokens used)
97
+ ```
355
98
 
356
- Loaded:
357
- ✓ Current webhook handler implementation
358
- ✓ Webhook specification
359
- ✓ Architecture documentation
99
+ **Benefits:**
360
100
 
361
- Token reduction: 94% (vs loading all payment context)
101
+ 1. **Context Isolation**
102
+ - Each sub-agent starts with empty context
103
+ - Doesn't inherit main conversation's 100K tokens
104
+ - Can load its own relevant skills
362
105
 
363
- Ready to debug!"
364
- ```
106
+ 2. **Parallelization**
107
+ - Multiple agents work simultaneously
108
+ - Each with own context budget
109
+ - Results merged back to main conversation
110
+
111
+ 3. **Token Multiplication**
112
+ - Main: 200K token limit
113
+ - Sub-agent 1: 200K token limit
114
+ - Sub-agent 2: 200K token limit
115
+ - **Effective capacity**: 600K+ tokens across parallel work
365
116
 
366
- ### Workflow 3: Related Features
117
+ ### Example Workflow
367
118
 
368
119
  ```
369
- User: "Show me related features for feature 003"
120
+ User: "Build a full-stack Next.js app with auth, payments, and admin"
370
121
 
371
- context-loader reads manifest:
372
- related_features:
373
- - 002-user-subscriptions
374
- - 004-billing-portal
122
+ Main conversation launches 3 sub-agents in parallel:
375
123
 
376
- Load context for all related features:
377
- features/002-user-subscriptions/context-manifest.yaml
378
- features/004-billing-portal/context-manifest.yaml
124
+ ├─ Sub-agent 1 (Frontend)
125
+ - Loads: nextjs, frontend skills
126
+ - Context: 12K tokens
127
+ │ - Implements: Auth UI, payment forms
128
+
129
+ ├─ Sub-agent 2 (Backend)
130
+ │ - Loads: nodejs-backend, security skills
131
+ │ - Context: 15K tokens
132
+ │ - Implements: API routes, auth logic
133
+
134
+ └─ Sub-agent 3 (DevOps)
135
+ - Loads: devops, hetzner-provisioner skills
136
+ - Context: 8K tokens
137
+ - Implements: Deployment configs
379
138
 
380
- Find overlapping context:
381
- Common specs:
382
- - specifications/modules/payments/shared/payment-entities.md
383
- Common architecture:
384
- - .specweave/docs/architecture/database-schema.md#payment-tables
139
+ All 3 work in parallel with isolated contexts
385
140
 
386
- Report:
387
- "Features 002, 003, 004 share common context:
141
+ Results merged back to main conversation
142
+
143
+ Total effective context: 35K tokens across 3 agents
144
+ (vs 175K+ if loaded all skills in main conversation)
145
+ ```
388
146
 
389
- Shared specifications:
390
- - Payment entities model
147
+ ### References
391
148
 
392
- Shared architecture:
393
- - Payment database schema
149
+ - [Sub-Agents Documentation](https://docs.claude.com/en/docs/claude-code/sub-agents)
394
150
 
395
- This suggests these features should be implemented together
396
- or in sequence to avoid conflicts."
397
- ```
151
+ ---
398
152
 
399
- ## Token Reduction Examples
153
+ ## Actual Token Savings
400
154
 
401
- ### Example 1: Payment Module (Enterprise Scale)
155
+ ### Progressive Disclosure Savings
402
156
 
403
- **Scenario**: Large payment module with 500 pages of specs
157
+ **Scenario**: User asks about Next.js
404
158
 
405
- **Without context-loader** (loading everything):
159
+ **Without progressive disclosure:**
406
160
  ```
407
- specifications/modules/payments/**/*.md
408
- Total files: 47
409
- Total tokens: 185,234
410
- Problem: Exceeds context window!
161
+ Load all 35 skills: ~175,000 tokens
162
+ Context bloat: Massive
411
163
  ```
412
164
 
413
- **With context-loader** (selective loading):
414
- ```yaml
415
- # Feature 003 manifest
416
- spec_sections:
417
- - specifications/modules/payments/stripe/spec.md
418
- - specifications/modules/payments/shared/payment-entities.md
419
- architecture:
420
- - .specweave/docs/architecture/system-design.md#stripe-integration
165
+ **With progressive disclosure:**
421
166
  ```
422
-
423
- ```
424
- Result:
425
- Total files: 3 (2 specs + 1 architecture section)
426
- Total tokens: 8,547
427
- Reduction: 95.4% 🎯
167
+ Metadata (all skills): ~2,625 tokens
168
+ Load relevant (2 skills): ~9,000 tokens
169
+ Total: ~11,625 tokens
170
+ Reduction: ~93%
428
171
  ```
429
172
 
430
- ### Example 2: Authentication Module
173
+ ### Sub-Agent Savings
431
174
 
432
- **Without context-loader**:
433
- ```
434
- specifications/modules/authentication/**/*.md
435
- OAuth spec: 15,234 tokens
436
- Session management: 8,765 tokens
437
- LDAP integration: 12,456 tokens
438
- SAML integration: 18,932 tokens
439
- Password policies: 5,643 tokens
440
- Total: 60,030 tokens
441
- ```
175
+ **Scenario**: Complex multi-domain task
442
176
 
443
- **With context-loader** (working on OAuth only):
444
- ```yaml
445
- spec_sections:
446
- - specifications/modules/authentication/oauth/spec.md
447
- - specifications/modules/authentication/shared/user-entities.md
177
+ **Single agent approach:**
178
+ ```
179
+ Load all relevant skills: ~50,000 tokens
180
+ Main conversation history: ~80,000 tokens
181
+ Total context used: ~130,000 tokens
182
+ Risk: Approaching context limit
448
183
  ```
449
184
 
185
+ **Sub-agent approach:**
450
186
  ```
451
- Result:
452
- OAuth spec: 15,234 tokens
453
- User entities: 2,341 tokens
454
- Total: 17,575 tokens
455
- Reduction: 70.7% 🎯
187
+ Main conversation: ~5,000 tokens (coordination only)
188
+ Sub-agent 1: ~15,000 tokens (isolated)
189
+ Sub-agent 2: ~18,000 tokens (isolated)
190
+ Sub-agent 3: ~12,000 tokens (isolated)
191
+ Total: ~50,000 tokens across 4 contexts
192
+ Reduction: ~62% (130K → 50K)
456
193
  ```
457
194
 
458
- ## Auto-Refresh Feature
195
+ **Note**: Exact percentages vary by task complexity. These are approximate based on typical usage patterns.
459
196
 
460
- ### Watch for Spec Changes
197
+ ---
461
198
 
462
- ```typescript
463
- // When auto_refresh: true in manifest
464
- function watchSpecChanges(manifest: ContextManifest) {
465
- const watchedFiles = resolveAllPaths(manifest);
199
+ ## How SpecWeave Leverages These Mechanisms
466
200
 
467
- for (const file of watchedFiles) {
468
- fs.watch(file, () => {
469
- console.log(`Spec changed: ${file}`);
470
- console.log('Auto-refreshing context...');
201
+ ### 1. Skill Organization (Progressive Disclosure)
471
202
 
472
- // Clear cache
473
- clearCache(manifest);
203
+ SpecWeave organizes **35+ skills** with clear, focused descriptions:
474
204
 
475
- // Reload context
476
- loadContext(manifest);
205
+ ```yaml
206
+ # Good: Focused description
207
+ ---
208
+ name: nextjs
209
+ description: NextJS 14+ App Router specialist. Server Components, SSR, routing.
210
+ ---
477
211
 
478
- console.log('✓ Context refreshed');
479
- });
480
- }
481
- }
212
+ # Bad: Vague description
213
+ ---
214
+ name: frontend
215
+ description: Does frontend stuff
216
+ ---
482
217
  ```
483
218
 
484
- ### Invalidate Cache on Changes
219
+ **Why this matters:**
220
+ - Clear descriptions help Claude identify relevance quickly
221
+ - Prevents loading irrelevant skills
222
+ - Maximizes progressive disclosure benefits
485
223
 
486
- ```typescript
487
- function shouldInvalidateCache(manifestPath: string): boolean {
488
- const cached = getCachedContext(manifestPath);
489
- if (!cached) return true;
224
+ ### 2. Agent Coordination (Sub-Agent Parallelization)
490
225
 
491
- const manifest = parseManifest(manifestPath);
492
- const files = resolveAllPaths(manifest);
226
+ SpecWeave's **role-orchestrator** skill automatically:
227
+ - Detects multi-domain tasks
228
+ - Launches specialized sub-agents (PM, Architect, DevOps, etc.)
229
+ - Each sub-agent loads only its relevant skills
230
+ - Coordinates results back to main conversation
493
231
 
494
- for (const file of files) {
495
- const fileModified = fs.statSync(file).mtimeMs;
496
- if (fileModified > cached.loadedAt) {
497
- return true; // File changed since cache created
498
- }
499
- }
232
+ **Example:**
500
233
 
501
- return false; // Cache still valid
502
- }
234
+ ```
235
+ User: "/specweave.inc 'Full-stack SaaS with Stripe payments'"
236
+
237
+ role-orchestrator activates
238
+
239
+ Launches sub-agents in parallel:
240
+ ├─ PM agent (requirements)
241
+ ├─ Architect agent (system design)
242
+ ├─ Security agent (threat model)
243
+ └─ DevOps agent (deployment)
244
+
245
+ Each loads only relevant skills in isolated context
246
+
247
+ Results merged into increment spec
503
248
  ```
504
249
 
505
- ## Performance Optimization
250
+ ---
506
251
 
507
- ### Parallel Loading
252
+ ## Common Misconceptions
508
253
 
509
- ```typescript
510
- async function loadContextParallel(manifest: ContextManifest): Promise<LoadedContent[]> {
511
- const allPaths = [
512
- ...manifest.spec_sections,
513
- ...manifest.architecture,
514
- ...manifest.adrs
515
- ];
254
+ ### ❌ Myth 1: "SpecWeave has custom context manifests"
516
255
 
517
- // Load all files in parallel
518
- const promises = allPaths.map(path => loadFile(path));
519
- const contents = await Promise.all(promises);
256
+ **Reality:** No. SpecWeave uses Claude's native progressive disclosure. Skills load based on Claude's relevance detection, not custom YAML manifests.
520
257
 
521
- return contents;
522
- }
523
- ```
258
+ ### ❌ Myth 2: "SpecWeave caches loaded context"
524
259
 
525
- ### Lazy Loading
260
+ **Reality:** No custom caching. Claude Code handles caching internally (if applicable). SpecWeave doesn't implement additional caching layers.
526
261
 
527
- ```typescript
528
- // Load only high-priority items immediately
529
- // Load medium/low priority on-demand
262
+ ### ❌ Myth 3: "70-90% token reduction"
530
263
 
531
- async function loadContextLazy(manifest: ContextManifest): Promise<ContextLoader> {
532
- // Immediate load (high priority)
533
- const highPriority = await loadHighPriorityContent(manifest);
264
+ **Reality:** Token savings vary by task:
265
+ - Simple tasks: 90%+ (load 1-2 skills vs all 35)
266
+ - Complex tasks: 50-70% (load 5-10 skills + use sub-agents)
267
+ - Exact percentages depend on task complexity
534
268
 
535
- // Return loader with deferred loading
536
- return {
537
- immediate: highPriority,
269
+ ### Truth: "It just works"
538
270
 
539
- loadMore: async () => {
540
- return await loadMediumPriorityContent(manifest);
541
- },
271
+ **Reality:** Progressive disclosure and sub-agents are **automatic**. You don't configure them. Claude handles skill loading, sub-agent context isolation happens automatically when agents are launched.
542
272
 
543
- loadAll: async () => {
544
- return await loadAllContent(manifest);
545
- }
546
- };
547
- }
548
- ```
273
+ ---
549
274
 
550
- ## Integration Points
275
+ ## Best Practices
551
276
 
552
- ### 1. Called By
277
+ ### For Skill Descriptions
553
278
 
554
- - **specweave-detector**: Auto-load when feature/issue detected
555
- - **increment-planner**: Load context when creating new features
556
- - **All implementation skills**: Load context before implementing
557
- - **Users**: Explicit "load context for feature 003"
279
+ **Do:**
280
+ - Be specific about what the skill does
281
+ - Include trigger keywords users might say
282
+ - List technologies/frameworks explicitly
558
283
 
559
- ### 2. Calls
284
+ **Don't:**
285
+ - Write vague descriptions ("helps with coding")
286
+ - Omit key activation triggers
287
+ - Mix multiple unrelated domains in one skill
560
288
 
561
- - File system: Read specification/architecture files
562
- - Cache: Read/write cached context
289
+ ### For Sub-Agent Usage
563
290
 
564
- ### 3. Updates
291
+ **When to use sub-agents:**
292
+ - Multi-domain tasks (frontend + backend + devops)
293
+ - Parallel work (multiple features simultaneously)
294
+ - Large codebase exploration (different modules)
565
295
 
566
- - `.specweave/cache/context/`: Cached loaded context
567
- - `.specweave/logs/context-loading.log`: Loading metrics
296
+ **When NOT to use sub-agents:**
297
+ - Simple single-domain tasks
298
+ - Sequential work requiring shared context
299
+ - When main conversation context is already low
568
300
 
569
- ## Configuration
301
+ ---
570
302
 
571
- ```yaml
572
- # .specweave/config.yaml
573
- context_loader:
574
- enabled: true
575
-
576
- # Cache settings
577
- cache:
578
- enabled: true
579
- ttl: 3600 # 1 hour in seconds
580
- directory: ".specweave/cache/context"
581
-
582
- # Performance
583
- parallel_loading: true
584
- max_parallel: 10
585
-
586
- # Auto-refresh
587
- watch_specs: true # Watch for file changes
588
-
589
- # Token optimization
590
- default_max_tokens: 10000
591
- warn_threshold: 8000 # Warn when approaching budget
592
-
593
- # Summarization (for over-budget content)
594
- auto_summarize: true
595
- summarization_ratio: 0.3 # Target 30% of original length
596
- ```
303
+ ## Debugging Context Usage
597
304
 
598
- ## Metrics and Monitoring
599
-
600
- ### Context Loading Metrics
601
-
602
- ```typescript
603
- interface ContextMetrics {
604
- feature: string;
605
- filesLoaded: number;
606
- tokensLoaded: number;
607
- tokenBudget: number;
608
- reductionPercentage: number;
609
- loadTimeMs: number;
610
- cacheHit: boolean;
611
- timestamp: number;
612
- }
613
-
614
- // Example log entry
615
- {
616
- feature: "003-stripe-payment",
617
- filesLoaded: 9,
618
- tokensLoaded: 8547,
619
- tokenBudget: 10000,
620
- reductionPercentage: 73.2,
621
- loadTimeMs: 145,
622
- cacheHit: false,
623
- timestamp: 1704067200000
624
- }
625
- ```
305
+ ### Check Active Skills
626
306
 
627
- ### Performance Dashboard
307
+ When Claude mentions using a skill:
628
308
 
629
309
  ```
630
- Context Loading Performance (Last 30 days)
310
+ User: "Create a Next.js page"
311
+ Claude: "🎨 Using nextjs skill..."
312
+ ```
313
+
314
+ **This means:**
315
+ - Progressive disclosure worked
316
+ - Only nextjs skill loaded (not all 35)
317
+ - Context efficient
631
318
 
632
- Average token reduction: 74.3% 🎯 (target: 70%+)
633
- Average load time: 156ms
634
- Cache hit rate: 67%
319
+ ### Check Sub-Agent Usage
635
320
 
636
- Top token savers:
637
- 1. Feature 003 (Stripe Payment): 95.4% reduction
638
- 2. Feature 007 (OAuth SSO): 82.1% reduction
639
- 3. Feature 012 (Webhooks): 78.9% reduction
321
+ When Claude mentions launching agents:
640
322
 
641
- Token budget warnings: 2 (features approaching limit)
323
+ ```
324
+ Claude: "🤖 Launching 3 specialized agents in parallel..."
642
325
  ```
643
326
 
644
- ## Testing
645
-
646
- ### Test Cases
647
-
648
- **TC-001: Basic Context Loading**
649
- - Given: Feature with context manifest
650
- - When: context-loader loads context
651
- - Then: All specified files loaded
652
- - And: Token count within budget
653
- - And: >70% reduction achieved
654
-
655
- **TC-002: Section-Level Loading**
656
- - Given: Manifest with section filters (#payment-flow)
657
- - When: context-loader loads architecture doc
658
- - Then: Only specified section extracted
659
- - And: Other sections not loaded
660
- - And: Token reduction maximized
661
-
662
- **TC-003: Cache Hit**
663
- - Given: Context loaded once (cached)
664
- - When: Same context requested again
665
- - Then: Loaded from cache (not file system)
666
- - And: Load time < 50ms
667
-
668
- **TC-004: Cache Invalidation**
669
- - Given: Cached context exists
670
- - When: Spec file modified
671
- - Then: Cache invalidated
672
- - And: Fresh context loaded
673
- - And: New cache created
674
-
675
- **TC-005: Token Budget Enforcement**
676
- - Given: Manifest with max_tokens: 5000
677
- - When: Specs total 7000 tokens
678
- - Then: Lower priority items summarized or dropped
679
- - And: Final total ≤ 5000 tokens
680
- - And: User warned about budget constraint
681
-
682
- **TC-006: Related Features**
683
- - Given: Feature with related_features specified
684
- - When: User requests related context
685
- - Then: All related manifests loaded
686
- - And: Common context identified
687
- - And: Report generated
688
-
689
- ## Resources
690
-
691
- ### YAML Processing
692
- - [js-yaml](https://github.com/nodeca/js-yaml) - YAML parser for JavaScript
693
- - [yaml](https://www.npmjs.com/package/yaml) - Modern YAML parser
694
- - [YAML Specification](https://yaml.org/spec/) - Official YAML spec
695
-
696
- ### File Globbing
697
- - [glob](https://github.com/isaacs/node-glob) - Match files using glob patterns
698
- - [fast-glob](https://github.com/mrmlnc/fast-glob) - Fast file pattern matching
699
- - [minimatch](https://github.com/isaacs/minimatch) - Glob pattern matcher
700
-
701
- ### Markdown Processing
702
- - [marked](https://marked.js.org/) - Markdown parser and compiler
703
- - [remark](https://remark.js.org/) - Markdown processor powered by plugins
704
- - [markdown-it](https://github.com/markdown-it/markdown-it) - Markdown parser
705
-
706
- ### Caching
707
- - [node-cache](https://github.com/node-cache/node-cache) - Simple caching module
708
- - [lru-cache](https://github.com/isaacs/node-lru-cache) - Least Recently Used cache
709
- - [flat-cache](https://github.com/jaredwray/flat-cache) - Flat file cache
710
-
711
- ### Token Estimation
712
- - [tiktoken](https://github.com/openai/tiktoken) - OpenAI's token counter
713
- - [js-tiktoken](https://github.com/dqbd/tiktoken) - TikToken for JavaScript
714
-
715
- ### Text Summarization
716
- - [node-sumy](https://github.com/chunksnbits/node-sumy) - Text summarization
717
- - [Hugging Face Transformers](https://huggingface.co/docs/transformers/) - Advanced summarization models
327
+ **This means:**
328
+ - Sub-agent parallelization active
329
+ - Each agent has isolated context
330
+ - Efficient multi-domain processing
718
331
 
719
332
  ---
720
333
 
721
334
  ## Summary
722
335
 
723
- The context-loader is SpecWeave's **precision context loading system** that:
724
- - ✅ Loads only relevant specifications (not everything)
725
- - Achieves 70%+ token reduction (constitution target)
726
- - Supports section-level granularity (`#anchor`)
727
- - ✅ Enables enterprise-scale specs (500+ pages) without bloat
728
- - Caches for performance (<50ms cache hits)
729
- - ✅ Auto-refreshes when specs change (optional)
730
- - Manages token budgets intelligently
336
+ SpecWeave achieves context efficiency through:
337
+
338
+ 1. **Progressive Disclosure (Native Claude)**
339
+ - Skills load only when relevant
340
+ - Metadata-first approach
341
+ - 90%+ savings on simple tasks
342
+
343
+ 2. **Sub-Agent Parallelization (Native Claude Code)**
344
+ - Isolated context windows
345
+ - Parallel processing
346
+ - 50-70% savings on complex tasks
347
+
348
+ **No custom manifests. No custom caching. Just smart use of Claude's native capabilities.**
349
+
350
+ ---
731
351
 
732
- **User benefit**: Work on massive codebases with 500+ page specifications without exceeding context windows. Load exactly what you need, when you need it.
352
+ ## References
733
353
 
734
- **Revolutionary impact**: Makes spec-driven development scalable to enterprise without sacrificing precision.
354
+ - [Claude Skills Documentation](https://support.claude.com/en/articles/12512176-what-are-skills)
355
+ - [Agent Skills Engineering Blog](https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills)
356
+ - [Sub-Agents Documentation](https://docs.claude.com/en/docs/claude-code/sub-agents)