Skip to content

Commit 6636209

Browse files
author
catlog22
committed
chore: update commands, specs, and ccw tools
Update DDD commands (doc-generate, doc-refresh, sync), workflow commands (session/sync, spec/add, spec/setup, spec/load), ccw specs, personal preferences, and add generate-ddd-docs tool.
1 parent cbd1813 commit 6636209

13 files changed

Lines changed: 1923 additions & 436 deletions

File tree

.ccw/personal/coding-style.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: "Personal Coding Style"
3+
dimension: personal
4+
category: general
5+
keywords:
6+
- style
7+
- preference
8+
readMode: optional
9+
priority: medium
10+
---
11+
12+
# Personal Coding Style
13+
14+
## Preferences
15+
16+
- Describe your preferred coding style here
17+
- Example: verbose variable names vs terse, functional vs imperative
18+
19+
## Patterns I Prefer
20+
21+
- List patterns you reach for most often
22+
- Example: builder pattern, factory functions, tagged unions
23+
24+
## Things I Avoid
25+
26+
- List anti-patterns or approaches you dislike
27+
- Example: deep inheritance hierarchies, magic strings

.ccw/personal/tool-preferences.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: "Tool Preferences"
3+
dimension: personal
4+
category: general
5+
keywords:
6+
- tool
7+
- cli
8+
- editor
9+
readMode: optional
10+
priority: low
11+
---
12+
13+
# Tool Preferences
14+
15+
## Editor
16+
17+
- Preferred editor and key extensions/plugins
18+
19+
## CLI Tools
20+
21+
- Preferred shell, package manager, build tools
22+
23+
## Debugging
24+
25+
- Preferred debugging approach and tools

.ccw/specs/architecture-constraints.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
---
2+
title: Architecture Constraints
3+
readMode: optional
4+
priority: medium
5+
category: general
6+
scope: project
7+
dimension: specs
8+
keywords: [architecture, constraint, schema, compatibility, portability, design, arch]
9+
---
10+
111
# Architecture Constraints
212

313
## Schema Evolution

.ccw/specs/coding-conventions.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
---
2+
title: Coding Conventions
3+
readMode: optional
4+
priority: medium
5+
category: general
6+
scope: project
7+
dimension: specs
8+
keywords: [coding, convention, style, naming, pattern, navigation, schema, error-handling, implementation, validation, clarity, doc]
9+
---
10+
111
# Coding Conventions
212

313
## Navigation & Path Handling
@@ -9,6 +19,7 @@
919
## Document Generation
1020

1121
- [architecture] For document generation systems, adopt Layer 3→2→1 pattern (components → features → indexes) for efficient incremental updates. (learned: 2026-03-07)
22+
- [tools] When commands need to generate files with deterministic paths and frontmatter, use dedicated ccw tool endpoints (`ccw tool exec`) instead of raw `ccw cli -p` calls. Endpoints control output path, file naming, and structural metadata; CLI tools only generate prose content. (learned: 2026-03-09)
1223

1324
## Implementation Quality
1425

.claude/commands/ddd/doc-generate.md

