ctx-cc 2.1.0 → 2.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/commands/help.md CHANGED
@@ -4,26 +4,60 @@ description: Show CTX commands and usage guide
4
4
  ---
5
5
 
6
6
  <objective>
7
- Display the CTX 2.1 command reference.
7
+ Display the CTX 2.3 command reference.
8
8
 
9
9
  Output ONLY the reference content below. Do NOT add project-specific analysis.
10
10
  </objective>
11
11
 
12
12
  <reference>
13
- # CTX 2.1 Command Reference
13
+ # CTX 2.3 Command Reference
14
14
 
15
15
  **CTX** (Continuous Task eXecution) - Smart workflow orchestration for Claude Code.
16
- 8 commands. Smart routing. Debug loop until 100% fixed.
16
+ 8 commands. PRD-driven. Design-first. Smart routing. Debug loop until 100% fixed.
17
17
 
18
18
  ## Quick Start
19
19
 
20
20
  ```
21
- 1. /ctx init Initialize project
21
+ 1. /ctx init Initialize project + generate PRD.json
22
22
  2. /ctx Smart router does the right thing
23
23
  3. /ctx status Check progress (read-only)
24
24
  4. /ctx pause Checkpoint when needed
25
25
  ```
26
26
 
27
+ ## What's New in 2.3
28
+
29
+ - **Design System Integration** - Full brand + UI design workflow
30
+ - **ctx-designer Agent** - WCAG 2.2 AA, W3C tokens, Figma MCP, Gemini
31
+ - **Story Types** - feature, brand, design, fix, refactor
32
+ - **3 Options Pattern** - Always present A/B/C for design decisions
33
+ - **Visual Approval Gates** - Mood board → Direction → Prototype → Final
34
+ - **BRAND_KIT.md** - Visual foundation with W3C design tokens
35
+ - **EAA 2025 Ready** - European Accessibility Act compliance
36
+
37
+ ## What's in 2.2
38
+
39
+ - **Front-Loaded Approach** - Gather ALL info upfront, execute autonomously
40
+ - **PRD.json** - Requirements contract with user stories
41
+ - **Secure Credentials** - `.ctx/.env` for test credentials (gitignored)
42
+ - **Acceptance Criteria** - Each story has verifiable criteria
43
+ - **`passes` Flag** - Auto-tracks story completion
44
+ - **Story-Driven Workflow** - Plan → Execute → Verify → Next Story
45
+
46
+ ## Front-Loaded Philosophy
47
+
48
+ ```
49
+ /ctx init gathers:
50
+ ├── Requirements → PRD.json stories
51
+ ├── Context → problem, target user, success criteria
52
+ ├── Credentials → .ctx/.env (gitignored)
53
+ └── Constitution → rules for autonomous decisions
54
+
55
+ Then /ctx runs autonomously:
56
+ ├── Only interrupts for architecture decisions
57
+ ├── Uses stored credentials for browser testing
58
+ └── Loops until all stories pass
59
+ ```
60
+
27
61
  ## The 8 Commands
28
62
 
29
63
  ### Smart (Auto-routing)
@@ -66,16 +100,21 @@ Output ONLY the reference content below. Do NOT add project-specific analysis.
66
100
 
67
101
  ## Smart Router States
68
102
 
69
- When you run `/ctx`, it reads STATE.md and auto-routes:
103
+ When you run `/ctx`, it reads STATE.md and PRD.json, auto-routes:
70
104
 
71
105
  | State | What happens |
72
106
  |-------|--------------|
73
- | initializing | Research + Plan (ArguSeek + ChunkHound) |
74
- | executing | Execute current task |
107
+ | initializing | Research + Plan for current story |
108
+ | executing | Execute tasks for current story |
75
109
  | debugging | **Debug loop until 100% fixed** |
76
- | verifying | Three-level verification |
110
+ | verifying | Verify acceptance criteria → mark story as passed |
77
111
  | paused | Resume from checkpoint |
