clavix 4.1.2 → 4.3.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 (35) hide show
  1. package/dist/cli/commands/deep.js +4 -58
  2. package/dist/cli/commands/init.js +13 -16
  3. package/dist/cli/commands/plan.js +2 -2
  4. package/dist/core/task-manager.d.ts +1 -2
  5. package/dist/core/task-manager.js +21 -26
  6. package/dist/templates/slash-commands/_canonical/deep.md +73 -80
  7. package/dist/templates/slash-commands/_canonical/fast.md +32 -9
  8. package/dist/templates/slash-commands/_canonical/plan.md +25 -7
  9. package/dist/templates/slash-commands/_canonical/prd.md +25 -7
  10. package/dist/templates/slash-commands/_canonical/start.md +25 -7
  11. package/dist/templates/slash-commands/_canonical/summarize.md +25 -7
  12. package/dist/templates/slash-commands/_components/agent-protocols/decision-rules.md +81 -0
  13. package/dist/templates/slash-commands/_components/agent-protocols/self-correction.md +42 -0
  14. package/dist/templates/slash-commands/_components/agent-protocols/state-assertion.md +52 -0
  15. package/dist/templates/slash-commands/_components/references/intent-types.md +37 -0
  16. package/dist/templates/slash-commands/_components/references/quality-dimensions.md +54 -0
  17. package/dist/templates/slash-commands/_components/sections/pattern-visibility.md +4 -4
  18. package/package.json +5 -3
  19. package/dist/templates/instructions/README 2.md +0 -311
  20. package/dist/templates/instructions/core 2/clavix-mode.md +0 -275
  21. package/dist/templates/instructions/core 2/file-operations.md +0 -330
  22. package/dist/templates/instructions/core 2/verification.md +0 -377
  23. package/dist/templates/instructions/troubleshooting 2/jumped-to-implementation.md +0 -234
  24. package/dist/templates/instructions/troubleshooting 2/mode-confusion.md +0 -402
  25. package/dist/templates/instructions/troubleshooting 2/skipped-file-creation.md +0 -385
  26. package/dist/templates/slash-commands/_canonical 2/archive.md +0 -410
  27. package/dist/templates/slash-commands/_canonical 2/deep.md +0 -512
  28. package/dist/templates/slash-commands/_canonical 2/execute.md +0 -80
  29. package/dist/templates/slash-commands/_canonical 2/fast.md +0 -370
  30. package/dist/templates/slash-commands/_canonical 2/implement.md +0 -364
  31. package/dist/templates/slash-commands/_canonical 2/plan.md +0 -329
  32. package/dist/templates/slash-commands/_canonical 2/prd.md +0 -320
  33. package/dist/templates/slash-commands/_canonical 2/prompts.md +0 -97
  34. package/dist/templates/slash-commands/_canonical 2/start.md +0 -204
  35. package/dist/templates/slash-commands/_canonical 2/summarize.md +0 -395
@@ -87,64 +87,13 @@ export default class Deep extends Command {
87
87
  console.log();
88
88
  }
89
89
  // ===== Enhanced Prompt =====
90
+ // Note: Pattern-generated content (Alternative Approaches, Edge Cases, Validation Checklist)
91
+ // is already embedded in result.enhanced by deep mode patterns
90
92
  console.log(chalk.bold.cyan('✨ Enhanced Prompt:\n'));
91
93
  console.log(chalk.dim('─'.repeat(80)));
92
94
  console.log(result.enhanced);
93
95
  console.log(chalk.dim('─'.repeat(80)));
94
96
  console.log();