Lines changed: 52 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ doc-index.json → tech-registry/*.md (L3) → feature-maps/*.md (L2) → _index
4848
├── tech-registry/ ← Component documentation (Layer 3)
4949
│ ├── _index.md
5050
│ └── {component-slug}.md
51-
└── sessions/
52-
└── _index.md ← Planning sessions index (Layer 1)
51+
└── planning/ ← Planning sessions (Layer 1)
52+
├── _index.md ← Planning sessions index
53+
└── {task-slug}-{date}/ ← Individual session folders
5354
```
5455

5556
## Phase 1: Load & Validate
@@ -87,165 +88,90 @@ IF docs already exist AND NOT --force:
8788
Ask user (unless -y → overwrite)
8889
```
8990

90-
## Phase 2: Layer 3 Component Documentation
91+
## Phase 2: Layer 3 -- Component Documentation
9192

92-
For each component in `technicalComponents[]`:
93+
For each component in `technicalComponents[]`, call the generate_ddd_docs endpoint:
9394

9495
```bash
95-
ccw cli -p "PURPOSE: Generate component documentation for {component.name}
96-
TASK:
97-
• Document component purpose and responsibility
98-
• List exported symbols (classes, functions, types)
99-
• Document dependencies (internal and external)
100-
• Include code examples for key APIs
101-
• Document integration points with other components
102-
MODE: write
103-
CONTEXT: @{component.codeLocations[].path}
104-
EXPECTED: Markdown file with: Overview, API Reference, Dependencies, Usage Examples
105-
CONSTRAINTS: Focus on public API | Include type signatures
106-
" --tool gemini --mode write --cd .workflow/.doc-index/tech-registry/
96+
for COMPONENT_ID in "${technicalComponents[@]}"; do
97+
ccw tool exec generate_ddd_docs '{"strategy":"component","entityId":"'"$COMPONENT_ID"'","tool":"gemini"}'
98+
done
10799
```
108100

109-
Output: `.workflow/.doc-index/tech-registry/{component-slug}.md`
110-
111-
Frontmatter:
112-
```markdown
113-
---
114-
layer: 3
115-
component_id: tech-{slug}
116-
name: ComponentName
117-
type: service|controller|model|...
118-
features: [feat-auth]
119-
code_locations:
120-
- path: src/services/auth.ts
121-
symbols: [AuthService, AuthService.login]
122-
generated_at: ISO8601
123-
---
124-
```
101+
The endpoint handles:
102+
- Loading the component entity from doc-index.json
103+
- Building YAML frontmatter (layer: 3, component_id, name, type, features, code_locations, generated_at)
104+
- Constructing the CLI prompt with code context paths
105+
- **Including Change History section**: Pull related entries from `doc-index.json.actions[]` where `affectedComponents` includes this component ID. Display as timeline (date, action type, description)
106+
- Writing output to `.workflow/.doc-index/tech-registry/{slug}.md`
107+
- Tool fallback (gemini -> qwen -> codex) on failure
125108

126-
Sections: Responsibility, Code Locations, Related Requirements, Architecture Decisions, Dependencies (in/out)
109+
Output: `.workflow/.doc-index/tech-registry/{component-slug}.md`
127110

128-
## Phase 3: Layer 2 Feature Documentation
111+
## Phase 3: Layer 2 -- Feature Documentation
129112

130-
For each feature in `features[]`:
113+
For each feature in `features[]`, call the generate_ddd_docs endpoint:
131114

132115
```bash
133-
ccw cli -p "PURPOSE: Generate feature documentation for {feature.name}
134-
TASK:
135-
• Describe feature purpose and business value
136-
• List requirements (from requirementIds)
137-
• Document components involved (from techComponentIds)
138-
• Include architecture decisions (from adrIds)
139-
• Provide integration guide
140-
MODE: write
141-
CONTEXT: @.workflow/.doc-index/tech-registry/{related-components}.md
142-
EXPECTED: Markdown file with: Overview, Requirements, Components, Architecture, Integration
143-
CONSTRAINTS: Reference Layer 3 component docs | Business-focused language
144-
" --tool gemini --mode write --cd .workflow/.doc-index/feature-maps/
116+
for FEATURE_ID in "${features[@]}"; do
117+
ccw tool exec generate_ddd_docs '{"strategy":"feature","entityId":"'"$FEATURE_ID"'","tool":"gemini"}'
118+
done
145119
```
146120

147-
Output: `.workflow/.doc-index/feature-maps/{feature-slug}.md`
148-
149-
Frontmatter:
150-
```markdown
151-
---
152-
layer: 2
153-
feature_id: feat-{slug}
154-
name: Feature Name
155-
epic_id: EPIC-NNN|null
156-
status: implemented|in-progress|planned|partial
157-
requirements: [REQ-001, REQ-002]
158-
components: [tech-auth-service, tech-user-model]
159-
depends_on_layer3: [tech-auth-service, tech-user-model]
160-
tags: [auth, security]
161-
generated_at: ISO8601
162-
---
163-
```
121+
The endpoint handles:
122+
- Loading the feature entity from doc-index.json
123+
- Building YAML frontmatter (layer: 2, feature_id, name, epic_id, status, requirements, components, tags, generated_at)
124+
- Constructing the CLI prompt referencing Layer 3 component docs
125+
- **Including Change History section**: Pull related entries from `doc-index.json.actions[]` where `affectedFeatures` includes this feature ID. Display as timeline (date, action type, description)
126+
- Writing output to `.workflow/.doc-index/feature-maps/{slug}.md`
127+
- Tool fallback (gemini -> qwen -> codex) on failure
164128

165-
Sections: Overview, Requirements (with mapping status), Technical Components, Architecture Decisions, Change History
129+
Output: `.workflow/.doc-index/feature-maps/{feature-slug}.md`
166130

167-
## Phase 4: Layer 1 Index & Overview Documentation
131+
## Phase 4: Layer 1 -- Index & Overview Documentation
168132

169133
### 4.1 Index Documents
170134

171-
Generate catalog files:
135+
Generate catalog files for each subdirectory:
172136

173-
- **feature-maps/_index.md** — Feature overview table with status
174-
- **tech-registry/_index.md** — Component registry table with types
175-
- **action-logs/_index.md** — Action history table (empty initially for new projects)
137+
```bash
138+
# Feature maps index
139+
ccw tool exec generate_ddd_docs '{"strategy":"index","entityId":"feature-maps","tool":"gemini"}'
176140

177-
### 4.2 README.md (unless --skip-overview)
141+
# Tech registry index
142+
ccw tool exec generate_ddd_docs '{"strategy":"index","entityId":"tech-registry","tool":"gemini"}'
178143

179-
```bash
180-
ccw cli -p "PURPOSE: Generate project README with overview and navigation
181-
TASK:
182-
• Project summary and purpose
183-
• Quick start guide
184-
• Navigation to features, components, and architecture
185-
• Link to doc-index.json
186-
MODE: write
187-
CONTEXT: @.workflow/.doc-index/doc-index.json @.workflow/.doc-index/feature-maps/_index.md
188-
EXPECTED: README.md with: Overview, Quick Start, Navigation, Links
189-
CONSTRAINTS: High-level only | Entry point for new developers
190-
" --tool gemini --mode write --cd .workflow/.doc-index/
144+
# Action logs index
145+
ccw tool exec generate_ddd_docs '{"strategy":"index","entityId":"action-logs","tool":"gemini"}'
146+
147+
# Planning sessions index
148+
ccw tool exec generate_ddd_docs '{"strategy":"index","entityId":"planning","tool":"gemini"}'
191149
```
192150

193-
### 4.3 ARCHITECTURE.md (unless --skip-overview)
151+
Or generate all indexes at once (omit entityId):
194152

195153
```bash
196-
ccw cli -p "PURPOSE: Generate architecture overview document
197-
TASK:
198-
• System design overview
199-
• Component relationships and dependencies
200-
• Key architecture decisions (from ADRs)
201-
• Technology stack
202-
MODE: write
203-
CONTEXT: @.workflow/.doc-index/doc-index.json @.workflow/.doc-index/tech-registry/*.md
204-
EXPECTED: ARCHITECTURE.md with: System Design, Component Diagram, ADRs, Tech Stack
205-
CONSTRAINTS: Architecture-focused | Reference component docs for details
206-
" --tool gemini --mode write --cd .workflow/.doc-index/
154+
ccw tool exec generate_ddd_docs '{"strategy":"index","tool":"gemini"}'
207155
```
208156

209-
### 4.4 sessions/_index.md (unless --skip-overview)
157+
### 4.2 README.md (unless --skip-overview)
210158

211159
```bash
212-
ccw cli -p "PURPOSE: Generate planning sessions index
213-
TASK:
214-
• List all planning session folders chronologically
215-
• Link to each session's plan.json
216-
• Show session status and task count
217-
MODE: write
218-
CONTEXT: @.workflow/.doc-index/planning/*/plan.json
219-
EXPECTED: sessions/_index.md with: Session List, Links, Status
220-
CONSTRAINTS: Chronological order | Link to session folders
221-
" --tool gemini --mode write --cd .workflow/.doc-index/sessions/
160+
ccw tool exec generate_ddd_docs '{"strategy":"overview","tool":"gemini"}'
222161
```
223162

224-
Layer 1 frontmatter:
225-
```markdown
226-
---
227-
layer: 1
228-
depends_on_layer2: [feat-auth, feat-orders]
229-
generated_at: ISO8601
230-
---
163+
### 4.3 ARCHITECTURE.md (unless --skip-overview)
164+
165+
```bash
166+
ccw tool exec generate_ddd_docs '{"strategy":"overview","entityId":"architecture","tool":"gemini"}'
231167
```
232168

