sparrow-ddd 0.1.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 ADDED
@@ -0,0 +1,316 @@
1
+ # ðŸŠķ Sparrow
2
+
3
+ ![Sparrow Logo](assets/sparrow-logo.png)
4
+
5
+ > Spec-driven DDD framework for AI coding assistants.
6
+ >
7
+ > The npm package is published as **`sparrow-ddd`**.
8
+
9
+ Sparrow transforms raw business requirements into production-ready code through a structured 6-step Domain-Driven Design (DDD) pipeline. It generates **skills and commands** for AI coding assistants (Claude Code, OpenCode, Cursor), letting each host's native AI capabilities guide you from business analysis to code generation — no multi-agent framework required.
10
+
11
+ ## Why Sparrow?
12
+
13
+ - **No lock-in**: Works with Claude Code, OpenCode, and Cursor out of the box. Uses each tool's native AI — no CrewAI, LangChain, or other agent frameworks.
14
+ - **Spec-driven**: Every step produces concrete, version-controlled Markdown artifacts. You always know what was decided and why.
15
+ - **DDD-native**: Follows Domain-Driven Design principles end-to-end: business services → subdomains → bounded contexts → domain models → code.
16
+ - **Multi-language**: Supports Java, Python, Node.js/TypeScript, Go, and Rust. Each bounded context can use a different tech stack.
17
+ - **Incremental & conversational**: Pause at any step, refine artifacts through dialog, then continue. Each skill reads the latest output from the previous step.
18
+
19
+ ## Installation
20
+
21
+ ### From npm (recommended)
22
+
23
+ ```bash
24
+ # Global install
25
+ npm install -g sparrow-ddd
26
+
27
+ # Or use without installing
28
+ npx sparrow-ddd init
29
+ ```
30
+
31
+ ### From local directory (development / offline)
32
+
33
+ If you have cloned the Sparrow repository locally, you can install directly from the local directory:
34
+
35
+ ```bash
36
+ # Option 1: Use npm link (recommended for development)
37
+ cd /path/to/sparrow # Navigate to the Sparrow project root
38
+ npm install # Install dependencies
39
+ npm run build # Build the project
40
+ npm link # Link sparrow globally
41
+
42
+ # Then use it from any directory
43
+ cd /path/to/your-project
44
+ sparrow init --tools claude
45
+
46
+ # To unlink
47
+ npm unlink -g sparrow-ddd
48
+ ```
49
+
50
+ ```bash
51
+ # Option 2: Install globally from local path
52
+ npm install -g /path/to/sparrow
53
+
54
+ # Option 3: Run the local build artifact directly with npx
55
+ node /path/to/sparrow/bin/sparrow.js init --tools claude
56
+ ```
57
+
58
+ > **Note**: Local installation is primarily intended for developing and debugging the Sparrow framework itself. For everyday use, install the published version via npm.
59
+
60
+ **Requirements**: Node.js >= 18
61
+
62
+ ## Quick Start
63
+
64
+ ### 1. Initialize Sparrow in your project
65
+
66
+ ```bash
67
+ cd your-project
68
+ sparrow init
69
+ ```
70
+
71
+ Sparrow detects which AI tools you have installed and asks which to configure. You can also specify explicitly:
72
+
73
+ ```bash
74
+ # Set up for Claude Code only
75
+ sparrow init --tools claude
76
+
77
+ # Set up for multiple tools
78
+ sparrow init --tools claude,opencode,cursor
79
+
80
+ # Set up for all supported tools, no prompts
81
+ sparrow init --tools all --force
82
+ ```
83
+
84
+ This creates skill and command files for each selected tool:
85
+
86
+ ```
87
+ your-project/
88
+ ├── .claude/
89
+ │ ├── skills/
90
+ │ │ ├── sparrow-explore/SKILL.md
91
+ │ │ ├── sparrow-arch/SKILL.md
92
+ │ │ ├── sparrow-design/SKILL.md
93
+ │ │ ├── sparrow-model/SKILL.md
94
+ │ │ ├── sparrow-plan/SKILL.md
95
+ │ │ └── sparrow-apply/SKILL.md
96
+ │ └── commands/sparrow/
97
+ │ ├── sparrow-explore.md
98
+ │ ├── sparrow-arch.md
99
+ │ └── ...
100
+ ├── .opencode/ # (if OpenCode selected)
101
+ │ └── ...
102
+ ├── .cursor/ # (if Cursor selected)
103
+ │ └── ...
104
+ └── sparrow.json # Project config
105
+ ```
106
+
107
+ ### 2. Run the pipeline
108
+
109
+ Invoke each skill in order as a slash command in your AI tool:
110
+
111
+ | Step | Command | Level | What it does |
112
+ |------|---------|-------|--------------|
113
+ | 1 | `/sparrow-explore` | Product | Identify business services from raw requirements |
114
+ | 2 | `/sparrow-arch` | Product | Define business architecture + application architecture with bounded contexts |
115
+ | 3 | `/sparrow-design @{slug}` | Team | Define API contracts and select tech stack for a bounded context |
116
+ | 4 | `/sparrow-model @{slug}` | Team | Extract static + dynamic domain model |
117
+ | 5 | `/sparrow-plan @{slug}` | Team | Devise implementation plan with task checklist |
118
+ | 6 | `/sparrow-apply @{slug}` | Team | Generate DDD-structured code with TDD |
119
+
120
+ > **Important**: Steps must run in order. Each skill checks that prerequisites exist and will tell you which step to run first if the order is wrong.
121
+
122
+ ### 3. Iterate and refine
123
+
124
+ After any step, you can:
125
+ - Review the generated Markdown artifacts
126
+ - Discuss changes with the AI ("Update the subdomain classification...")
127
+ - Re-run the skill with modifications
128
+ - Continue to the next step — it always reads the latest version
129
+
130
+ ## The 6-Step Pipeline
131
+
132
+ ### Step 1: sparrow-explore (Product-level)
133
+
134
+ **Input**: Raw requirements document or description
135
+ **Output**: `docs/sparrow/requirement/spec.md` — structured business service definitions
136
+
137
+ Identifies business services with: service number, name, description (as a user story), trigger event, basic flow, alternative flows, and acceptance criteria.
138
+
139
+ ```
140
+ Service IDïžšI-001
141
+ Service NameïžšSubmit Order
142
+ Description: As a buyer, I want to submit an order to purchase products.
143
+ Trigger: Buyer clicks "Submit Order"
144
+ Basic Flow: 1. Validate order; 2. Check inventory; 3. Insert order; ...
145
+ Alternative Flow: 1a. If order is invalid, show error...
146
+ Acceptance Criteria: ...
147
+ ```
148
+
149
+ ### Step 2: sparrow-arch (Product-level)
150
+
151
+ **Input**: `requirement/spec.md`
152
+ **Output**:
153
+ - `docs/sparrow/architecture/business.md` — subdomains (core/supporting/generic) + Mermaid business architecture diagram
154
+ - `docs/sparrow/architecture/application.md` — bounded contexts, context mapping, four-layer application architecture diagram
155
+ - `docs/sparrow/design/{slug}/spec.md` — per-context sliced business specs
156
+
157
+ Classifies subdomains into core (competitive advantage), supporting (business-essential), and generic (buy vs build). Maps them to bounded contexts with relationship patterns (ACL, OHS, Conformist, Customer-Supplier, Shared Kernel).
158
+
159
+ ### Step 3: sparrow-design (Team-level, per bounded context)
160
+
161
+ **Input**: `architecture/application.md` + `design/{slug}/spec.md`
162
+ **Output**:
163
+ - `docs/sparrow/design/{slug}/api.md` — service contracts with Mermaid sequence diagrams and RESTful API definitions
164
+ - `docs/sparrow/design/{slug}/tech.md` — technology stack selection (language, framework, database, messaging, testing)
165
+
166
+ Interactive tech stack selection: choose from Java (Spring Boot), Python (FastAPI), Node.js/TypeScript (Express/NestJS), Go (chi/net/http), or Rust (Axum). Each language gets multiple concrete stack options.
167
+
168
+ ### Step 4: sparrow-model (Team-level)
169
+
170
+ **Input**: `spec.md` + `api.md` + `tech.md`
171
+ **Output**: `docs/sparrow/design/{slug}/model.md` — complete domain model
172
+
173
+ - **Static model**: Unified language glossary, entities (yellow) and value objects (blue), aggregate identification (aggregate root in light red), PlantUML class diagram with relationship modeling (Composite/Aggregation/Association)
174
+ - **Dynamic model**: Task decomposition trees, role stereotype assignment (Command/Query/AppService/DomainService/Aggregate/Port), PlantUML sequence diagrams with color-coded participants and strict collaboration constraints
175
+
176
+ ### Step 5: sparrow-plan (Team-level)
177
+
178
+ **Input**: `spec.md` + `api.md` + `tech.md` + `model.md`
179
+ **Output**: `docs/sparrow/design/{slug}/plan.md` — ordered implementation plan
180
+
181
+ Creates tasks with `[ ]` checkboxes, sorted by DDD layer dependency (domain → infrastructure → application → api). Each task specifies: executor (`dev` for product code with TDD, `qa` for integration tests), parallelizability, and step-level granularity matching aggregate boundaries.
182
+
183
+ ### Step 6: sparrow-apply (Team-level)
184
+
185
+ **Input**: `plan.md`
186
+ **Output**:
187
+ - `code/{slug}/` — DDD four-layer module (api/application/domain/infrastructure)
188
+ - `integration-tests/{slug}/` — isolated integration/API tests
189
+ - `docs/sparrow/design/{slug}/code_review.md` — review report
190
+
191
+ Drives three roles: Development Engineer (DDD code + domain TDD), QA Engineer (integration/API tests), and Code Review. Follows language-specific coding standards and directory layouts. Checks off completed steps in `plan.md`.
192
+
193
+ ## Output Structure
194
+
195
+ After running the full pipeline, your project will have:
196
+
197
+ ```
198
+ your-project/
199
+ ├── docs/sparrow/
200
+ │ ├── requirement/
201
+ │ │ └── spec.md # sparrow-explore
202
+ │ ├── architecture/
203
+ │ │ ├── business.md # sparrow-arch (phase 1)
204
+ │ │ └── application.md # sparrow-arch (phase 2)
205
+ │ ├── project.md # Project catalog index
206
+ │ └── design/{english-slug}/
207
+ │ ├── spec.md # Per-context sliced spec
208
+ │ ├── api.md # sparrow-design
209
+ │ ├── tech.md # sparrow-design
210
+ │ ├── model.md # sparrow-model
211
+ │ ├── plan.md # sparrow-plan
212
+ │ └── code_review.md # sparrow-apply
213
+ ├── code/{slug}/ # sparrow-apply
214
+ │ ├── api/command/, query/, dto/
215
+ │ ├── application/
216
+ │ ├── domain/aggregate/, entity/, valueobject/, service/
217
+ │ └── infrastructure/port/, adapter/
218
+ ├── integration-tests/{slug}/ # sparrow-apply (qa tasks)
219
+ └── sparrow.json # Project config
220
+ ```
221
+
222
+ All bounded contexts share the same project root namespace, but each is an independent module with its own language-specific scaffold and dependency management.
223
+
224
+ ## Supported AI Tools
225
+
226
+ | Tool | Skills Directory | Commands Directory | Detection |
227
+ |------|-----------------|-------------------|-----------|
228
+ | **Claude Code** | `.claude/skills/` | `.claude/commands/sparrow/` | `.claude/` directory |
229
+ | **OpenCode** | `.opencode/skills/` | `.opencode/commands/` | `.opencode/` directory |
230
+ | **Cursor** | `.cursor/skills/` | `.cursor/commands/` | `.cursor/` directory |
231
+
232
+ ## Configuration
233
+
234
+ ### sparrow.json
235
+
236
+ Generated by `sparrow init` in your project root:
237
+
238
+ ```json
239
+ {
240
+ "version": "0.1.0",
241
+ "tools": ["claude", "opencode"],
242
+ "createdAt": "2026-06-29T04:05:45.650Z",
243
+ "outputBase": "docs/sparrow",
244
+ "codeBase": "code"
245
+ }
246
+ ```
247
+
248
+ ### Overriding output paths
249
+
250
+ Future versions will support a `sparrow.yaml` file for customizing output paths:
251
+
252
+ ```yaml
253
+ sparrow_docs_root: docs/my-company
254
+ paths:
255
+ requirement_spec: specs/requirements.md
256
+ architecture_business: specs/architecture/biz.md
257
+ architecture_application: specs/architecture/app.md
258
+ ```
259
+
260
+ ## Supported Languages & Tech Stacks
261
+
262
+ | Language | Default Framework | Build Tool | Status |
263
+ |----------|------------------|------------|--------|
264
+ | Java 17+ | Spring Boot 3.x | Maven | ✅ |
265
+ | Python 3.12+ | FastAPI | uv | ✅ |
266
+ | Node.js | Express / NestJS | npm | ✅ |
267
+ | Go 1.22+ | chi / net/http | Go modules | ✅ |
268
+ | Rust (stable) | Axum | Cargo | ✅ |
269
+
270
+ Each language has its own DDD directory layout, coding standards, and anti-pattern rules embedded in the skill prompts.
271
+
272
+ ## How It Works
273
+
274
+ 1. **`sparrow init`** generates skill/command files into each AI tool's directory
275
+ 2. Each **skill** is a Markdown file with YAML frontmatter containing:
276
+ - Role definition (business architect, application architect, DDD expert, etc.)
277
+ - First principles and design rules
278
+ - Step-by-step instructions
279
+ - Output templates with Mermaid/PlantUML examples
280
+ - Quality checklists
281
+ 3. The **AI assistant** reads the skill and executes it, reading input files and writing output files
282
+ 4. Each skill **checks prerequisites** — if something is missing, it tells you which skill to run first
283
+ 5. After completing, each skill **hints at the next step**
284
+
285
+ **No multi-agent framework needed.** The AI coding assistant itself provides intelligence, multi-agent capabilities, and LLM configuration. Sparrow only provides the structured knowledge and process guidance.
286
+
287
+ ## Development
288
+
289
+ ```bash
290
+ # Install dependencies
291
+ npm install
292
+
293
+ # Build
294
+ npm run build
295
+
296
+ # Type check
297
+ npm run typecheck
298
+ # or: npx tsc --noEmit
299
+
300
+ # Run locally (dev mode)
301
+ npm run dev -- init --tools claude --force
302
+
303
+ # Run compiled binary
304
+ node bin/sparrow.js init --tools claude
305
+
306
+ # Clean build artifacts
307
+ npm run clean
308
+ ```
309
+
310
+ ## License
311
+
312
+ MIT
313
+
314
+ ---
315
+
316
+ ðŸŠķ *From business requirements to production code, one spec at a time.*