ctx-cc 2.0.0 → 2.2.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/init.md CHANGED
@@ -1,12 +1,34 @@
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, 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.2 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
12
+ - `.ctx/.env` - Secure credentials (gitignored)
8
13
  </objective>
9
14
 
15
+ <philosophy>
16
+ ## Front-Loaded Approach
17
+
18
+ **Gather EVERYTHING upfront:**
19
+ 1. Project requirements → PRD.json
20
+ 2. User stories → PRD.json stories
21
+ 3. Credentials for testing → .ctx/.env
22
+ 4. URLs and endpoints → .ctx/.env
23
+ 5. Constitution/rules → PRD.json constitution
24
+
25
+ **Then execute autonomously:**
26
+ - Minimal user interruption during execution
27
+ - Only ask user for architecture decisions (Rule 4)
28
+ - Use stored credentials for browser verification
29
+ - Deliver complete, verified project
30
+ </philosophy>
31
+
10
32
  <workflow>
11
33
  ## Step 1: Check Existing
12
34
  If `.ctx/STATE.md` exists:
@@ -24,9 +46,12 @@ Scan the codebase:
24
46
  ## Step 3: Create Structure
25
47
  ```
26
48
  .ctx/
27
- ├── STATE.md # Living digest - ALWAYS read first
49
+ ├── STATE.md # Living digest - execution state
50
+ ├── PRD.json # Requirements contract - stories + acceptance criteria
51
+ ├── .env # Credentials for testing (GITIGNORED)
52
+ ├── .gitignore # Protects secrets
28
53
  ├── phases/ # Phase-specific data
29
- │ └── {phase-id}/
54
+ │ └── {story_id}/
30
55
  │ ├── RESEARCH.md
31
56
  │ ├── PLAN.md
32
57
  │ └── VERIFY.md
@@ -35,6 +60,13 @@ Scan the codebase:
35
60
  └── archive/ # Archived states
36
61
  ```
37
62
 
63
+ **Create `.ctx/.gitignore`:**
64
+ ```
65
+ .env
66
+ *.secrets
67
+ credentials.json
68
+ ```
69
+
38
70
  ## Step 4: Initialize STATE.md
39
71
  Create STATE.md from template with:
40
72
  - Project name (from package.json or directory name)
