clavix 4.9.0 → 4.11.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 (98) hide show
  1. package/dist/cli/commands/analyze.d.ts +17 -0
  2. package/dist/cli/commands/analyze.js +133 -0
  3. package/dist/cli/commands/execute.d.ts +2 -2
  4. package/dist/cli/commands/execute.js +23 -21
  5. package/dist/cli/commands/improve.d.ts +32 -0
  6. package/dist/cli/commands/improve.js +250 -0
  7. package/dist/cli/commands/init.js +35 -29
  8. package/dist/cli/commands/prd.js +14 -13
  9. package/dist/cli/commands/prompts/clear.d.ts +2 -2
  10. package/dist/cli/commands/prompts/clear.js +32 -26
  11. package/dist/cli/commands/prompts/list.js +14 -19
  12. package/dist/cli/commands/summarize.js +23 -14
  13. package/dist/cli/commands/verify.d.ts +2 -2
  14. package/dist/cli/commands/verify.js +26 -24
  15. package/dist/core/doc-injector.d.ts +2 -0
  16. package/dist/core/doc-injector.js +12 -13
  17. package/dist/core/intelligence/intent-detector.d.ts +4 -0
  18. package/dist/core/intelligence/intent-detector.js +8 -18
  19. package/dist/core/intelligence/pattern-library.d.ts +16 -10
  20. package/dist/core/intelligence/pattern-library.js +47 -35
  21. package/dist/core/intelligence/patterns/actionability-enhancer.d.ts +2 -2
  22. package/dist/core/intelligence/patterns/actionability-enhancer.js +1 -1
  23. package/dist/core/intelligence/patterns/alternative-phrasing-generator.d.ts +2 -2
  24. package/dist/core/intelligence/patterns/alternative-phrasing-generator.js +1 -1
  25. package/dist/core/intelligence/patterns/ambiguity-detector.d.ts +2 -2
  26. package/dist/core/intelligence/patterns/ambiguity-detector.js +1 -1
  27. package/dist/core/intelligence/patterns/assumption-explicitizer.d.ts +2 -2
  28. package/dist/core/intelligence/patterns/assumption-explicitizer.js +1 -1
  29. package/dist/core/intelligence/patterns/base-pattern.d.ts +10 -7
  30. package/dist/core/intelligence/patterns/base-pattern.js +7 -3
  31. package/dist/core/intelligence/patterns/completeness-validator.d.ts +2 -2
  32. package/dist/core/intelligence/patterns/completeness-validator.js +1 -1
  33. package/dist/core/intelligence/patterns/conciseness-filter.d.ts +2 -2
  34. package/dist/core/intelligence/patterns/conciseness-filter.js +1 -1
  35. package/dist/core/intelligence/patterns/context-precision.d.ts +2 -2
  36. package/dist/core/intelligence/patterns/context-precision.js +1 -1
  37. package/dist/core/intelligence/patterns/conversation-summarizer.d.ts +2 -2
  38. package/dist/core/intelligence/patterns/conversation-summarizer.js +1 -1
  39. package/dist/core/intelligence/patterns/dependency-identifier.d.ts +2 -2
  40. package/dist/core/intelligence/patterns/dependency-identifier.js +1 -1
  41. package/dist/core/intelligence/patterns/domain-context-enricher.d.ts +2 -2
  42. package/dist/core/intelligence/patterns/domain-context-enricher.js +1 -1
  43. package/dist/core/intelligence/patterns/edge-case-identifier.d.ts +2 -2
  44. package/dist/core/intelligence/patterns/edge-case-identifier.js +1 -1
  45. package/dist/core/intelligence/patterns/error-tolerance-enhancer.d.ts +2 -2
  46. package/dist/core/intelligence/patterns/error-tolerance-enhancer.js +1 -1
  47. package/dist/core/intelligence/patterns/implicit-requirement-extractor.d.ts +2 -2
  48. package/dist/core/intelligence/patterns/implicit-requirement-extractor.js +1 -1
  49. package/dist/core/intelligence/patterns/objective-clarifier.d.ts +2 -2
  50. package/dist/core/intelligence/patterns/objective-clarifier.js +1 -1
  51. package/dist/core/intelligence/patterns/output-format-enforcer.d.ts +2 -2
  52. package/dist/core/intelligence/patterns/output-format-enforcer.js +1 -1
  53. package/dist/core/intelligence/patterns/prd-structure-enforcer.d.ts +2 -2
  54. package/dist/core/intelligence/patterns/prd-structure-enforcer.js +1 -1
  55. package/dist/core/intelligence/patterns/prerequisite-identifier.d.ts +2 -2
  56. package/dist/core/intelligence/patterns/prerequisite-identifier.js +1 -1
  57. package/dist/core/intelligence/patterns/requirement-prioritizer.d.ts +2 -2
  58. package/dist/core/intelligence/patterns/requirement-prioritizer.js +1 -1
  59. package/dist/core/intelligence/patterns/scope-definer.d.ts +2 -2
  60. package/dist/core/intelligence/patterns/scope-definer.js +1 -1
  61. package/dist/core/intelligence/patterns/step-decomposer.d.ts +2 -2
  62. package/dist/core/intelligence/patterns/step-decomposer.js +1 -1
  63. package/dist/core/intelligence/patterns/structure-organizer.d.ts +2 -2
  64. package/dist/core/intelligence/patterns/structure-organizer.js +1 -1
  65. package/dist/core/intelligence/patterns/success-criteria-enforcer.d.ts +2 -2
  66. package/dist/core/intelligence/patterns/success-criteria-enforcer.js +1 -1
  67. package/dist/core/intelligence/patterns/success-metrics-enforcer.d.ts +2 -2
  68. package/dist/core/intelligence/patterns/success-metrics-enforcer.js +1 -1
  69. package/dist/core/intelligence/patterns/technical-context-enricher.d.ts +2 -2
  70. package/dist/core/intelligence/patterns/technical-context-enricher.js +1 -1
  71. package/dist/core/intelligence/patterns/topic-coherence-analyzer.d.ts +2 -2
  72. package/dist/core/intelligence/patterns/topic-coherence-analyzer.js +1 -1
  73. package/dist/core/intelligence/patterns/user-persona-enricher.d.ts +2 -2
  74. package/dist/core/intelligence/patterns/user-persona-enricher.js +1 -1
  75. package/dist/core/intelligence/patterns/validation-checklist-creator.d.ts +2 -2
  76. package/dist/core/intelligence/patterns/validation-checklist-creator.js +1 -1
  77. package/dist/core/intelligence/types.d.ts +6 -3
  78. package/dist/core/intelligence/universal-optimizer.d.ts +20 -15
  79. package/dist/core/intelligence/universal-optimizer.js +44 -29
  80. package/dist/core/prompt-manager.d.ts +24 -22
  81. package/dist/core/prompt-manager.js +65 -92
  82. package/dist/core/verification-manager.d.ts +8 -7
  83. package/dist/core/verification-manager.js +34 -41
  84. package/dist/templates/agents/octo.md +6 -8
  85. package/dist/templates/slash-commands/_canonical/execute.md +52 -41
  86. package/dist/templates/slash-commands/_canonical/implement.md +28 -0
  87. package/dist/templates/slash-commands/_canonical/improve.md +604 -0
  88. package/dist/templates/slash-commands/_canonical/verify.md +1 -1
  89. package/dist/templates/slash-commands/_components/agent-protocols/cli-reference.md +12 -0
  90. package/dist/templates/slash-commands/_components/agent-protocols/self-correction.md +20 -1
  91. package/dist/templates/slash-commands/_components/sections/escalation-factors.md +25 -25
  92. package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +27 -33
  93. package/dist/types/config.d.ts +1 -2
  94. package/dist/types/verification.d.ts +7 -6
  95. package/dist/types/verification.js +2 -1
  96. package/package.json +1 -1
  97. package/dist/templates/slash-commands/_canonical/deep.md +0 -616
  98. package/dist/templates/slash-commands/_canonical/fast.md +0 -503
