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.
- package/CLAUDE.md +600 -0
- package/README.md +245 -81
- package/bin/install-all.sh +1 -1
- package/bin/install-commands.sh +3 -3
- package/bin/specweave.js +39 -9
- package/dist/adapters/adapter-base.d.ts +1 -1
- package/dist/adapters/adapter-base.d.ts.map +1 -1
- package/dist/adapters/adapter-base.js +6 -41
- package/dist/adapters/adapter-base.js.map +1 -1
- package/dist/adapters/adapter-interface.js +1 -2
- package/dist/adapters/adapter-interface.js.map +1 -1
- package/dist/adapters/adapter-loader.d.ts +86 -0
- package/dist/adapters/adapter-loader.d.ts.map +1 -0
- package/dist/adapters/adapter-loader.js +216 -0
- package/dist/adapters/adapter-loader.js.map +1 -0
- package/dist/adapters/agents-md-generator.d.ts +48 -0
- package/dist/adapters/agents-md-generator.d.ts.map +1 -0
- package/dist/adapters/agents-md-generator.js +132 -0
- package/dist/adapters/agents-md-generator.js.map +1 -0
- package/dist/adapters/claude/adapter.d.ts +2 -2
- package/dist/adapters/claude/adapter.d.ts.map +1 -1
- package/dist/adapters/claude/adapter.js +5 -42
- package/dist/adapters/claude/adapter.js.map +1 -1
- package/dist/adapters/claude-md-generator.d.ts +78 -0
- package/dist/adapters/claude-md-generator.d.ts.map +1 -0
- package/dist/adapters/claude-md-generator.js +246 -0
- package/dist/adapters/claude-md-generator.js.map +1 -0
- package/dist/adapters/codex/adapter.d.ts +50 -0
- package/dist/adapters/codex/adapter.d.ts.map +1 -0
- package/dist/adapters/codex/adapter.js +316 -0
- package/dist/adapters/codex/adapter.js.map +1 -0
- package/dist/adapters/copilot/adapter.d.ts +10 -9
- package/dist/adapters/copilot/adapter.d.ts.map +1 -1
- package/dist/adapters/copilot/adapter.js +35 -100
- package/dist/adapters/copilot/adapter.js.map +1 -1
- package/dist/adapters/cursor/adapter.d.ts +8 -6
- package/dist/adapters/cursor/adapter.d.ts.map +1 -1
- package/dist/adapters/cursor/adapter.js +47 -130
- package/dist/adapters/cursor/adapter.js.map +1 -1
- package/dist/adapters/doc-generator.d.ts +69 -0
- package/dist/adapters/doc-generator.d.ts.map +1 -0
- package/dist/adapters/doc-generator.js +247 -0
- package/dist/adapters/doc-generator.js.map +1 -0
- package/dist/adapters/gemini/adapter.d.ts +50 -0
- package/dist/adapters/gemini/adapter.d.ts.map +1 -0
- package/dist/adapters/gemini/adapter.js +281 -0
- package/dist/adapters/gemini/adapter.js.map +1 -0
- package/dist/adapters/generic/adapter.d.ts +7 -4
- package/dist/adapters/generic/adapter.d.ts.map +1 -1
- package/dist/adapters/generic/adapter.js +60 -59
- package/dist/adapters/generic/adapter.js.map +1 -1
- package/dist/cli/commands/init.d.ts +3 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +272 -170
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +22 -58
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/list.d.ts.map +1 -1
- package/dist/cli/commands/list.js +27 -64
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/core/credentials-manager.d.ts +90 -0
- package/dist/core/credentials-manager.d.ts.map +1 -0
- package/dist/core/credentials-manager.js +271 -0
- package/dist/core/credentials-manager.js.map +1 -0
- package/dist/core/project-structure-detector.d.ts +92 -0
- package/dist/core/project-structure-detector.d.ts.map +1 -0
- package/dist/core/project-structure-detector.js +289 -0
- package/dist/core/project-structure-detector.js.map +1 -0
- package/dist/core/rfc-generator-v2.d.ts +149 -0
- package/dist/core/rfc-generator-v2.d.ts.map +1 -0
- package/dist/core/rfc-generator-v2.js +399 -0
- package/dist/core/rfc-generator-v2.js.map +1 -0
- package/dist/core/rfc-generator.d.ts +147 -0
- package/dist/core/rfc-generator.d.ts.map +1 -0
- package/dist/core/rfc-generator.js +434 -0
- package/dist/core/rfc-generator.js.map +1 -0
- package/dist/integrations/ado/ado-client.d.ts +123 -0
- package/dist/integrations/ado/ado-client.d.ts.map +1 -0
- package/dist/integrations/ado/ado-client.js +398 -0
- package/dist/integrations/ado/ado-client.js.map +1 -0
- package/dist/integrations/jira/jira-client.d.ts +139 -0
- package/dist/integrations/jira/jira-client.d.ts.map +1 -0
- package/dist/integrations/jira/jira-client.js +386 -0
- package/dist/integrations/jira/jira-client.js.map +1 -0
- package/dist/integrations/jira/jira-incremental-mapper.d.ts +75 -0
- package/dist/integrations/jira/jira-incremental-mapper.d.ts.map +1 -0
- package/dist/integrations/jira/jira-incremental-mapper.js +474 -0
- package/dist/integrations/jira/jira-incremental-mapper.js.map +1 -0
- package/dist/integrations/jira/jira-mapper.d.ts +105 -0
- package/dist/integrations/jira/jira-mapper.d.ts.map +1 -0
- package/dist/integrations/jira/jira-mapper.js +494 -0
- package/dist/integrations/jira/jira-mapper.js.map +1 -0
- package/dist/testing/test-generator.d.ts +117 -0
- package/dist/testing/test-generator.d.ts.map +1 -0
- package/dist/testing/test-generator.js +370 -0
- package/dist/testing/test-generator.js.map +1 -0
- package/dist/utils/auto-install.d.ts +3 -0
- package/dist/utils/auto-install.d.ts.map +1 -1
- package/dist/utils/auto-install.js +16 -82
- package/dist/utils/auto-install.js.map +1 -1
- package/dist/utils/esm-helpers.d.ts +50 -0
- package/dist/utils/esm-helpers.d.ts.map +1 -0
- package/dist/utils/esm-helpers.js +57 -0
- package/dist/utils/esm-helpers.js.map +1 -0
- package/package.json +16 -7
- package/src/adapters/README.md +1 -2
- package/src/adapters/adapter-base.ts +6 -3
- package/src/adapters/adapter-loader.ts +261 -0
- package/src/adapters/agents-md-generator.ts +162 -0
- package/src/adapters/claude/README.md +6 -14
- package/src/adapters/claude/adapter.ts +4 -4
- package/src/adapters/claude-md-generator.ts +311 -0
- package/src/adapters/codex/README.md +105 -0
- package/src/adapters/codex/adapter.ts +333 -0
- package/src/adapters/copilot/adapter.ts +36 -65
- package/src/adapters/cursor/README.md +0 -2
- package/src/adapters/cursor/adapter.ts +46 -92
- package/src/adapters/doc-generator.ts +331 -0
- package/src/adapters/gemini/README.md +97 -0
- package/src/adapters/gemini/adapter.ts +298 -0
- package/src/adapters/generic/adapter.ts +61 -57
- package/src/adapters/registry.yaml +86 -25
- package/src/agents/devops/AGENT.md +16 -18
- package/src/agents/docs-writer/AGENT.md +2 -2
- package/src/agents/pm/AGENT.md +1 -50
- package/src/commands/README.md +134 -111
- package/src/commands/{build.md → specweave.do.md} +141 -69
- package/src/commands/{done.md → specweave.done.md} +3 -3
- package/src/commands/{inc.md → specweave.inc.md} +4 -4
- package/src/commands/{increment.md → specweave.increment.md} +143 -76
- package/src/commands/specweave.md +430 -0
- package/src/commands/specweave.next.md +495 -0
- package/src/commands/{progress.md → specweave.progress.md} +12 -12
- package/src/commands/specweave.sync-docs.md +665 -0
- package/src/commands/specweave.sync-github.md +269 -0
- package/src/commands/specweave.sync-jira.md +197 -0
- package/src/commands/{validate.md → specweave.validate.md} +4 -4
- package/src/hooks/README.md +19 -29
- package/src/hooks/post-task-completion.sh +25 -30
- package/src/skills/ado-sync/README.md +1 -36
- package/src/skills/bmad-method-expert/SKILL.md +1 -3
- package/src/skills/brownfield-analyzer/SKILL.md +429 -23
- package/src/skills/brownfield-onboarder/SKILL.md +221 -8
- package/src/skills/context-loader/SKILL.md +239 -617
- package/src/skills/context-optimizer/SKILL.md +0 -30
- package/src/skills/github-sync/SKILL.md +1 -19
- package/src/skills/increment-planner/SKILL.md +64 -18
- package/src/skills/increment-quality-judge/SKILL.md +1 -36
- package/src/skills/jira-sync/README.md +1 -38
- package/src/skills/role-orchestrator/README.md +1 -22
- package/src/skills/role-orchestrator/SKILL.md +1 -59
- package/src/skills/skill-router/SKILL.md +0 -18
- package/src/skills/spec-kit-expert/SKILL.md +1 -3
- package/src/skills/specweave-detector/SKILL.md +225 -275
- package/src/skills/task-builder/README.md +1 -7
- package/src/templates/AGENTS.md.template +334 -0
- package/src/templates/CLAUDE.md.template +131 -298
- package/src/templates/README.md.template +115 -23
- package/src/templates/environments/minimal/README.md +0 -1
- package/INSTALL.md +0 -848
- package/SPECWEAVE.md +0 -743
- package/src/adapters/copilot/.github/copilot/instructions.md +0 -376
- package/src/adapters/cursor/.cursorrules +0 -325
- package/src/adapters/generic/SPECWEAVE-MANUAL.md +0 -676
- package/src/commands/create-project.md +0 -528
- package/src/commands/generate-docs.md +0 -623
- package/src/commands/review-docs.md +0 -331
- package/src/commands/sync-github.md +0 -115
- package/src/skills/ado-sync/test-cases/test-1.yaml +0 -9
- package/src/skills/ado-sync/test-cases/test-2.yaml +0 -8
- package/src/skills/ado-sync/test-cases/test-3.yaml +0 -9
- package/src/skills/bmad-method-expert/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/bmad-method-expert/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/bmad-method-expert/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/brownfield-analyzer/test-cases/test-1-basic-analysis.yaml +0 -48
- package/src/skills/brownfield-analyzer/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/brownfield-analyzer/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/brownfield-onboarder/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/brownfield-onboarder/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/brownfield-onboarder/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/calendar-system/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/calendar-system/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/calendar-system/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/context-loader/test-cases/test-1-basic-loading.yaml +0 -39
- package/src/skills/context-loader/test-cases/test-2-token-budget-exceeded.yaml +0 -44
- package/src/skills/context-loader/test-cases/test-3-section-anchors.yaml +0 -45
- package/src/skills/context-optimizer/test-cases/test-1-bug-fix-narrow.yaml +0 -97
- package/src/skills/context-optimizer/test-cases/test-2-feature-focused.yaml +0 -109
- package/src/skills/context-optimizer/test-cases/test-3-architecture-broad.yaml +0 -98
- package/src/skills/cost-optimizer/test-cases/test-1-basic-comparison.yaml +0 -75
- package/src/skills/cost-optimizer/test-cases/test-2-budget-constraint.yaml +0 -52
- package/src/skills/cost-optimizer/test-cases/test-3-scale-requirement.yaml +0 -63
- package/src/skills/cost-optimizer/test-results/README.md +0 -46
- package/src/skills/design-system-architect/test-cases/test-1-token-structure.yaml +0 -23
- package/src/skills/design-system-architect/test-cases/test-2-component-hierarchy.yaml +0 -24
- package/src/skills/design-system-architect/test-cases/test-3-accessibility-checklist.yaml +0 -23
- package/src/skills/diagrams-architect/test-cases/test-1-c4-context.yaml +0 -13
- package/src/skills/diagrams-architect/test-cases/test-2-sequence-diagram.yaml +0 -13
- package/src/skills/diagrams-architect/test-cases/test-3-er-diagram.yaml +0 -13
- package/src/skills/diagrams-generator/test-cases/test-1.yaml +0 -9
- package/src/skills/diagrams-generator/test-cases/test-2.yaml +0 -9
- package/src/skills/diagrams-generator/test-cases/test-3.yaml +0 -8
- package/src/skills/docs-updater/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/docs-updater/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/docs-updater/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/dotnet-backend/test-cases/test-1-rest-api.yaml +0 -14
- package/src/skills/dotnet-backend/test-cases/test-2-authentication.yaml +0 -13
- package/src/skills/dotnet-backend/test-cases/test-3-minimal-api.yaml +0 -13
- package/src/skills/e2e-playwright/test-cases/TC-001-basic-navigation.yaml +0 -54
- package/src/skills/e2e-playwright/test-cases/TC-002-form-interaction.yaml +0 -64
- package/src/skills/e2e-playwright/test-cases/TC-003-specweave-integration.yaml +0 -74
- package/src/skills/e2e-playwright/test-cases/TC-004-accessibility-check.yaml +0 -98
- package/src/skills/figma-designer/test-cases/test-1-design-system.yaml +0 -13
- package/src/skills/figma-designer/test-cases/test-2-component-library.yaml +0 -13
- package/src/skills/figma-designer/test-cases/test-3-responsive-layout.yaml +0 -13
- package/src/skills/figma-implementer/test-cases/test-1-design-to-react.yaml +0 -13
- package/src/skills/figma-implementer/test-cases/test-2-storybook.yaml +0 -13
- package/src/skills/figma-implementer/test-cases/test-3-design-tokens.yaml +0 -13
- package/src/skills/figma-mcp-connector/test-cases/test-1-read-file-desktop.yaml +0 -22
- package/src/skills/figma-mcp-connector/test-cases/test-2-read-file-framelink.yaml +0 -21
- package/src/skills/figma-mcp-connector/test-cases/test-3-error-handling.yaml +0 -18
- package/src/skills/figma-to-code/test-cases/test-1-token-generation.yaml +0 -29
- package/src/skills/figma-to-code/test-cases/test-2-component-generation.yaml +0 -27
- package/src/skills/figma-to-code/test-cases/test-3-typescript-generation.yaml +0 -28
- package/src/skills/frontend/test-cases/test-1-react-component.yaml +0 -13
- package/src/skills/frontend/test-cases/test-2-form-validation.yaml +0 -13
- package/src/skills/frontend/test-cases/test-3-state-management.yaml +0 -13
- package/src/skills/github-sync/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/github-sync/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/github-sync/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/hetzner-provisioner/test-cases/test-1-basic-provision.yaml +0 -71
- package/src/skills/hetzner-provisioner/test-cases/test-2-postgres-provision.yaml +0 -85
- package/src/skills/hetzner-provisioner/test-cases/test-3-ssl-config.yaml +0 -126
- package/src/skills/hetzner-provisioner/test-results/README.md +0 -259
- package/src/skills/increment-planner/test-cases/test-1-basic-feature.yaml +0 -27
- package/src/skills/increment-planner/test-cases/test-2-complex-feature.yaml +0 -30
- package/src/skills/increment-planner/test-cases/test-3-auto-numbering.yaml +0 -24
- package/src/skills/increment-quality-judge/test-cases/test-1-good-spec.yaml +0 -95
- package/src/skills/increment-quality-judge/test-cases/test-2-poor-spec.yaml +0 -108
- package/src/skills/increment-quality-judge/test-cases/test-3-export-suggestions.yaml +0 -87
- package/src/skills/jira-sync/test-cases/test-1.yaml +0 -9
- package/src/skills/jira-sync/test-cases/test-2.yaml +0 -9
- package/src/skills/jira-sync/test-cases/test-3.yaml +0 -10
- package/src/skills/nextjs/test-cases/test-1-app-router.yaml +0 -13
- package/src/skills/nextjs/test-cases/test-2-server-actions.yaml +0 -13
- package/src/skills/nextjs/test-cases/test-3-api-routes.yaml +0 -13
- package/src/skills/nodejs-backend/test-cases/test-1-express-api.yaml +0 -13
- package/src/skills/nodejs-backend/test-cases/test-2-prisma-orm.yaml +0 -13
- package/src/skills/nodejs-backend/test-cases/test-3-authentication.yaml +0 -13
- package/src/skills/notification-system/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/notification-system/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/notification-system/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/python-backend/test-cases/test-1-fastapi-crud.yaml +0 -13
- package/src/skills/python-backend/test-cases/test-2-sqlalchemy.yaml +0 -13
- package/src/skills/python-backend/test-cases/test-3-authentication.yaml +0 -13
- package/src/skills/role-orchestrator/test-cases/test-1-simple-product.yaml +0 -98
- package/src/skills/role-orchestrator/test-cases/test-2-quality-gate-failure.yaml +0 -73
- package/src/skills/role-orchestrator/test-cases/test-3-security-workflow.yaml +0 -121
- package/src/skills/role-orchestrator/test-cases/test-4-parallel-execution.yaml +0 -145
- package/src/skills/role-orchestrator/test-cases/test-5-feedback-loops.yaml +0 -149
- package/src/skills/skill-creator/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/skill-creator/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/skill-creator/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/skill-router/test-cases/test-1-basic-routing.yaml +0 -33
- package/src/skills/skill-router/test-cases/test-2-ambiguous-request.yaml +0 -42
- package/src/skills/skill-router/test-cases/test-3-nested-orchestration.yaml +0 -50
- package/src/skills/spec-driven-brainstorming/test-cases/TC-001-simple-idea-to-design.yaml +0 -148
- package/src/skills/spec-driven-brainstorming/test-cases/TC-002-complex-ultrathink-design.yaml +0 -190
- package/src/skills/spec-driven-brainstorming/test-cases/TC-003-unclear-requirements-socratic.yaml +0 -233
- package/src/skills/spec-driven-debugging/test-cases/TC-001-simple-auth-bug.yaml +0 -212
- package/src/skills/spec-driven-debugging/test-cases/TC-002-race-condition-ultrathink.yaml +0 -461
- package/src/skills/spec-driven-debugging/test-cases/TC-003-brownfield-missing-spec.yaml +0 -366
- package/src/skills/spec-kit-expert/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/spec-kit-expert/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/spec-kit-expert/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/specweave-ado-mapper/test-cases/test-1-export-to-ado.yaml +0 -13
- package/src/skills/specweave-ado-mapper/test-cases/test-2-import-from-ado.yaml +0 -13
- package/src/skills/specweave-ado-mapper/test-cases/test-3-bidirectional-sync.yaml +0 -13
- package/src/skills/specweave-detector/test-cases/test-1-basic-detection.yaml +0 -37
- package/src/skills/specweave-detector/test-cases/test-2-missing-config.yaml +0 -37
- package/src/skills/specweave-detector/test-cases/test-3-non-specweave-project.yaml +0 -34
- package/src/skills/specweave-jira-mapper/test-cases/test-1-export-to-jira.yaml +0 -13
- package/src/skills/specweave-jira-mapper/test-cases/test-2-import-from-jira.yaml +0 -13
- package/src/skills/specweave-jira-mapper/test-cases/test-3-sync-status.yaml +0 -13
- package/src/skills/stripe-integrator/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/stripe-integrator/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/stripe-integrator/test-cases/test-3-placeholder.yaml +0 -12
- package/src/skills/task-builder/test-cases/test-1-placeholder.yaml +0 -12
- package/src/skills/task-builder/test-cases/test-2-placeholder.yaml +0 -12
- package/src/skills/task-builder/test-cases/test-3-placeholder.yaml +0 -12
- package/src/templates/config.yaml +0 -351
- /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:
|
|
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
|
|
6
|
+
# Context Management in SpecWeave
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Overview
|
|
9
9
|
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
17
|
+
---
|
|
28
18
|
|
|
29
|
-
|
|
19
|
+
## 1. Progressive Disclosure (Skills)
|
|
30
20
|
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
|
54
|
+
### Example Workflow
|
|
291
55
|
|
|
292
56
|
```
|
|
293
|
-
User: "
|
|
294
|
-
↓
|
|
295
|
-
specweave-detector detects feature 003
|
|
296
|
-
↓
|
|
297
|
-
context-loader activates
|
|
57
|
+
User: "Create a Next.js authentication page"
|
|
298
58
|
↓
|
|
299
|
-
|
|
300
|
-
features/003-stripe-payment/context-manifest.yaml
|
|
59
|
+
Claude reviews skill metadata (35 skills × 75 tokens = 2,625 tokens)
|
|
301
60
|
↓
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
-
|
|
315
|
-
|
|
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
|
-
|
|
321
|
-
✓ 4 specification files
|
|
322
|
-
✓ 3 architecture documents (2 section-filtered)
|
|
323
|
-
✓ 2 ADRs
|
|
74
|
+
### References
|
|
324
75
|
|
|
325
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
334
|
-
↓
|
|
335
|
-
context-loader detects active issue
|
|
90
|
+
Main conversation (100K tokens used)
|
|
336
91
|
↓
|
|
337
|
-
|
|
92
|
+
Launches 3 sub-agents in parallel
|
|
338
93
|
↓
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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
|
-
|
|
357
|
-
✓ Current webhook handler implementation
|
|
358
|
-
✓ Webhook specification
|
|
359
|
-
✓ Architecture documentation
|
|
99
|
+
**Benefits:**
|
|
360
100
|
|
|
361
|
-
|
|
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
|
-
|
|
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
|
|
117
|
+
### Example Workflow
|
|
367
118
|
|
|
368
119
|
```
|
|
369
|
-
User: "
|
|
120
|
+
User: "Build a full-stack Next.js app with auth, payments, and admin"
|
|
370
121
|
↓
|
|
371
|
-
|
|
372
|
-
related_features:
|
|
373
|
-
- 002-user-subscriptions
|
|
374
|
-
- 004-billing-portal
|
|
122
|
+
Main conversation launches 3 sub-agents in parallel:
|
|
375
123
|
↓
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
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
|
-
|
|
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
|
-
|
|
387
|
-
|
|
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
|
-
|
|
390
|
-
- Payment entities model
|
|
147
|
+
### References
|
|
391
148
|
|
|
392
|
-
|
|
393
|
-
- Payment database schema
|
|
149
|
+
- [Sub-Agents Documentation](https://docs.claude.com/en/docs/claude-code/sub-agents)
|
|
394
150
|
|
|
395
|
-
|
|
396
|
-
or in sequence to avoid conflicts."
|
|
397
|
-
```
|
|
151
|
+
---
|
|
398
152
|
|
|
399
|
-
## Token
|
|
153
|
+
## Actual Token Savings
|
|
400
154
|
|
|
401
|
-
###
|
|
155
|
+
### Progressive Disclosure Savings
|
|
402
156
|
|
|
403
|
-
**Scenario**:
|
|
157
|
+
**Scenario**: User asks about Next.js
|
|
404
158
|
|
|
405
|
-
**Without
|
|
159
|
+
**Without progressive disclosure:**
|
|
406
160
|
```
|
|
407
|
-
|
|
408
|
-
|
|
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
|
|
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
|
-
|
|
425
|
-
|
|
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
|
-
###
|
|
173
|
+
### Sub-Agent Savings
|
|
431
174
|
|
|
432
|
-
**
|
|
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
|
-
**
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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
|
-
|
|
195
|
+
**Note**: Exact percentages vary by task complexity. These are approximate based on typical usage patterns.
|
|
459
196
|
|
|
460
|
-
|
|
197
|
+
---
|
|
461
198
|
|
|
462
|
-
|
|
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
|
-
|
|
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
|
-
|
|
473
|
-
clearCache(manifest);
|
|
203
|
+
SpecWeave organizes **35+ skills** with clear, focused descriptions:
|
|
474
204
|
|
|
475
|
-
|
|
476
|
-
|
|
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
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
212
|
+
# Bad: Vague description
|
|
213
|
+
---
|
|
214
|
+
name: frontend
|
|
215
|
+
description: Does frontend stuff
|
|
216
|
+
---
|
|
482
217
|
```
|
|
483
218
|
|
|
484
|
-
|
|
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
|
-
|
|
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
|
-
|
|
492
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
250
|
+
---
|
|
506
251
|
|
|
507
|
-
|
|
252
|
+
## Common Misconceptions
|
|
508
253
|
|
|
509
|
-
|
|
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
|
-
|
|
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
|
-
|
|
522
|
-
}
|
|
523
|
-
```
|
|
258
|
+
### ❌ Myth 2: "SpecWeave caches loaded context"
|
|
524
259
|
|
|
525
|
-
|
|
260
|
+
**Reality:** No custom caching. Claude Code handles caching internally (if applicable). SpecWeave doesn't implement additional caching layers.
|
|
526
261
|
|
|
527
|
-
|
|
528
|
-
// Load only high-priority items immediately
|
|
529
|
-
// Load medium/low priority on-demand
|
|
262
|
+
### ❌ Myth 3: "70-90% token reduction"
|
|
530
263
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
-
|
|
536
|
-
return {
|
|
537
|
-
immediate: highPriority,
|
|
269
|
+
### ✅ Truth: "It just works"
|
|
538
270
|
|
|
539
|
-
|
|
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
|
-
|
|
544
|
-
return await loadAllContent(manifest);
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
```
|
|
273
|
+
---
|
|
549
274
|
|
|
550
|
-
##
|
|
275
|
+
## Best Practices
|
|
551
276
|
|
|
552
|
-
###
|
|
277
|
+
### For Skill Descriptions
|
|
553
278
|
|
|
554
|
-
|
|
555
|
-
-
|
|
556
|
-
-
|
|
557
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
562
|
-
- Cache: Read/write cached context
|
|
289
|
+
### For Sub-Agent Usage
|
|
563
290
|
|
|
564
|
-
|
|
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
|
-
|
|
567
|
-
-
|
|
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
|
-
|
|
301
|
+
---
|
|
570
302
|
|
|
571
|
-
|
|
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
|
-
|
|
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
|
-
|
|
307
|
+
When Claude mentions using a skill:
|
|
628
308
|
|
|
629
309
|
```
|
|
630
|
-
|
|
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
|
-
|
|
633
|
-
Average load time: 156ms
|
|
634
|
-
Cache hit rate: 67%
|
|
319
|
+
### Check Sub-Agent Usage
|
|
635
320
|
|
|
636
|
-
|
|
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
|
-
|
|
323
|
+
```
|
|
324
|
+
Claude: "🤖 Launching 3 specialized agents in parallel..."
|
|
642
325
|
```
|
|
643
326
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
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
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
-
|
|
727
|
-
-
|
|
728
|
-
-
|
|
729
|
-
|
|
730
|
-
-
|
|
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
|
-
|
|
352
|
+
## References
|
|
733
353
|
|
|
734
|
-
|
|
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)
|