95
- // ===== DEEP MODE EXCLUSIVE FEATURES =====
96
- // Alternative Approaches (TODO: when AlternativePhrasingGenerator pattern is implemented)
97
- console.log(chalk.bold.cyan('🎨 Alternative Approaches:\n'));
98
- console.log(chalk.cyan(' 1. Functional Decomposition: Break the task into smaller, testable functions'));
99
- console.log(chalk.cyan(' 2. Test-Driven Approach: Write tests first, then implement to satisfy them'));
100
- console.log(chalk.cyan(' 3. Example-Driven: Start with concrete input/output examples'));
101
- console.log(chalk.gray(' Note: Full alternative generation coming soon with deep mode patterns\n'));
102
- // Alternative Structures (TODO: when StructureVariationGenerator pattern is implemented)
103
- console.log(chalk.bold.cyan('📋 Alternative Structures:\n'));
104
- console.log(chalk.cyan(' Step-by-step:'));
105
- console.log(chalk.gray(' • Break complex task into sequential steps'));
106
- console.log(chalk.gray(' • Each step has clear input/output'));
107
- console.log(chalk.cyan(' Template-based:'));
108
- console.log(chalk.gray(' • Provide code/document template to fill'));
109
- console.log(chalk.gray(' • Reduces ambiguity with concrete structure'));
110
- console.log(chalk.cyan(' Example-driven:'));
111
- console.log(chalk.gray(' • Show concrete examples of desired output'));
112
- console.log(chalk.gray(' • AI learns from patterns in examples\n'));
113
- // Validation Checklist (TODO: when ValidationChecklistCreator pattern is implemented)
114
- console.log(chalk.bold.yellow('✅ Validation Checklist:\n'));
115
- console.log(chalk.yellow(' Before considering this task complete, verify:'));
116
- console.log(chalk.yellow(' ☐ Requirements match the objective stated above'));
117
- console.log(chalk.yellow(' ☐ All edge cases are handled (empty, null, invalid inputs)'));
118
- console.log(chalk.yellow(' ☐ Error handling is appropriate for the context'));
119
- console.log(chalk.yellow(' ☐ Output format matches specifications'));
120
- console.log(chalk.yellow(' ☐ Performance is acceptable for expected input sizes'));
121
- if (result.intent.primaryIntent === 'code-generation') {
122
- console.log(chalk.yellow(' ☐ Code is testable and maintainable'));
123
- console.log(chalk.yellow(' ☐ Security considerations addressed (injection, XSS, etc.)'));
124
- }
125
- console.log();
126
- // Edge Cases (TODO: when EdgeCaseIdentifier pattern is implemented)
127
- console.log(chalk.bold.yellow('⚠️ Edge Cases to Consider:\n'));
128
- if (result.intent.primaryIntent === 'code-generation') {
129
- console.log(chalk.yellow(' • Empty or null inputs'));
130
- console.log(chalk.yellow(' • Very large inputs (performance implications)'));
131
- console.log(chalk.yellow(' • Invalid or malformed data'));
132
- console.log(chalk.yellow(' • Concurrent access (if applicable)'));
133
- console.log(chalk.yellow(' • Network failures or timeouts (if I/O involved)'));
134
- }
135
- else if (result.intent.primaryIntent === 'planning') {
136
- console.log(chalk.yellow(' • Scope creep during implementation'));
137
- console.log(chalk.yellow(' • Technical constraints not identified upfront'));
138
- console.log(chalk.yellow(' • Timeline assumptions that may not hold'));
139
- console.log(chalk.yellow(' • Dependencies on external systems'));
140
- }
141
- else {
142
- console.log(chalk.yellow(' • Unexpected user behavior'));
143
- console.log(chalk.yellow(' • Error conditions and recovery'));
144
- console.log(chalk.yellow(' • Resource limitations'));
145
- console.log(chalk.yellow(' • Compatibility across environments'));
146
- }
147
- console.log();
148
97
  // Patterns Applied
149
98
  if (result.appliedPatterns.length > 0) {
150
99
  console.log(chalk.bold.blue('🧩 Patterns Applied:\n'));
@@ -168,7 +117,7 @@ export default class Deep extends Command {
168
117
  console.log(chalk.blue(` ${recommendation}\n`));
169
118
  }
170
119
  console.log(chalk.gray(`⚡ Processed in ${result.processingTimeMs}ms\n`));
171
- console.log(chalk.gray('💡 Tip: Use the enhanced prompt with the validation checklist and edge cases in mind\n'));
120
+ console.log(chalk.gray('💡 Tip: The enhanced prompt above includes alternative approaches, edge cases, and validation checklist\n'));
172
121
  }
