musubix 3.3.10 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/.github/AGENTS.md +949 -0
  2. package/.github/prompts/sdd-change-apply.prompt.md +283 -0
  3. package/.github/prompts/sdd-change-archive.prompt.md +241 -0
  4. package/.github/prompts/sdd-change-init.prompt.md +269 -0
  5. package/.github/prompts/sdd-design.prompt.md +250 -0
  6. package/.github/prompts/sdd-implement.prompt.md +387 -0
  7. package/.github/prompts/sdd-requirements.prompt.md +193 -0
  8. package/.github/prompts/sdd-review.prompt.md +155 -0
  9. package/.github/prompts/sdd-security.prompt.md +228 -0
  10. package/.github/prompts/sdd-steering.prompt.md +269 -0
  11. package/.github/prompts/sdd-tasks.prompt.md +255 -0
  12. package/.github/prompts/sdd-test.prompt.md +230 -0
  13. package/.github/prompts/sdd-validate.prompt.md +304 -0
  14. package/.github/skills/musubix-adr-generation/SKILL.md +209 -0
  15. package/.github/skills/musubix-best-practices/SKILL.md +315 -0
  16. package/.github/skills/musubix-c4-design/SKILL.md +162 -0
  17. package/.github/skills/musubix-code-generation/SKILL.md +237 -0
  18. package/.github/skills/musubix-domain-inference/SKILL.md +196 -0
  19. package/.github/skills/musubix-ears-validation/SKILL.md +161 -0
  20. package/.github/skills/musubix-sdd-workflow/SKILL.md +217 -0
  21. package/.github/skills/musubix-technical-writing/SKILL.md +444 -0
  22. package/.github/skills/musubix-test-generation/SKILL.md +212 -0
  23. package/.github/skills/musubix-traceability/SKILL.md +141 -0
  24. package/AGENTS.md +1134 -0
  25. package/LICENSE +21 -0
  26. package/README.ja.md +313 -0
  27. package/README.md +315 -50
  28. package/bin/musubix-mcp.js +15 -0
  29. package/bin/musubix.js +9 -1
  30. package/docs/API-REFERENCE.md +1425 -0
  31. package/docs/GITHUB-ACTIONS-NPM-SETUP.md +132 -0
  32. package/docs/INSTALL-GUIDE.ja.md +459 -0
  33. package/docs/INSTALL-GUIDE.md +459 -0
  34. package/docs/MIGRATION-v3.0.md +324 -0
  35. package/docs/MUSUBI-enhancement_roadmap_20260105.md +651 -0
  36. package/docs/MUSUBIX-v3.0-User-Guide.md +1357 -0
  37. package/docs/MUSUBIXv2.2.0-Manual-outline.md +136 -0
  38. package/docs/MUSUBIXv2.2.0-Manual.md +3123 -0
  39. package/docs/MUSUBIXv2.3.5-Refactering.md +1310 -0
  40. package/docs/MUSUBIv1.6.1-enhancement_roadmap_20260105.md +291 -0
  41. package/docs/MUSUBIv2.2.0-USERGUIDE.md +2079 -0
  42. package/docs/ROADMAP-v1.5.md +116 -0
  43. package/docs/SwarmCoding.md +1284 -0
  44. package/docs/Test-prompt.md +105 -0
  45. package/docs/USER-GUIDE-v1.8.0.md +2371 -0
  46. package/docs/USER-GUIDE.ja.md +2147 -0
  47. package/docs/USER-GUIDE.md +3022 -0
  48. package/docs/YATA-GLOBAL-GUIDE.ja.md +750 -0
  49. package/docs/YATA-GLOBAL-GUIDE.md +595 -0
  50. package/docs/YATA-LOCAL-GUIDE.ja.md +989 -0
  51. package/docs/YATA-LOCAL-GUIDE.md +730 -0
  52. package/docs/adr/0001-real-time-pattern-learning-architecture-for-v1-5-0.md +75 -0
  53. package/docs/adr/0002-pattern-sharing-protocol-for-cross-team-collaborat.md +79 -0
  54. package/docs/adr/0003-owl-2-rl-implementation-strategy-for-advanced-infe.md +90 -0
  55. package/docs/adr/ADR-v3.4.0-001-deep-research-architecture.md +217 -0
  56. package/docs/adr/ADR-v3.4.0-002-search-provider-selection.md +308 -0
  57. package/docs/adr/ADR-v3.4.0-003-lm-api-integration.md +475 -0
  58. package/docs/enterprise-knowledge-management.md +1737 -0
  59. package/docs/evolution-from-musubi-to-musubix.md +2170 -0
  60. package/docs/getting-started-with-sdd.md +1602 -0
  61. package/docs/moodle-refactering-codegraph-musubix.md +391 -0
  62. package/docs/moodle-refactering-codegraph.md +278 -0
  63. package/docs/overview/MUSUBIX-CodeGraph.md +322 -0
  64. package/docs/overview/MUSUBIX-Core.md +671 -0
  65. package/docs/overview/MUSUBIX-Decisions.md +494 -0
  66. package/docs/overview/MUSUBIX-FormalVerify.md +566 -0
  67. package/docs/overview/MUSUBIX-Knowledge.md +1231 -0
  68. package/docs/overview/MUSUBIX-Learning.md +837 -0
  69. package/docs/overview/MUSUBIX-MCP-Server.md +535 -0
  70. package/docs/overview/MUSUBIX-Overview.md +264 -0
  71. package/docs/overview/MUSUBIX-Phase1-Complete.md +271 -0
  72. package/docs/overview/MUSUBIX-Phase2-Complete.md +310 -0
  73. package/docs/overview/MUSUBIX-Policy.md +477 -0
  74. package/docs/overview/MUSUBIX-Roadmap-v2.md +399 -0
  75. package/docs/overview/MUSUBIX-Security-Plan.md +939 -0
  76. package/docs/overview/MUSUBIX-Security-v2.1.md +668 -0
  77. package/docs/overview/MUSUBIX-Security.md +891 -0
  78. package/docs/overview/MUSUBIX-YATA.md +666 -0
  79. package/docs/overview/MUSUBIX-v2.2.0-Advanced-Learning.md +513 -0
  80. package/docs/overview/Neuro-SymbolicAI.md +159 -0
  81. package/docs/packages/knowledge.md +594 -0
  82. package/docs/qiita-linux-kernel-knowledge-graph.md +596 -0
  83. package/package.json +55 -49
  84. package/scripts/generate-quality-gate-report.ts +106 -0
  85. package/scripts/postinstall.js +94 -0
  86. package/steering/.musubi-version +1 -0
  87. package/steering/product.ja.md +572 -0
  88. package/steering/project.yml +66 -0
  89. package/steering/rules/constitution.md +491 -0
  90. package/steering/structure.ja.md +503 -0
  91. package/steering/tech.ja.md +208 -0
  92. package/dist/index.d.ts +0 -25
  93. package/dist/index.d.ts.map +0 -1
  94. package/dist/index.js +0 -74
  95. package/dist/index.js.map +0 -1
