Prompt Management System
This directory contains all versioned system prompts for Vibn's chat modes.
📁 Structure
prompts/
├── index.ts # Exports all prompts
├── shared.ts # Shared prompt components
├── collector.ts # Collector mode prompts
├── extraction-review.ts # Extraction review mode prompts
├── vision.ts # Vision mode prompts
├── mvp.ts # MVP mode prompts
├── marketing.ts # Marketing mode prompts
└── general-chat.ts # General chat mode prompts
🔄 Versioning
Each prompt file contains:
- Version history - All versions of the prompt
- Metadata - Version number, date, description
- Current version - Which version is active
Example Structure
const COLLECTOR_V1: PromptVersion = {
version: 'v1',
createdAt: '2024-11-17',
description: 'Initial version',
prompt: `...`,
};
const COLLECTOR_V2: PromptVersion = {
version: 'v2',
createdAt: '2024-12-01',
description: 'Added context-aware chunking',
prompt: `...`,
};
export const collectorPrompts = {
v1: COLLECTOR_V1,
v2: COLLECTOR_V2,
current: 'v2', // ← Active version
};
📝 How to Add a New Prompt Version
- Open the relevant mode file (e.g.,
collector.ts) - Create a new version constant:
const COLLECTOR_V2: PromptVersion = { version: 'v2', createdAt: '2024-12-01', description: 'What changed in this version', prompt: ` Your new prompt text here... `, }; - Add to the prompts object:
export const collectorPrompts = { v1: COLLECTOR_V1, v2: COLLECTOR_V2, // Add new version current: 'v2', // Update current }; - Done! The system will automatically use the new version.
🔙 How to Rollback
Simply change the current field:
export const collectorPrompts = {
v1: COLLECTOR_V1,
v2: COLLECTOR_V2,
current: 'v1', // Rolled back to v1
};
📊 Benefits of This System
- Version History - Keep all previous prompts for reference
- Easy Rollback - Instantly revert to a previous version
- Git-Friendly - Clear diffs show exactly what changed
- Documentation - Each version has a description of changes
- A/B Testing Ready - Can easily test multiple versions
- Isolated Changes - Changing one prompt doesn't affect others
🎯 Usage in Code
// Import current prompts (most common)
import { MODE_SYSTEM_PROMPTS } from '@/lib/ai/chat-modes';
const prompt = MODE_SYSTEM_PROMPTS['collector_mode'];
// Or access version history
import { collectorPrompts } from '@/lib/ai/prompts';
console.log(collectorPrompts.v1.prompt); // Old version
console.log(collectorPrompts.current); // 'v2'
🚀 Future Enhancements
Analytics Tracking
Track performance by prompt version:
await logPromptUsage({
mode: 'collector_mode',
version: collectorPrompts.current,
userId: user.id,
responseQuality: 0.85,
});
A/B Testing
Test multiple versions simultaneously:
const promptVersion = userInExperiment ? 'v2' : 'v1';
const prompt = collectorPrompts[promptVersion].prompt;
Database Storage
Move to Firestore for dynamic updates:
// Future: Load from database
const prompt = await getPrompt('collector_mode', 'latest');
📚 Best Practices
- Always add a description - Future you will thank you
- Never delete old versions - Keep history for rollback
- Test before deploying - Ensure new prompts work as expected
- Document changes - What problem does the new version solve?
- Version incrementally - Don't skip version numbers
🔍 Example: Adding Context-Aware Chunking
// 1. Create new version
const COLLECTOR_V2: PromptVersion = {
version: 'v2',
createdAt: '2024-11-17',
description: 'Added instructions for context-aware chunking',
prompt: `
${COLLECTOR_V1.prompt}
**Context-Aware Retrieval**:
When referencing retrieved chunks, always cite the source document
and chunk number for transparency.
`,
};
// 2. Update prompts object
export const collectorPrompts = {
v1: COLLECTOR_V1,
v2: COLLECTOR_V2,
current: 'v2',
};
// 3. Deploy and monitor
// If issues arise, simply change current: 'v1' to rollback
Questions? Check the code in any prompt file for examples.