clawstrap 1.2.0 → 1.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/README.md +59 -1
- package/dist/index.cjs +48 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,12 +49,15 @@ Scaffold a production-ready AI agent workspace.
|
|
|
49
49
|
|
|
50
50
|
? Enable session handoff checklists? (for multi-session work) Yes
|
|
51
51
|
|
|
52
|
+
? Enable Spec-Driven Development? (write specs before implementing) Yes
|
|
53
|
+
|
|
52
54
|
Configuration:
|
|
53
55
|
Workspace: my-project
|
|
54
56
|
Workload: Research & Analysis
|
|
55
57
|
Parallel agents: single
|
|
56
58
|
Quality level: team
|
|
57
59
|
Session handoff: yes
|
|
60
|
+
Spec-driven dev: yes
|
|
58
61
|
|
|
59
62
|
Generating your workspace...
|
|
60
63
|
|
|
@@ -103,6 +106,8 @@ my-project/
|
|
|
103
106
|
│ │ └── SKILL_REGISTRY.md # Skill index
|
|
104
107
|
│ ├── memory/
|
|
105
108
|
│ │ └── MEMORY.md # Cross-session memory (session handoff only)
|
|
109
|
+
│ ├── commands/
|
|
110
|
+
│ │ └── spec.md # /spec slash command (SDD only)
|
|
106
111
|
│ ├── subagent-bootstrap.md # Lightweight ad-hoc governance (multi-agent only)
|
|
107
112
|
│ ├── gotcha-log.md # Incident tracking — why rules exist
|
|
108
113
|
│ └── future-considerations.md # Deferred ideas parking lot
|
|
@@ -110,6 +115,8 @@ my-project/
|
|
|
110
115
|
│ └── _template/
|
|
111
116
|
│ ├── README.md # Project metadata template
|
|
112
117
|
│ └── process.md # Workflow and session checklist template
|
|
118
|
+
├── specs/
|
|
119
|
+
│ └── _template.md # Spec template (SDD only)
|
|
113
120
|
├── tmp/ # Gitignored session workspace
|
|
114
121
|
├── research/ # Reference material
|
|
115
122
|
├── context/ # Session checkpoints
|
|
@@ -321,6 +328,7 @@ Every rule in a Clawstrap workspace exists because something went wrong without
|
|
|
321
328
|
```
|
|
322
329
|
clawstrap init [directory] Scaffold a new workspace (interactive)
|
|
323
330
|
clawstrap init [directory] --yes Use defaults, skip prompts
|
|
331
|
+
clawstrap init [directory] --sdd Enable Spec-Driven Development mode
|
|
324
332
|
clawstrap add agent <name> Add a new agent definition
|
|
325
333
|
clawstrap add skill <name> Add a new skill with SKILL.md
|
|
326
334
|
clawstrap add project <name> Add a new project with README + process.md
|
|
@@ -346,11 +354,60 @@ Generates a directory with `paperclip.manifest.json`, agent definitions with fro
|
|
|
346
354
|
| `--mission`, `-m` | Company mission statement |
|
|
347
355
|
| `--adapter`, `-a` | Agent adapter type (default: `claude_local`) |
|
|
348
356
|
|
|
357
|
+
## Spec-Driven Development
|
|
358
|
+
|
|
359
|
+
Enable SDD mode to enforce a spec-first workflow. Before Claude implements anything, it writes a structured spec, saves it to `specs/{name}.md`, and gets your explicit approval.
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
npx clawstrap init --sdd
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
What you get:
|
|
366
|
+
|
|
367
|
+
- **`specs/_template.md`** — reusable spec format with problem statement, acceptance criteria, technical constraints, out-of-scope, and implementation notes
|
|
368
|
+
- **`.claude/rules/sdd.md`** — governance rule Claude loads every session: "Never implement from a vague prompt"
|
|
369
|
+
- **`.claude/commands/spec.md`** — `/spec` slash command that walks Claude through writing, saving, and presenting a spec for approval
|
|
370
|
+
|
|
371
|
+
In practice:
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
You: Build a CSV export for the orders table.
|
|
375
|
+
|
|
376
|
+
Claude: Writing spec to specs/csv-export-orders.md...
|
|
377
|
+
|
|
378
|
+
# Spec: CSV Export — Orders Table
|
|
379
|
+
Status: draft | Created: 2026-04-04
|
|
380
|
+
|
|
381
|
+
## Problem Statement
|
|
382
|
+
Users need to export order data for reporting in external tools.
|
|
383
|
+
|
|
384
|
+
## Acceptance Criteria
|
|
385
|
+
- [ ] Export all orders or filter by date range
|
|
386
|
+
- [ ] CSV includes: order_id, customer, total, status, created_at
|
|
387
|
+
- [ ] Empty state handled gracefully
|
|
388
|
+
- [ ] File named orders-export-{date}.csv
|
|
389
|
+
|
|
390
|
+
## Technical Constraints
|
|
391
|
+
- Must use existing DB connection pool
|
|
392
|
+
- Must stream for large datasets (>10k rows)
|
|
393
|
+
|
|
394
|
+
## Out of Scope
|
|
395
|
+
- PDF export
|
|
396
|
+
- Scheduled exports
|
|
397
|
+
|
|
398
|
+
Does this spec look right? Any changes before I start?
|
|
399
|
+
|
|
400
|
+
You: Looks good, go ahead.
|
|
401
|
+
|
|
402
|
+
Claude: Implementing from spec...
|
|
403
|
+
```
|
|
404
|
+
|
|
349
405
|
## Flags
|
|
350
406
|
|
|
351
407
|
| Flag | Description |
|
|
352
408
|
|------|-------------|
|
|
353
409
|
| `--yes`, `-y` | Skip prompts, use sensible defaults (init only) |
|
|
410
|
+
| `--sdd` | Enable Spec-Driven Development mode (init only) |
|
|
354
411
|
| `--version` | Show version |
|
|
355
412
|
| `--help` | Show help |
|
|
356
413
|
|
|
@@ -360,7 +417,8 @@ Generates a directory with `paperclip.manifest.json`, agent definitions with fro
|
|
|
360
417
|
|---------|--------|------|
|
|
361
418
|
| **v1.0** | Done | `init` command, 4 workspace profiles, full governance templates, `--yes` mode |
|
|
362
419
|
| **v1.1** | Done | `add agent`, `add skill`, `add project`, `status` commands |
|
|
363
|
-
| **v1.2** |
|
|
420
|
+
| **v1.2** | Done | `export --format paperclip` — Paperclip company template export |
|
|
421
|
+
| **v1.3** | **Now** | `--sdd` flag — Spec-Driven Development mode with `/spec` slash command |
|
|
364
422
|
| **v2.0** | Planned | Multi-model support, `upgrade` command, ClipMart publishing |
|
|
365
423
|
|
|
366
424
|
## Contributing
|
package/dist/index.cjs
CHANGED
|
@@ -57,6 +57,7 @@ var ClawstrapConfigSchema = import_zod.z.object({
|
|
|
57
57
|
parallelAgents: import_zod.z.enum(PARALLEL_AGENTS),
|
|
58
58
|
qualityLevel: import_zod.z.enum(QUALITY_LEVELS),
|
|
59
59
|
sessionHandoff: import_zod.z.boolean(),
|
|
60
|
+
sdd: import_zod.z.boolean().default(false),
|
|
60
61
|
lastExport: LastExportSchema
|
|
61
62
|
});
|
|
62
63
|
|
|
@@ -104,7 +105,9 @@ function deriveTemplateVars(config) {
|
|
|
104
105
|
hasQualityGates: config.qualityLevel !== "solo",
|
|
105
106
|
isProductionQuality: config.qualityLevel === "production",
|
|
106
107
|
// Session handoff
|
|
107
|
-
sessionHandoff: config.sessionHandoff
|
|
108
|
+
sessionHandoff: config.sessionHandoff,
|
|
109
|
+
// Spec-Driven Development
|
|
110
|
+
sddEnabled: config.sdd
|
|
108
111
|
};
|
|
109
112
|
}
|
|
110
113
|
|
|
@@ -210,15 +213,30 @@ var OUTPUT_MANIFEST = [
|
|
|
210
213
|
templateKey: "memoryIndex",
|
|
211
214
|
outputPath: "{%systemDir%}/memory/MEMORY.md",
|
|
212
215
|
condition: "sessionHandoff"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
templateKey: "sddRule",
|
|
219
|
+
outputPath: "{%systemDir%}/rules/sdd.md",
|
|
220
|
+
condition: "sddEnabled"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
templateKey: "sddSpecTemplate",
|
|
224
|
+
outputPath: "specs/_template.md",
|
|
225
|
+
condition: "sddEnabled"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
templateKey: "sddSpecCommand",
|
|
229
|
+
outputPath: "{%systemDir%}/commands/spec.md",
|
|
230
|
+
condition: "sddEnabled"
|
|
213
231
|
}
|
|
214
232
|
];
|
|
215
233
|
var EMPTY_DIRS = ["tmp", "research", "context", "artifacts"];
|
|
216
234
|
|
|
217
235
|
// src/templates/governance-file.md.tmpl
|
|
218
|
-
var governance_file_md_default = "# {%governanceFile%} \u2014 Master Governance Rules\n> **Workspace**: {%workspaceName%} | **Generated**: {%generatedDate%} | **Status**: active\n> Loaded every session. Keep lean. Move details to skills or rules files.\n\n---\n\n## Workflow Rules\n\n**Approval-first, always.**\nPlan work and get explicit approval before executing. No speculative actions.\nIf scope changes mid-task, pause and re-confirm.\n\n**If it's not on disk, it didn't happen.**\nSave findings immediately, not at session end. Flush {%flushCadence%}.\nWrite corrections to durable locations before applying them.\n{%#if hasSubagents%}Subagents return file paths, not raw data.{%/if%}\n\n**Quality > context cleanliness > speed > token cost.**\nQuality failures require full rework (100% waste). Never trade quality for tokens.\n{%#if isResearch%}\n**Research-specific:**\n- Cite sources for every claim \u2014 no unsourced assertions\n- Write findings to file immediately, not at session end\n- Separate facts from interpretation in all output\n{%/if%}\n{%#if isContent%}\n**Content-specific:**\n- Every piece of content follows the draft \u2192 review \u2192 approve cycle\n- Never publish or finalize without explicit approval\n- Track all revision feedback in a dedicated file\n{%/if%}\n{%#if isDataProcessing%}\n**Data processing-specific:**\n- Define batch size before starting \u2014 never process unbounded sets\n- Validate schema on every write\n- Log every transformation step for auditability\n{%/if%}\n\n---\n\n## Persistence Hierarchy\n\nFrom most ephemeral to most durable:\n\n| Layer | Location | Loaded When |\n|-------|----------|-------------|\n| Conversation | (in-context) | Always \u2014 volatile |\n| Temp files | `tmp/` | Per-task, gitignored |\n{%#if sessionHandoff%}| Memory | `{%systemDir%}/memory/` | On demand |\n{%/if%}| Skills | `{%systemDir%}/skills/*/SKILL.md` | When triggered |\n| Rules | `{%systemDir%}/rules/*.md` | Every session |\n| **{%governanceFile%}** | `./{%governanceFile%}` | **Every session** |\n\n---\n\n## Context Discipline\n\n- Flush working state to file {%flushCadence%}\n{%#if hasSubagents%}- Subagents write output to `tmp/{task}/{name}.json`; return one-line receipt\n- Main session reads subagent files ONLY if needed for the next step\n- Never hold raw batch results in conversation \u2014 write to disk first\n{%/if%}- Before batch work: write execution plan to file (survives context loss)\n\n---\n{%#if sessionHandoff%}\n## Session Handoff Checklist\n\nRun this at every session end (mandatory, not optional):\n\n1. Save all work to SSOT files\n2. Sync derived files (rebuild from SSOTs)\n3. SSOT integrity check (no duplicates, no stale data)\n4. Update progress tracker\n5. Write next-session plan (with pre-execution hooks listed)\n6. Launch QC on work done this session\n\n---\n{%/if%}\n\n## Security Rules\n\n- Never read `.env` files or echo credentials\n- Never install third-party MCP servers/plugins without explicit approval\n- Never write outside this workspace root \u2014 use project-local `tmp/`, not system `/tmp/`\n- Approved tools only \u2014 ask before using new tools/APIs\n\n---\n\n## Quality Rules\n{%#if isProductionQuality%}\n- QC is a structural gate, not an optional post-step\n- Run spot-checks after every 5 items in batch work (Ralph Loop)\n- Combined agents (extract + classify) beat split agents on quality\n- Disagreements between agents reveal ambiguity \u2014 escalate, don't suppress\n{%/if%}\n{%#if hasQualityGates%}\n{%#unless isProductionQuality%}- QC is a structural gate, not an optional post-step\n- Run QC checkpoints at regular intervals during batch work\n- All results must be reviewed before being marked complete\n{%/unless%}\n{%/if%}\n{%#unless hasQualityGates%}- Run a quick check before finishing any task\n- Review outputs before marking work complete\n{%/unless%}\n\n---\n\n## Pointers to Other Layers\n\n- Rules: `{%systemDir%}/rules/` \u2014 domain-specific rules loaded every session\n- Skills: `{%systemDir%}/skills/SKILL_REGISTRY.md` \u2014 index of all skills\n{%#if hasSubagents%}- Agents: `{%systemDir%}/agents/` \u2014 subagent definitions with governance baked in\n{%/if%}- Gotchas: `{%systemDir%}/gotcha-log.md` \u2014 incident log (why rules exist)\n- Future: `{%systemDir%}/future-considerations.md` \u2014 deferred ideas\n";
|
|
236
|
+
var governance_file_md_default = "# {%governanceFile%} \u2014 Master Governance Rules\n> **Workspace**: {%workspaceName%} | **Generated**: {%generatedDate%} | **Status**: active\n> Loaded every session. Keep lean. Move details to skills or rules files.\n\n---\n\n## Workflow Rules\n\n**Approval-first, always.**\nPlan work and get explicit approval before executing. No speculative actions.\nIf scope changes mid-task, pause and re-confirm.\n\n**If it's not on disk, it didn't happen.**\nSave findings immediately, not at session end. Flush {%flushCadence%}.\nWrite corrections to durable locations before applying them.\n{%#if hasSubagents%}Subagents return file paths, not raw data.{%/if%}\n\n**Quality > context cleanliness > speed > token cost.**\nQuality failures require full rework (100% waste). Never trade quality for tokens.\n{%#if isResearch%}\n**Research-specific:**\n- Cite sources for every claim \u2014 no unsourced assertions\n- Write findings to file immediately, not at session end\n- Separate facts from interpretation in all output\n{%/if%}\n{%#if isContent%}\n**Content-specific:**\n- Every piece of content follows the draft \u2192 review \u2192 approve cycle\n- Never publish or finalize without explicit approval\n- Track all revision feedback in a dedicated file\n{%/if%}\n{%#if isDataProcessing%}\n**Data processing-specific:**\n- Define batch size before starting \u2014 never process unbounded sets\n- Validate schema on every write\n- Log every transformation step for auditability\n{%/if%}\n\n---\n\n## Persistence Hierarchy\n\nFrom most ephemeral to most durable:\n\n| Layer | Location | Loaded When |\n|-------|----------|-------------|\n| Conversation | (in-context) | Always \u2014 volatile |\n| Temp files | `tmp/` | Per-task, gitignored |\n{%#if sessionHandoff%}| Memory | `{%systemDir%}/memory/` | On demand |\n{%/if%}| Skills | `{%systemDir%}/skills/*/SKILL.md` | When triggered |\n| Rules | `{%systemDir%}/rules/*.md` | Every session |\n| **{%governanceFile%}** | `./{%governanceFile%}` | **Every session** |\n\n---\n\n## Context Discipline\n\n- Flush working state to file {%flushCadence%}\n{%#if hasSubagents%}- Subagents write output to `tmp/{task}/{name}.json`; return one-line receipt\n- Main session reads subagent files ONLY if needed for the next step\n- Never hold raw batch results in conversation \u2014 write to disk first\n{%/if%}- Before batch work: write execution plan to file (survives context loss)\n\n---\n{%#if sessionHandoff%}\n## Session Handoff Checklist\n\nRun this at every session end (mandatory, not optional):\n\n1. Save all work to SSOT files\n2. Sync derived files (rebuild from SSOTs)\n3. SSOT integrity check (no duplicates, no stale data)\n4. Update progress tracker\n5. Write next-session plan (with pre-execution hooks listed)\n6. Launch QC on work done this session\n\n---\n{%/if%}\n\n## Security Rules\n\n- Never read `.env` files or echo credentials\n- Never install third-party MCP servers/plugins without explicit approval\n- Never write outside this workspace root \u2014 use project-local `tmp/`, not system `/tmp/`\n- Approved tools only \u2014 ask before using new tools/APIs\n\n---\n\n## Quality Rules\n{%#if isProductionQuality%}\n- QC is a structural gate, not an optional post-step\n- Run spot-checks after every 5 items in batch work (Ralph Loop)\n- Combined agents (extract + classify) beat split agents on quality\n- Disagreements between agents reveal ambiguity \u2014 escalate, don't suppress\n{%/if%}\n{%#if hasQualityGates%}\n{%#unless isProductionQuality%}- QC is a structural gate, not an optional post-step\n- Run QC checkpoints at regular intervals during batch work\n- All results must be reviewed before being marked complete\n{%/unless%}\n{%/if%}\n{%#unless hasQualityGates%}- Run a quick check before finishing any task\n- Review outputs before marking work complete\n{%/unless%}\n\n---\n\n## Pointers to Other Layers\n\n- Rules: `{%systemDir%}/rules/` \u2014 domain-specific rules loaded every session\n- Skills: `{%systemDir%}/skills/SKILL_REGISTRY.md` \u2014 index of all skills\n{%#if hasSubagents%}- Agents: `{%systemDir%}/agents/` \u2014 subagent definitions with governance baked in\n{%/if%}- Gotchas: `{%systemDir%}/gotcha-log.md` \u2014 incident log (why rules exist)\n- Future: `{%systemDir%}/future-considerations.md` \u2014 deferred ideas\n{%#if sddEnabled%}\n---\n\n## Spec-Driven Development\n\nThis workspace uses SDD. Before implementing any feature:\n\n1. Write a spec \u2192 `specs/{name}.md` (use `/spec` or copy `specs/_template.md`)\n2. Get explicit user approval\n3. Implement from the approved spec \u2014 not from the conversation\n\nRule details: `{%systemDir%}/rules/sdd.md`\n{%/if%}\n";
|
|
219
237
|
|
|
220
238
|
// src/templates/getting-started.md.tmpl
|
|
221
|
-
var getting_started_md_default = "# Getting Started \u2014 {%workspaceName%}\n> Generated by Clawstrap v{%clawstrapVersion%} on {%generatedDate%}\n\nWelcome to your AI agent workspace. This workspace is configured for\n**{%workloadLabel%}** workflows.\n\n---\n\n## Quick Start\n\n1. **Read `{%governanceFile%}`** \u2014 this is your master governance file. It loads\n automatically every session and defines the rules your AI assistant follows.\n\n2. **Check `{%systemDir%}/rules/`** \u2014 these rule files also load every session.\n They contain detailed procedures for context discipline, approval workflows,\n and quality gates.\n\n3. **Start working** \u2014 open a Claude Code session in this directory. The\n governance files will load automatically.\n\n---\n\n## What's in This Workspace\n\n```\n{%governanceFile%} \u2190 Master governance (always loaded)\nGETTING_STARTED.md \u2190 You are here\n.clawstrap.json \u2190 Your workspace configuration\n\n{%systemDir%}/\n rules/ \u2190 Auto-loaded rules (every session)\n skills/ \u2190 Skill definitions (loaded when triggered)\n{%#if hasSubagents%} agents/ \u2190 Agent definitions\n{%/if%} gotcha-log.md \u2190 Incident log\n future-considerations.md \u2190 Deferred ideas\n{%#if sessionHandoff%} memory/ \u2190 Persistent memory across sessions\n{%/if%}\nprojects/\n _template/ \u2190 Template for new projects\n\ntmp/ \u2190 Temporary files (gitignored)\nresearch/ \u2190 Reference material\ncontext/ \u2190 Session checkpoints\nartifacts/ \u2190 Durable output\n```\n\n---\n\n## Key Principles\n\nThis workspace enforces five principles:\n\n1. **If it's not on disk, it didn't happen.** Context windows compress. Sessions\n end. The only thing that persists is files. Flush work {%flushCadence%}.\n\n2. **Approval-first, always.** Plan work, get approval, then execute. No\n speculative actions.\n\n3. **Quality is a structural gate.** Quality checks happen during work, not after.\n{%#if hasQualityGates%} See `{%systemDir%}/rules/quality-gates.md` for the full procedure.{%/if%}\n\n4. **Disagreements reveal ambiguity.** When agents disagree, the rules are\n ambiguous. Escalate and clarify \u2014 don't suppress.\n\n5. **One decision at a time.** Binary decisions made sequentially compound into\n reliable outcomes.\n{%#if hasSubagents%}\n\n---\n\n## Working with Multiple Agents\n\nYour workspace is configured for multi-agent workflows. Key rules:\n\n- **Subagents write to `tmp/`** \u2014 they return file paths and one-line summaries,\n never raw data in conversation.\n- **The main session is an orchestrator** \u2014 it tracks progress, launches agents,\n and checks output files. It does not hold subagent data in memory.\n- **Agent definitions live in `{%systemDir%}/agents/`** \u2014 each file becomes the\n system prompt for a subagent. Governance is baked into the definition.\n{%/if%}\n{%#if sessionHandoff%}\n\n---\n\n## Session Handoff\n\nThis workspace uses session handoff checklists. At the end of every session:\n\n1. Save all work to SSOT files\n2. Sync derived files\n3. Check SSOT integrity\n4. Update progress tracker\n5. Write next-session plan\n6. Run QC on session work\n\nThis ensures no context is lost between sessions.\n{%/if%}\n{%#if isResearch%}\n\n---\n\n## Research Tips\n\n- Write findings to disk immediately \u2014 don't accumulate in conversation\n- Cite sources for every claim\n- Separate facts from interpretation\n- Use `research/` for reference material, `artifacts/` for synthesis output\n{%/if%}\n{%#if isContent%}\n\n---\n\n## Content Workflow Tips\n\n- Every piece follows: draft \u2192 review \u2192 approve\n- Track revision feedback in dedicated files\n- Never finalize without explicit approval\n- Use `artifacts/` for final deliverables\n{%/if%}\n{%#if isDataProcessing%}\n\n---\n\n## Data Processing Tips\n\n- Define batch size before starting any processing run\n- Validate schema on every write\n- Checkpoint every 5 batch items\n- Log all transformations for auditability\n{%/if%}\n\n---\n\n*This workspace was generated by [Clawstrap](https://github.com/clawstrap/clawstrap).\nEdit any file to fit your needs \u2014 there's no lock-in.*\n";
|
|
239
|
+
var getting_started_md_default = "# Getting Started \u2014 {%workspaceName%}\n> Generated by Clawstrap v{%clawstrapVersion%} on {%generatedDate%}\n\nWelcome to your AI agent workspace. This workspace is configured for\n**{%workloadLabel%}** workflows.\n\n---\n\n## Quick Start\n\n1. **Read `{%governanceFile%}`** \u2014 this is your master governance file. It loads\n automatically every session and defines the rules your AI assistant follows.\n\n2. **Check `{%systemDir%}/rules/`** \u2014 these rule files also load every session.\n They contain detailed procedures for context discipline, approval workflows,\n and quality gates.\n\n3. **Start working** \u2014 open a Claude Code session in this directory. The\n governance files will load automatically.\n\n---\n\n## What's in This Workspace\n\n```\n{%governanceFile%} \u2190 Master governance (always loaded)\nGETTING_STARTED.md \u2190 You are here\n.clawstrap.json \u2190 Your workspace configuration\n\n{%systemDir%}/\n rules/ \u2190 Auto-loaded rules (every session)\n skills/ \u2190 Skill definitions (loaded when triggered)\n{%#if hasSubagents%} agents/ \u2190 Agent definitions\n{%/if%} gotcha-log.md \u2190 Incident log\n future-considerations.md \u2190 Deferred ideas\n{%#if sessionHandoff%} memory/ \u2190 Persistent memory across sessions\n{%/if%}\nprojects/\n _template/ \u2190 Template for new projects\n\ntmp/ \u2190 Temporary files (gitignored)\nresearch/ \u2190 Reference material\ncontext/ \u2190 Session checkpoints\nartifacts/ \u2190 Durable output\n{%#if sddEnabled%}specs/\n _template.md \u2190 Spec template (copy for each feature)\n{%/if%}```\n\n---\n\n## Key Principles\n\nThis workspace enforces five principles:\n\n1. **If it's not on disk, it didn't happen.** Context windows compress. Sessions\n end. The only thing that persists is files. Flush work {%flushCadence%}.\n\n2. **Approval-first, always.** Plan work, get approval, then execute. No\n speculative actions.\n\n3. **Quality is a structural gate.** Quality checks happen during work, not after.\n{%#if hasQualityGates%} See `{%systemDir%}/rules/quality-gates.md` for the full procedure.{%/if%}\n\n4. **Disagreements reveal ambiguity.** When agents disagree, the rules are\n ambiguous. Escalate and clarify \u2014 don't suppress.\n\n5. **One decision at a time.** Binary decisions made sequentially compound into\n reliable outcomes.\n{%#if hasSubagents%}\n\n---\n\n## Working with Multiple Agents\n\nYour workspace is configured for multi-agent workflows. Key rules:\n\n- **Subagents write to `tmp/`** \u2014 they return file paths and one-line summaries,\n never raw data in conversation.\n- **The main session is an orchestrator** \u2014 it tracks progress, launches agents,\n and checks output files. It does not hold subagent data in memory.\n- **Agent definitions live in `{%systemDir%}/agents/`** \u2014 each file becomes the\n system prompt for a subagent. Governance is baked into the definition.\n{%/if%}\n{%#if sessionHandoff%}\n\n---\n\n## Session Handoff\n\nThis workspace uses session handoff checklists. At the end of every session:\n\n1. Save all work to SSOT files\n2. Sync derived files\n3. Check SSOT integrity\n4. Update progress tracker\n5. Write next-session plan\n6. Run QC on session work\n\nThis ensures no context is lost between sessions.\n{%/if%}\n{%#if isResearch%}\n\n---\n\n## Research Tips\n\n- Write findings to disk immediately \u2014 don't accumulate in conversation\n- Cite sources for every claim\n- Separate facts from interpretation\n- Use `research/` for reference material, `artifacts/` for synthesis output\n{%/if%}\n{%#if isContent%}\n\n---\n\n## Content Workflow Tips\n\n- Every piece follows: draft \u2192 review \u2192 approve\n- Track revision feedback in dedicated files\n- Never finalize without explicit approval\n- Use `artifacts/` for final deliverables\n{%/if%}\n{%#if isDataProcessing%}\n\n---\n\n## Data Processing Tips\n\n- Define batch size before starting any processing run\n- Validate schema on every write\n- Checkpoint every 5 batch items\n- Log all transformations for auditability\n{%/if%}\n\n---\n\n{%#if sddEnabled%}\n\n---\n\n## Spec-Driven Development\n\nThis workspace enforces a spec-first workflow. Before any implementation:\n\n1. **Type `/spec`** to start a new spec interactively \u2014 Claude will guide you\n2. Or copy `specs/_template.md` manually, fill it in, and get approval\n3. Only implement after the spec is approved\n\nYour specs live in `specs/`. Each approved spec is the contract between you and\nClaude \u2014 implementation follows the spec, not the conversation.\n\nSee `{%systemDir%}/rules/sdd.md` for the full rules and exemptions.\n{%/if%}\n\n---\n\n*This workspace was generated by [Clawstrap](https://github.com/clawstrap/clawstrap).\nEdit any file to fit your needs \u2014 there's no lock-in.*\n";
|
|
222
240
|
|
|
223
241
|
// src/templates/gitignore.tmpl
|
|
224
242
|
var gitignore_default = "# Dependencies\nnode_modules/\n\n# Temporary files (subagent output, session data)\ntmp/\n\n# Secrets\n.env\n.env.*\ncredentials.json\n*.pem\n*.key\n\n# OS\n.DS_Store\nThumbs.db\n\n# Editor\n*.swp\n*.swo\n*~\n";
|
|
@@ -327,6 +345,15 @@ var add_project_readme_md_default = "# Project: {%projectName%}\n> **Status**: a
|
|
|
327
345
|
// src/templates/projects/add-project-process.md.tmpl
|
|
328
346
|
var add_project_process_md_default = '# Process: {%projectName%}\n> Workflow, hooks, and session checklist for this project.\n> Update this file as the workflow evolves.\n\n---\n{%#if sessionHandoff%}\n## Session Start Checklist (Pre-Hooks)\n\nRun these at the start of every session on this project:\n\n1. [ ] Read `README.md` \u2014 confirm current status and next step\n2. [ ] Read `{%governanceFile%}` (auto-loaded, but confirm it\'s current)\n3. [ ] Check `tmp/{task}/plan.md` if a batch is in progress\n4. [ ] Confirm SSOT files are in expected state (no stale data)\n\n---\n\n## Session End Checklist (Post-Hooks)\n\nRun these at the end of every session (mandatory \u2014 not optional):\n\n1. [ ] Save all work to SSOT files\n2. [ ] Sync derived files (regenerate from SSOTs)\n3. [ ] SSOT integrity check (no duplicates, no stale data)\n4. [ ] Update `README.md` \u2192 "Last done" and "Next" fields\n5. [ ] Write next-session plan to `tmp/{task}/plan.md`\n6. [ ] Run QC on work done this session\n\n---\n{%/if%}\n\n## Execution Workflow\n\n*(Describe the main execution loop for this project\'s primary task)*\n{%#if isResearch%}\n```\n1. Define research question \u2192 get approval\n2. Gather sources \u2192 write findings to file immediately\n3. Synthesize \u2192 cite all sources\n4. QC gate: {%flushCadence%}\n5. Output: artifacts/{topic}/synthesis.md\n```\n{%/if%}\n{%#if isContent%}\n```\n1. Brief \u2192 get approval on scope and outline\n2. Draft \u2192 write to artifacts/\n3. Review \u2192 collect feedback in dedicated file\n4. Revise \u2192 approval required before finalizing\n5. QC gate: {%flushCadence%}\n```\n{%/if%}\n{%#if isDataProcessing%}\n```\n1. Plan \u2192 get approval \u2192 define batch size\n2. Process batch \u2192 validate schema on every write\n3. QC gate: {%flushCadence%} (Ralph Loop)\n4. Output: tmp/{task}/{name}.json\n5. Human review \u2192 finalize\n```\n{%/if%}\n{%#if isCustom%}\n```\n1. Plan \u2192 get approval \u2192 execute\n2. Batch size: [N items per batch]\n3. QC gate: {%flushCadence%}\n4. Output: tmp/{task}/{name}.json\n```\n{%/if%}\n\n---\n{%#if hasQualityGates%}\n## Active Batch Tracking\n\n| Batch | Status | QC Grade | Notes |\n|-------|--------|----------|-------|\n| *(none yet)* | \u2014 | \u2014 | \u2014 |\n\n---\n{%/if%}\n\n## Known Gotchas (Project-Specific)\n\n*(1-2 line summaries of project-specific failure modes)*\n\n*(None yet \u2014 add entries as issues arise)*\n';
|
|
329
347
|
|
|
348
|
+
// src/templates/rules/sdd.md.tmpl
|
|
349
|
+
var sdd_md_default = '# Rule: Spec-Driven Development\n> **Scope**: All sessions | **Version**: 1.0 | **Generated**: {%generatedDate%}\n\n## The Rule\n\nNever implement from a vague prompt. Before writing any code or making structural\nchanges, write a spec. Get explicit approval. Then implement from the spec.\n\nThis rule exists because "just do it" prompts produce work that satisfies the\nsurface request while violating unstated constraints. Specs surface those\nconstraints before the work starts.\n\n---\n\n## When to Write a Spec\n\nA spec is required for:\n\n- Any new feature or component\n- Any refactor that touches more than 3 files\n- Any change to a public API or data schema\n- Any work whose scope is not fully clear from the request\n\nA spec is **not** required for:\n\n- Bug fixes under 5 lines\n- Documentation-only changes\n- Adding tests for existing, already-specified behavior\n- Changes explicitly described as "no spec needed" by the user\n\n---\n\n## The Workflow\n\n1. **Receive request** \u2014 user describes what they want\n2. **Write spec** \u2014 create `specs/{kebab-name}.md` using `specs/_template.md`\n3. **Present for approval** \u2014 show the spec to the user before doing any implementation\n4. **Incorporate feedback** \u2014 update the spec until approved; do not start work until then\n5. **Implement from spec** \u2014 treat the approved spec as the contract; flag deviations\n6. **Mark complete** \u2014 update spec status to `complete` after implementation\n\n---\n\n## Spec Naming\n\nUse kebab-case, descriptive, scoped to the feature:\n\n```\nspecs/user-authentication.md\nspecs/csv-export-pipeline.md\nspecs/agent-retry-logic.md\n```\n\n---\n\n## On Pushback\n\nIf the user says "just do it, skip the spec":\n\n- Acknowledge the preference\n- Offer a 5-minute lightweight spec (problem + criteria only) as a compromise\n- If they explicitly confirm "no spec", proceed \u2014 but note the deviation\n\nThe rule exists to protect the user\'s time, not to create friction for its own sake.\n';
|
|
350
|
+
|
|
351
|
+
// src/templates/sdd-spec-template.md.tmpl
|
|
352
|
+
var sdd_spec_template_md_default = "# Spec: {title}\n> **Status**: draft | **Created**: {%generatedDate%} | **Workspace**: {%workspaceName%}\n\n---\n\n## Problem Statement\n\n_What problem does this solve? What is the user need or pain point?_\n\n---\n\n## Acceptance Criteria\n\n_What must be true for this to be considered done? Be specific and testable._\n\n- [ ] ...\n- [ ] ...\n- [ ] ...\n\n---\n\n## Technical Constraints\n\n_What must this solution comply with?_\n\n- Must use: ...\n- Must not: ...\n- Performance: ...\n- Compatibility: ...\n\n---\n\n## Out of Scope\n\n_What are we explicitly NOT doing in this spec?_\n\n- ...\n\n---\n\n## Open Questions\n\n_What needs to be decided before or during implementation?_\n\n- [ ] ...\n\n---\n\n## Implementation Notes\n\n_Claude fills this in after implementation is complete._\n\n- Approach taken: ...\n- Key decisions made: ...\n- Deviations from spec (if any): ...\n\n---\n\n> Copy this file to `specs/{kebab-feature-name}.md`, fill it in, and get approval\n> before starting work. See `.claude/rules/sdd.md` for the full workflow.\n";
|
|
353
|
+
|
|
354
|
+
// src/templates/commands/spec.md.tmpl
|
|
355
|
+
var spec_md_default = 'Write a spec for the feature or change the user just described. Follow these steps exactly:\n\n1. Ask the user for the feature name if they haven\'t provided one. Use it to create the spec filename in kebab-case: `specs/{name}.md`.\n\n2. Copy the structure from `specs/_template.md` and fill in each section based on what you know from the conversation:\n - **Problem Statement**: why this feature is needed\n - **Acceptance Criteria**: specific, testable conditions for done\n - **Technical Constraints**: things the solution must or must not do\n - **Out of Scope**: what you are explicitly not building\n - **Open Questions**: anything that needs a decision before or during work\n\n3. Save the completed spec to `specs/{name}.md`.\n\n4. Present the spec to the user and ask: "Does this spec look right? Any changes before I start?"\n\n5. Do NOT begin implementation until the user explicitly approves the spec. If they request changes, update the spec and re-present it.\n\n6. Once approved, implement from the spec. If you need to deviate from it during implementation, flag the deviation and get confirmation before proceeding.\n\nThe spec is the contract. Build what the spec says, not what you think was meant.\n';
|
|
356
|
+
|
|
330
357
|
// src/templates/index.ts
|
|
331
358
|
var templates = {
|
|
332
359
|
governanceFile: governance_file_md_default,
|
|
@@ -347,7 +374,10 @@ var templates = {
|
|
|
347
374
|
newAgent: new_agent_md_default,
|
|
348
375
|
newSkill: new_skill_md_default,
|
|
349
376
|
addProjectReadme: add_project_readme_md_default,
|
|
350
|
-
addProjectProcess: add_project_process_md_default
|
|
377
|
+
addProjectProcess: add_project_process_md_default,
|
|
378
|
+
sddRule: sdd_md_default,
|
|
379
|
+
sddSpecTemplate: sdd_spec_template_md_default,
|
|
380
|
+
sddSpecCommand: spec_md_default
|
|
351
381
|
};
|
|
352
382
|
|
|
353
383
|
// src/writer.ts
|
|
@@ -476,12 +506,17 @@ async function runPrompts() {
|
|
|
476
506
|
message: "Enable session handoff checklists? (for multi-session work)",
|
|
477
507
|
default: true
|
|
478
508
|
});
|
|
509
|
+
const sdd = await (0, import_prompts.confirm)({
|
|
510
|
+
message: "Enable Spec-Driven Development? (write specs before implementing)",
|
|
511
|
+
default: false
|
|
512
|
+
});
|
|
479
513
|
return {
|
|
480
514
|
workspaceName,
|
|
481
515
|
workloadType,
|
|
482
516
|
parallelAgents,
|
|
483
517
|
qualityLevel,
|
|
484
|
-
sessionHandoff
|
|
518
|
+
sessionHandoff,
|
|
519
|
+
sdd
|
|
485
520
|
};
|
|
486
521
|
}
|
|
487
522
|
function getDefaults(targetDir) {
|
|
@@ -491,7 +526,8 @@ function getDefaults(targetDir) {
|
|
|
491
526
|
workloadType: "custom",
|
|
492
527
|
parallelAgents: "single",
|
|
493
528
|
qualityLevel: "solo",
|
|
494
|
-
sessionHandoff: true
|
|
529
|
+
sessionHandoff: true,
|
|
530
|
+
sdd: false
|
|
495
531
|
};
|
|
496
532
|
}
|
|
497
533
|
|
|
@@ -537,7 +573,8 @@ async function init(directory, options) {
|
|
|
537
573
|
workloadType: answers.workloadType,
|
|
538
574
|
parallelAgents: answers.parallelAgents,
|
|
539
575
|
qualityLevel: answers.qualityLevel,
|
|
540
|
-
sessionHandoff: answers.sessionHandoff
|
|
576
|
+
sessionHandoff: answers.sessionHandoff,
|
|
577
|
+
sdd: options.sdd ?? answers.sdd
|
|
541
578
|
});
|
|
542
579
|
console.log("\nConfiguration:");
|
|
543
580
|
console.log(` Workspace: ${config.workspaceName}`);
|
|
@@ -547,6 +584,7 @@ async function init(directory, options) {
|
|
|
547
584
|
console.log(
|
|
548
585
|
` Session handoff: ${config.sessionHandoff ? "yes" : "no"}`
|
|
549
586
|
);
|
|
587
|
+
console.log(` Spec-driven dev: ${config.sdd ? "yes" : "no"}`);
|
|
550
588
|
const vars = deriveTemplateVars(config);
|
|
551
589
|
console.log("\nGenerating your workspace...\n");
|
|
552
590
|
const result = writeWorkspace(targetDir, vars, config);
|
|
@@ -776,6 +814,7 @@ Configuration:`);
|
|
|
776
814
|
console.log(
|
|
777
815
|
` Session handoff: ${config.sessionHandoff ? "yes" : "no"}`
|
|
778
816
|
);
|
|
817
|
+
console.log(` Spec-driven dev: ${config.sdd ? "yes" : "no"}`);
|
|
779
818
|
console.log(`
|
|
780
819
|
Structure:`);
|
|
781
820
|
console.log(` Agents: ${agentCount} (${systemDir}/agents/)`);
|
|
@@ -1191,8 +1230,8 @@ Exported to ${import_node_path13.default.relative(process.cwd(), outDir) || outD
|
|
|
1191
1230
|
|
|
1192
1231
|
// src/index.ts
|
|
1193
1232
|
var program = new import_commander.Command();
|
|
1194
|
-
program.name("clawstrap").description("Scaffold a production-ready AI agent workspace").version("1.
|
|
1195
|
-
program.command("init").description("Create a new AI workspace in the current directory").argument("[directory]", "Target directory", ".").option("-y, --yes", "Use defaults, skip prompts").action(async (directory, options) => {
|
|
1233
|
+
program.name("clawstrap").description("Scaffold a production-ready AI agent workspace").version("1.3.0");
|
|
1234
|
+
program.command("init").description("Create a new AI workspace in the current directory").argument("[directory]", "Target directory", ".").option("-y, --yes", "Use defaults, skip prompts").option("--sdd", "Enable Spec-Driven Development mode").action(async (directory, options) => {
|
|
1196
1235
|
await init(directory, options);
|
|
1197
1236
|
});
|
|
1198
1237
|
var add = program.command("add").description("Add components to the workspace");
|