Overview
PromptRepo provides Git-like version control for your prompts. Every content change creates a new immutable version, allowing you to track evolution, compare changes, and restore previous versions at any time.How Versioning Works
Immutable History
PromptRepo uses an append-only versioning model:- Each content change creates a new version with an incremented version number
- Existing versions can never be modified or deleted
- Version numbers are sequential integers starting from 1
- Each version is timestamped with
created_at
Metadata updates (title, description) do not create new versions. Only content changes trigger version creation.
Version Creation
When you save a new version:src/features/prompts/actions/save-new-version.ts:
Validation Rules
Content must meet these requirements:- Minimum: 1 character (after trimming)
- Maximum: 20,000 characters
- Version note: Optional, max 200 characters
src/features/prompts/actions/save-new-version.ts:8-11:
Viewing Version History
Fetching History
Get all versions for a prompt, ordered newest to oldest:src/features/prompts/queries/get-prompt-history.ts:7-23.
Version Display
Versions are typically displayed in a timeline showing:- Version number (v1, v2, v3…)
- Creation timestamp
- Version note (if provided)
- Content preview or full content
- Actions (view, restore, compare)
Restoring Versions
How Restore Works
Restoring a version doesn’t modify history. Instead, it creates a new version with the old content:src/features/prompts/actions/restore-version.ts:7-67:
The version note automatically indicates which version was restored (e.g., “Restored from v3”).
Why Not Modify History?
PromptRepo never modifies existing versions because:- Audit trail: You can see every change, including restores
- Safety: Accidental restores don’t lose work
- Clarity: Version numbers always increase
- Snapshots: Snapshots reference specific versions by ID, which must remain stable
Version Comparison
Diff Utility
PromptRepo includes a diff utility for comparing versions:- Show what changed between versions
- Highlight additions and removals
- Display side-by-side comparisons
Database Schema
Unique Constraint
Version numbers are enforced unique per prompt:Cascade Deletion
Versions are deleted when their parent prompt is deleted:Search Integration
Version Content in Search
The latest version’s content is automatically indexed for search. When a new version is created, a trigger updates the search tokens:supabase/migrations/20260208000002_search_index.sql:61-64.
Search weights:
- Title: Weight A (highest)
- Description: Weight B (medium)
- Latest content: Weight C (lower)
Best Practices
Meaningful Version Notes
Always add version notes for significant changes. Future you will appreciate the context.
Frequent Commits
Create versions frequently as you iterate. Storage is cheap, and history is valuable.
Test Before Committing
Test prompts with variable resolution before creating a version. Use snapshots to save test configurations.
Review History
Periodically review version history to understand what works and what doesn’t.
Advanced Use Cases
API Access
Access version history via the MCP API:Snapshots with Versions
Snapshots reference specific versions byprompt_version_id, not the prompt HEAD. This ensures:
- Snapshots remain tied to exact content
- Variable configurations match the prompt they were tested with
- You can restore both content (via version) and variables (via snapshot)
Next Steps
Variable Resolution
Add dynamic variables and save test configurations
Public Sharing
Share specific versions with others
Prompt Management
Learn about the full prompt lifecycle
MCP API
Access versions programmatically