@@ -0,0 +1,315 @@
1
+ ---
2
+ name: musubix-best-practices
3
+ description: Guide for applying MUSUBIX's 17 learned best practices. Use this when asked about coding patterns, design patterns, or testing patterns that MUSUBIX recommends.
4
+ license: MIT
5
+ ---
6
+
7
+ # MUSUBIX Best Practices Skill
8
+
9
+ This skill guides you through applying the 17 best practices learned from MUSUBIX virtual projects.
10
+
11
+ ## Overview
12
+
13
+ MUSUBIX has learned these best practices from implementing 14+ virtual projects. Apply them consistently for high-quality code.
14
+
15
+ ## Code Patterns (5)
16
+
17
+ ### BP-CODE-001: Entity Input DTO
18
+
19
+ Use Input DTO objects for entity creation instead of multiple parameters.
20
+
21
+ ```typescript
22
+ // ✅ Recommended: Input DTO
23
+ interface CreatePetInput {
24
+ name: string;
25
+ species: string;
26
+ ownerId: string;
27
+ }
28
+
29
+ function createPet(input: CreatePetInput): Pet {
30
+ return new Pet(input);
31
+ }
32
+
33
+ // ❌ Avoid: Multiple parameters
34
+ function createPet(name: string, species: string, ownerId: string): Pet {
35
+ // Hard to extend, easy to mix up parameter order
36
+ }
37
+ ```
38
+
39
+ ### BP-CODE-002: Date-based ID Format
40
+
41
+ Generate IDs with PREFIX-YYYYMMDD-NNN format for sortability.
42
+
43
+ ```typescript
44
+ // ✅ Recommended: Date-based ID
45
+ const id = `PET-20260104-001`; // Sortable, traceable
46
+
47
+ // ❌ Avoid: UUID only
48
+ const id = crypto.randomUUID(); // Not human-readable
49
+ ```
50
+
51
+ ### BP-CODE-003: Value Objects
52
+
53
+ Use Value Objects for domain concepts.
54
+
55
+ ```typescript
56
+ // ✅ Recommended: Value Object
57
+ interface Price {
58
+ readonly amount: number;
59
+ readonly currency: 'JPY';
60
+ }
61
+
62
+ // ❌ Avoid: Primitive types
63
+ const price: number = 1000; // No currency context
64
+ ```
65
+
66
+ ### BP-CODE-004: Function-based Value Objects
67
+
68
+ Use interface + factory function instead of classes for Value Objects.
69
+
70
+ ```typescript
71
+ // ✅ Recommended: Interface + Factory Function
72
+ interface Price {
73
+ readonly amount: number;
74
+ readonly currency: 'JPY';
75
+ }
76
+
77
+ function createPrice(amount: number): Result<Price, ValidationError> {
78
+ if (amount < 100 || amount > 1_000_000) {
79
+ return err(new ValidationError('Price must be between 100 and 1,000,000 JPY'));
80
+ }
81
+ return ok({ amount, currency: 'JPY' });
82
+ }
83
+
84
+ // ❌ Avoid: Class-based (doesn't work well with TypeScript structural typing)
85
+ class Price {
86
+ private constructor(readonly amount: number) {}
87
+ static create(amount: number): Price { ... }
88
+ }
89
+ ```
90
+
91
+ ### BP-CODE-005: Result Type
92
+
93
+ Use Result<T, E> for operations that can fail.
94
+
95
+ ```typescript
96
+ // ✅ Recommended: Result type
97
+ type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };
98
+
99
+ function divide(a: number, b: number): Result<number, Error> {
100
+ if (b === 0) return { ok: false, error: new Error('Division by zero') };
101
+ return { ok: true, value: a / b };
102
+ }
103
+
104
+ // ❌ Avoid: Throwing exceptions for expected errors
105
+ function divide(a: number, b: number): number {
106
+ if (b === 0) throw new Error('Division by zero');
107
+ return a / b;
108
+ }
109
+ ```
110
+
111
+ ## Design Patterns (7)
112
+
113
+ ### BP-DESIGN-001: Status Transition Map
114
+
115
+ Define valid status transitions in a Map.
116
+
117
+ ```typescript
118
+ // ✅ Recommended: Transition map
119
+ const validTransitions: Record<Status, Status[]> = {
120
+ draft: ['active', 'cancelled'],
121
+ active: ['completed', 'cancelled'],
122
+ completed: [],
123
+ cancelled: [],
124
+ };
125
+
126
+ function canTransition(from: Status, to: Status): boolean {
127
+ return validTransitions[from].includes(to);
128
+ }
129
+ ```
130
+
131
+ ### BP-DESIGN-002: Repository Async Pattern
132
+
133
+ Make repositories async for future DB migration.
134
+
135
+ ```typescript
136
+ // ✅ Recommended: Async repository
137
+ interface PetRepository {
138
+ findById(id: PetId): Promise<Pet | null>;
139
+ save(pet: Pet): Promise<void>;
140
+ }
141
+
142
+ // ❌ Avoid: Sync repository (hard to migrate later)
143
+ interface PetRepository {
144
+ findById(id: PetId): Pet | null;
145
+ }
146
+ ```
147
+
148
+ ### BP-DESIGN-003: Service Layer with DI
149
+
150
+ Use dependency injection for services.
151
+
152
+ ```typescript
153
+ // ✅ Recommended: Constructor DI
154
+ class PetService {
155
+ constructor(
156
+ private readonly petRepository: PetRepository,
157
+ private readonly auditService: AuditService
158
+ ) {}
159
+ }
160
+ ```
161
+
162
+ ### BP-DESIGN-004: Optimistic Locking
163
+
164
+ Use version field for concurrent edit detection.
165
+
166
+ ```typescript
167
+ // ✅ Recommended: Version field
168
+ interface Entity {
169
+ id: string;
170
+ version: number;
171
+ updatedAt: Date;
172
+ }
173
+
174
+ function update(entity: Entity, currentVersion: number): Result<Entity, ConcurrencyError> {
175
+ if (entity.version !== currentVersion) {
176
+ return err(new ConcurrencyError('Entity was modified'));
177
+ }
178
+ return ok({ ...entity, version: entity.version + 1 });
179
+ }
180
+ ```
181
+
182
+ ### BP-DESIGN-005: AuditService
183
+
184
+ Record data changes in audit logs.
185
+
186
+ ```typescript
187
+ // ✅ Recommended: Audit logging
188
+ interface AuditEntry {
189
+ id: string;
190
+ entityType: string;
191
+ entityId: string;
192
+ action: 'CREATE' | 'UPDATE' | 'DELETE';
193
+ changes: object;
194
+ userId: string;
195
+ timestamp: Date;
196
+ }
197
+ ```
198
+
199
+ ### BP-DESIGN-006: Entity Counter Reset
200
+
201
+ Provide reset functions for test isolation.
202
+
203
+ ```typescript
204
+ // ✅ Recommended: Resettable counter
205
+ let petCounter = 0;
206
+
207
+ export function generatePetId(): string {
208
+ return `PET-${Date.now()}-${++petCounter}`;
209
+ }
210
+
211
+ export function resetPetCounter(): void {
212
+ petCounter = 0; // For tests
213
+ }
214
+ ```
215
+
216
+ ### BP-DESIGN-007: Expiry Time Logic
217
+
218
+ Use expiresAt field for time-limited entities.
219
+
220
+ ```typescript
221
+ // ✅ Recommended: Explicit expiry
222
+ interface Reservation {
223
+ id: string;
224
+ createdAt: Date;
225
+ expiresAt: Date; // Explicit expiry time
226
+ }
227
+
228
+ function isExpired(reservation: Reservation): boolean {
229
+ return new Date() > reservation.expiresAt;
230
+ }
231
+ ```
232
+
233
+ ## Test Patterns (5)
234
+
235
+ ### BP-TEST-001: Test Counter Reset
236
+
237
+ Reset ID counters in beforeEach.
238
+
239
+ ```typescript
240
+ beforeEach(() => {
241
+ resetPetCounter();
242
+ resetReservationCounter();
243
+ });
244
+ ```
245
+
246
+ ### BP-TEST-002: Verify API Before Test
247
+
248
+ Check method signatures before writing tests.
249
+
250
+ ### BP-TEST-003: Vitest ESM Configuration
251
+
252
+ Use proper ESM setup for Vitest.
253
+
254
+ ```typescript
255
+ // vitest.config.ts
256
+ export default defineConfig({
257
+ test: {
258
+ globals: true,
259
+ environment: 'node',
260
+ },
261
+ });
262
+ ```
263
+
264
+ ### BP-TEST-004: Result Type Test Pattern
265
+
266
+ Test both success and error cases.
267
+
268
+ ```typescript
269
+ it('should succeed with valid input', () => {
270
+ const result = createPrice(1000);
271
+ expect(result.isOk()).toBe(true);
272
+ });
273
+
274
+ it('should fail with invalid input', () => {
275
+ const result = createPrice(-1);
276
+ expect(result.isErr()).toBe(true);
277
+ });
278
+ ```
279
+
280
+ ### BP-TEST-005: Status Transition Testing
281
+
282
+ Test all valid and invalid transitions.
283
+
284
+ ```typescript
285
+ describe('status transitions', () => {
286
+ it.each([
287
+ ['draft', 'active', true],
288
+ ['draft', 'completed', false],
289
+ ['active', 'completed', true],
290
+ ])('%s -> %s should be %s', (from, to, valid) => {
291
+ expect(canTransition(from, to)).toBe(valid);
292
+ });
293
+ });
294
+ ```
295
+
296
+ ## CLI Commands
297
+
298
+ ```bash
299
+ # Show all best practices
300
+ npx musubix learn best-practices
301
+
302
+ # Filter by category
303
+ npx musubix learn best-practices --category code
304
+ npx musubix learn best-practices --category design
305
+ npx musubix learn best-practices --category test
306
+
307
+ # High confidence only
308
+ npx musubix learn best-practices --high-confidence
309
+ ```
310
+
311
+ ## Related Skills
312
+
313
+ - `musubix-code-generation` - Apply patterns in code
314
+ - `musubix-test-generation` - Apply test patterns
315
+ - `musubix-sdd-workflow` - Full workflow with patterns
@@ -0,0 +1,162 @@
1
+ ---
2
+ name: musubix-c4-design
3
+ description: Guide for creating C4 model design documents. Use this when asked to create architecture designs, system context diagrams, container diagrams, or component diagrams following the C4 model methodology.
4
+ license: MIT
5
+ ---
6
+
7
+ # MUSUBIX C4 Design Skill
8
+
9
+ This skill guides you through creating C4 model architecture designs for MUSUBIX projects.
10
+
11
+ ## Overview
12
+
13
+ The C4 model provides four levels of abstraction for describing software architecture:
14
+
15
+ 1. **Context** - System boundaries and external actors
16
+ 2. **Container** - Technology choices and deployable units
17
+ 3. **Component** - Internal structure of containers
18
+ 4. **Code** - Implementation details (optional)
19
+
20
+ ## Prerequisites
21
+
22
+ Before creating designs:
23
+
24
+ 1. Read requirements from `storage/specs/` (REQ-* files)
25
+ 2. Check `steering/structure.ja.md` for architecture guidelines
26
+ 3. Review `steering/tech.ja.md` for technology constraints
27
+
28
+ ## Design Document Template
29
+
30
+ ```markdown
31
+ # DES-[CATEGORY]-[NUMBER]: [Design Title]
32
+
33
+ ## メタデータ
34
+ - **作成日**: YYYY-MM-DD
35
+ - **トレーサビリティ**: REQ-XXX-NNN
36
+
37
+ ## 1. Context Level
38
+
39
+ ### システムコンテキスト図
40
+ [External actors and systems that interact with our system]
41
+
42
+ ### 外部アクター
43
+ | アクター | 説明 | インタラクション |
44
+ |---------|------|-----------------|
45
+ | User | システム利用者 | Web UI経由でアクセス |
46
+
47
+ ## 2. Container Level
48
+
49
+ ### コンテナ構成
50
+ | コンテナ | 技術 | 責務 |
51
+ |---------|------|------|
52
+ | Web App | React/Next.js | UI提供 |
53
+ | API Server | Node.js/Express | ビジネスロジック |
54
+ | Database | PostgreSQL | データ永続化 |
55
+
56
+ ### コンテナ間通信
57
+ [Describe how containers communicate]
58
+
59
+ ## 3. Component Level
60
+
61
+ ### [Container Name] コンポーネント
62
+
63
+ | コンポーネント | 種別 | 責務 | 依存先 |
64
+ |---------------|------|------|--------|
65
+ | XxxService | Service | ビジネスロジック | XxxRepository |
66
+ | XxxRepository | Repository | データアクセス | Database |
67
+ | XxxController | Controller | リクエスト処理 | XxxService |
68
+
69
+ ## 4. 設計パターン
70
+
71
+ ### 適用パターン
72
+ | パターン | 適用箇所 | 理由 |
73
+ |---------|---------|------|
74
+ | Repository | データアクセス層 | 永続化の抽象化 |
75
+ | Service | ビジネス層 | ロジックの集約 |
76
+ | Factory | オブジェクト生成 | 生成ロジックの分離 |
77
+
78
+ ## 5. 非機能要件への対応
79
+
80
+ ### セキュリティ
81
+ - 認証: [方式]
82
+ - 認可: [方式]
83
+ - データ保護: [方式]
84
+
85
+ ### スケーラビリティ
86
+ - [スケーリング戦略]
87
+
88
+ ### 可用性
89
+ - [可用性設計]
90
+ ```
91
+
92
+ ## C4 Diagram Syntax (Mermaid)
93
+
94
+ ### Context Diagram
95
+ ```mermaid
96
+ flowchart TB
97
+ subgraph External["外部システム"]
98
+ User[ユーザー]
99
+ ExtAPI[外部API]
100
+ end
101
+
102
+ subgraph System["対象システム"]
103
+ App[アプリケーション]
104
+ end
105
+
106
+ User --> App
107
+ App --> ExtAPI
108
+ ```
109
+
110
+ ### Container Diagram
111
+ ```mermaid
112
+ flowchart TB
113
+ subgraph Containers["コンテナ構成"]
114
+ Web[Web App<br/>React]
115
+ API[API Server<br/>Node.js]
116
+ DB[(Database<br/>PostgreSQL)]
117
+ end
118
+
119
+ Web --> API
120
+ API --> DB
121
+ ```
122
+
123
+ ### Component Diagram
124
+ ```mermaid
125
+ flowchart TB
126
+ subgraph APIServer["API Server"]
127
+ Controller[Controller]
128
+ Service[Service]
129
+ Repository[Repository]
130
+ end
131
+
132
+ Controller --> Service
133
+ Service --> Repository
134
+ ```
135
+
136
+ ## Design Patterns Reference
137
+
138
+ | パターン | 用途 | 適用場面 |
139
+ |---------|------|---------|
140
+ | **Repository** | データアクセス抽象化 | DB操作 |
141
+ | **Service** | ビジネスロジック集約 | ユースケース実装 |
142
+ | **Factory** | オブジェクト生成 | 複雑な生成ロジック |
143
+ | **Strategy** | アルゴリズム切替 | 認証方式、計算方式 |
144
+ | **Observer** | イベント通知 | 状態変更の伝播 |
145
+ | **Decorator** | 機能追加 | ログ、キャッシュ |
146
+
147
+ ## Domain-Specific Components
148
+
149
+ Use `npx musubix design generate` to get domain-specific component recommendations for 62 domains.
150
+
151
+ ## Output Location
152
+
153
+ Save design documents to:
154
+ ```
155
+ storage/design/DES-[CATEGORY]-[NUMBER].md
156
+ ```
157
+
158
+ ## Related Skills
159
+
160
+ - `musubix-ears-validation` - Requirements validation
161
+ - `musubix-code-generation` - Generate code from design
162
+ - `musubix-adr-generation` - Document architecture decisions
@@ -0,0 +1,237 @@
1
+ ---
2
+ name: musubix-code-generation
3
+ description: Guide for generating code from design specifications using MUSUBIX. Use this when asked to generate code, implement features, or create components following design documents.
4
+ license: MIT
5
+ ---
6
+
7
+ # MUSUBIX Code Generation Skill
8
+
9
+ This skill guides you through generating code from design specifications following MUSUBIX methodology.
10
+
11
+ ## Prerequisites
12
+
13
+ Before generating code:
14
+
15
+ 1. Verify design document exists (`DES-*`)
16
+ 2. Verify requirements are traceable (`REQ-*`)
17
+ 3. Check `steering/tech.ja.md` for technology stack
18
+
19
+ ## Supported Languages
20
+
21
+ | Language | Extension | Features |
22
+ |----------|-----------|----------|
23
+ | TypeScript | `.ts` | Full support with types |
24
+ | JavaScript | `.js` | ES6+ modules |
25
+ | Python | `.py` | Type hints support |
26
+ | Java | `.java` | Interface/Class generation |
27
+ | Go | `.go` | Struct/Interface generation |
28
+ | Rust | `.rs` | Trait/Struct generation |
29
+ | C# | `.cs` | Interface/Class generation |
30
+
31
+ ## Code Generation Workflow
32
+
33
+ ### Step 1: Read Design Document
34
+
35
+ ```bash
36
+ # Generate code from design
37
+ npx musubix codegen generate <design-file>
38
+ ```
39
+
40
+ ### Step 2: Generate with Traceability
41
+
42
+ Always include requirement references:
43
+
44
+ ```typescript
45
+ /**
46
+ * UserService - Handles user operations
47
+ *
48
+ * @see REQ-INT-001 - Neuro-Symbolic Integration
49
+ * @see DES-INT-001 - Integration Layer Design
50
+ */
51
+ export class UserService {
52
+ // Implementation
53
+ }
54
+ ```
55
+
56
+ ### Step 3: Follow Test-First (Article III)
57
+
58
+ 1. **Write test first**:
59
+ ```typescript
60
+ describe('UserService', () => {
61
+ it('should create user', async () => {
62
+ const service = new UserService();
63
+ const user = await service.create({ name: 'Test' });
64
+ expect(user.id).toBeDefined();
65
+ });
66
+ });
67
+ ```
68
+
69
+ 2. **Implement minimal code**:
70
+ ```typescript
71
+ export class UserService {
72
+ async create(data: CreateUserDto): Promise<User> {
73
+ return { id: generateId(), ...data };
74
+ }
75
+ }
76
+ ```
77
+
78
+ 3. **Refactor**
79
+
80
+ ## Design Pattern Templates
81
+
82
+ ### Singleton Pattern
83
+ ```typescript
84
+ /**
85
+ * @see REQ-DES-001 - Pattern Detection
86
+ * @pattern Singleton
87
+ */
88
+ export class ConfigManager {
89
+ private static instance: ConfigManager;
90
+
91
+ private constructor() {}
92
+
93
+ static getInstance(): ConfigManager {
94
+ if (!ConfigManager.instance) {
95
+ ConfigManager.instance = new ConfigManager();
96
+ }
97
+ return ConfigManager.instance;
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### Factory Pattern
103
+ ```typescript
104
+ /**
105
+ * @see REQ-DES-001 - Pattern Detection
106
+ * @pattern Factory
107
+ */
108
+ export interface ServiceFactory {
109
+ create(type: string): Service;
110
+ }
111
+
112
+ export class DefaultServiceFactory implements ServiceFactory {
113
+ create(type: string): Service {
114
+ switch (type) {
115
+ case 'auth': return new AuthService();
116
+ case 'user': return new UserService();
117
+ default: throw new Error(`Unknown service: ${type}`);
118
+ }
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Repository Pattern
124
+ ```typescript
125
+ /**
126
+ * @see REQ-COD-001 - Code Generation
127
+ * @pattern Repository
128
+ */
129
+ export interface Repository<T> {
130
+ findById(id: string): Promise<T | null>;
131
+ findAll(): Promise<T[]>;
132
+ save(entity: T): Promise<T>;
133
+ delete(id: string): Promise<void>;
134
+ }
135
+
136
+ export class UserRepository implements Repository<User> {
137
+ async findById(id: string): Promise<User | null> {
138
+ // Implementation
139
+ }
140
+ // ... other methods
141
+ }
142
+ ```
143
+
144
+ ## CLI Commands
145
+
146
+ ```bash
147
+ # Generate code from design
148
+ npx musubix codegen generate <design-file>
149
+
150
+ # Generate status transition code (v3.1.0)
151
+ npx musubix codegen status <spec>
152
+ npx musubix codegen status <spec> --enum # Use enum type
153
+
154
+ # Analyze existing code
155
+ npx musubix codegen analyze <file>
156
+
157
+ # Security scan
158
+ npx musubix codegen security <path>
159
+
160
+ # Scaffold with Value Objects and Status machines (v3.1.0)
161
+ npx musubix scaffold domain-model <name> -v "Price,Email"
162
+ npx musubix scaffold domain-model <name> -s "Order,Task"
163
+ ```
164
+
165
+ ## Quality Checks (Article IX)
166
+
167
+ Before committing code:
168
+
169
+ - [ ] **Type Safety**: No `any` types (TypeScript)
170
+ - [ ] **Traceability**: All classes/functions have `@see` references
171
+ - [ ] **Tests**: Test coverage ≥ 80%
172
+ - [ ] **Linting**: `npm run lint` passes
173
+ - [ ] **Build**: `npm run build` succeeds
174
+
175
+ ## Neuro-Symbolic Integration (REQ-INT-002)
176
+
177
+ When generating code that involves decision-making:
178
+
179
+ ```typescript
180
+ /**
181
+ * @see REQ-INT-002 - Confidence Evaluation
182
+ */
183
+ async function integrateResults(
184
+ neuralResult: NeuralResult,
185
+ symbolicResult: SymbolicResult
186
+ ): Promise<FinalResult> {
187
+ // Decision rules from REQ-INT-002
188
+ if (symbolicResult.status === 'invalid') {
189
+ return rejectNeural(neuralResult);
190
+ }
191
+
192
+ if (neuralResult.confidence >= 0.8) {
193
+ return adoptNeural(neuralResult);
194
+ }
195
+
196
+ return prioritizeSymbolic(symbolicResult);
197
+ }
198
+ ```
199
+
200
+ ## File Structure Convention
201
+
202
+ ```
203
+ packages/
204
+ ├── core/
205
+ │ └── src/
206
+ │ ├── [feature]/
207
+ │ │ ├── index.ts # Public exports
208
+ │ │ ├── [feature].ts # Main implementation
209
+ │ │ ├── types.ts # Type definitions
210
+ │ │ └── __tests__/ # Tests
211
+ │ └── index.ts # Package exports
212
+ ```
213
+
214
+ ## Error Handling Pattern
215
+
216
+ ```typescript
217
+ /**
218
+ * @see REQ-ERR-001 - Graceful Degradation
219
+ */
220
+ export class MuSubixError extends Error {
221
+ constructor(
222
+ message: string,
223
+ public code: string,
224
+ public recoverable: boolean = true
225
+ ) {
226
+ super(message);
227
+ this.name = 'MuSubixError';
228
+ }
229
+ }
230
+
231
+ // Usage
232
+ throw new MuSubixError(
233
+ 'Failed to connect to YATA',
234
+ 'YATA_CONNECTION_ERROR',
235
+ true // Can retry
236
+ );
237
+ ```