musubix 3.6.1 → 3.7.3

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 (36) hide show
  1. package/.github/skills/build-fix/SKILL.md +124 -0
  2. package/.github/skills/checkpoint/SKILL.md +131 -0
  3. package/.github/skills/codemap/SKILL.md +120 -0
  4. package/.github/skills/codemap/templates/codemap-index.md +142 -0
  5. package/.github/skills/codemap/templates/package-codemap.md +160 -0
  6. package/.github/skills/context-optimizer/SKILL.md +109 -0
  7. package/.github/skills/context-optimizer/contexts/dev.md +40 -0
  8. package/.github/skills/context-optimizer/contexts/research.md +55 -0
  9. package/.github/skills/context-optimizer/contexts/review.md +49 -0
  10. package/.github/skills/e2e-runner/SKILL.md +145 -0
  11. package/.github/skills/eval-harness/SKILL.md +111 -0
  12. package/.github/skills/eval-harness/examples/capability-eval.md +158 -0
  13. package/.github/skills/eval-harness/examples/human-grader-template.md +326 -0
  14. package/.github/skills/eval-harness/examples/regression-eval.md +228 -0
  15. package/.github/skills/learning-hooks/SKILL.md +101 -0
  16. package/.github/skills/learning-hooks/templates/learned-skill-template.md +79 -0
  17. package/.github/skills/musubix-adr-generation/SKILL.md +33 -168
  18. package/.github/skills/musubix-best-practices/SKILL.md +46 -276
  19. package/.github/skills/musubix-c4-design/SKILL.md +48 -124
  20. package/.github/skills/musubix-code-generation/SKILL.md +46 -193
  21. package/.github/skills/musubix-domain-inference/SKILL.md +54 -168
  22. package/.github/skills/musubix-ears-validation/SKILL.md +49 -136
  23. package/.github/skills/musubix-sdd-workflow/SKILL.md +56 -178
  24. package/.github/skills/musubix-technical-writing/SKILL.md +45 -381
  25. package/.github/skills/musubix-test-generation/SKILL.md +52 -176
  26. package/.github/skills/musubix-traceability/SKILL.md +52 -99
  27. package/.github/skills/refactor-cleaner/SKILL.md +105 -0
  28. package/.github/skills/session-manager/SKILL.md +119 -0
  29. package/.github/skills/session-manager/scripts/session-end.sh +175 -0
  30. package/.github/skills/session-manager/scripts/session-start.sh +87 -0
  31. package/.github/skills/verification-loop/SKILL.md +111 -0
  32. package/.github/skills/verification-loop/scripts/verify.sh +305 -0
  33. package/AGENTS.md +231 -1034
  34. package/docs/CODEMAPS/CODEMAP.md +1 -0
  35. package/docs/adr/ADR-v3.7.0-001-everything-claude-code-integration.md +102 -0
  36. package/package.json +2 -2
@@ -1,212 +1,88 @@
1
1
  ---
2
2
  name: musubix-test-generation
3
- description: Guide for generating test code from designs and requirements. Use this when asked to create unit tests, integration tests, or test coverage analysis following TDD/BDD practices.
3
+ description: テストコード生成ガイド。TDD/BDDによるユニット・統合テスト作成に使用。
4
4
  license: MIT
5
5
  ---
6
6
 
7
- # MUSUBIX Test Generation Skill
7
+ # Test Generation Skill
8
8
 
9
- This skill guides you through generating comprehensive test suites that maintain traceability.
9
+ **Article III - Test-First**: Red-Green-Blue TDDサイクルでテストを生成。
10
10
 
11
- ## Overview
11
+ ## TDD Cycle
12
12
 