233169
## Phase 5: SCHEMA.md (unless --skip-schema)
234170

235171
### 5.1 Generate Schema Documentation
236172

237173
```bash
238-
ccw cli -p "PURPOSE: Document doc-index.json schema structure and versioning
239-
TASK:
240-
• Document current schema structure (all fields)
241-
• Define versioning policy (semver: major.minor)
242-
• Document migration protocol for version upgrades
243-
• Provide examples for each schema section
244-
MODE: write
245-
CONTEXT: @.workflow/.doc-index/doc-index.json
246-
EXPECTED: SCHEMA.md with: Schema Structure, Versioning Policy, Migration Protocol, Examples
247-
CONSTRAINTS: Complete field documentation | Clear migration steps
248-
" --tool gemini --mode write --cd .workflow/.doc-index/
174+
ccw tool exec generate_ddd_docs '{"strategy":"schema","tool":"gemini"}'
249175
```
250176

251177
### 5.2 Versioning Policy
@@ -284,7 +210,7 @@ Total: {N} documents generated
284210
| `-y, --yes` | Auto-confirm all decisions |
285211
| `--layer <3\|2\|1\|all>` | Generate specific layer only (default: all) |
286212
| `--force` | Overwrite existing documents |
287-
| `--skip-overview` | Skip README.md, ARCHITECTURE.md, sessions/_index.md |
213+
| `--skip-overview` | Skip README.md, ARCHITECTURE.md, planning/_index.md |
288214
| `--skip-schema` | Skip SCHEMA.md generation |
289215