78
112
 
113
+ **Story Flow:**
114
+ ```
115
+ S001 → plan → execute → verify ✓ → S002 → plan → execute → verify ✓ → ...
116
+ ```
117
+
79
118
  ## Debug Loop
80
119
 
81
120
  When something breaks, CTX enters debug mode:
@@ -102,6 +141,47 @@ Loop (max 5 attempts):
102
141
  | Substantive | Real code, not stub? | No TODOs, no placeholders |
103
142
  | Wired | Imported and used? | Trace imports |
104
143
 
144
+ ## Design Workflow
145
+
146
+ CTX handles visual work with dedicated agents and approval gates.
147
+
148
+ ### Story Types
149
+ | Type | Agent | Purpose |
150
+ |------|-------|---------|
151
+ | feature | ctx-executor | Standard implementation |
152
+ | brand | ctx-designer | BRAND_KIT.md + tokens |
153
+ | design | ctx-designer | UI components/pages |
154
+ | fix | ctx-debugger | Bug fixes |
155
+ | refactor | ctx-executor | Code improvements |
156
+
157
+ ### Design Approval Gates
158
+ ```
159
+ Mood Board → Direction (A/B/C) → Prototype → Final
160
+ ```
161
+ Each gate requires user approval before proceeding.
162
+
163
+ ### 3 Options Pattern
164
+ All design decisions present:
165
+ - **Option A**: Conservative (safe, proven)
166
+ - **Option B**: Balanced (recommended)
167
+ - **Option C**: Bold (distinctive)
168
+
169
+ ### WCAG 2.2 AA Compliance
170
+ | Criterion | Requirement |
171
+ |-----------|-------------|
172
+ | 2.4.11 | Focus not obscured |
173
+ | 2.5.7 | Drag alternatives |
174
+ | 2.5.8 | 24x24px targets |
175
+ | 3.3.8 | Accessible auth |
176
+
177
+ ### W3C Design Tokens
178
+ ```
179
+ tokens/
180
+ ├── primitive.tokens.json # Raw values
181
+ ├── semantic.tokens.json # Purpose aliases
182
+ └── component.tokens.json # Component-specific
183
+ ```
184
+
105
185
  ## Key Design Principles
106
186
 
107
187
  ### Atomic Planning (2-3 Tasks Max)
@@ -122,13 +202,14 @@ Prevents context degradation. Big work = multiple phases.
122
202
  | 30-50% | Good | Continue |
123
203
  | 50%+ | Degrading | Auto-checkpoint |
124
204
 
125
- ## 5 Specialized Agents
205
+ ## 6 Specialized Agents
126
206
 
127
207
  | Agent | When spawned |
128
208
  |-------|--------------|
129
209
  | ctx-researcher | During planning (ArguSeek + ChunkHound) |
130
210
  | ctx-planner | After research |
131
- | ctx-executor | During execution |
211
+ | ctx-executor | During execution (feature stories) |
212
+ | ctx-designer | During execution (brand/design stories) |
132
213
  | ctx-debugger | When debugging |
133
214
  | ctx-verifier | During verification |
134
215
 
@@ -137,19 +218,71 @@ Prevents context degradation. Big work = multiple phases.
137
218
  - **ArguSeek**: Web research during planning
138
219
  - **ChunkHound**: Semantic code search (`uv tool install chunkhound`)
139
220
  - **Playwright/DevTools**: Browser verification for UI
221
+ - **Figma MCP**: Design context extraction and screenshots
222
+ - **Gemini Design**: Image generation and UI code generation
140
223
 
141
224
  ## Directory Structure
142
225
 