13
- MUSUBIX follows **Article III - Test-First**: Red-Green-Blue TDD cycle.
14
-
15
- ```mermaid
16
- flowchart LR
17
- RED[🔴 Red<br/>Failing Test] --> GREEN[🟢 Green<br/>Minimal Code]
18
- GREEN --> BLUE[🔵 Blue<br/>Refactor]
19
- BLUE --> RED
13
+ ```
14
+ 🔴 Red (Failing Test) → 🟢 Green (Minimal Code) → 🔵 Blue (Refactor)
20
15
  ```
21
16
 
22
- ## Test Structure
17
+ ## Test Categories
23
18
 
24
- ### Unit Test Template
19
+ | カテゴリ | 目的 | 場所 |
20
+ |---------|------|------|
21
+ | Unit | 単一コンポーネント | `__tests__/unit/` |
22
+ | Integration | 複数コンポーネント連携 | `__tests__/integration/` |
23
+ | E2E | フルユーザーフロー | `__tests__/e2e/` |
25
24
 
26
- ```typescript
27
- /**
28
- * @requirement REQ-XXX-NNN
29
- * @design DES-XXX-NNN
30
- */
31
- import { describe, it, expect, beforeEach } from 'vitest';
32
- import { XxxService } from './xxx-service.js';
33
- import { resetXxxCounter } from './xxx-entity.js';
25
+ ## WHEN → DO
34
26
 
35
- describe('XxxService', () => {
36
- let service: XxxService;
37
- let repository: MockXxxRepository;
27
+ | WHEN | DO |
28
+ |------|-----|
29
+ | 機能実装前 | テストを先に書く(Red) |
30
+ | テスト失敗 | 最小限のコードで通す(Green) |
31
+ | テスト成功 | リファクタリング(Blue) |
38
32
 
39
- beforeEach(() => {
40
- // BP-TEST-001: Reset counters before each test
41
- resetXxxCounter();
42
- repository = new MockXxxRepository();
43
- service = new XxxService(repository);
44
- });
45
-
46
- describe('create', () => {
47
- it('should create entity with valid input', async () => {
48
- // Arrange
49
- const input = { name: 'Test', value: 100 };
50
-
51
- // Act
52
- const result = await service.create(input);
53
-
54
- // Assert
55
- expect(result.isOk()).toBe(true);
56
- if (result.isOk()) {
57
- expect(result.value.name).toBe('Test');
58
- }
59
- });
60
-
61
- it('should return error for invalid input', async () => {
62
- // Arrange
63
- const input = { name: '', value: -1 };
64
-
65
- // Act
66
- const result = await service.create(input);
67
-
68
- // Assert
69
- expect(result.isErr()).toBe(true);
70
- });
71
- });
72
- });
73
- ```
74
-
75
- ### Integration Test Template
33
+ ## Test Template
76
34
 
77
35
  ```typescript
78
36
  /**
79
37
  * @requirement REQ-XXX-NNN
80
38
  * @design DES-XXX-NNN
81
39
  */
