An intelligent prompt engineering platform using metaprompts, few-shot learning, and orchestrated AI workflows
Features • System Design • Architecture • Technologies • Contributing • Security
PromptTriage is an enterprise-grade prompt engineering platform that transforms rough ideas and vague requirements into structured, production-ready AI prompts. Unlike simple prompt wrappers, PromptTriage employs a sophisticated orchestration design built on metaprompts, system prompts, and few-shot learning to deliver consistent, high-quality results. The system analyzes user intent, identifies gaps through structured blueprints, asks intelligent follow-up questions, and generates optimized prompts tailored for specific AI models and use cases.
This is not just a Gemini API wrapper—it's a specialized prompt engineering system that uses carefully crafted system instructions, curated few-shot examples across multiple domains (creative, analytical, technical), and a two-phase orchestration workflow to ensure every generated prompt meets production standards.
- Deep Context Understanding: Gemini analyzes your initial prompt to identify gaps, ambiguities, and missing context
- Risk Assessment: Automatically detects potential issues, biases, and edge cases in your prompt design
- Structured Blueprint Generation: Creates a comprehensive blueprint with intent, audience, success criteria, constraints, and evaluation checklists
- Context-Aware Questions: Generates 2-5 custom follow-up questions based on detected gaps
- Adaptive Intelligence: Questions evolve based on the target AI model, tone, and output requirements
- Efficient Information Gathering: Streamlined workflow to capture all necessary details
- Multi-Model Support: Optimized prompts for OpenAI GPT, Claude (Sonnet/Opus/Haiku), Gemini (Pro/Flash), Grok, and Mistral
- Structured Output: Generates markdown-formatted prompts with nine comprehensive sections
- Quality Guardrails: Includes assumptions, change summaries, and evaluation criteria for response validation
- Firecrawl Integration: Optional web search capability to enrich prompts with real-time information
- Source Attribution: Transparent citation system for all external context
- Fresh Data Pipeline: Ensures prompts are informed by current information when needed
- One-Click Rewrite: Generate alternative refinements without re-answering questions
- Version Tracking: Built-in prompt versioning system for iteration management
- Metaprompt-Driven Consistency: Curated system prompts guide Gemini to maintain quality across generations
PromptTriage is built on a foundation of advanced prompt engineering techniques, not just API calls.
The system uses sophisticated metaprompts (system instructions) that define how Gemini should reason about and transform user inputs:
- Analyzer Metaprompt: Guides the analysis phase with specific reasoning steps, output structure requirements, and quality criteria
- Refiner Metaprompt: Orchestrates the synthesis phase with section templates, formatting rules, and consistency checks
- Versioned Prompts: Each metaprompt is versioned (e.g.,
2024-12-claude-hybrid) for reproducibility and iteration
PromptTriage includes curated few-shot examples across multiple domains to teach Gemini the expected behavior:
- Creative Domain: Website design, interactive applications (e.g., EduQuest learning platform)
- Analytical Domain: Business analysis, financial reports (e.g., Matterport 10-K summaries)
- Technical Domain: Bug reports, crash troubleshooting, error diagnostics
- Data Domain: Excel automation, SQL query specifications
- 5+ Hand-Crafted Examples: Each example includes user input and ideal assistant response demonstrating the target behavior
The few-shot examples are injected before every API call, ensuring Gemini understands the exact output format, reasoning depth, and quality standards expected.
The system uses a two-phase orchestration design with structured blueprints:
Phase 1 - Analysis:
- Extracts intent, audience, success criteria, constraints, risks
- Generates targeted follow-up questions (2-5 questions)
- Creates a structured blueprint with 10+ fields for later synthesis
- Validates completeness through confidence scoring
Phase 2 - Refinement:
- Reconciles the original prompt with blueprint and user answers
- Synthesizes a production-ready prompt with 9 standardized sections
- Generates usage guidance, change summaries, assumptions, and evaluation criteria
- Maintains consistency through template enforcement
Unlike general-purpose AI assistants, PromptTriage is specifically optimized for one task: transforming vague ideas into production-ready prompts. This specialization enables:
- Domain-specific validation logic for prompt quality
- Structured output formats that work across AI models
- Consistent reasoning patterns through metaprompt conditioning
- Reproducible results through versioning and few-shot stability
The system doesn't rely on Gemini's function calling or native tools—it uses pure prompt engineering techniques (system instructions, few-shot learning, structured output requirements) to achieve reliable results.
- Google OAuth 2.0: Secure authentication with Google Sign-In
- NextAuth.js Integration: Session management and authentication flows
- Environment-based Configuration: Secure API key management
- TypeScript-First: Full type safety across the application
- Modern Tooling: ESLint, Turbopack, and PostCSS for optimal development
- Responsive Design: Tailwind CSS-powered UI that works on all devices
┌─────────────────┐
│ User Input │
│ (Rough Idea) │
└────────┬────────┘
│
▼
┌─────────────────────────────────────────┐
│ Analyzer API │
│ /api/analyze │
│ │
│ ┌────────────────────────────────┐ │
│ │ System Prompt Injection │ │◄──── ANALYZER_SYSTEM_PROMPT
│ │ + Few-Shot Examples (5) │ │ (Metaprompt v2024-12)
│ └────────────────────────────────┘ │
│ ↓ │
│ ┌────────────────────────────────┐ │
│ │ Google Gemini Processing │ │◄──── Few-Shot Examples:
│ │ (Guided by Metaprompt) │ │ - Creative (EduQuest)
│ └────────────────────────────────┘ │ - Analytical (Matterport)
│ ↓ │ - Crash (Submit Bug)
│ • Blueprint Generation │ - Excel Automation
│ • Follow-up Questions │ - SQL Analytics
│ • Risk Assessment │
└─────────┬───────────────────────────────┘
│
▼
┌─────────────────┐
│ User Answers │
│ Questions │
└────────┬────────┘
│
▼
┌─────────────────────────────────────────┐
│ Refiner API │
│ /api/refine │
│ │
│ ┌────────────────────────────────┐ │
│ │ System Prompt Injection │ │◄──── REFINER_SYSTEM_PROMPT
│ │ + Few-Shot Examples (5) │ │ (Synthesis Instructions)
│ └────────────────────────────────┘ │
│ ↓ │
│ ┌────────────────────────────────┐ │
│ │ Blueprint + Answers Fusion │ │
│ │ Structured Output Generation │ │
│ └────────────────────────────────┘ │
│ ↓ │
│ • 9-Section Prompt Generation │
│ • Quality Checks │
│ • Evaluation Criteria │
└─────────┬───────────────────────────────┘
│
▼
┌─────────────────┐
│ Final Prompt │
│ (AI-Ready) │
└─────────────────┘
page.tsx: Main UI orchestration and state management- Responsive Interface: Tailwind CSS-powered responsive design
- Real-time Feedback: Loading states and progressive enhancement
analyze/route.ts: Prompt analysis endpoint with metaprompt injectionrefine/route.ts: Prompt refinement and generation endpoint with few-shot learning- RESTful Design: Clean API contracts with TypeScript validation
gemini.ts: Gemini API client wrapper with error handling- JSON Parsing Utilities: Robust extraction and validation
prompt.ts: Shared interfaces for request/response payloads- Type Safety: End-to-end TypeScript coverage
This is the heart of PromptTriage's intelligence:
metaprompt.ts: System prompts and few-shot examples repositoryANALYZER_SYSTEM_PROMPT: 500+ line metaprompt defining analysis reasoning stepsREFINER_SYSTEM_PROMPT: 400+ line metaprompt for synthesis with section templatesANALYZER_FEW_SHOTS: 5 domain-specific examples (creative, analytical, crash, Excel, SQL)REFINER_FEW_SHOTS: 5 corresponding refinement examples showing target output- Version Control:
PROMPT_VERSION = "2024-12-claude-hybrid"for reproducibility - Example Repository: Hand-crafted scenarios (1000+ lines each) demonstrating optimal behavior
How It Works: Before every Gemini API call, the system constructs a conversation history starting with the system prompt, followed by all few-shot example pairs (user → assistant), and finally the actual user request. This teaches Gemini the exact reasoning pattern, output structure, and quality standards expected—achieving consistent, production-ready results without function calling or tool use.
- Next.js 15.1.6: React framework with server-side rendering and API routes
- React 19.0.0: Component-based UI library
- TypeScript 5: Type-safe JavaScript superset
- Tailwind CSS 3.4: Utility-first CSS framework
- Google Gemini API: Language model for executing metaprompt-guided workflows
- Custom Metaprompts: Hand-crafted system instructions defining reasoning patterns
- Few-Shot Learning: Domain-specific examples teaching expected behavior
- Structured Outputs: JSON schema enforcement through prompt design
- Firecrawl (Optional): Web scraping for context enrichment
- NextAuth.js 4.24: Authentication library with OAuth 2.0 support
- ESLint 9: Code linting and style enforcement
- Turbopack: High-performance Next.js bundler
- PostCSS 8: CSS transformation pipeline
- Node.js 18.17+: JavaScript runtime (optimized for Node 20+)
- npm: Package management
- AI Product Development: Generate production-ready prompts for AI features
- Content Creation: Craft precise prompts for copywriting, marketing, and creative work
- Data Analysis: Structure prompts for analytical tasks and reporting
- Research: Formulate clear research questions and analysis frameworks
- Education: Teach effective prompt engineering techniques
- Automation: Create consistent, reusable prompt templates
- Input: User provides a rough idea or initial prompt
- Metaprompt Injection: System injects ANALYZER_SYSTEM_PROMPT + 5 few-shot examples
- Analysis: Gemini (guided by metaprompt) analyzes the prompt and generates a structured blueprint
- Clarification: System asks 2-5 targeted follow-up questions based on detected gaps
- User Response: User answers the clarifying questions
- Metaprompt Injection: System injects REFINER_SYSTEM_PROMPT + 5 few-shot examples
- Synthesis: User answers + blueprint are reconciled through the refiner metaprompt
- Generation: Final AI-ready prompt is generated following 9-section template with metadata
- Iteration: Optional one-click rewrite for alternative perspectives (uses variation hints)
Generated prompts include nine comprehensive sections:
- Context: Background and situational information
- Objective: Clear goal statement
- Constraints: Limitations and boundaries
- Audience: Target users or stakeholders
- Tone & Style: Communication approach
- Format: Expected output structure
- Examples: Reference cases (when applicable)
- Success Criteria: Evaluation metrics
- Additional Notes: Edge cases and considerations
Plus metadata:
- Usage Guidance: How to use the prompt effectively
- Change Summary: What was refined from the original
- Assumptions Made: Inferred context
- Evaluation Checklist: Quality validation points
- User authentication and prompt history storage
- Multi-LLM provider support (OpenAI, Anthropic, etc.)
- Collaborative prompt editing
- A/B testing framework for prompt versions
- Automated testing suite
- Template marketplace
- API for programmatic access
- Analytics dashboard for prompt performance
We welcome contributions! Please see our Contributing Guidelines for details on:
- Code of Conduct
- Development setup
- Pull request process
- Coding standards
Security is a top priority. Please see our Security Policy for:
- Reporting vulnerabilities
- Security best practices
- Disclosure policy
This project is licensed under the terms specified in the LICENSE file.
- Google Gemini Team: For providing the powerful language model that executes our metaprompts
- Vercel: For the Next.js framework
- Open Source Community: For the amazing tools and libraries
- Prompt Engineering Research: Inspired by advances in few-shot learning, chain-of-thought prompting, and structured output generation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with ❤️ using metaprompts, few-shot learning, Next.js, TypeScript, and Google Gemini
Not just an API wrapper—a specialized prompt engineering system