143
226
  ```
144
227
  .ctx/
145
- ├── STATE.md # Living digest - ALWAYS read first
146
- ├── phases/{id}/ # Phase data
228
+ ├── STATE.md # Living digest - execution state
229
+ ├── PRD.json # Requirements contract - stories + criteria
230
+ ├── .env # Test credentials (GITIGNORED)
231
+ ├── .gitignore # Protects secrets
232
+ ├── phases/{story_id}/ # Per-story data
147
233
  │ ├── RESEARCH.md # ArguSeek + ChunkHound results
148
- │ ├── PLAN.md # 2-3 tasks (atomic)
149
- └── VERIFY.md # Verification report
234
+ │ ├── PLAN.md # Tasks mapped to acceptance criteria
235
+ ├── VERIFY.md # Verification report
236
+ │ ├── MOOD_BOARD.md # Design references (design stories)
237
+ │ └── DESIGN_BRIEF.md # Design decisions (design stories)
150
238
  ├── checkpoints/ # Auto-checkpoints
151
239
  ├── debug/ # Debug screenshots
152
240
  └── verify/ # Verification screenshots
241
+
242
+ project/
243
+ ├── BRAND_KIT.md # Visual foundation (brand stories)
244
+ └── tokens/ # W3C design tokens
245
+ ├── primitive.tokens.json
246
+ ├── semantic.tokens.json
247
+ └── component.tokens.json
248
+ ```
249
+
250
+ ## PRD.json Structure
251
+
252
+ ```json
253
+ {
254
+ "brand": {
255
+ "hasBrandKit": false,
256
+ "personality": ["professional", "modern"],
257
+ "euMarket": true
258
+ },
259
+ "design": {
260
+ "wcagLevel": "AA",
261
+ "eaaCompliance": true,
262
+ "tokenFormat": "w3c"
263
+ },
264
+ "stories": [
265
+ {
266
+ "id": "S001",
267
+ "type": "brand",
268
+ "title": "Establish brand kit",
269
+ "acceptanceCriteria": ["BRAND_KIT.md exists", "tokens/ populated"],
270
+ "passes": false
271
+ },
272
+ {
273
+ "id": "S002",
274
+ "type": "design",
275
+ "title": "Login page",
276
+ "acceptanceCriteria": ["WCAG 2.2 AA compliant", "All states implemented"],
277
+ "passes": false
278
+ }
279
+ ],
280
+ "metadata": {
281
+ "currentStory": "S001",
282
+ "passedStories": 0,
283
+ "totalStories": 5
284
+ }
285
+ }
153
286
  ```
154
287
 
155
288
  ## Updating CTX
@@ -159,5 +292,5 @@ npx ctx-cc --force
159
292
  ```
160
293
 
161
294
  ---
162
- *CTX 2.1 - 8 commands, smart routing, debug loop, 100% verified*
295
+ *CTX 2.3 - PRD-driven, design-first, story-verified, debug loop until 100% fixed*
163
296
  </reference>
package/commands/init.md CHANGED
@@ -1,12 +1,38 @@
1
1
  ---
2
2
  name: ctx:init
3
- description: Initialize CTX project with STATE.md
3
+ description: Initialize CTX project with STATE.md, PRD.json, design context, and secure credentials
4
4
  ---
5
5
 
6
6
  <objective>
7
- Initialize a new CTX 2.0 project. Creates `.ctx/` directory with STATE.md as the single source of truth.
7
+ Initialize a new CTX 2.3 project. Front-loads ALL information gathering so execution runs autonomously with minimal interruption.
8
+
9
+ Creates:
10
+ - `.ctx/STATE.md` - Execution state
11
+ - `.ctx/PRD.json` - Requirements contract with design context
12
+ - `.ctx/.env` - Secure credentials (gitignored)
13
+ - `BRAND_KIT.md` - Visual foundation (if design work needed)
8
14
  </objective>
9
15
 
16
+ <philosophy>
17
+ ## Front-Loaded Approach
18
+
19
+ **Gather EVERYTHING upfront:**
20
+ 1. Project requirements → PRD.json
21
+ 2. User stories → PRD.json stories
22
+ 3. Credentials for testing → .ctx/.env
23
+ 4. URLs and endpoints → .ctx/.env
24
+ 5. Constitution/rules → PRD.json constitution
25
+ 6. Design context → PRD.json brand/design sections
26
+ 7. Visual requirements → Brand personality, mood, inspirations
27
+
28
+ **Then execute autonomously:**
29
+ - Minimal user interruption during execution
30
+ - Only ask user for architecture decisions (Rule 4)
31
+ - Only ask user for design approvals at gates
32
+ - Use stored credentials for browser verification
33
+ - Deliver complete, verified project
34
+ </philosophy>
35
+
10
36
  <workflow>
11
37
  ## Step 1: Check Existing
12
38
  If `.ctx/STATE.md` exists:
@@ -24,9 +50,12 @@ Scan the codebase:
24
50
  ## Step 3: Create Structure
25
51
  ```