82
- import { describe, it, expect, beforeAll, afterAll } from 'vitest';
83
-
84
- describe('XxxService Integration', () => {
85
- beforeAll(async () => {
86
- // Setup test environment
40
+ describe('XxxService', () => {
41
+ let service: XxxService;
42
+
43
+ beforeEach(() => {
44
+ resetXxxCounter(); // BP-TEST-001
45
+ service = new XxxService(new MockRepository());
87
46
  });
88
47
 
89
- afterAll(async () => {
90
- // Cleanup
48
+ it('should create entity with valid input', async () => {
49
+ const result = await service.create({ name: 'Test' });
50
+ expect(result.isOk()).toBe(true);
91
51
  });
92
52
 
93
- it('should complete full workflow', async () => {
94
- // Test full user journey
53
+ it('should return error for invalid input', async () => {
54
+ const result = await service.create({ name: '' });
55
+ expect(result.isErr()).toBe(true);
95
56
  });
96
57
  });
97
58
  ```
98
59
 
99
- ## Best Practices for Testing
100
-
101
- ### BP-TEST-001: Test Counter Reset
102
-
103
- ```typescript
104
- beforeEach(() => {
105
- resetPetCounter(); // Reset ID counters
106
- resetReservationCounter();
107
- });
108
- ```
109
-
110
- ### BP-TEST-002: Verify API Before Test
60
+ ## Best Practices
111
61
 
112
- ```typescript
113
- // ✅ Check actual API signature first
114
- const service = new PetService(repository);
115
- // Verify method exists and parameters match
116
- ```
62
+ | ID | パターン | 内容 |
63
+ |----|---------|------|
64
+ | BP-TEST-001 | Counter Reset | beforeEachでIDカウンターリセット |
65
+ | BP-TEST-004 | Result Type | isOk()/isErr()で両ケーステスト |
66
+ | BP-TEST-005 | Status Transition | 有効・無効遷移を網羅 |
117
67
 
118
- ### BP-TEST-004: Result Type Test Pattern
119
-
120
- ```typescript
121
- // ✅ Test both success and failure cases
122
- it('should handle success', async () => {
123
- const result = await service.create(validInput);
124
- expect(result.isOk()).toBe(true);
125
- if (result.isOk()) {
126
- expect(result.value.id).toBeDefined();
127
- }
128
- });
129
-
130
- it('should handle failure', async () => {
131
- const result = await service.create(invalidInput);
132
- expect(result.isErr()).toBe(true);
133
- if (result.isErr()) {
134
- expect(result.error.message).toContain('validation');
135
- }
136
- });
137
- ```
138
-
139
- ### BP-TEST-005: Status Transition Testing
140
-
141
- ```typescript
142
- describe('status transitions', () => {
143
- // Valid transitions
144
- it('should allow draft -> active', () => {
145
- const result = workflow.transition('draft', 'activate');
146
- expect(result).toBe('active');
147
- });
148
-
149
- // Invalid transitions
150
- it('should reject completed -> draft', () => {
151
- expect(() => workflow.transition('completed', 'revert'))
152
- .toThrow('Invalid transition');
153
- });
154
- });
155
- ```
156
-
157
- ## Test Categories
158
-
159
- | Category | Purpose | Location |
160
- |----------|---------|----------|
161
- | Unit | Single component | `__tests__/unit/` |
162
- | Integration | Multiple components | `__tests__/integration/` |
163
- | E2E | Full user flows | `__tests__/e2e/` |
164
-
165
- ## CLI Commands
68
+ ## CLI
166
69
 
167
70
  ```bash
168
- # Generate tests from design
169
- npx musubix test generate storage/design/DES-XXX.md
170
-
171
- # Run all tests
172
- npm test
173
-
174
- # Coverage report
175
- npx musubix test coverage src/
176
-
177
- # Run specific test file
178
- npm test -- xxx.test.ts
71
+ npx musubix test generate <design-file> # テスト生成
72
+ npm test # 全テスト実行
73
+ npx musubix test coverage src/ # カバレッジ計測
179
74
  ```
180
75
 
181
- ## Vitest Configuration
76
+ ## 出力例
182
77
 
183
- ```typescript
184
- // vitest.config.ts
185
- import { defineConfig } from 'vitest/config';
186
-
187
- export default defineConfig({
188
- test: {
189
- globals: true,
190
- environment: 'node',
191
- include: ['**/*.test.ts'],
192
- coverage: {
193
- provider: 'v8',
194
- reporter: ['text', 'json', 'html'],
195
- },
196
- },
197
- });
198
78
  ```
199
-
200
- ## Coverage Targets
201
-
202
- | Metric | Target |
203
- |--------|--------|
204
- | Line Coverage | ≥80% |
205
- | Branch Coverage | ≥75% |
206
- | Function Coverage | ≥90% |
207
-
208
- ## Related Skills
209
-
210
- - `musubix-sdd-workflow` - Full SDD workflow with TDD
211
- - `musubix-code-generation` - Generate code to test
212
- - `musubix-traceability` - Link tests to requirements
79
+ ┌─────────────────────────────────────────┐
80
+ Test Generation Result │
81
+ ├─────────────────────────────────────────┤
82
+ Source: DES-AUTH-001 │
83
+ │ Unit Tests: 8 generated │
84
+ Coverage: @requirement tags added │
85
+ Patterns: BP-TEST-001, 004, 005 │
86
+ Status: Ready for TDD cycle │
87
+ └─────────────────────────────────────────┘
88
+ ```
@@ -1,50 +1,40 @@
1
1
  ---
2
2
  name: musubix-traceability
3
- description: Guide for managing traceability between requirements, designs, code, and tests. Use this when asked to verify traceability, create traceability matrices, or perform impact analysis.
3
+ description: 要件・設計・コード・テスト間のトレーサビリティ管理ガイド。影響分析・マトリクス作成に使用。
4
4
  license: MIT
5
5
  ---
6
6
 
7
- # MUSUBIX Traceability Skill
7
+ # Traceability Skill
8
8
 
9
- This skill guides you through maintaining full traceability across the development lifecycle.
9
+ **Article V - Traceability**: 100%双方向トレーサビリティを維持。
10
10
 
11
- ## Overview
12
-
13
- MUSUBIX enforces **Article V - Traceability**: Complete bidirectional tracing between:
11
+ ## Traceability Chain
14
12
 
15
13
  ```
16
- Requirements (REQ-*)Design (DES-*)Tasks (TSK-*) ↔ Code ↔ Tests
14
+ REQ-* ↔ DES-* ↔ TSK-* ↔ Code ↔ Tests
17
15
  ```
18
16
 
19
- ## Traceability Matrix
17
+ ## WHEN → DO
20
18
 
21
- ### Creating a Traceability Matrix
19
+ | WHEN | DO |
20
+ |------|-----|
21
+ | 要件作成 | REQ-* IDを付与 |
22
+ | 設計作成 | DES-* IDを付与、REQ-*に紐付け |
23
+ | タスク作成 | TSK-* IDを付与、DES-*・REQ-*に紐付け |
24
+ | コード作成 | @requirement, @design タグ追加 |
25
+ | テスト作成 | @requirement, @design タグ追加 |
26
+ | 要件変更 | 影響分析を実施 |
22
27
 
23
- ```markdown
24
- # Traceability Matrix
28
+ ## Traceability Matrix
25
29
 
30
+ ```markdown
26
31
  | 要件ID | 設計ID | タスクID | コード | テスト |
27
32
  |--------|--------|---------|--------|--------|
28
- | REQ-AUTH-001 | DES-AUTH-001 | TSK-001 | src/auth/auth-service.ts | auth.test.ts |
29
- | REQ-AUTH-002 | DES-AUTH-001 | TSK-002 | src/auth/token-manager.ts | token.test.ts |
30
- ```
31
-
32
- ### CLI Commands
33
-
34
- ```bash
35
- # Generate traceability matrix
36
- npx musubix trace matrix
37
-
38
- # Impact analysis for a specific requirement
39
- npx musubix trace impact REQ-AUTH-001
40
-
41
- # Validate all traceability links
42
- npx musubix trace validate
33
+ | REQ-AUTH-001 | DES-AUTH-001 | TSK-001 | auth-service.ts | auth.test.ts |
34
+ | REQ-AUTH-002 | DES-AUTH-001 | TSK-002 | token-manager.ts | token.test.ts |
43
35
  ```
44
36
 
45
- ## Traceability in Code
46
-
47
- ### Adding Traceability Comments
37
+ ## Code Traceability
48
38
 
49
39
  ```typescript
50
40
  /**
@@ -53,89 +43,52 @@ npx musubix trace validate
53
43
  * @design DES-AUTH-001
54
44
  * @task TSK-001
55
45
  */
56
- export class AuthService {
57
- /**
58
- * ユーザー認証
59
- * @requirement REQ-AUTH-001
60
- */
61
- async authenticate(credentials: Credentials): Promise<Result<Token, AuthError>> {
62
- // Implementation
63
- }
64
- }
65
- ```
66
-
67
- ### Test Traceability
68
-
69
- ```typescript
70
- /**
71
- * @requirement REQ-AUTH-001
72
- * @design DES-AUTH-001
73
- */
74
- describe('AuthService', () => {
75
- describe('authenticate', () => {
76
- it('should return token for valid credentials', async () => {
77
- // Test implementation
78
- });
79
- });
80
- });
46
+ export class AuthService { ... }
81
47
  ```
82
48
 
83
49
  ## Impact Analysis
84
50
 
85
- When a requirement changes, identify all affected artifacts:
86
-
87
- ```mermaid
88
- flowchart LR
89
- REQ[REQ-AUTH-001<br/>変更] --> DES[DES-AUTH-001<br/>設計]
90
- DES --> TSK1[TSK-001<br/>タスク]
91
- DES --> TSK2[TSK-002<br/>タスク]
92
- TSK1 --> CODE1[auth-service.ts]
93
- TSK2 --> CODE2[token-manager.ts]
94
- CODE1 --> TEST1[auth.test.ts]
95
- CODE2 --> TEST2[token.test.ts]
96
- ```
97
-
98
- ### Impact Analysis Steps
99
-
100
- 1. Identify changed requirement (REQ-*)
101
- 2. Find linked designs (DES-*)
102
- 3. Find linked tasks (TSK-*)
103
- 4. Locate affected code files
104
- 5. Identify tests to update
105
- 6. Update all artifacts
106
-
107
- ## Traceability Storage
51
+ 要件変更時の影響範囲特定:
108
52
 
109
53
  ```
110
- storage/traceability/
111
- ├── matrix.json # Full traceability matrix
112
- ├── requirements-map.json # REQ -> DES mappings
113
- ├── design-map.json # DES -> TSK mappings
114
- └── code-map.json # TSK -> Code mappings
54
+ REQ-AUTH-001 変更
55
+
56
+ DES-AUTH-001 (設計)
57
+
58
+ TSK-001, TSK-002 (タスク)
59
+
60
+ auth-service.ts, token-manager.ts (コード)
61
+
62
+ auth.test.ts, token.test.ts (テスト)
115
63
  ```
116
64
 
117
65
  ## Verification Checklist
118
66
 
119
- Before completing any feature:
67
+ - [ ] 全要件に設計がリンク
68
+ - [ ] 全設計にタスクがリンク
69
+ - [ ] 全コードにトレーサビリティコメント
70
+ - [ ] 全テストに@requirementタグ
120
71
 
121
- - [ ] All requirements have linked designs
122
- - [ ] All designs have linked tasks
123
- - [ ] All tasks have linked code
124
- - [ ] All code has linked tests
125
- - [ ] Traceability comments in code
126
- - [ ] Matrix updated
72
+ ## CLI
127
73
 
128
- ## MCP Tool
74
+ ```bash
75
+ npx musubix trace matrix # マトリクス生成
76
+ npx musubix trace impact REQ-* # 影響分析
77
+ npx musubix trace validate # リンク検証
78
+ npx musubix trace sync # 自動更新
79
+ ```
129
80
 
130
- Use MCP tool for automated validation:
81
+ ## 出力例
131
82
 
132
83
  ```
133
- Tool: sdd_validate_traceability
134
- Description: Validates bidirectional traceability across all artifacts
84
+ ┌─────────────────────────────────────────┐
85
+ Traceability Report │
86
+ ├─────────────────────────────────────────┤
87
+ │ Requirements: 5 (100% linked) │
88
+ │ Designs: 3 (100% linked) │
89
+ │ Tasks: 8 (100% linked) │
90
+ │ Code Files: 12 (100% tagged) │
91
+ │ Test Files: 12 (100% tagged) │
92
+ │ Coverage: 100% │
93
+ └─────────────────────────────────────────┘
135
94
  ```
136
-
137
- ## Related Skills
138
-
139
- - `musubix-sdd-workflow` - Full SDD workflow
140
- - `musubix-ears-validation` - Requirements validation
141
- - `musubix-test-generation` - Generate tests with traceability
@@ -0,0 +1,105 @@
1
+ ---
2
+ name: refactor-cleaner
3
+ description: デッドコード検出・安全な削除。knip/depcheck/ts-pruneと連携。
4
+ license: MIT
5
+ version: 1.1.0
6
+ triggers:
7
+ - /refactor
8
+ - /cleanup
9
+ - /deadcode
10
+ ---
11
+
12
+ # Refactor Cleaner
13
+
14
+ > **要約**: デッドコードを検出し、安全に削除。すべての削除操作をログに記録。
15
+
16
+ ## 📌 コマンド
17
+
18
+ | コマンド | 説明 |
19
+ |---------|------|
20
+ | `/refactor analyze` | デッドコード検出 |
21
+ | `/refactor clean [--safe-only]` | 安全な削除 |
22
+ | `/refactor report` | レポート表示 |
23
+
24
+ ---
25
+
26
+ ## 🔍 検出ツール (REQ-RC-001)
27
+
28
+ | ツール | 検出内容 | コマンド |
29
+ |--------|---------|---------|
30
+ | **knip** | 未使用ファイル/エクスポート/依存 | `npx knip` |
31
+ | **depcheck** | 未使用npm依存 | `npx depcheck` |
32
+ | **ts-prune** | 未使用TSエクスポート | `npx ts-prune` |
33
+
34
+ ---
35
+
36
+ ## ⚠️ 安全な削除 (REQ-RC-002)
37
+
38
+ **BEFORE** 削除実行
39
+ **DO** 以下を検証
40
+
41
+ | チェック | コマンド |
42
+ |---------|---------|
43
+ | 動的インポート | `grep -rn "import(" src/` |
44
+ | テスト参照 | `grep -rn "<name>" tests/` |
45
+ | ドキュメント参照 | `grep -rn "<name>" docs/` |
46
+
47
+ **検出された場合**: 削除対象から除外
48
+
49
+ ---
50
+
51
+ ## 📊 リスク分類 (REQ-RC-004)
52
+
53
+ | レベル | 説明 | アクション |
54
+ |--------|------|----------|
55
+ | 🟢 **SAFE** | 静的解析で参照なし | 自動削除可 |
56
+ | 🟡 **CAUTION** | 動的参照の可能性 | 確認必要 |
57
+ | 🔴 **DANGER** | 公開API/エントリーポイント | 自動削除禁止 |
58
+
59
+ **出力例**:
60
+ ```
61
+ 🔍 Dead Code Analysis
62
+ ━━━━━━━━━━━━━━━━━━━━━━━━
63
+ 🟢 SAFE (5):
64
+ • src/utils/deprecated.ts
65
+ • src/helpers/old.ts
66
+
67
+ 🟡 CAUTION (2):
68
+ • src/lib/maybe-used.ts
69
+
70
+ 🔴 DANGER (1):
71
+ • src/index.ts (entry point)
72
+ ━━━━━━━━━━━━━━━━━━━━━━━━
73
+ ```
74
+
75
+ ---
76
+
77
+ ## 📝 Deletion Log (REQ-RC-003)
78
+
79
+ **WHEN** コード削除
80
+ **DO** `docs/DELETION_LOG.md`に記録
81
+
82
+ ```markdown
83
+ ## [日付]
84
+
85
+ ### Deleted
86
+ - `src/utils/deprecated.ts`
87
+ - `src/helpers/old.ts`
88
+
89
+ ### Reason
90
+ knip検出: 未使用エクスポート
91
+
92
+ ### Restore
93
+ `git checkout abc1234 -- <file>`
94
+ ```
95
+
96
+ **レポート保存**: `.reports/dead-code-analysis.md`
97
+
98
+ ---
99
+
100
+ ## トレーサビリティ
101
+
102
+ - REQ-RC-001: Dead Code Detection
103
+ - REQ-RC-002: Safe Deletion
104
+ - REQ-RC-003: Deletion Log
105
+ - REQ-RC-004: Risk Classification
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: session-manager
3
+ description: セッション開始時にコンテキスト復元、終了時に状態保存。TodoWrite統合でタスク追跡。
4
+ license: MIT
5
+ version: 1.1.0
6
+ triggers:
7
+ - セッション開始
8
+ - セッション終了
9
+ - /session
10
+ - マルチステップタスク
11
+ ---
12
+
13
+ # Session Manager
14
+
15
+ > **要約**: セッション間の継続性を提供。開始時に過去コンテキストを復元、終了時に状態を永続化。
16
+
17
+ ## 🔄 トリガーと即時アクション
18
+
19
+ ### セッション開始時
20
+
21
+ **WHEN** 新しいセッションが開始される
22
+ **DO** 以下を順に実行:
23
+
24
+ 1. `~/.musubix/sessions/` から過去7日間のファイルを検索
25
+ 2. 直近セッションの「Notes for Next Session」を読む
26
+ 3. ユーザーに引き継ぎ内容を通知
27
+
28
+ ```bash
29
+ find ~/.musubix/sessions/ -name "*.md" -mtime -7 2>/dev/null | head -5
30
+ ```
31
+
32
+ **出力フォーマット**:
33
+ ```
34
+ 📋 前回セッションからの引き継ぎ
35
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
36
+ 📅 日時: [YYYY-MM-DD HH:MM]
37
+ 📝 未完了: [タスクリスト]
38
+ 💡 メモ: [重要コンテキスト]
39
+ 📂 推奨ファイル: [パスリスト]
40
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━
41
+ 続きから再開しますか?
42
+ ```
43
+
44
+ ---
45
+
46
+ ### セッション終了時
47
+
48
+ **WHEN** セッション終了/長時間中断
49
+ **DO** 状態を `~/.musubix/sessions/YYYY-MM-DD-HH-MM.md` に保存
50
+
51
+ **保存フォーマット**:
52
+ ```markdown
53
+ # Session: [日付]
54
+ **Project:** [名前] | **Started:** [HH:MM] | **Updated:** [HH:MM]
55
+
56
+ ## Completed
57
+ - [x] 完了タスク
58
+
59
+ ## In Progress
60
+ - [ ] 進行中タスク
61
+
62
+ ## Notes for Next Session
63
+ - 重要コンテキスト
64
+
65
+ ## Context to Load
66
+ - `path/to/file`
67
+ ```
68
+
69
+ ---
70
+
71
+ ### コンテキスト圧縮前
72
+
73
+ **WHEN** コンテキスト圧縮がトリガーされる
74
+ **DO** 圧縮前に重要な状態をセッションファイルに追記
75
+
76
+ **保存項目**: 現在のタスク状態、重要な変数/設定、次のアクション
77
+
78
+ ---
79
+
80
+ ## ✅ TodoWrite統合
81
+
82
+ **WHEN** マルチステップタスク(3ステップ以上)を開始
83
+ **DO** TodoWriteツールで進捗を追跡
84
+
85
+ ### ベストプラクティス
86
+
87
+ | やること | 理由 |
88
+ |---------|------|
89
+ | タスク開始時にリスト作成 | 実行順序を明示 |
90
+ | 完了ごとにチェック | 進捗を可視化 |
91
+ | 欠落ステップを検出 | 抜け漏れ防止 |
92
+ | 終了時に未完了を記録 | 次回引き継ぎ |
93
+
94
+ **例**:
95
+ ```
96
+ □ 1. 要件定義の確認
97
+ □ 2. 設計ドキュメント作成
98
+ ☑ 3. 実装(完了)
99
+ □ 4. テスト作成
100
+ □ 5. レビュー依頼
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 📁 ストレージ
106
+
107
+ | パス | 内容 |
108
+ |------|------|
109
+ | `~/.musubix/sessions/` | セッションファイル(30日保持) |
110
+ | `~/.musubix/sessions/YYYY-MM-DD-HH-MM.md` | 個別セッション |
111
+
112
+ ---
113
+
114
+ ## トレーサビリティ
115
+
116
+ - REQ-SM-001: SessionStart Hook
117
+ - REQ-SM-002: SessionEnd Hook
118
+ - REQ-SM-003: Pre-Compact State Saving
119
+ - REQ-SM-004: TodoWrite統合