/**
* Template Resources
* Provides prompt templates as MCP resources
*/
export interface PromptTemplate {
id: string;
name: string;
description: string;
category: string;
template: string;
variables: string[];
example?: string;
}
export const templates: PromptTemplate[] = [
{
id: 'coding-debug',
name: 'Debug Code',
description: 'Analyze and fix bugs in code',
category: 'coding',
template: `You are a senior software engineer with expertise in debugging.
## Code to Debug
\`\`\`{{language}}
{{code}}
\`\`\`
## Error/Issue
{{error}}
## Instructions
1. Identify the root cause of the issue
2. Explain why this bug occurs
3. Provide a corrected version of the code
4. Suggest preventive measures for similar issues`,
variables: ['language', 'code', 'error'],
example: 'language: typescript\ncode: const x = null; x.length;\nerror: Cannot read property length of null',
},
{
id: 'coding-review',
name: 'Code Review',
description: 'Review code for quality, security, and best practices',
category: 'coding',
template: `You are a code reviewer with expertise in {{language}}.
## Code to Review
\`\`\`{{language}}
{{code}}
\`\`\`
## Review Focus
{{focus}}
## Instructions
Provide a thorough code review covering:
1. **Correctness**: Logic errors or bugs
2. **Security**: Potential vulnerabilities
3. **Performance**: Optimization opportunities
4. **Readability**: Code clarity and maintainability
5. **Best Practices**: Adherence to {{language}} conventions
Rate each category (1-5) and provide specific recommendations.`,
variables: ['language', 'code', 'focus'],
},
{
id: 'writing-blog',
name: 'Blog Post',
description: 'Generate a blog post outline or draft',
category: 'writing',
template: `You are a professional content writer specializing in {{topic}}.
## Topic
{{title}}
## Target Audience
{{audience}}
## Key Points to Cover
{{keyPoints}}
## Instructions
Write a comprehensive blog post that:
- Opens with a compelling hook
- Uses clear headers and subheaders
- Includes practical examples or case studies
- Ends with a strong call to action
- Maintains a {{tone}} tone throughout
Word count target: {{wordCount}} words`,
variables: ['topic', 'title', 'audience', 'keyPoints', 'tone', 'wordCount'],
},
{
id: 'writing-email',
name: 'Professional Email',
description: 'Draft a professional email',
category: 'writing',
template: `Draft a professional email with the following parameters:
## Context
- **Purpose**: {{purpose}}
- **Recipient**: {{recipient}}
- **Tone**: {{tone}}
- **Key Message**: {{message}}
## Requirements
- Clear subject line
- Professional greeting
- Concise body (2-3 paragraphs max)
- Clear call to action
- Appropriate closing
Additional context: {{context}}`,
variables: ['purpose', 'recipient', 'tone', 'message', 'context'],
},
{
id: 'research-summary',
name: 'Research Summary',
description: 'Summarize research findings',
category: 'research',
template: `You are a research analyst specializing in {{field}}.
## Research Topic
{{topic}}
## Key Questions to Address
{{questions}}
## Instructions
Provide a comprehensive research summary that:
1. **Executive Summary**: 2-3 sentence overview
2. **Key Findings**: Bullet points of main discoveries
3. **Analysis**: Detailed breakdown of findings
4. **Implications**: What this means for {{audience}}
5. **Recommendations**: Actionable next steps
6. **Sources**: Note any sources or data referenced
Focus on accuracy, objectivity, and actionable insights.`,
variables: ['field', 'topic', 'questions', 'audience'],
},
{
id: 'analysis-swot',
name: 'SWOT Analysis',
description: 'Conduct a SWOT analysis',
category: 'analysis',
template: `Conduct a comprehensive SWOT analysis for:
## Subject
{{subject}}
## Industry/Context
{{context}}
## Instructions
Provide a detailed SWOT analysis:
### Strengths (Internal Positives)
- What advantages does {{subject}} have?
- What does it do well?
- What unique resources does it possess?
### Weaknesses (Internal Negatives)
- What could be improved?
- What is done poorly?
- What should be avoided?
### Opportunities (External Positives)
- What opportunities are available?
- What trends could be leveraged?
- What changes in the market could benefit it?
### Threats (External Negatives)
- What obstacles exist?
- What is the competition doing?
- What threats could cause problems?
End with 3-5 strategic recommendations based on the analysis.`,
variables: ['subject', 'context'],
},
{
id: 'analysis-comparison',
name: 'Comparison Analysis',
description: 'Compare multiple options or solutions',
category: 'analysis',
template: `You are an analyst tasked with comparing options.
## Options to Compare
{{options}}
## Comparison Criteria
{{criteria}}
## Context
{{context}}
## Instructions
Create a detailed comparison that includes:
1. **Overview Table**: Side-by-side comparison matrix
2. **Detailed Analysis**: Pros and cons of each option
3. **Scoring**: Rate each option on the criteria (1-10)
4. **Recommendation**: Which option is best for what use case
5. **Decision Framework**: Questions to help choose
Be objective and data-driven in your analysis.`,
variables: ['options', 'criteria', 'context'],
},
{
id: 'factcheck-verify',
name: 'Fact Check',
description: 'Verify claims and statements',
category: 'factcheck',
template: `You are a fact-checker with expertise in verifying claims.
## Statement to Verify
{{statement}}
## Source (if available)
{{source}}
## Instructions
Analyze the statement and provide:
1. **Verdict**: TRUE / FALSE / PARTIALLY TRUE / UNVERIFIABLE
2. **Confidence Level**: High / Medium / Low
3. **Evidence**: Supporting or contradicting information
4. **Context**: Important context that affects interpretation
5. **Sources**: Reliable sources to verify the claim
6. **Explanation**: Clear explanation of your verdict
Be thorough, objective, and cite reliable sources.`,
variables: ['statement', 'source'],
},
];
/**
* Get all templates
*/
export function getAllTemplates(): PromptTemplate[] {
return templates;
}
/**
* Get templates by category
*/
export function getTemplatesByCategory(category: string): PromptTemplate[] {
return templates.filter(t => t.category === category);
}
/**
* Get a specific template by ID
*/
export function getTemplateById(id: string): PromptTemplate | undefined {
return templates.find(t => t.id === id);
}
/**
* Get available categories
*/
export function getCategories(): string[] {
return [...new Set(templates.map(t => t.category))];
}
/**
* Fill a template with variables
*/
export function fillTemplate(template: PromptTemplate, variables: Record<string, string>): string {
let filled = template.template;
for (const [key, value] of Object.entries(variables)) {
filled = filled.replace(new RegExp(`{{${key}}}`, 'g'), value);
}
// Remove any unfilled variables
filled = filled.replace(/{{[^}]+}}/g, '[NOT PROVIDED]');
return filled;
}
export default templates;