@@ -49,33 +81,177 @@ chunkhound index . --output .ctx/chunks.json
49
81
  ```
50
82
  This enables semantic code search during planning.
51
83
 
52
- ## Step 6: Prompt for Goal
84
+ ## Step 6: Gather Requirements
53
85
  Ask user: **"What do you want to build/fix/improve?"**
54
86
 
55
- Do NOT start planning yet. Just store the goal in STATE.md and set status to "initializing".
87
+ Then ask follow-up questions to elicit user stories:
88
+ - **"What are the main features/outcomes?"** (becomes stories)
89
+ - **"How will you know each is done?"** (becomes acceptance criteria)
90
+ - **"Any constraints or rules?"** (becomes constitution)
91
+
92
+ ## Step 7: Generate PRD.json
93
+ Create PRD.json with gathered information:
94
+
95
+ ```json
96
+ {
97
+ "$schema": "https://ctx.dev/schemas/prd.json",
98
+ "version": "1.0",
99
+ "project": {
100
+ "name": "{{project_name}}",
101
+ "description": "{{project_description}}",
102
+ "stack": "{{tech_stack}}",
103
+ "created": "{{timestamp}}"
104
+ },
105
+ "constitution": {
106
+ "principles": ["{{from user or defaults}}"],
107
+ "always": ["{{from user or defaults}}"],
108
+ "never": ["{{from user or defaults}}"],
109
+ "askFirst": ["{{from user or defaults}}"]
110
+ },
111
+ "stories": [
112
+ {
113
+ "id": "S001",
114
+ "title": "{{story_title}}",
115
+ "description": "{{story_description}}",
116
+ "acceptanceCriteria": ["{{criterion_1}}", "{{criterion_2}}"],
117
+ "priority": 1,
118
+ "phase": 1,
119
+ "passes": false,
120
+ "verifiedAt": null,
121
+ "notes": ""
122
+ }
123
+ ],
124
+ "metadata": {
125
+ "totalStories": {{count}},
126
+ "passedStories": 0,
127
+ "currentStory": "S001",
128
+ "lastUpdated": "{{timestamp}}"
129
+ }
130
+ }
131
+ ```
132
+
133
+ **Story Generation Rules:**
134
+ - Each distinct feature/outcome = one story
135
+ - Max 3 acceptance criteria per story (keep atomic)
136
+ - Ordered by dependency (foundation first)
137
+ - All stories start with `passes: false`
138
+
139
+ ## Step 8: Gather Credentials for Testing
140
+
141
+ Ask user about testing requirements:
142
+
143
+ **"Will this project need browser testing?"**
144
+ If yes, gather:
145
+ - **App URL** (local dev, staging, or production)
146
+ - **Test user credentials** (email/password for login flows)
147
+ - **Admin credentials** (if admin features exist)
148
+
149
+ **"Are there external APIs or services?"**
150
+ If yes, gather:
151
+ - **API keys** (third-party services)
152
+ - **Database URLs** (if direct DB testing needed)
153
+ - **OAuth tokens** (if OAuth flows)
154
+
155
+ **"Any other secrets needed for testing?"**
156
+ - Environment-specific values
157
+ - Feature flags
158
+ - Test data identifiers
159
+
160
+ ## Step 9: Create .ctx/.env
161
+
162
+ Write credentials to `.ctx/.env`:
163
+
164
+ ```bash
165
+ # CTX Test Credentials - DO NOT COMMIT
166
+ # Generated by /ctx init
167
+
168
+ # App URLs
169
+ APP_URL=http://localhost:3000
170
+ STAGING_URL=
171
+
172
+ # Test User
173
+ TEST_USER_EMAIL=
174
+ TEST_USER_PASSWORD=
175
+
176
+ # Admin User (if applicable)
177
+ ADMIN_EMAIL=
178
+ ADMIN_PASSWORD=
179
+
180
+ # API Keys
181
+ API_KEY=
182
+
183
+ # Database (if applicable)
184
+ DATABASE_URL=
185
+
186
+ # Other Secrets
187
+ # Add as needed
188
+ ```
189
+
190
+ **IMPORTANT:**
191
+ - Create `.ctx/.gitignore` with `.env` entry
192
+ - Warn user: "Credentials stored in .ctx/.env - NEVER commit this file"
193
+ - Verify .gitignore is in place before proceeding
194
+
195
+ ## Step 10: Link STATE.md to PRD
196
+ Update STATE.md to reference current story:
197
+ - **Current Story**: S001 - {{title}}
198
+
199
+ Do NOT start planning yet. Set status to "initializing".
56
200
  The user will run `/ctx` to begin the research + planning phase.
57
201
  </workflow>
58
202
 
59
203
  <output_format>
60
204
  ```
61
- [CTX 2.0] Initialized
205
+ [CTX 2.2] Initialized
62
206
 
63
207
  Project: {{name}}
64
208
  Stack: {{language}} + {{framework}}
65
209
  Directory: .ctx/
66
210
 
211
+ PRD: {{story_count}} stories
212
+ S001: {{story_1_title}} ⬜
213
+ S002: {{story_2_title}} ⬜
214
+ ...
215
+
216
+ Constitution:
217
+ Principles: {{count}}
218
+ Always: {{count}}
219
+ Never: {{count}}
220
+
221
+ Credentials:
222
+ App URL: {{configured | not set}}
223
+ Test User: {{configured | not set}}
224
+ API Keys: {{count}} configured
225
+ ⚠️ Stored in .ctx/.env (gitignored)
226
+
67
227
  Integrations:
68
228
  ArguSeek: ready
69
229
  ChunkHound: {{indexed | not found}}
230
+ Browser Testing: {{ready | needs credentials}}
70
231
 