26
52
  .ctx/
27
- ├── STATE.md # Living digest - ALWAYS read first
53
+ ├── STATE.md # Living digest - execution state
54
+ ├── PRD.json # Requirements contract - stories + acceptance criteria
55
+ ├── .env # Credentials for testing (GITIGNORED)
56
+ ├── .gitignore # Protects secrets
28
57
  ├── phases/ # Phase-specific data
29
- │ └── {phase-id}/
58
+ │ └── {story_id}/
30
59
  │ ├── RESEARCH.md
31
60
  │ ├── PLAN.md
32
61
  │ └── VERIFY.md
@@ -35,6 +64,13 @@ Scan the codebase:
35
64
  └── archive/ # Archived states
36
65
  ```
37
66
 
67
+ **Create `.ctx/.gitignore`:**
68
+ ```
69
+ .env
70
+ *.secrets
71
+ credentials.json
72
+ ```
73
+
38
74
  ## Step 4: Initialize STATE.md
39
75
  Create STATE.md from template with:
40
76
  - Project name (from package.json or directory name)
@@ -49,33 +85,240 @@ chunkhound index . --output .ctx/chunks.json
49
85
  ```
50
86
  This enables semantic code search during planning.
51
87
 
52
- ## Step 6: Prompt for Goal
88
+ ## Step 6: Gather Requirements
53
89
  Ask user: **"What do you want to build/fix/improve?"**
54
90
 
