This page demonstrates advanced prompt patterns that can be used to standardize AI interactions in your project.
Generate a focused code review request:
import { z } from 'zod'
export default defineMcpPrompt({
name: 'code-review',
title: 'Code Review',
description: 'Generate a code review prompt',
inputSchema: {
code: z.string().describe('Code to review'),
language: z.string().describe('Programming language'),
focus: z.enum(['performance', 'security', 'style', 'all']).default('all'),
},
handler: async ({ code, language, focus }) => {
const focusText = focus === 'all'
? 'performance, security, and style'
: focus
return {
messages: [{
role: 'user',
content: {
type: 'text',
text: `Please review this ${language} code focusing on ${focusText}:\n\n\`\`\`${language}\n${code}\n\`\`\``,
},
}],
}
},
})
Create documentation in various formats:
import { z } from 'zod'
export default defineMcpPrompt({
name: 'documentation',
title: 'Generate Documentation',
description: 'Create documentation for code',
inputSchema: {
code: z.string().describe('Code to document'),
style: z.enum(['jsdoc', 'tsdoc', 'markdown']).default('jsdoc'),
},
handler: async ({ code, style }) => {
const prompt = style === 'markdown'
? `Generate markdown documentation for this code:\n\n\`\`\`\n${code}\n\`\`\``
: `Generate ${style.toUpperCase()} documentation for this code:\n\n\`\`\`\n${code}\n\`\`\``
return {
messages: [{
role: 'user',
content: {
type: 'text',
text: prompt,
},
}],
}
},
})
Generate emails with customizable tone:
import { z } from 'zod'
export default defineMcpPrompt({
name: 'email-template',
title: 'Email Template',
description: 'Generate email from template',
inputSchema: {
recipient: z.string().describe('Recipient name'),
subject: z.string().describe('Email subject'),
tone: z.enum(['formal', 'casual', 'friendly']).default('friendly'),
},
handler: async ({ recipient, subject, tone }) => {
const greeting = tone === 'formal'
? 'Dear'
: tone === 'casual'
? 'Hi'
: 'Hello'
return {
messages: [{
role: 'user',
content: {
type: 'text',
text: `Write an email:\n\nTo: ${recipient}\nSubject: ${subject}\nTone: ${tone}\n\nGreeting: ${greeting}`,
},
}],
}
},
})
Generate standardized commit messages:
import { z } from 'zod'
export default defineMcpPrompt({
name: 'commit-message',
title: 'Commit Message',
description: 'Generate a conventional commit message',
inputSchema: {
changes: z.string().describe('Description of the changes made'),
type: z.enum(['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']).default('feat'),
scope: z.string().optional().describe('Scope of the change (e.g., auth, api)'),
},
handler: async ({ changes, type, scope }) => {
const scopeText = scope ? `(${scope})` : ''
return {
messages: [{
role: 'user',
content: {
type: 'text',
text: `Generate a commit message following this format:
${type}${scopeText}: <description>
Changes made:
${changes}
Guidelines:
- Use imperative mood ("add" not "added")
- Keep the description under 72 characters
- Be specific and concise`,
},
}],
}
},
})