@@ -0,0 +1,604 @@
1
+ ---
2
+ name: "Clavix: Optimize Your Prompt"
3
+ description: Analyze and optimize prompts with auto-detected depth
4
+ ---
5
+
6
+ # Clavix: Optimize Your Prompt
7
+
8
+ ## STOP: OPTIMIZATION MODE - NOT IMPLEMENTATION
9
+
10
+ **THIS IS A PROMPT OPTIMIZATION WORKFLOW. YOU MUST NOT IMPLEMENT ANYTHING.**
11
+
12
+ ## Critical Understanding
13
+
14
+ This template exists because agents (including you) tend to "help" by doing work immediately.
15
+ **That's the wrong behavior here.** Your job is to ANALYZE and IMPROVE the prompt, then STOP.
16
+
17
+ ## What "Implementation" Looks Like (ALL FORBIDDEN)
18
+ - Reading project files to "understand context" before showing analysis
19
+ - Writing any code files (functions, classes, components)
20
+ - Creating components, features, or API endpoints
21
+ - Running build/test commands on the user's project
22
+ - Making git commits
23
+ - ANY action that modifies files outside `.clavix/`
24
+ - Exploring the codebase before outputting your analysis
25
+
26
+ ## The ONLY Actions Allowed
27
+ 1. Read the user's prompt text (the `{{ARGS}}` provided)
28
+ 2. Analyze it using the workflow below
29
+ 3. Output the analysis (intent, quality, optimized prompt)
30
+ 4. Save to `.clavix/outputs/prompts/`
31
+ 5. STOP and wait for `/clavix:execute`
32
+
33
+ ## IF USER WANTS TO IMPLEMENT:
34
+ Tell them: **"Run `/clavix:execute --latest` to implement this prompt."**
35
+
36
+ **DO NOT IMPLEMENT YOURSELF. YOUR JOB ENDS AFTER SHOWING THE OPTIMIZED PROMPT.**
37
+
38
+ ---
39
+
40
+ ## CLAVIX MODE: Prompt Optimization Only
41
+
42
+ **You are in Clavix prompt optimization mode. You help analyze and optimize PROMPTS, NOT implement features.**
43
+
44
+ **YOUR ROLE:**
45
+ - Analyze prompts for quality
46
+ - Apply optimization patterns
47
+ - Generate improved versions
48
+ - Provide quality assessments
49
+ - Save the optimized prompt
50
+ - **STOP** after optimization
51
+
52
+ **DO NOT IMPLEMENT. DO NOT IMPLEMENT. DO NOT IMPLEMENT.**
53
+ - DO NOT write application code for the feature
54
+ - DO NOT implement what the prompt/PRD describes
55
+ - DO NOT generate actual components/functions
56
+ - DO NOT continue after showing the optimized prompt
57
+
58
+ **You are optimizing prompts, not building what they describe.**
59
+
60
+ ---
61
+
62
+ ## State Assertion (Required)
63
+
64
+ **Before starting analysis, output:**
65
+ ```
66
+ **CLAVIX MODE: Improve**
67
+ Mode: planning
68
+ Purpose: Optimizing user prompt with Clavix Intelligence
69
+ Depth: [standard|comprehensive] (auto-detected based on quality score)
70
+ Implementation: BLOCKED - I will analyze and improve the prompt, not implement it
71
+ ```
72
+
73
+ ---
74
+
75
+ ## What is Clavix Improve Mode?
76
+
77
+ v4.11 introduces a unified **improve** mode that intelligently selects the appropriate analysis depth:
78
+
79
+ **Smart Depth Selection:**
80
+ - **Quality Score >= 75%**: Auto-selects **comprehensive** depth (the prompt is good, add polish)
81
+ - **Quality Score 60-74%**: Asks user to choose depth (borderline quality)
82
+ - **Quality Score < 60%**: Auto-selects **standard** depth (needs basic fixes first)
83
+
84
+ **Standard Depth Features:**
85
+ - Intent Detection: Automatically identifies what you're trying to achieve
86
+ - Quality Assessment: 6-dimension analysis (Clarity, Efficiency, Structure, Completeness, Actionability, Specificity)
87
+ - Smart Optimization: Applies core patterns based on your intent
88
+ - Single improved prompt with quality feedback
89
+
90
+ **Comprehensive Depth Adds:**
91
+ - Alternative Approaches: 2-3 different ways to phrase the request
92
+ - Edge Case Analysis: Potential issues and failure modes
93
+ - Validation Checklist: Steps to verify implementation
94
+ - Risk Assessment: "What could go wrong" analysis
95
+
96
+ ---
97
+
98
+ ## Self-Correction Protocol
99
+
100
+ **DETECT**: If you find yourself doing any of these mistake types:
101
+
102
+ | Type | What It Looks Like |
103
+ |------|--------------------|
104
+ | 1. Implementation Code | Writing function/class definitions, creating components, generating API endpoints |
105
+ | 2. Skipping Quality Assessment | Not scoring all 6 dimensions, jumping to improved prompt without analysis |
106
+ | 3. Wrong Depth Selection | Not explaining why standard/comprehensive was chosen |
107
+ | 4. Incomplete Pattern Application | Not showing which patterns were applied |
108
+ | 5. Missing Depth Features | In comprehensive mode: missing alternatives, edge cases, or validation |
109
+ | 6. Capability Hallucination | Claiming features Clavix doesn't have, inventing pattern names |
110
+
111
+ **STOP**: Immediately halt the incorrect action
112
+
113
+ **CORRECT**: Output:
114
+ "I apologize - I was [describe mistake]. Let me return to prompt optimization."
115
+
116
+ **RESUME**: Return to the prompt optimization workflow with correct approach.
117
+
118
+ ---
119
+
120
+ ## Instructions
121
+
122
+ 1. Take the user's prompt: `{{ARGS}}`
123
+
124
+ 2. **Intent Detection** - Analyze what the user is trying to achieve:
125
+ - **code-generation**: Writing new code or functions
126
+ - **planning**: Designing architecture or breaking down tasks
127
+ - **refinement**: Improving existing code or prompts
128
+ - **debugging**: Finding and fixing issues
129
+ - **documentation**: Creating docs or explanations
130
+ - **prd-generation**: Creating requirements documents
131
+ - **testing**: Writing tests, improving test coverage
132
+ - **migration**: Version upgrades, porting code between frameworks
133
+ - **security-review**: Security audits, vulnerability checks
134
+ - **learning**: Conceptual understanding, tutorials, explanations
135
+ - **summarization**: Extracting requirements from conversations
136
+
137
+ 3. **Quality Assessment** - Evaluate across 6 dimensions:
138
+
139
+ - **Clarity**: Is the objective clear and unambiguous?
140
+ - **Efficiency**: Is the prompt concise without losing critical information?
141
+ - **Structure**: Is information organized logically?
142
+ - **Completeness**: Are all necessary details provided?
143
+ - **Actionability**: Can AI take immediate action on this prompt?
144
+ - **Specificity**: How concrete and precise is the prompt? (versions, paths, identifiers)
145
+
146
+ Score each dimension 0-100%, calculate weighted overall score.
147
+
148
+ 4. **Smart Depth Selection**:
149
+
150
+ Based on the quality assessment:
151
+
152
+ **If Overall Quality >= 75%**:
153
+ - Auto-select **comprehensive** depth
154
+ - Explain: "Quality is good (XX%) - using comprehensive depth for polish"
155
+
156
+ **If Overall Quality 60-74%**:
157
+ - Ask user to choose:
158
+ ```
159
+ Quality score: XX% (borderline)
160
+
161
+ Choose analysis depth:
162
+ - Comprehensive: Alternative approaches, edge cases, validation checklist
163
+ - Standard: Quick improvements and core optimization
164
+ ```
165
+
166
+ **If Overall Quality < 60%**:
167
+ - Auto-select **standard** depth
168
+ - Explain: "Quality is low (XX%) - using standard depth for basic fixes"
169
+
170
+ 5. **Generate Output** based on selected depth:
171
+
172
+ **Standard Depth Output:**
173
+ - Intent Analysis (type, confidence)
174
+ - Quality Assessment (6 dimensions)
175
+ - Optimized Prompt (applying core patterns)
176
+ - Improvements Applied (labeled with quality dimensions)
177
+ - Patterns Applied
178
+
179
+ **Comprehensive Depth Output (includes all standard plus):**
180
+ - Alternative Approaches (2-3 different ways to structure the request)
181
+ - Validation Checklist (steps to verify implementation)
182
+ - Edge Cases to Consider
183
+ - What Could Go Wrong (risk assessment)
184
+ - Patterns Applied (all patterns including comprehensive-only)
185
+
186
+ 6. **Quality-labeled feedback**:
187
+ - Label all improvements with quality dimension tags
188
+ - Example: "[Efficiency] Removed 15 unnecessary phrases"
189
+ - Example: "[Structure] Reorganized into logical sections"
190
+ - Example: "[Completeness] Added missing technical constraints"
191
+
192
+ 7. Present everything in a well-organized format.
193
+
194
+ ---
195
+
196
+ ## Example - Standard Depth
197
+
198
+ If user provides: "Please could you maybe help me create a login page?"
199
+
200
+ ```
201
+ ## Clavix Improve Mode Analysis
202
+
203
+ ### Depth Selection
204
+ Quality Score: 42% - Using standard depth for basic optimization
205
+
206
+ ### Intent Detection:
207
+ Type: code-generation
208
+ Confidence: 85%
209
+
210
+ ### Quality Assessment:
211
+
212
+ Clarity: 40%
213
+ Efficiency: 35%
214
+ Structure: 85%
215
+ Completeness: 20%
216
+ Actionability: 30%
217
+ Specificity: 25%
218
+
219
+ Overall Quality: 42% (needs-improvement)
220
+
221
+ ### Optimized Prompt:
222
+
223
+ Objective: Build a secure user authentication login page
224
+
225
+ Requirements:
226
+ - Email and password input fields with validation
227
+ - "Remember me" checkbox
228
+ - "Forgot password" link
229
+ - Clear error messages for invalid credentials
230
+ - Responsive design for mobile and desktop
231
+
232
+ Technical Constraints:
233
+ - Use React with TypeScript
234
+ - Integrate with existing JWT authentication API
235
+ - Follow WCAG 2.1 AA accessibility standards
236
+
237
+ Expected Output:
238
+ - Fully functional login component
239
+ - Unit tests with >80% coverage
240
+
241
+ Success Criteria:
242
+ - Users can log in successfully
243
+ - Invalid credentials show appropriate errors
244
+ - Page is accessible via keyboard navigation
245
+
246
+ ### Improvements Applied:
247
+
248
+ [Efficiency] Removed 4 pleasantries, reduced from 11 words to core intent
249
+ [Structure] Organized: Objective -> Requirements -> Constraints -> Output -> Criteria
250
+ [Clarity] Added explicit specifications: React TypeScript, component output, production-ready
251
+ [Completeness] Added tech stack, authentication method, accessibility standards
252
+ [Actionability] Converted vague "create" into specific implementation requirements
253
+
254
+ ### Patterns Applied:
255
+ - ConcisenessFilter: Removed unnecessary phrases
256
+ - ObjectiveClarifier: Extracted clear goal statement
257
+ - TechnicalContextEnricher: Added React/TypeScript stack
258
+ ```
259
+
260
+ ---
261
+
262
+ ## Example - Comprehensive Depth
263
+
264
+ If user provides: "Build a notification system for our SaaS platform" (higher quality prompt)
265
+
266
+ ```
267
+ ## Clavix Improve Mode Analysis
268
+
269
+ ### Depth Selection
270
+ Quality Score: 78% - Using comprehensive depth for thorough analysis
271
+
272
+ ### Intent Detection:
273
+ Type: planning
274
+ Confidence: 90%
275
+ Characteristics:
276
+ - Has code context: No
277
+ - Technical terms: Yes
278
+ - Open-ended: Yes
279
+ - Needs structure: Yes
280
+
281
+ ### Quality Assessment:
282
+
283
+ Clarity: 75%
284
+ Efficiency: 85%
285
+ Structure: 70%
286
+ Completeness: 65%
287
+ Actionability: 70%
288
+
289
+ Overall Quality: 78% (good)
290
+
291
+ ### Optimized Prompt:
292
+ [... full optimized prompt ...]
293
+
294
+ ### Improvements Applied:
295
+ [... improvements with labels ...]
296
+
297
+ ### Alternative Approaches
298
+
299
+ **1. Event-Driven Architecture**
300
+ Define notification triggers and handlers separately
301
+ Best for: Systems with many notification types
302
+
303
+ **2. Channel-First Design**
304
+ Design around delivery channels (email, push, in-app)
305
+ Best for: Multi-channel notification requirements
306
+
307
+ **3. Template-Based System**
308
+ Focus on notification templates and personalization
309
+ Best for: Marketing-heavy notification needs
310
+
311
+ ### Validation Checklist
312
+
313
+ Before considering this task complete, verify:
314
+
315
+ - [ ] All notification channels implemented
316
+ - [ ] Delivery retry logic in place
317
+ - [ ] User preferences respected
318
+ - [ ] Unsubscribe mechanism working
319
+ - [ ] Rate limiting configured
320
+ - [ ] Notification history stored
321
+ - [ ] Analytics tracking enabled
322
+
323
+ ### Edge Cases to Consider
324
+
325
+ - User has disabled all notifications
326
+ - Notification delivery fails repeatedly
327
+ - High notification volume bursts
328
+ - Timezone-sensitive notifications
329
+ - Notification stacking/grouping
330
+
331
+ ### What Could Go Wrong
332
+
333
+ - Missing rate limiting leading to spam
334
+ - No delivery confirmation causing silent failures
335
+ - Poor batching overwhelming users
336
+ - Missing unsubscribe compliance issues
337
+ ```
338
+
339
+ ---
340
+
341
+ ## CHECKPOINT: Analysis Complete?
342
+
343
+ **Before proceeding to save, verify you have output ALL of the following:**
344
+
345
+ **Standard Depth:**
346
+ - [ ] **Intent Analysis** with type and confidence
347
+ - [ ] **Quality Assessment** with all 6 dimensions
348
+ - [ ] **Optimized Prompt** in code block
349
+ - [ ] **Improvements Applied** with dimension labels
350
+
351
+ **Comprehensive Depth (add to above):**
352
+ - [ ] **Alternative Approaches** (2-3 alternatives)
353
+ - [ ] **Validation Checklist**
354
+ - [ ] **Edge Cases**
355
+
356
+ **Self-Check Before Any Action:**
357
+ - Am I about to write/edit code files? STOP (only `.clavix/` files allowed)
358
+ - Am I about to run a command that modifies the project? STOP
359
+ - Am I exploring the codebase before showing analysis? STOP
360
+ - Have I shown the user the optimized prompt yet? If NO, do that first
361
+
362
+ ---
363
+
364
+ ## ⛔ SAVING CHECKPOINT (REQUIRED - DO NOT SKIP)
365
+
366
+ **DO NOT output any "saved" message until you have COMPLETED and VERIFIED all save steps.**
367
+
368
+ This is a BLOCKING checkpoint. You cannot proceed to the final message until saving is verified.
369
+
370
+ ### What You MUST Do Before Final Output:
371
+
372
+ | Step | Action | Tool to Use | Verification |
373
+ |------|--------|-------------|--------------|
374
+ | 1 | Create directory | Write tool (create parent dirs) | Directory exists |
375
+ | 2 | Generate prompt ID | Format: `{std\|comp}-YYYYMMDD-HHMMSS-<random>` | ID is unique |
376
+ | 3 | Write prompt file | **Write tool** | File created |
377
+ | 4 | Update .index.json | **Write tool** | Entry added |
378
+ | 5 | **VERIFY: Read back files** | **Read tool** | Both files readable |
379
+
380
+ **⚠️ WARNING:** If you output "saved" without completing verification, you are LYING to the user.
381
+
382
+ ---
383
+
384
+ ### Step 1: Create Directory Structure
385
+
386
+ Use the Write tool - it will create parent directories automatically.
387
+ Path: `.clavix/outputs/prompts/<prompt-id>.md`
388
+
389
+ ### Step 2: Generate Unique Prompt ID
390
+
391
+ Create a unique identifier using this format:
392
+ - **Standard depth format**: `std-YYYYMMDD-HHMMSS-<random>`
393
+ - **Comprehensive depth format**: `comp-YYYYMMDD-HHMMSS-<random>`
394
+ - **Example**: `std-20250117-143022-a3f2` or `comp-20250117-143022-a3f2`
395
+
396
+ ### Step 3: Save Prompt File (Write Tool)
397
+
398
+ **Use the Write tool** to create the prompt file at:
399
+ - **Path**: `.clavix/outputs/prompts/<prompt-id>.md`
400
+
401
+ **File content format**:
402
+ ```markdown
403
+ ---
404
+ id: <prompt-id>
405
+ depthUsed: standard|comprehensive
406
+ timestamp: <ISO-8601 timestamp>
407
+ executed: false
408
+ originalPrompt: <user's original prompt text>
409
+ ---
410
+
411
+ # Improved Prompt
412
+
413
+ <Insert the optimized prompt content from your analysis above>
414
+
415
+ ## Quality Scores
416
+ - **Clarity**: <percentage>%
417
+ - **Efficiency**: <percentage>%
418
+ - **Structure**: <percentage>%
419
+ - **Completeness**: <percentage>%
420
+ - **Actionability**: <percentage>%
421
+ - **Overall**: <percentage>% (<rating>)
422
+
423
+ ## Original Prompt
424
+ ```
425
+ <user's original prompt text>
426
+ ```
427
+
428
+ [For comprehensive depth, also include:]
429
+ ## Alternative Approaches
430
+ <Insert alternatives>
431
+
432
+ ## Validation Checklist
433
+ <Insert checklist>
434
+
435
+ ## Edge Cases
436
+ <Insert edge cases>
437
+ ```
438
+
439
+ ### Step 4: Update Index File (Write Tool)
440
+
441
+ **Use the Write tool** to update the index at `.clavix/outputs/prompts/.index.json`:
442
+
443
+ **If index file doesn't exist**, create it with:
444
+ ```json
445
+ {
446
+ "version": "2.0",
447
+ "prompts": []
448
+ }
449
+ ```
450
+
451
+ **Then add a new metadata entry** to the `prompts` array:
452
+ ```json
453
+ {
454
+ "id": "<prompt-id>",
455
+ "filename": "<prompt-id>.md",
456
+ "depthUsed": "standard|comprehensive",
457
+ "timestamp": "<ISO-8601 timestamp>",
458
+ "createdAt": "<ISO-8601 timestamp>",
459
+ "path": ".clavix/outputs/prompts/<prompt-id>.md",
460
+ "originalPrompt": "<user's original prompt text>",
461
+ "executed": false,
462
+ "executedAt": null
463
+ }
464
+ ```
465
+
466
+ ---
467
+
468
+ ## ✅ VERIFICATION (REQUIRED - Must Pass Before Final Output)
469
+
470
+ **After completing Steps 1-4, you MUST verify the save succeeded.**
471
+
472
+ ### Verification Step A: Read the Prompt File
473
+
474
+ Use the **Read tool** to read the file you just created:
475
+ - Path: `.clavix/outputs/prompts/<your-prompt-id>.md`
476
+
477
+ **If Read fails:** ⛔ STOP - Saving failed. Retry Steps 3-4.
478
+
479
+ ### Verification Step B: Read the Index File
480
+
481
+ Use the **Read tool** to read the index:
482
+ - Path: `.clavix/outputs/prompts/.index.json`
483
+
484
+ **Confirm:** Your prompt ID appears in the `prompts` array.
485
+
486
+ **If not found:** ⛔ STOP - Index update failed. Retry Step 4.
487
+
488
+ ### Verification Checklist
489
+
490
+ Before outputting final message, confirm ALL of these:
491
+
492
+ - [ ] I used the **Write tool** to create `.clavix/outputs/prompts/<id>.md`
493
+ - [ ] I used the **Write tool** to update `.clavix/outputs/prompts/.index.json`
494
+ - [ ] I used the **Read tool** to verify the prompt file exists and has content
495
+ - [ ] I used the **Read tool** to verify my prompt ID is in .index.json
496
+ - [ ] I know the **exact file path** I created (not a placeholder)
497
+
498
+ **If ANY checkbox is unchecked: ⛔ STOP and complete the missing step.**
499
+
500
+ ---
501
+
502
+ ## Final Output (ONLY After Verification Passes)
503
+
504
+ **Your workflow ends here. ONLY output the final message after verification passes.**
505
+
506
+ ### Required Response Ending
507
+
508
+ **Your response MUST end with the ACTUAL file path you created:**
509
+
510
+ ```
511
+ ✅ Prompt saved to: `.clavix/outputs/prompts/<actual-prompt-id>.md`
512
+
513
+ Ready to build this? Just say "let's implement" or run:
514
+ /clavix:execute --latest
515
+ ```
516
+
517
+ **Replace `<actual-prompt-id>` with the real ID you generated (e.g., `std-20250126-143022-a3f2`).**
518
+
519
+ **⚠️ If you cannot state the actual file path, you have NOT saved the prompt. Go back and complete saving.**
520
+
521
+ **IMPORTANT: Don't start implementing. Don't write code. Your job is done.**
522
+ Wait for the user to decide what to do next.
523
+
524
+ ---
525
+
526
+ ## Workflow Navigation
527
+
528
+ **You are here:** Improve Mode (Unified Prompt Intelligence)
529
+
530
+ **Common workflows:**
531
+ - **Quick cleanup**: `/clavix:improve` -> `/clavix:execute --latest` -> Implement
532
+ - **Force comprehensive**: `/clavix:improve --comprehensive` -> Full analysis with alternatives
533
+ - **Strategic planning**: `/clavix:improve` -> (suggests) `/clavix:prd` -> Plan -> Implement -> Archive
534
+
535
+ **Related commands:**
536
+ - `/clavix:execute` - Execute saved prompt (IMPLEMENTATION starts here)
537
+ - `/clavix:prd` - Generate PRD for strategic planning
538
+ - `/clavix:start` - Conversational exploration before prompting
539
+ - `/clavix:verify` - Verify implementation against checklist
540
+
541
+ **CLI commands:**
542
+ - `clavix prompts list` - View saved prompts
543
+ - `clavix prompts clear --executed` - Clean up executed prompts
544
+
545
+ ---
546
+
547
+ ## Agent Transparency (v4.11)
548
+
549
+ ### CLI Reference (Commands I Execute)
550
+ {{INCLUDE:agent-protocols/cli-reference.md}}
551
+
552
+ ### How to Explain Improvements
553
+ {{INCLUDE:sections/improvement-explanations.md}}
554
+
555
+ ### Quality Dimensions (Plain English)
556
+ {{INCLUDE:references/quality-dimensions.md}}
557
+
558
+ ### When to Recommend PRD Mode
559
+ {{INCLUDE:sections/escalation-factors.md}}
560
+
561
+ ### What Made the Biggest Difference
562
+ {{INCLUDE:sections/pattern-impact.md}}
563
+
564
+ ### Agent Decision Rules
565
+ {{INCLUDE:agent-protocols/decision-rules.md}}
566
+
567
+ ### Error Handling
568
+ {{INCLUDE:agent-protocols/error-handling.md}}
569
+
570
+ ---
571
+
572
+ ## Tips
573
+
574
+ - **Smart depth selection**: Let the quality score guide depth choice
575
+ - **Override when needed**: Use `--comprehensive` or `--standard` flags to force depth
576
+ - Label all changes with quality dimensions for education
577
+ - For strategic planning with architecture decisions, recommend `/clavix:prd`
578
+ - Focus on making prompts **actionable** quickly
579
+
580
+ ## Troubleshooting
581
+
582
+ ### Issue: Prompt Not Saved
583
+
584
+ **Error: Cannot create directory**
585
+ ```bash
586
+ mkdir -p .clavix/outputs/prompts
587
+ ```
588
+
589
+ **Error: Index file corrupted or invalid JSON**
590
+ ```bash
591
+ echo '{"version":"2.0","prompts":[]}' > .clavix/outputs/prompts/.index.json
592
+ ```
593
+
594
+ ### Issue: Wrong depth auto-selected
595
+ **Cause**: Borderline quality score
596
+ **Solution**:
597
+ - User can override with `--comprehensive` or `--standard` flags
598
+ - Or re-run with explicit depth choice
599
+
600
+ ### Issue: Improved prompt still feels incomplete
601
+ **Cause**: Standard depth was used but comprehensive needed
602
+ **Solution**:
603
+ - Re-run with `/clavix:improve --comprehensive`
604
+ - Or use `/clavix:prd` if strategic planning is needed
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: "Clavix: Verify"
3
- description: Verify implementation against validation checklist from deep/fast mode
3
+ description: Verify implementation against validation checklist from improve mode
4
4
  ---