173
122
  displayAnalysisOnly(result) {
174
123
  console.log(chalk.bold.cyan('🎯 Intent Analysis:\n'));
@@ -198,9 +147,6 @@ export default class Deep extends Command {
198
147
  async savePrompt(result) {
199
148
  try {
200
149
  const manager = new PromptManager();
201
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
202
- const hash = this.generateShortHash(result.original);
203
- const filename = `deep-${timestamp}-${hash}`;
204
150
  // Format enhanced prompt as content
205
151
  const content = result.enhanced;
206
152
  await manager.savePrompt(content, 'deep', result.original);
@@ -215,7 +161,7 @@ export default class Deep extends Command {
215
161
  let hash = 0;
216
162
  for (let i = 0; i < text.length; i++) {
217
163
  const char = text.charCodeAt(i);
218
- hash = ((hash << 5) - hash) + char;
164
+ hash = (hash << 5) - hash + char;
219
165
  hash = hash & hash;
220
166
  }
221
167
  return Math.abs(hash).toString(16).slice(0, 4);
@@ -17,9 +17,7 @@ import { loadCommandTemplates } from '../../utils/template-loader.js';
17
17
  import { collectLegacyCommandFiles } from '../../utils/legacy-command-cleanup.js';
18
18
  export default class Init extends Command {
19
19
  static description = 'Initialize Clavix in the current project';
20
- static examples = [
21
- '<%= config.bin %> <%= command.id %>',
22
- ];
20
+ static examples = ['<%= config.bin %> <%= command.id %>'];
23
21
  async run() {
24
22
  console.log(chalk.bold.cyan('\n🚀 Clavix Initialization\n'));
25
23
  try {
@@ -47,7 +45,7 @@ export default class Init extends Command {
47
45
  const config = JSON.parse(configContent);
48
46
  existingIntegrations = config.integrations || config.providers || [];
49
47
  }
50
- catch (error) {
48
+ catch {
51
49
  // Ignore parse errors, will use empty array
52
50
  }
53
51
  }
@@ -161,9 +159,10 @@ export default class Init extends Command {
161
159
  },
162
160
  ]);
163
161
  if (!useNamespace) {
164
- adapter = adapter.name === 'gemini'
165
- ? new GeminiAdapter({ useNamespace: false })
166
- : new QwenAdapter({ useNamespace: false });
162
+ adapter =
163
+ adapter.name === 'gemini'
164
+ ? new GeminiAdapter({ useNamespace: false })
165
+ : new QwenAdapter({ useNamespace: false });
167
166
  console.log(chalk.gray(` → Using ${adapter.getCommandPath()} (no namespacing)`));
168
167
  }
169
168
  }
@@ -235,19 +234,17 @@ export default class Init extends Command {
235
234
  catch (error) {
236
235
  const { getErrorMessage, toError } = await import('../../utils/error-utils.js');
237
236
  console.error(chalk.red('\n✗ Initialization failed:'), getErrorMessage(error));
238
- if (error && typeof error === 'object' && 'hint' in error && typeof error.hint === 'string') {
237
+ if (error &&
238
+ typeof error === 'object' &&
239
+ 'hint' in error &&
240
+ typeof error.hint === 'string') {
239
241
  console.error(chalk.yellow(' Hint:'), error.hint);
240
242
  }
241
243
  throw toError(error);
242
244
  }
243
245
  }
244
246
  async createDirectoryStructure() {
245
- const dirs = [
246
- '.clavix',
247
- '.clavix/sessions',
248
- '.clavix/outputs',
249
- '.clavix/templates',
250
- ];
247
+ const dirs = ['.clavix', '.clavix/sessions', '.clavix/outputs', '.clavix/templates'];
251
248
  for (const dir of dirs) {
252
249
  await FileSystem.ensureDir(dir);
253
250
  }
@@ -289,8 +286,8 @@ Welcome to Clavix! This directory contains your local Clavix configuration and d
289
286
  ## CLI Commands Reference
290
287
 
291
288
  ### Prompt Improvement
292
- - \`clavix fast "<prompt>"\` - Quick CLEAR (C/L/E) improvements with smart triage
293
- - \`clavix deep "<prompt>"\` - Comprehensive CLEAR (C/L/E/A/R) analysis with alternatives
289
+ - \`clavix fast "<prompt>"\` - Quick Clavix Intelligence improvements with smart triage
290
+ - \`clavix deep "<prompt>"\` - Comprehensive Clavix Intelligence analysis with alternatives
294
291
  - \`clavix execute [--latest]\` - Execute saved prompts from fast/deep optimization
295
292
  - \`clavix prompts list\` - View all saved prompts with status (NEW/EXECUTED/OLD/STALE)
296
293
  - \`clavix prompts clear\` - Cleanup prompts (\`--executed\`, \`--stale\`, \`--fast\`, \`--deep\`, \`--all\`)
@@ -80,7 +80,7 @@ export default class Plan extends Command {
80
80
  const resolvedProjectName = projectName ?? path.basename(prdPath);
81
81
  // Check if tasks.md already exists
82
82
  const tasksPath = path.join(prdPath, 'tasks.md');
83
- if (await fs.pathExists(tasksPath) && !flags.overwrite) {
83
+ if ((await fs.pathExists(tasksPath)) && !flags.overwrite) {
84
84
  console.log(chalk.yellow('Warning: tasks.md already exists.'));
85
85
  console.log(chalk.gray(`Location: ${tasksPath}`));
86
86
  console.log(chalk.gray('Use --overwrite to regenerate tasks.md.\n'));
@@ -151,7 +151,7 @@ export default class Plan extends Command {
151
151
  console.log(chalk.gray(' 2. Edit if needed (add/remove/modify tasks)'));
152
152
  console.log(chalk.gray(' 3. Run'), chalk.cyan('clavix implement'), chalk.gray('to start implementation'));
153
153
  console.log();
154
- console.log(chalk.dim('Tip: Tasks follow CLEAR framework principles for optimal AI execution\n'));
154
+ console.log(chalk.dim('Tip: Tasks are optimized with Clavix Intelligence for optimal AI execution\n'));
155
155
  }
156
156
  catch (error) {
157
157
  const errorMessage = error instanceof Error ? error.message : 'An unexpected error occurred';
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * This class handles:
5
5
  * - Analyzing PRD documents
6
- * - Generating CLEAR-optimized task breakdowns
6
+ * - Generating optimized task breakdowns
7
7
  * - Reading/writing tasks.md with checkbox format
8
8
  * - Tracking task completion state
9
9
  * - Managing session resume capability
@@ -51,7 +51,6 @@ export interface TaskGenerationResult {
51
51
  * Generates and manages implementation tasks from PRD documents
52
52
  */
53
53
  export declare class TaskManager {
54
- private readonly optimizer;
55
54
  constructor();
56
55
  /**
57
56
  * Generate tasks.md from PRD
@@ -3,14 +3,13 @@
3
3
  *
4
4
  * This class handles:
5
5
  * - Analyzing PRD documents
6
- * - Generating CLEAR-optimized task breakdowns
6
+ * - Generating optimized task breakdowns
7
7
  * - Reading/writing tasks.md with checkbox format
8
8
  * - Tracking task completion state
9
9
  * - Managing session resume capability
10
10
  */
11
11
  import fs from 'fs-extra';
12
12
  import * as path from 'path';
13
- import { PromptOptimizer } from './prompt-optimizer.js';
14
13
  import { FileSystem } from '../utils/file-system.js';
15
14
  const SOURCE_FILE_MAP = {
16
15
  full: ['full-prd.md', 'PRD.md', 'prd.md', 'Full-PRD.md', 'FULL_PRD.md', 'FULL-PRD.md'],
@@ -18,7 +17,12 @@ const SOURCE_FILE_MAP = {
18
17
  mini: ['mini-prd.md'],
19
18
  prompt: ['optimized-prompt.md'],
20
19
  };
21
- const SOURCE_ORDER_AUTO = ['full', 'quick', 'mini', 'prompt'];
20
+ const SOURCE_ORDER_AUTO = [
21
+ 'full',
22
+ 'quick',
23
+ 'mini',
24
+ 'prompt',
25
+ ];
22
26
  const ALL_KNOWN_PRD_FILES = Array.from(new Set(Object.values(SOURCE_FILE_MAP).flat()));
23
27
  /**
24
28
  * TaskManager class
@@ -26,9 +30,8 @@ const ALL_KNOWN_PRD_FILES = Array.from(new Set(Object.values(SOURCE_FILE_MAP).fl
26
30
  * Generates and manages implementation tasks from PRD documents
27
31
  */
28
32
  export class TaskManager {
29
- optimizer;
30
33
  constructor() {
31
- this.optimizer = new PromptOptimizer();
34
+ // TaskManager uses Clavix Intelligence for optimization
32
35
  }
33
36
  /**
34
37
  * Generate tasks.md from PRD
@@ -184,7 +187,7 @@ export class TaskManager {
184
187
  'Configuration & Setup': [],
185
188
  'Core Implementation': [],
186
189
  'Testing & Validation': [],
187
- 'Documentation': [],
190
+ Documentation: [],
188
191
  'Integration & Release': [],
189
192
  };
190
193
  features.forEach((feature) => {
@@ -235,7 +238,9 @@ export class TaskManager {
235
238
  if (topLevelMatch) {
236
239
  const value = topLevelMatch[1].trim();
237
240
  // Skip items that look like code examples, file paths, or implementation details
238
- if (value && !this.looksLikeCodeOrPath(value) && !this.looksLikeImplementationDetail(value)) {
241
+ if (value &&
242
+ !this.looksLikeCodeOrPath(value) &&
243
+ !this.looksLikeImplementationDetail(value)) {
239
244
  items.push(value.replace(/\s+/g, ' ').replace(/\.$/, ''));
240
245
  }
241
246
  }
@@ -311,17 +316,11 @@ export class TaskManager {
311
316
  }
312
317
  // Conversion/migration tasks - Convert + test
313
318
  if (isConversion) {
314
- return [
315
- this.convertBehaviorToTask(feature),
316
- `Test ${formattedFeature} works correctly`,
317
- ];
319
+ return [this.convertBehaviorToTask(feature), `Test ${formattedFeature} works correctly`];
318
320
  }
319
321
  // Default for complex features - Implementation + testing only
320
322
  // (No more "integrate into end-to-end" boilerplate)
321
- return [
322
- this.convertBehaviorToTask(feature),
323
- `Add tests covering ${formattedFeature}`,
324
- ];
323
+ return [this.convertBehaviorToTask(feature), `Add tests covering ${formattedFeature}`];
325
324
  }
326
325
  formatInlineText(text) {
327
326
  if (!text) {
@@ -446,9 +445,7 @@ export class TaskManager {
446
445
  const featureName = featureHeaders[i][2].trim();
447
446
  // Extract content between this header and the next one
448
447
  const startIndex = featureHeaders[i].index;
449
- const endIndex = i < featureHeaders.length - 1
450
- ? featureHeaders[i + 1].index
451
- : featuresContent.length;
448
+ const endIndex = i < featureHeaders.length - 1 ? featureHeaders[i + 1].index : featuresContent.length;
452
449
  const featureContent = featuresContent.substring(startIndex, endIndex);
453
450
  // Extract behavior points using hierarchical parsing
454
451
  const behaviorMatch = featureContent.match(/\*\*Behavior\*\*:([\s\S]*?)(?=\*\*|####|$)/);
@@ -740,9 +737,7 @@ export class TaskManager {
740
737
  const content = await fs.readFile(tasksPath, 'utf-8');
741
738
  // Find the task line and replace [ ] with [x]
742
739
  // We need to find the exact task by description
743
- const targetTask = phases
744
- .flatMap((p) => p.tasks)
745
- .find((t) => t.id === taskId);
740
+ const targetTask = phases.flatMap((p) => p.tasks).find((t) => t.id === taskId);
746
741
  if (!targetTask) {
747
742
  throw new Error(`Task not found: ${taskId}`);
748
743
  }
@@ -769,7 +764,7 @@ export class TaskManager {
769
764
  */
770
765
  validateTaskExists(phases, taskId) {
771
766
  for (const phase of phases) {
772
- const task = phase.tasks.find(t => t.id === taskId);
767
+ const task = phase.tasks.find((t) => t.id === taskId);
773
768
  if (task) {
774
769
  return task;
775
770
  }
@@ -828,7 +823,7 @@ export class TaskManager {
828
823
  const task = this.validateTaskExists(phases, taskId);
829
824
  if (!task) {
830
825
  // Task not found - provide helpful error
831
- const allTaskIds = phases.flatMap(p => p.tasks.map(t => t.id));
826
+ const allTaskIds = phases.flatMap((p) => p.tasks.map((t) => t.id));
832
827
  return {
833
828
  success: false,
834
829
  error: `Task ID "${taskId}" not found. Available task IDs:\n${allTaskIds.join('\n')}`,
@@ -876,7 +871,7 @@ export class TaskManager {
876
871
  }
877
872
  }
878
873
  // Clean up backup on success
879
- if (backupPath && await fs.pathExists(backupPath)) {
874
+ if (backupPath && (await fs.pathExists(backupPath))) {
880
875
  await fs.remove(backupPath);
881
876
  }
882
877
  return {
@@ -886,7 +881,7 @@ export class TaskManager {
886
881
  }
887
882
  catch (error) {
888
883
  // Restore from backup if available
889
- if (backupPath && await fs.pathExists(backupPath)) {
884
+ if (backupPath && (await fs.pathExists(backupPath))) {
890
885
  try {
891
886
  await fs.copyFile(backupPath, tasksPath);
892
887
  warnings.push('Restored tasks.md from backup due to error');
@@ -919,7 +914,7 @@ export class TaskManager {
919
914
  */
920
915
  async findPrdDirectory(projectName) {
921
916
  const baseDir = '.clavix/outputs';
922
- if (!await fs.pathExists(baseDir)) {
917
+ if (!(await fs.pathExists(baseDir))) {
923
918
  throw new Error('No .clavix/outputs directory found. Have you generated a PRD yet?');
924
919
  }
925
920
  // If project name specified, look for it
@@ -33,17 +33,35 @@ For complete mode documentation, see: `.clavix/instructions/core/clavix-mode.md`
33
33
 
34
34
  ## Self-Correction Protocol
35
35
 
36
- **DETECT**: If you find yourself:
37
- - Writing function/class definitions for the user's feature
38
- - Creating component implementations
39
- - Generating API endpoint code
36
+ **DETECT**: If you find yourself doing any of these 6 mistake types:
40
37
 
41
- **STOP**: Immediately halt code generation
38
+ | Type | What It Looks Like |
39
+ |------|--------------------|
40
+ | 1. Implementation Code | Writing function/class definitions, creating components, generating API endpoints, test files, database schemas, or configuration files for the user's feature |
41
+ | 2. Skipping Quality Assessment | Not scoring all 6 dimensions, providing analysis without showing dimension breakdown |
42
+ | 3. Missing Alternatives | Not generating 2-3 alternative approaches in deep mode |
43
+ | 4. Missing Validation Checklist | Not creating verification checklist for implementation |
44
+ | 5. Missing Edge Cases | Not identifying potential edge cases and failure modes |
45
+ | 6. Capability Hallucination | Claiming features Clavix doesn't have, inventing pattern names |
46
+
47
+ **STOP**: Immediately halt the incorrect action
42
48
 
43
49
  **CORRECT**: Output:
44
- "I apologize - I was implementing instead of analyzing. Let me return to deep prompt analysis."
50
+ "I apologize - I was [describe mistake]. Let me return to deep prompt analysis."
51
+
52
+ **RESUME**: Return to the deep prompt analysis workflow with all required outputs.
53
+
54
+ ---
45
55
 
46
- **RESUME**: Return to the deep prompt analysis workflow.
56
+ ## State Assertion (Required)
57
+
58
+ **Before starting analysis, output:**
59
+ ```
60
+ **CLAVIX MODE: Deep Analysis**
61
+ Mode: planning
62
+ Purpose: Comprehensive prompt analysis with alternatives, edge cases, and validation
63
+ Implementation: BLOCKED - I will analyze the prompt thoroughly, not implement it
64
+ ```
47
65
 
48
66
  ---
49
67
 
@@ -53,7 +71,7 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
53
71
 
54
72
  **Deep Mode Features:**
55
73
  - **Intent Detection**: Identifies what you're trying to achieve
56
- - **Quality Assessment**: 5-dimension deep analysis (Clarity, Efficiency, Structure, Completeness, Actionability)
74
+ - **Quality Assessment**: 6-dimension deep analysis (Clarity, Efficiency, Structure, Completeness, Actionability, Specificity)
57
75
  - **Advanced Optimization**: Applies all available patterns
58
76
  - **Alternative Approaches**: Multiple ways to phrase and structure your prompt
59
77
  - **Edge Case Analysis**: Identifies potential issues and failure modes
@@ -71,6 +89,10 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
71
89
  - **debugging**: Finding and fixing issues
72
90
  - **documentation**: Creating docs or explanations
73
91
  - **prd-generation**: Creating requirements documents
92
+ - **testing**: Writing tests, improving test coverage
93
+ - **migration**: Version upgrades, porting code between frameworks
94
+ - **security-review**: Security audits, vulnerability checks
95
+ - **learning**: Conceptual understanding, tutorials, explanations
74
96
 
75
97
  3. **Strategic Scope Detection** (before detailed analysis):
76
98
 
@@ -88,13 +110,14 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
88
110
 
89
111
  **If user chooses to continue**, proceed with deep analysis but remind them at the end that `/clavix:prd` is available for strategic planning.
90
112
 
91
- 4. **Comprehensive Quality Assessment** - Evaluate across 5 dimensions:
113
+ 4. **Comprehensive Quality Assessment** - Evaluate across 6 dimensions:
92
114
 
93
115
  - **Clarity**: Is the objective clear and unambiguous?
94
116
  - **Efficiency**: Is the prompt concise without losing critical information?
95
117
  - **Structure**: Is information organized logically?
96
118
  - **Completeness**: Are all necessary details provided?
97
119
  - **Actionability**: Can AI take immediate action on this prompt?
120
+ - **Specificity**: How concrete and precise is the prompt? (versions, paths, identifiers)
98
121
 
99
122
  Score each dimension 0-100%, calculate weighted overall score.
100
123
 
@@ -102,24 +125,18 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
102
125
 
103
126
  a. **Intent Analysis** (type, confidence, characteristics)
104
127
 
105
- b. **Quality Assessment** (5 dimensions with detailed feedback)
128
+ b. **Quality Assessment** (6 dimensions with detailed feedback)
106
129
 
107
130
  c. **Optimized Prompt** (applying all patterns)
108
131
 
109
132
  d. **Improvements Applied** (labeled with quality dimensions)
110
133
 
111
- e. **Alternative Approaches**:
112
- - 2-3 different ways to phrase the request
113
- - Alternative structures (user story, job story, structured sections)
114
- - When each approach is most appropriate
115
- - Temperature/model recommendations
134
+ e. **Alternative Approaches** (generated by AlternativePhrasingGenerator pattern):
135
+ - 2-3 different ways to approach the request
136
+ - Each approach with title, description, and "best for" context
137
+ - Intent-specific alternatives (e.g., Functional Decomposition for code, Top-Down Design for planning)
116
138
 
117
- f. **Alternative Structures**:
118
- - **Step-by-step**: Break into sequential steps
119
- - **Template-based**: Provide code/document template to fill
120
- - **Example-driven**: Show concrete examples of desired output
121
-
122
- g. **Validation Checklist**:
139
+ f. **Validation Checklist** (generated by ValidationChecklistCreator pattern):
123
140
  - Steps to verify accuracy
124
141
  - Requirements match checks
125
142
  - Edge case handling verification
@@ -127,7 +144,7 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
127
144
  - Output format validation
128
145
  - Performance considerations
129
146
 
130
- h. **Edge Cases to Consider**:
147
+ g. **Edge Cases to Consider** (generated by EdgeCaseIdentifier pattern):
131
148
  - Intent-specific edge cases
132
149
  - Error conditions and recovery
133
150
  - Unexpected inputs or behavior
@@ -146,12 +163,11 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
146
163
 
147
164
  **Include:**
148
165
  - **Intent Detection**: Automatic classification with confidence
149
- - **Quality Assessment**: All 5 dimensions with detailed analysis
166
+ - **Quality Assessment**: All 6 dimensions with detailed analysis
150
167
  - **Advanced Optimization**: All applicable patterns
151
- - **Alternative Approaches**: Multiple phrasings and perspectives
152
- - **Alternative Structures**: Different organization approaches
153
- - **Validation Checklist**: Steps to verify completion
154
- - **Edge Case Analysis**: Potential issues and failure modes
168
+ - **Alternative Approaches**: Multiple approaches (generated by AlternativePhrasingGenerator pattern)
169
+ - **Validation Checklist**: Steps to verify completion (generated by ValidationChecklistCreator pattern)
170
+ - **Edge Case Analysis**: Potential issues and failure modes (generated by EdgeCaseIdentifier pattern)
155
171
  - **Risk Assessment**: "What could go wrong" analysis
156
172
 
157
173
  **Do NOT include (these belong in `/clavix:prd`):**
@@ -180,6 +196,9 @@ Deep mode has access to all patterns including deep-exclusive patterns:
180
196
  - **ValidationChecklistCreator**: Creates implementation verification checklist
181
197
  - **AssumptionExplicitizer**: Makes implicit assumptions explicit
182
198
  - **ScopeDefiner**: Adds explicit scope boundaries
199
+ - **PRDStructureEnforcer**: Ensures PRD completeness (PRD mode only)
200
+ - **ErrorToleranceEnhancer**: Adds error handling requirements
201
+ - **PrerequisiteIdentifier**: Identifies prerequisites and dependencies
183
202
 
184
203
  ---
185
204
 
@@ -264,66 +283,40 @@ Success Criteria:
264
283
  [Completeness] Added tech stack (React/TypeScript), API endpoint, accessibility standards, testing requirements
265
284
  [Actionability] Converted vague request into specific, measurable implementation requirements
266
285
 
267
- ### Alternative Approaches:
286
+ ### Alternative Approaches
268
287
 
269
- 1. **Functional Decomposition**: "Build a React login component that: (1) validates email/password inputs, (2) calls JWT auth API, (3) handles errors gracefully, (4) manages session persistence"
288
+ **1. Functional Decomposition**
289
+ Break down into discrete functions with clear interfaces
270
290
  → Best for: Step-by-step implementation, clarity on sequence
271
291
 
272
- 2. **User-Centric**: "As a user, I need to log into my account securely using email/password, with clear feedback if credentials are invalid"
273
- Best for: Emphasizing user experience and value
274
-
275
- 3. **Example-Driven**: "Create a login page similar to [reference], with email/password fields, validation, and integration with our JWT API"
276
- → Best for: When you have a reference implementation
277
-
278
- ### Alternative Structures:
292
+ **2. Test-Driven Approach**
293
+ Define expected behavior through tests first
294
+ → Best for: When requirements are clear and testable
279
295
 
280
- **Step-by-step approach:**
281
- 1. Create form with email/password inputs and validation
282
- 2. Implement API integration with JWT endpoint
283
- 3. Add error handling and user feedback
284
- 4. Implement "remember me" and "forgot password" features
285
- 5. Add accessibility and responsive design
286
- 6. Write tests and documentation
296
+ **3. Example-Driven**
297
+ Provide concrete input/output examples
298
+ Best for: When you have reference implementations
287
299
 
288
- **Template-based approach:**
289
- Provide a component template with:
290
- - Form structure with input fields
291
- - Validation logic placeholders
292
- - API call hooks
293
- - Error state management
294
- - Accessibility attributes
295
-
296
- **Example-driven approach:**
297
- Show concrete examples of:
298
- - Login form HTML structure
299
- - Validation error messages
300
- - Success/failure API responses
301
- - Loading and error states
302
-
303
- ### Validation Checklist:
300
+ ### Validation Checklist
304
301
 
305
302
  Before considering this task complete, verify:
306
- ☐ Email and password fields validate input correctly
307
- Invalid credentials show appropriate, user-friendly error messages
308
- Successful login redirects to correct page or updates auth state
309
- "Remember me" persists session across browser sessions
310
- "Forgot password" link navigates to password reset flow
311
- Form is keyboard accessible (tab navigation, enter to submit)
312
- Screen readers announce errors and state changes
313
- Loading state prevents duplicate submissions
314
- Component renders correctly on mobile and desktop
315
- ☐ Unit tests cover success, failure, and edge cases (>80% coverage)
316
-
317
- ### Edge Cases to Consider:
318
-
319
- • **Empty or invalid inputs**: How to handle blank email, malformed email, empty password?
320
- • **API failures**: What happens if auth API is down or times out?
321
- • **Slow network**: How to indicate loading state and prevent double-submission?
322
- • **Expired sessions**: How to handle JWT expiration during login attempt?
323
- • **Account locked**: What if user account is temporarily locked after failed attempts?
324
- • **Password reset in progress**: How to handle user who requested reset but tries to login?
325
- • **Browser autofill**: Does component work correctly with password managers?
326
- • **Concurrent logins**: What happens if user logs in on multiple devices?
303
+
304
+ Code compiles/runs without errors
305
+ All requirements from prompt are implemented
306
+ Edge cases are handled gracefully
307
+ UI renders correctly on different screen sizes
308
+ Keyboard navigation works correctly
309
+ Code follows project conventions/style guide
310
+ No console errors or warnings
311
+ Documentation updated if needed
312
+
313
+ ### Edge Cases to Consider
314
+
315
+ • **Boundary conditions**: What happens at min/max values, empty collections, or single items?
316
+ • **Empty or null inputs**: How should the system handle missing or undefined values?
317
+ • **Invalid input types**: What happens if input is wrong type (string vs number)?
318
+ • **Network failures**: How to handle timeouts, connection errors, and retries?
319
+ • **Session expiration**: What happens when user session expires mid-operation?
327
320
 
328
321
  ### What Could Go Wrong:
329
322
 
@@ -32,17 +32,35 @@ For complete mode documentation, see: `.clavix/instructions/core/clavix-mode.md`
32
32
 
33
33
  ## Self-Correction Protocol
34
34
 
35
- **DETECT**: If you find yourself:
36
- - Writing function/class definitions for the user's feature
37
- - Creating component implementations
38
- - Generating API endpoint code
35
+ **DETECT**: If you find yourself doing any of these 6 mistake types:
39
36
 
40
- **STOP**: Immediately halt code generation
37
+ | Type | What It Looks Like |
38
+ |------|--------------------|
39
+ | 1. Implementation Code | Writing function/class definitions, creating components, generating API endpoints, test files, database schemas, or configuration files for the user's feature |
40
+ | 2. Skipping Quality Assessment | Not scoring all 6 dimensions, jumping to improved prompt without analysis |
41
+ | 3. Wrong Mode Selection | Not suggesting `/clavix:deep` when quality <65% or escalation factors present |
42
+ | 4. Incomplete Pattern Application | Not showing which patterns were applied, skipping patterns without explanation |
43
+ | 5. Missing Triage | Not evaluating if deep mode is needed, ignoring secondary indicators |
44
+ | 6. Capability Hallucination | Claiming features Clavix doesn't have, inventing pattern names |
45
+
46
+ **STOP**: Immediately halt the incorrect action
41
47
 
42
48
  **CORRECT**: Output:
43
- "I apologize - I was implementing instead of optimizing the prompt. Let me return to prompt optimization."
49
+ "I apologize - I was [describe mistake]. Let me return to prompt optimization."
50
+
51
+ **RESUME**: Return to the prompt optimization workflow with correct approach.
52
+
53
+ ---
44
54
 
45
- **RESUME**: Return to the prompt optimization workflow.
55
+ ## State Assertion (Required)
56
+
57
+ **Before starting analysis, output:**
58
+ ```
59
+ **CLAVIX MODE: Fast Optimization**
60
+ Mode: planning
61
+ Purpose: Optimizing user prompt with Clavix Intelligence™
62
+ Implementation: BLOCKED - I will analyze and improve the prompt, not implement it
63
+ ```
46
64
 
47
65
  ---
48
66
 
@@ -52,7 +70,7 @@ Clavix provides **Clavix Intelligence™** that automatically detects intent and
52
70
 
53
71
  **Fast Mode Features:**
54
72
  - **Intent Detection**: Automatically identifies what you're trying to achieve
55
- - **Quality Assessment**: 5-dimension analysis (Clarity, Efficiency, Structure, Completeness, Actionability)
73
+ - **Quality Assessment**: 6-dimension analysis (Clarity, Efficiency, Structure, Completeness, Actionability, Specificity)
56
74
  - **Smart Optimization**: Applies proven patterns based on your intent
57
75
  - **Intelligent Triage**: Recommends deep mode when comprehensive analysis would help
58
76
 
@@ -69,14 +87,19 @@ Clavix provides **Clavix Intelligence™** that automatically detects intent and
69
87
  - **debugging**: Finding and fixing issues
70
88
  - **documentation**: Creating docs or explanations
71
89
  - **prd-generation**: Creating requirements documents
90
+ - **testing**: Writing tests, improving test coverage
91
+ - **migration**: Version upgrades, porting code between frameworks
92
+ - **security-review**: Security audits, vulnerability checks
93
+ - **learning**: Conceptual understanding, tutorials, explanations
72
94
 
73
- 3. **Quality Assessment** - Evaluate across 5 dimensions:
95
+ 3. **Quality Assessment** - Evaluate across 6 dimensions:
74
96
 
75
97
  - **Clarity**: Is the objective clear and unambiguous?
76
98
  - **Efficiency**: Is the prompt concise without losing critical information?
77
99
  - **Structure**: Is information organized logically?
78
100
  - **Completeness**: Are all necessary details provided?
79
101
  - **Actionability**: Can AI take immediate action on this prompt?
102
+ - **Specificity**: How concrete and precise is the prompt? (versions, paths, identifiers)
80
103
 
81
104
  Score each dimension 0-100%, calculate weighted overall score.
82
105