55
- Do NOT start planning yet. Just store the goal in STATE.md and set status to "initializing".
91
+ Then ask follow-up questions to elicit user stories:
92
+ - **"What are the main features/outcomes?"** (becomes stories)
93
+ - **"How will you know each is done?"** (becomes acceptance criteria)
94
+ - **"Any constraints or rules?"** (becomes constitution)
95
+
96
+ ## Step 7: Generate PRD.json
97
+ Create PRD.json with gathered information:
98
+
99
+ ```json
100
+ {
101
+ "$schema": "https://ctx.dev/schemas/prd.json",
102
+ "version": "1.0",
103
+ "project": {
104
+ "name": "{{project_name}}",
105
+ "description": "{{project_description}}",
106
+ "stack": "{{tech_stack}}",
107
+ "created": "{{timestamp}}"
108
+ },
109
+ "constitution": {
110
+ "principles": ["{{from user or defaults}}"],
111
+ "always": ["{{from user or defaults}}"],
112
+ "never": ["{{from user or defaults}}"],
113
+ "askFirst": ["{{from user or defaults}}"]
114
+ },
115
+ "stories": [
116
+ {
117
+ "id": "S001",
118
+ "title": "{{story_title}}",
119
+ "description": "{{story_description}}",
120
+ "acceptanceCriteria": ["{{criterion_1}}", "{{criterion_2}}"],
121
+ "priority": 1,
122
+ "phase": 1,
123
+ "passes": false,
124
+ "verifiedAt": null,
125
+ "notes": ""
126
+ }
127
+ ],
128
+ "metadata": {
129
+ "totalStories": {{count}},
130
+ "passedStories": 0,
131
+ "currentStory": "S001",
132
+ "lastUpdated": "{{timestamp}}"
133
+ }
134
+ }
135
+ ```
136
+
137
+ **Story Generation Rules:**
138
+ - Each distinct feature/outcome = one story
139
+ - Max 3 acceptance criteria per story (keep atomic)
140
+ - Ordered by dependency (foundation first)
141
+ - All stories start with `passes: false`
142
+
143
+ ## Step 8: Gather Credentials for Testing
144
+
145
+ Ask user about testing requirements:
146
+
147
+ **"Will this project need browser testing?"**
148
+ If yes, gather:
149
+ - **App URL** (local dev, staging, or production)
150
+ - **Test user credentials** (email/password for login flows)
151
+ - **Admin credentials** (if admin features exist)
152
+
153
+ **"Are there external APIs or services?"**
154
+ If yes, gather:
155
+ - **API keys** (third-party services)
156
+ - **Database URLs** (if direct DB testing needed)
157
+ - **OAuth tokens** (if OAuth flows)
158
+
159
+ **"Any other secrets needed for testing?"**
160
+ - Environment-specific values
161
+ - Feature flags
162
+ - Test data identifiers
163
+
164
+ ## Step 9: Create .ctx/.env
165
+
166
+ Write credentials to `.ctx/.env`:
167
+
168
+ ```bash
169
+ # CTX Test Credentials - DO NOT COMMIT
170
+ # Generated by /ctx init
171
+
172
+ # App URLs
173
+ APP_URL=http://localhost:3000
174
+ STAGING_URL=
175
+
176
+ # Test User
177
+ TEST_USER_EMAIL=
178
+ TEST_USER_PASSWORD=
179
+
180
+ # Admin User (if applicable)
181
+ ADMIN_EMAIL=
182
+ ADMIN_PASSWORD=
183
+
184
+ # API Keys
185
+ API_KEY=
186
+
187
+ # Database (if applicable)
188
+ DATABASE_URL=
189
+
190
+ # Other Secrets
191
+ # Add as needed
192
+ ```
193
+
194
+ **IMPORTANT:**
195
+ - Create `.ctx/.gitignore` with `.env` entry
196
+ - Warn user: "Credentials stored in .ctx/.env - NEVER commit this file"
197
+ - Verify .gitignore is in place before proceeding
198
+
199
+ ## Step 10: Gather Design Context
200
+
201
+ **"Does this project need visual/UI work?"**
202
+
203
+ If yes, gather brand context:
204
+
205
+ **Brand Personality:**
206
+ - "What 3-5 adjectives describe the desired brand feel?"
207
+ - "Any brands you admire visually?" (inspirations)
208
+ - "Any visual styles to AVOID?" (anti-inspirations)
209
+
210
+ **Existing Assets:**
211
+ - "Do you have existing brand assets?" (logo, colors, fonts)
212
+ - "Figma file link?" (optional but recommended)
213
+
214
+ **Accessibility Requirements:**
215
+ - "Target market includes EU?" (EAA 2025 compliance)
216
+ - "WCAG level needed?" (default: 2.2 AA)
217
+
218
+ **Mode Support:**
219
+ - "Dark mode needed?" (light-only or light+dark)
220
+
221
+ Store in PRD.json `brand` section:
222
+ ```json
223
+ {
224
+ "brand": {
225
+ "hasBrandKit": false,
226
+ "personality": ["professional", "trustworthy", "modern"],
227
+ "visualMood": "Clean, minimal, with subtle warmth",
228
+ "inspirations": ["Stripe", "Linear"],
229
+ "antiInspirations": ["flashy", "cluttered"],
230
+ "existingAssets": ["logo.svg"],
231
+ "darkModeRequired": true,
232
+ "euMarket": true
233
+ },
234
+ "design": {
235
+ "wcagLevel": "AA",
236
+ "eaaCompliance": true,
237
+ "tokenFormat": "w3c",
238
+ "figmaFileKey": null,
239
+ "breakpoints": { "mobile": 375, "tablet": 768, "desktop": 1440 }
240
+ }
241
+ }
242
+ ```
243
+
244
+ **Story Type Assignment:**
245
+ - If no brand kit exists and UI work needed → Create brand story first (type: "brand")
246
+ - For each UI component/page → Create design story (type: "design")
247
+ - For backend/logic work → Create feature story (type: "feature")
248
+
249
+ ## Step 11: Link STATE.md to PRD
250
+ Update STATE.md to reference current story:
251
+ - **Current Story**: S001 - {{title}}
252
+
253
+ Do NOT start planning yet. Set status to "initializing".
56
254
  The user will run `/ctx` to begin the research + planning phase.