5
5
 
6
6
  # Clavix: Verify Implementation
@@ -24,6 +24,18 @@ clavix fast "build a todo app"
24
24
  clavix deep "create authentication system with OAuth"
25
25
  ```
26
26
 
27
+ #### `clavix analyze "prompt"`
28
+ **What it does:** Returns structured JSON with intent, quality scores, and escalation recommendation
29
+ **When to run:** When you need data-driven decision on which mode to use
30
+ **You say:** Nothing - this is for internal decision-making
31
+ **Example:**
32
+ ```bash
33
+ clavix analyze "build a login page"
34
+ ```
35
+ **Output:** JSON with `intent`, `confidence`, `quality` (6 dimensions), `escalation` (score + recommendation)
36
+ **Flags:**
37
+ - `--pretty` - Pretty-print the JSON output
38
+
27
39
  #### `clavix prompts list`
28
40
  **What it does:** Shows all saved prompts with their status
29
41
  **When to run:** To verify a prompt was saved, or find prompt IDs
@@ -9,6 +9,8 @@
9
9
  - Writing test files for the user's feature
10
10
  - Creating database schemas/migrations
11
11
  - Writing configuration files for deployment
12
+ - **Reading project files to "understand context" before showing analysis**
13
+ - **Exploring the codebase before outputting optimized prompt**
12
14
 
13
15
  ### Mistake Type 2: Skipping Quality Assessment
14
16
  - Not scoring all 6 quality dimensions
@@ -37,6 +39,23 @@
37
39
 
38
40
  **STOP**: Immediately halt the incorrect action
39
41
 
40
- **CORRECT**: Output an acknowledgment and return to correct workflow
42
+ **CORRECT**: Output an acknowledgment:
43
+ > "I was about to [describe action]. Let me return to [fast/deep] prompt analysis."
41
44
 
42
45
  **RESUME**: Return to the appropriate Clavix workflow for this mode
46
+
47
+ ---
48
+
49
+ ## Anti-Implementation Tripwires
50
+
51
+ **Before your next tool call or action, check:**
52
+
53
+ | Action | Tripwire | Response |
54
+ |--------|----------|----------|
55
+ | About to read project files | STOP | "I don't need to explore the codebase for prompt optimization" |
56
+ | About to write code files | STOP | "Only `.clavix/` files are allowed in optimization mode" |
57
+ | About to run build/test commands | STOP | "Project commands are for `/clavix:execute`, not optimization" |
58
+ | About to make git commits | STOP | "Git operations belong in implementation mode" |
59
+ | Haven't shown optimized prompt yet | STOP | "I need to show the analysis first" |
60
+
61
+ **If any tripwire triggers:** Output the response and return to prompt analysis.