290216
## Integration Points
@@ -293,3 +219,4 @@ Total: {N} documents generated
293219
- **Called by**: `/ddd:scan` (after index assembly), `/ddd:index-build` (after index assembly)
294220
- **Standalone**: Can be run independently on any project with existing doc-index.json
295221
- **Output**: Complete document tree in `.workflow/.doc-index/`
222+
- **Endpoint**: `ccw tool exec generate_ddd_docs` handles prompt construction, frontmatter, tool fallback, and file creation

.claude/commands/ddd/doc-refresh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ ccw cli -p "PURPOSE: Update project overview docs after feature changes
163163
TASK:
164164
• Update README.md feature list
165165
• Update ARCHITECTURE.md if new components added
166-
• Update sessions/_index.md with new planning sessions
166+
• Update planning/_index.md with new planning sessions
167167
MODE: write
168168
CONTEXT: @.workflow/.doc-index/feature-maps/*.md @.workflow/.doc-index/doc-index.json
169169
EXPECTED: Updated overview docs with current project state

.claude/commands/ddd/sync.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,42 @@ After completing a development task, synchronize the document index with actual
3737
- `doc-index.json` must exist
3838
- Git repository with committed or staged changes
3939

40+
## Phase 0: Consistency Validation
41+
42+
Before processing changes, verify that `doc-index.json` entries are consistent with actual code state.
43+
44+
### 0.1 Validate Code Locations
45+
46+
For each `technicalComponents[].codeLocations[]`:
47+
- Verify file exists on disk
48+
- If file was deleted/moved → flag for removal or update
49+
- If file exists → verify listed `symbols[]` still exist (quick grep/AST check)
50+
51+
### 0.2 Validate Symbols
52+
53+
For components with `codeLocations[].symbols[]`:
54+
- Check each symbol still exists in the referenced file
55+
- Detect new exported symbols not yet tracked
56+
- Report: `{N} stale symbols, {N} untracked symbols`
57+
58+
### 0.3 Validation Report
59+
60+
```
61+
Consistency Check:
62+
Components validated: {N}
63+
Files verified: {N}
64+
Stale references: {N} (files missing or symbols removed)
65+
Untracked symbols: {N} (new exports not in index)
66+
```
67+
68+
If stale references found: warn and auto-fix during Phase 3 updates.
69+
If `--dry-run`: report only, no fixes.
70+
4071
## Phase 1: Change Detection
4172

42-
### 0.1 Schema Version Check (TASK-006)
73+
### 1.0.1 Schema Version Check
4374

44-
Before processing changes, verify doc-index schema compatibility:
75+
Before processing changes, verify doc-index.json schema compatibility:
4576

4677
```javascript
4778
const docIndex = JSON.parse(Read('.workflow/.doc-index/doc-index.json'));
@@ -201,6 +232,7 @@ For each affected component in `doc-index.json`:
201232
- Update `codeLocations` if file paths or line ranges changed
202233
- Update `symbols` if new exports were added
203234
- Add new `actionIds` entry
235+
- **Auto-update `responsibility`**: If symbols changed (new methods/exports added or removed), re-infer responsibility from current symbols list using Gemini analysis. This prevents stale descriptions (e.g., responsibility still says "登录、注册" after adding logout support)
204236

205237
### 3.2 Register New Components
206238

0 commit comments

Comments
 (0)