Skip to content

PM (PromptManager)

PromptManager
"Prompts with superpowers"
Parse YAML metadata from markdown, expand shell references, and render ERB templates on demand

PM (PromptManager) treats prompt files as composable, parameterized templates. Write prompts in markdown with YAML front matter, shell references, and ERB — PM handles the rest.

Key Features

  • YAML Metadata - Parse from markdown strings or files
  • Shell Expansion - $VAR, ${VAR}, and $(command) substitution
  • ERB Rendering - On-demand rendering with named parameters
  • File Includes - Compose prompts from multiple files
  • Custom Directives - Register custom methods for ERB templates
  • Configurable Pipeline - Enable/disable stages per prompt or globally
  • Comment Stripping - HTML comments removed before processing
  • Processing Pipeline

    Every prompt passes through four stages:

    graph LR
        A[Strip HTML Comments] --> B[Extract YAML Metadata]
        B --> C[Shell Expansion]
        C --> D["ERB Rendering (on to_s)"]
    1. Strip HTML comments -- <!-- ... --> removed before anything else
    2. Extract YAML metadata -- Front-matter between --- fences parsed into PM::Metadata
    3. Shell expansion -- Environment variables and commands expanded (when shell: true)
    4. ERB rendering -- Templates evaluated on demand when to_s is called (when erb: true)

    Quick Example

    Given a file review.md:

    ---
    title: Code Review
    parameters:
      language: ruby
      code: null
    ---
    Review the following <%= language %> code:
    
    <%= code %>
    

    Parse and render:

    require 'pm'
    
    parsed = PM.parse('review.md')
    puts parsed.metadata.title        #=> "Code Review"
    puts parsed.to_s('code' => source) #=> rendered prompt
    

    Getting Started

    Head to Installation to add PM to your project, then follow the Quick Start guide.