71
- Next: Run /ctx to start planning
232
+ Ready for autonomous execution.
233
+ Next: Run /ctx to start planning for S001
72
234
  ```
73
235
  </output_format>
74
236
 
75
237
  <success_criteria>
76
238
  - [ ] .ctx/ directory created
239
+ - [ ] .ctx/.gitignore created (protects .env)
77
240
  - [ ] STATE.md initialized with detected info
241
+ - [ ] PRD.json created with user stories
242
+ - [ ] Constitution defined (user or defaults)
243
+ - [ ] All stories have acceptance criteria
244
+ - [ ] .ctx/.env created with credentials (if provided)
78
245
  - [ ] ChunkHound index attempted
79
- - [ ] User prompted for goal
80
246
  - [ ] Status set to "initializing"
247
+ - [ ] User warned about credential security
81
248
  </success_criteria>
249
+
250
+ <security_reminders>
251
+ **CRITICAL - Credential Security:**
252
+ 1. NEVER commit `.ctx/.env` to version control
253
+ 2. NEVER echo credentials in logs or output
254
+ 3. ALWAYS verify `.ctx/.gitignore` exists before storing secrets
255
+ 4. WARN user if `.gitignore` is missing or incomplete
256
+ 5. Use credentials ONLY for automated testing
257
+ </security_reminders>
@@ -0,0 +1,149 @@
1
+ ---
2
+ name: ctx:phase
3
+ description: Phase management - list, add, next, skip
4
+ args: subcommand (list|add|next|skip)
5
+ ---
6
+
7
+ <objective>
8
+ Manage project phases explicitly. CRUD operations for the phase roadmap.
9
+ </objective>
10
+
11
+ <usage>
12
+ ```
13
+ /ctx phase list # Show all phases with status
14
+ /ctx phase add "goal" # Add new phase to roadmap
15
+ /ctx phase next # Mark current complete, move to next
16
+ /ctx phase skip # Skip current phase (mark skipped)
17
+ ```
18
+ </usage>
19
+
20
+ <subcommands>
21
+
22
+ ## /ctx phase list
23
+
24
+ Show all phases with their status.
25
+
26
+ **Output:**
27
+ ```
28
+ [CTX Phases]
29
+
30
+ # Status Goal
31
+ ─────────────────────────────────────────
32
+ 1 ✓ complete Set up project structure
33
+ 2 ● current Add user authentication
34
+ 3 ○ pending Implement dashboard
35
+ 4 ○ pending Add API endpoints
36
+
37
+ Current: Phase 2 - Add user authentication
38
+ Progress: 1/3 tasks complete
39
+ ```
40
+
41
+ **Status indicators:**
42
+ - `✓` complete - Phase verified and done
43
+ - `●` current - Currently active phase
44
+ - `○` pending - Not yet started
45
+ - `⊘` skipped - Explicitly skipped
46
+
47
+ ---
48
+
49
+ ## /ctx phase add "goal"
50
+
51
+ Add a new phase to the end of the roadmap.
52
+
53
+ **Process:**
54
+ 1. Generate phase ID (increment)
55
+ 2. Create `.ctx/phases/{id}/` directory
56
+ 3. Update STATE.md with new phase in roadmap
57
+ 4. Do NOT start planning yet (user runs `/ctx plan` when ready)
58
+
59
+ **Output:**
60
+ ```
61
+ [CTX Phase] Added phase {id}
62
+
63
+ Goal: {goal}
64
+ Status: pending
65
+
66
+ Roadmap now has {n} phases.
67
+ Run /ctx plan "{goal}" when ready to plan this phase.
68
+ ```
69
+
70
+ ---
71
+
72
+ ## /ctx phase next
73
+
74
+ Mark current phase complete and move to the next.
75
+
76
+ **Process:**
77
+ 1. Verify current phase is complete (all tasks done)
78
+ 2. If not complete, warn user
79
+ 3. Mark current phase as "complete"
80
+ 4. Set next pending phase as "current"
81
+ 5. Update STATE.md
82
+
83
+ **Output (success):**
84
+ ```
85
+ [CTX Phase] Completed phase {id}: {goal}
86
+
87
+ Moving to phase {next_id}: {next_goal}
88
+ Run /ctx to start planning.
89
+ ```
90
+
91
+ **Output (not ready):**
92
+ ```
93
+ [CTX Phase] Cannot complete phase {id}
94
+
95
+ Remaining tasks:
96
+ - {task_1}
97
+ - {task_2}
98
+
99
+ Run /ctx to continue, or /ctx phase skip to skip.
100
+ ```
101
+
102
+ ---
103
+
104
+ ## /ctx phase skip
105
+
106
+ Skip the current phase without completing it.
107
+
108
+ **Process:**
109
+ 1. Mark current phase as "skipped"
110
+ 2. Log reason (optional prompt)
111
+ 3. Move to next phase
112
+ 4. Update STATE.md
113
+
114
+ **Output:**
115
+ ```
116
+ [CTX Phase] Skipped phase {id}: {goal}
117
+
118
+ Moving to phase {next_id}: {next_goal}
119
+ Run /ctx to start planning.
120
+ ```
121
+
122
+ </subcommands>
123
+
124
+ <state_management>
125
+ Phases are tracked in STATE.md:
126
+
127
+ ```markdown
128
+ ## Phases
129
+ | ID | Status | Goal |
130
+ |----|--------|------|
131
+ | 1 | complete | Set up project structure |
132
+ | 2 | current | Add user authentication |
133
+ | 3 | pending | Implement dashboard |
134
+ ```
135
+
136
+ And in individual directories:
137
+ ```
138
+ .ctx/phases/
139
+ ├── 1/
140
+ │ ├── RESEARCH.md
141
+ │ ├── PLAN.md
142
+ │ └── VERIFY.md
143
+ ├── 2/
144
+ │ ├── RESEARCH.md
145
+ │ └── PLAN.md
146
+ └── 3/
147
+ (empty until planned)
148
+ ```
149
+ </state_management>
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: ctx:plan
3
+ description: Force research + planning phase for current PRD story
4
+ args: story_id (optional - specific story to plan, defaults to current)
5
+ ---
6
+
7
+ <objective>
8
+ Force enter planning mode for a PRD story. Reads acceptance criteria from PRD.json,
9
+ runs research (ArguSeek + ChunkHound), and creates atomic plan to satisfy the story.
10
+ </objective>
11
+
12
+ <usage>
13
+ ```
14
+ /ctx plan # Plan for current story (from PRD.json)
15
+ /ctx plan S003 # Plan for specific story
16
+ ```
17
+ </usage>
18
+
19
+ <workflow>
20
+ ## Step 1: Validate Project
21
+ If `.ctx/STATE.md` or `.ctx/PRD.json` doesn't exist:
22
+ - Error: "No project found. Run /ctx init first."
23
+
24
+ ## Step 2: Load Story from PRD
25
+ Read `.ctx/PRD.json`:
26
+
27
+ If story_id argument provided:
28
+ - Find story with matching id
29
+ - Error if not found
30
+
31
+ If no argument:
32
+ - Use `metadata.currentStory` from PRD.json
33
+ - If null, use first story where `passes: false`
34
+
35
+ **Story data provides:**
36
+ - `title` → Phase goal
37
+ - `description` → Context for research
38
+ - `acceptanceCriteria` → Verification checklist
39
+
40
+ ## Step 3: Research Phase
41
+ Spawn **ctx-researcher** agent with story context:
42
+
43
+ 1. **ArguSeek Research**
44
+ - Best practices for story goal
45
+ - Security considerations
46
+ - Common pitfalls for acceptance criteria
47
+ - Performance patterns
48
+
49
+ 2. **ChunkHound Analysis** (if available)
50
+ - Semantic search for story-related code
51
+ - Pattern detection
52
+ - Entry point mapping
53
+
54
+ 3. **Output**: `.ctx/phases/{story_id}/RESEARCH.md`
55
+
56
+ ## Step 4: Planning Phase
57
+ Spawn **ctx-planner** agent:
58
+
59
+ 1. Read RESEARCH.md
60
+ 2. Map acceptance criteria to verification steps
61
+ 3. Break into **2-3 atomic tasks** (strict limit)
62
+ 4. Each task contributes to passing acceptance criteria
63
+ 5. Assign execution order
64
+
65
+ Output: `.ctx/phases/{story_id}/PLAN.md`
66
+
67
+ **Plan Format:**
68
+ ```yaml
69
+ story: S001
70
+ title: "{{story_title}}"
71
+ acceptanceCriteria:
72
+ - criterion: "{{criterion_1}}"
73
+ tasks: [1]
74
+ - criterion: "{{criterion_2}}"
75
+ tasks: [1, 2]
76
+ tasks:
77
+ - id: 1
78
+ title: "{{task_title}}"
79
+ criteria: ["{{criterion_1}}", "{{criterion_2}}"]
80
+ ```
81
+
82
+ ## Step 5: Update State
83
+ Update STATE.md:
84
+ - Status: "executing"
85
+ - Current Story: {story_id} - {title}
86
+ - Phase goal: {story_title}
87
+ - Total tasks: {count}
88
+ - Completed: 0
89
+
90
+ Update PRD.json:
91
+ - `metadata.currentStory`: {story_id}
92
+ </workflow>
93
+
94
+ <output_format>
95
+ ```
96
+ [CTX Plan] Story: {story_id} - {title}
97
+
98
+ Acceptance Criteria:
99
+ ✓ {criterion_1}
100
+ ✓ {criterion_2}
101
+ ✓ {criterion_3}
102
+
103
+ Research:
104
+ ArguSeek: {n} findings
105
+ ChunkHound: {n} relevant files
106
+
107
+ Plan Created:
108
+ Tasks: {count} (atomic)
109
+ Files: .ctx/phases/{story_id}/PLAN.md
110
+
111
+ Tasks:
112
+ 1. {task_1_title} → [criteria 1, 2]
113
+ 2. {task_2_title} → [criteria 2, 3]
114
+
115
+ Ready to execute. Run /ctx to start.
116
+ ```
117
+ </output_format>
118
+
119
+ <guardrails>
120
+ - Plans are ALWAYS atomic: 2-3 tasks maximum
121
+ - Each task must map to at least one acceptance criterion
122
+ - If story requires more tasks, ask user to split into smaller stories
123
+ - Research runs even if ChunkHound unavailable (ArguSeek only)
124
+ - Story acceptance criteria = verification checklist
125
+ </guardrails>
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: ctx:status
3
+ description: Read-only status check - see state without triggering action
4
+ ---
5
+
6
+ <objective>
7
+ Display current project status without triggering any workflow action.
8
+ Pure inspection - read STATE.md and report.
9
+ </objective>
10
+
11
+ <workflow>
12
+ ## Step 1: Check Project Exists
13
+ If `.ctx/STATE.md` doesn't exist:
14
+ ```
15
+ [CTX] No project found. Run /ctx init to start.
16
+ ```
17
+
18
+ ## Step 2: Read State
19
+ Load `.ctx/STATE.md` and extract:
20
+ - Project name and tech stack
21
+ - Current status (initializing/executing/debugging/verifying/paused)
22
+ - Current phase and goal
23
+ - Task progress
24
+ - Debug session info (if active)
25
+ - Context budget usage
26
+
27
+ ## Step 3: Read Phase Data
28
+ If phase exists, also load:
29
+ - `.ctx/phases/{id}/PLAN.md` - task list
30
+ - `.ctx/phases/{id}/RESEARCH.md` - research summary (if exists)
31
+ - `.ctx/phases/{id}/VERIFY.md` - verification results (if exists)
32
+
33
+ ## Step 4: Calculate Metrics
34
+ - Tasks completed vs total
35
+ - Context usage percentage
36
+ - Time since last checkpoint
37
+ </workflow>
38
+
39
+ <output_format>
40
+ ```
41
+ ┌─────────────────────────────────────────┐
42
+ │ CTX Status │
43
+ ├─────────────────────────────────────────┤
44
+ │ Project: {name} │
45
+ │ Stack: {tech_stack} │
46
+ │ Status: {status} │
47
+ └─────────────────────────────────────────┘
48
+
49
+ Phase: {phase_id} - {phase_goal}
50
+ Progress: {completed}/{total} tasks [{progress_bar}]
51
+
52
+ Current Task: {task_name}
53
+ Task Status: {pending|in_progress|blocked|debugging}
54
+
55
+ {If debugging:}
56
+ Debug Session:
57
+ Issue: {debug_issue}
58
+ Attempt: {n}/5
59
+ Last Error: {error_summary}
60
+
61
+ Context Budget:
62
+ Used: {percent}% ({quality_level})
63
+ Action: {continue|checkpoint-soon|checkpoint-now}
64
+
65
+ Last Checkpoint: {timestamp or "none"}
66
+
67
+ Next Action: Run /ctx to {recommended_action}
68
+ ```
69
+ </output_format>
70
+
71
+ <key_principle>
72
+ This command is READ-ONLY. It never:
73
+ - Modifies STATE.md
74
+ - Triggers any agent
75
+ - Starts any workflow action
76
+
77
+ It only inspects and reports.
78
+ </key_principle>