Prompt Library
The Prompt Library is a feature that allows users to save, organize, share, and discover AI prompts. Users can create their own prompts, categorize them, and optionally make them public for others to use.
Features
Core Functionality
- Save Prompts: Users can save prompts they create while using the AI agents
- Organize Prompts: Categorize prompts by usage type and custom categories
- Public/Private Settings: Control visibility of prompts to other users
- Import Functionality: Copy public prompts to your personal library
- Dedicated Pages: Access prompts at
/prompt-library
and individual prompts at/prompt-library/[id]
Enhanced Features
-
Advanced Filtering: Filter prompts by multiple criteria including:
- Text search
- Categories
- Usage types
- Tags
- Minimum rating
- Date ranges
-
Sorting Options:
- Newest first
- Oldest first
- Most viewed
- Most imported
- Most forked
- Highest rated
-
Rating System:
- Rate prompts on a 5-star scale
- Add optional comments to ratings
- View average ratings and rating counts
- Update your ratings
-
Fork/Clone System:
- Fork public prompts to create your own version
- Track relationships between original prompts and forks
- View fork history and statistics
- Navigate between original prompts and their forks
-
Tagging System:
- Add multiple tags to prompts for better organization
- Filter prompts by tags
- Discover related prompts through common tags
Database Schema
The Prompt Library uses the following database tables:
prompt_categories
: Stores categories for organizing promptsuser_prompts
: Stores user-created promptsprompt_ratings
: Stores user ratings for prompts
Views and Functions
prompt_stats
: A view that provides aggregated statistics for promptsincrement_prompt_view_count
: Function to increment the view countincrement_prompt_fork_count
: Function to increment the fork countget_prompt_rating
: Function to get rating statistics for a prompt
Components
Main Components
PromptCard
: Displays a prompt in a card formatPromptForm
: Form for creating and editing promptsPromptRating
: Component for rating promptsTagsInput
: Component for adding and managing tagsStarRating
: Visual component for displaying ratings
Pages
/prompt-library
: Main page with tabs for personal and public prompts/prompt-library/[id]
: Public prompt detail page/prompt-library/my-prompts/[id]
: Personal prompt detail page
Usage
Saving Prompts
When using an AI agent, a "Save Prompt" button appears in the chat interface. Clicking this button opens a modal where you can:
- Enter a title for the prompt
- Add an optional description
- Select a category
- Add tags
- Choose whether to make it public or private
Managing Prompts
From the Prompt Library page, you can:
- View all your saved prompts
- Edit or delete your prompts
- Change visibility settings
- View usage statistics
Discovering Prompts
The "Public Prompts" tab allows you to:
- Browse prompts shared by other users
- Filter by various criteria
- Sort by different metrics
- Import or fork prompts you find useful
Rating Prompts
On any public prompt detail page, you can:
- Rate the prompt on a 5-star scale
- Add an optional comment
- Update your rating if you change your mind
Copying Prompts
When viewing a public prompt, you can:
- Import it (creates a copy without tracking the relationship).
- Fork it (creates a copy that tracks the relationship to the original).
Integration Points
- User Profile: The Prompt Library is accessible from the user profile page
- Agent Interface: Save button in the agent chat interface
- Authentication: Integrated with the existing authentication system
- Database: Uses Supabase for storage and RLS policies for security
Security Checks
- Row Level Security (RLS) policies ensure users can only access their own prompts or public prompts
- Rating system is protected to prevent multiple ratings from the same user
- Fork tracking maintains proper attribution of original content
Future Enhancements
Potential future enhancements could include:
- Collaborative prompt editing
- Version history for prompts
- AI-powered prompt recommendations
- Advanced analytics on prompt performance
- Community features like comments and collections