Creating Custom Prompts

Learn how to create your own custom prompt templates.

Table of Contents

  1. Overview
  2. Basic Structure
  3. Required Fields
  4. Template Syntax
    1. Variable Substitution
    2. Conditional Text
    3. Multi-line Templates
  5. Example: Code Review Prompt
  6. Validation
  7. Testing Your Prompt
  8. Best Practices
    1. 1. Clear Descriptions
    2. 2. Descriptive Argument Names
    3. 3. Provide Argument Descriptions
    4. 4. Use Optional Arguments Wisely
    5. 5. Structure Complex Templates
    6. 6. Add Comments
  9. Advanced Patterns
    1. Multiple Conditionals
    2. Nested Context
  10. Sharing Your Prompts
  11. Examples Gallery

Overview

Prompts in Prompt Muse are stored as individual YAML files in the prompts/ directory. Each prompt follows a simple schema that defines its name, description, arguments, and template.

Basic Structure

Create a new .yaml file in the prompts/ directory:

# Comment describing the prompt
name: my-prompt           # Unique identifier (required)
description: What this prompt does  # Brief description (required)

# Optional arguments with template variable substitution
arguments:
  - name: param1
    description: Parameter description
    required: true      # or false

# The actual prompt text (required)
template: |
  Prompt text with {param1} placeholder
  Multiple lines supported

Required Fields

Every prompt must have:

  1. name (string): Unique identifier for the prompt
  2. description (string): Brief description shown to users
  3. template (string): The actual prompt text

Template Syntax

Variable Substitution

Use curly braces to create placeholders:

template: |
  Please help me with {taskName}.

Conditional Text

Include text only when an argument is provided:

template: |
  Please review this code{focus} with focus on {focus}{/focus}.
  • {focus} - Opens conditional block
  • {/focus} - Closes conditional block

If focus argument is provided, the text between tags is included. If not, it’s omitted.

Multi-line Templates

Use YAML’s | for multi-line templates:

template: |
  Line 1
  Line 2
  Line 3

Example: Code Review Prompt

Let’s create a comprehensive code review prompt:

File: prompts/code-review.yaml

# Code Review Prompt
# Provides thorough code review with best practices

name: code-review
description: Get comprehensive code review with best practices

arguments:
  - name: focus
    description: Specific focus area (e.g., 'security', 'performance', 'readability')
    required: false
  - name: style
    description: Coding style guide to follow (e.g., 'Airbnb', 'Google')
    required: false

template: |
  Please review this code{focus} with special focus on {focus}{/focus}{style} following the {style} style guide{/style}.

  Provide:
  1. **Code Quality Assessment**
     - Overall code quality rating
     - Strengths and weaknesses

  2. **Best Practices**
     - Which best practices are followed
     - Which are violated or missing

  3. **Potential Issues**
     - Bugs or logical errors
     - Edge cases not handled
     - Performance concerns
     - Security vulnerabilities

  4. **Suggestions**
     - Specific improvements with code examples
     - Refactoring opportunities
     - Better patterns or approaches

  5. **Positive Feedback**
     - What was done well
     - Good patterns or techniques used

Validation

When you add a new prompt, the server validates it on startup. Common validation errors:

  • Missing required fields (name, description, template)
  • Duplicate prompt names
  • Invalid argument definitions
  • Mismatched template placeholders

Check server logs for validation errors:

node index.js

Testing Your Prompt

After creating a prompt:

  1. Restart the MCP server
  2. Check server logs for validation errors
  3. Try using the prompt in your MCP client
  4. Test with and without optional arguments
  5. Verify conditional text works as expected

Best Practices

1. Clear Descriptions

Write clear, concise descriptions that explain what the prompt does:

# Good
description: Generate unit tests for any testing framework

# Not as good
description: Tests

2. Descriptive Argument Names

Use clear argument names that indicate their purpose:

arguments:
  - name: framework        # Good
  - name: f               # Avoid single letters

3. Provide Argument Descriptions

Always describe what each argument does:

arguments:
  - name: framework
    description: Testing framework to use (e.g., 'Jest', 'Mocha', 'pytest')

4. Use Optional Arguments Wisely

Make arguments optional when they provide customization but aren’t strictly necessary:

arguments:
  - name: audience
    description: Target audience level
    required: false    # Prompt works with or without this

5. Structure Complex Templates

For long templates, use clear sections:

template: |
  ## Overview
  {introduction text}

  ## Steps
  1. First step
  2. Second step

  ## Expected Output
  {what to expect}

6. Add Comments

Document your prompts with YAML comments:

# This prompt helps with database schema design
# It considers normalization, indexing, and performance
name: database-schema

Advanced Patterns

Multiple Conditionals

template: |
  Analyze this code{language} written in {language}{/language}.

  Focus areas:
  {performance}- Performance optimization{/performance}
  {security}- Security vulnerabilities{/security}
  {readability}- Code readability{/readability}

Nested Context

template: |
  {detailed}Please provide a detailed analysis including:
  - Code metrics
  - Complexity analysis
  - Maintainability index{/detailed}
  {detailed}

{/detailed}{quick}Provide a quick review focusing on major issues only.{/quick}

Sharing Your Prompts

Consider contributing your prompts back to the community:

  1. Test your prompt thoroughly
  2. Document it well
  3. Submit a pull request on GitHub

See the Contributing Guide for details.

Check out the built-in prompts for more examples and inspiration.