Skip to content
GitHub

Inheritance System

The prompd inheritance system allows prompt templates to extend and build upon other templates, similar to object-oriented programming inheritance. This enables code reuse, standardization, and composition of complex AI workflows from simpler components.

  1. File Path Resolution: Inherit from local files (./base.prmd) or package files ("@scope/package@version/path.prmd")
  2. Content Merging: Child content is appended after parent content (not merged)
  3. Parameter Merging: Child parameters override parent parameters by name
  4. Context Merging: Child context arrays are merged with parent context
  5. Package References: All @ references must be quoted for valid YAML
---
id: child-template
name: "Child Template"
inherits: "./base-template.prmd"
parameters:
- name: model
type: string
default: "gpt-4o" # Override parent value
---
Child-specific content is appended after parent content.

Syntax requirements:

  • Use forward slashes / even on Windows
  • Relative paths start with ./ or ../
  • File extension .prmd is required
---
id: security-audit-specialized
name: "Fintech Security Audit"
inherits: "@prompd.io/security-toolkit@1.0.0/prompts/security-audit.prmd"
parameters:
- name: compliance_requirements
type: array
default: ["PCI-DSS", "SOX", "FFIEC"]
---
Additional fintech-specific security requirements...

For precise control over inherited content, use section-based overrides to selectively replace or remove specific sections:

---
name: "Healthcare Security Audit"
inherits: "./base-security-audit.prmd"
override:
system-prompt: "./healthcare-system-prompt.md"
examples: null # Remove section
compliance-requirements: "./hipaa-compliance.md"
---

Discover available sections with:

Terminal window
prompd show base-template.prmd --sections
  • Parent parameters are inherited
  • Child parameters with the same name override parent parameters
  • Child can add new parameters
# Parent template
parameters:
- name: temperature
type: number
default: 0.7
- name: model
type: string
default: "gpt-3.5-turbo"
# Child template
parameters:
- name: model
type: string
default: "gpt-4o" # Overrides parent
- name: system_role # New parameter
type: string
default: "security expert"
  • Parent content is included first
  • Child content is appended after parent content
  • No content merging - purely additive
  • id, name, description, version can be overridden
  • author is inherited unless overridden
  • Custom fields are merged
  • Parent context files are included
  • Child context files are appended to the list

YAML frontmatter fields and markdown content are completely separate systems:

YAML field override works:

# child.prmd
---
inherits: "./parent.prmd"
system: "You are a security expert" # Overrides parent YAML field
---

Markdown headers do NOT override YAML:

# child.prmd
---
inherits: "./parent.prmd"
# No system: field here
---
# System
You are a security expert # Does NOT override parent's system YAML field
  • YAML to YAML: Child YAML fields completely override parent YAML fields
  • Markdown to Markdown: Child markdown is appended to parent markdown
  • YAML to Markdown: No interaction - completely separate
  • Markdown to YAML: No interaction - completely separate

Package references can appear in any YAML field and must include the full file path:

---
id: comprehensive-security-audit
using:
- name: "@prompd.io/api-toolkit@1.2.1"
prefix: "@api"
- name: "@prompd.io/security-toolkit@1.0.0"
prefix: "@security"
inherits: "@prompd.io/core-patterns@2.0.0/templates/analysis-framework.prmd"
system: "@security/systems/security-expert.prmd"
context:
- "@security/contexts/owasp-top-10.md"
- "./local-context.md"
---

base-security-audit.prmd:

---
id: base-security-audit
name: "Base Security Audit"
version: "0.0.1"
description: "Base Security Audit example"
parameters:
- name: application_name
type: string
required: true
- name: technology_stack
type: string
required: true
- name: audit_scope
type: string
enum: [basic, comprehensive]
default: basic
---
# Security Audit for {{ application_name }}
## Technology Stack
- **Stack:** {{ technology_stack }}
- **Audit Scope:** {{ audit_scope }}
## Base Security Assessment
Perform standard security evaluation including:
- Input validation review
- Authentication mechanism analysis
- Authorization control verification

security-audit.prmd (child):

---
id: security-audit
name: "Comprehensive Security Audit"
version: "0.0.1"
description: "Comprehensive Security Audit example inheritance."
inherits: "./base-security-audit.prmd"
parameters:
- name: application_name
type: string
required: true
- name: technology_stack
type: string
required: true
- name: audit_scope
type: string
enum: [basic, comprehensive, compliance]
default: comprehensive # Override parent default
- name: compliance_requirements
type: array
items:
enum: [SOC2, PCI-DSS, HIPAA, GDPR]
required: false
---
## Advanced Security Testing
### OWASP Top 10 Assessment
### Penetration Testing Simulation
{% if compliance_requirements %}
### Compliance Validation
{% for item in compliance_requirements %}
- **{{ item }} Compliance:** Evaluate against {{ item }} security controls
{% endfor %}
{% endif %}
---
id: fintech-security-audit
name: "Fintech Security Audit"
inherits: "@prompd.io/security-toolkit@1.0.0/prompts/security-audit.prmd"
parameters:
- name: compliance_requirements
type: array
default: ["PCI-DSS", "SOX", "FFIEC"]
- name: financial_data_types
type: array
items:
enum: [card_data, account_numbers, transaction_data, pii]
required: true
context:
- "@prompd.io/fintech-context@1.2.0/contexts/pci-requirements.md"
- "./fintech-specific-rules.md"
---
## Financial Services Specific Requirements
{% for item in financial_data_types %}
- **{{ item }}**: Enhanced protection requirements
{% endfor %}

Create inheritance chains where each level adds specialization:

base-analysis.prmd
├── security-analysis.prmd
│ ├── web-security-audit.prmd
│ └── api-security-audit.prmd
└── performance-analysis.prmd

Keep inheritance chains shallow - maximum 3-4 levels deep. Prefer composition over deep inheritance.

You can reference external files in any YAML field (system:, user:, assistant:, context:, inherits:):

Text Files (Direct Content):

system: "./prompts/system-prompt.txt"
context:
- "./data/sample-code.py"
- "./data/export.csv"

Structured Data (Formatted Output):

context:
- "./config/api-settings.json" # Pretty JSON with markdown
- "./deployment/k8s-config.yaml" # Formatted YAML

Binary Files (Automatic Extraction):

context:
- "./reports/analysis.xlsx" # Extracted as CSV/tabular data
- "./docs/manual.docx" # Plain text extraction
- "./documents/policy.pdf" # OCR text extraction

Supported binary formats: Excel (.xlsx, .xlsm), Word (.docx), PowerPoint (.pptx), PDF (.pdf), Images (.png, .jpg, .gif, .bmp, .webp).

YAML Syntax Errors with Package References:

# WRONG
inherits: @prompd.io/package@1.0.0/prompts/base.prmd
# CORRECT
inherits: "@prompd.io/package@1.0.0/prompts/base.prmd"

File Not Found: Verify relative paths are correct from the child file’s location:

# If child is in ./specialized/audit.prmd
# and base is in ./base.prmd
inherits: "../base.prmd"

Package Path Errors: Include the full file path within the package:

# WRONG - Missing file path
inherits: "@prompd.io/toolkit@1.0.0"
# CORRECT - Include full path
inherits: "@prompd.io/toolkit@1.0.0/prompts/base-tool.prmd"
Terminal window
# Compile the template
prompd compile ./child-template.prmd --to-markdown -o output.md
# Check parameter resolution
prompd show ./child-template.prmd
# Validate package references
prompd deps ./child-template.prmd