57
255
  </workflow>
58
256
 
59
257
  <output_format>
60
258
  ```
61
- [CTX 2.0] Initialized
259
+ [CTX 2.3] Initialized
62
260
 
63
261
  Project: {{name}}
64
262
  Stack: {{language}} + {{framework}}
65
263
  Directory: .ctx/
66
264
 
265
+ PRD: {{story_count}} stories
266
+ S001: [{{type}}] {{story_1_title}} ⬜
267
+ S002: [{{type}}] {{story_2_title}} ⬜
268
+ ...
269
+
270
+ Constitution:
271
+ Principles: {{count}}
272
+ Always: {{count}}
273
+ Never: {{count}}
274
+
275
+ Design Context:
276
+ Brand Kit: {{exists | needs creation}}
277
+ Personality: {{adjectives}}
278
+ WCAG Level: 2.2 {{level}}
279
+ EAA 2025: {{required | not required}}
280
+ Dark Mode: {{yes | no}}
281
+ Figma: {{linked | not linked}}
282
+
283
+ Credentials:
284
+ App URL: {{configured | not set}}
285
+ Test User: {{configured | not set}}
286
+ API Keys: {{count}} configured
287
+ ⚠️ Stored in .ctx/.env (gitignored)
288
+
67
289
  Integrations:
68
290
  ArguSeek: ready
69
291
  ChunkHound: {{indexed | not found}}
292
+ Browser Testing: {{ready | needs credentials}}
293
+ Figma MCP: {{ready | not configured}}
294
+ Gemini Design: {{ready | not configured}}
70
295
 
71
- Next: Run /ctx to start planning
296
+ Ready for autonomous execution.
297
+ Next: Run /ctx to start planning for S001
72
298
  ```
73
299
  </output_format>
74
300
 
75
301
  <success_criteria>
76
302
  - [ ] .ctx/ directory created
303
+ - [ ] .ctx/.gitignore created (protects .env)
77
304
  - [ ] STATE.md initialized with detected info
305
+ - [ ] PRD.json created with user stories
306
+ - [ ] Constitution defined (user or defaults)
307
+ - [ ] All stories have acceptance criteria
308
+ - [ ] Stories assigned correct type (feature/brand/design)
309
+ - [ ] Design context gathered (if UI work needed)
310
+ - [ ] Brand story created first (if no BRAND_KIT.md)
311
+ - [ ] .ctx/.env created with credentials (if provided)
78
312
  - [ ] ChunkHound index attempted
79
- - [ ] User prompted for goal
80
313
  - [ ] Status set to "initializing"
314
+ - [ ] User warned about credential security
81
315
  </success_criteria>
316
+
317
+ <security_reminders>
318
+ **CRITICAL - Credential Security:**
319
+ 1. NEVER commit `.ctx/.env` to version control
320
+ 2. NEVER echo credentials in logs or output
321
+ 3. ALWAYS verify `.ctx/.gitignore` exists before storing secrets
322
+ 4. WARN user if `.gitignore` is missing or incomplete
323
+ 5. Use credentials ONLY for automated testing
324
+ </security_reminders>