Inheritance System
Overview
Section titled “Overview”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.
Key Inheritance Rules
Section titled “Key Inheritance Rules”- File Path Resolution: Inherit from local files (
./base.prmd) or package files ("@scope/package@version/path.prmd") - Content Merging: Child content is appended after parent content (not merged)
- Parameter Merging: Child parameters override parent parameters by name
- Context Merging: Child context arrays are merged with parent context
- Package References: All
@references must be quoted for valid YAML
Basic Inheritance Syntax
Section titled “Basic Inheritance Syntax”Local File Inheritance
Section titled “Local File Inheritance”---id: child-templatename: "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
.prmdis required
Package Reference Inheritance
Section titled “Package Reference Inheritance”---id: security-audit-specializedname: "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...Section-Based Content Override
Section titled “Section-Based Content Override”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:
prompd show base-template.prmd --sectionsWhat Gets Inherited
Section titled “What Gets Inherited”Parameters
Section titled “Parameters”- Parent parameters are inherited
- Child parameters with the same
nameoverride parent parameters - Child can add new parameters
# Parent templateparameters: - name: temperature type: number default: 0.7 - name: model type: string default: "gpt-3.5-turbo"
# Child templateparameters: - name: model type: string default: "gpt-4o" # Overrides parent - name: system_role # New parameter type: string default: "security expert"Content
Section titled “Content”- Parent content is included first
- Child content is appended after parent content
- No content merging - purely additive
Metadata Fields
Section titled “Metadata Fields”id,name,description,versioncan be overriddenauthoris inherited unless overridden- Custom fields are merged
Context Arrays
Section titled “Context Arrays”- Parent context files are included
- Child context files are appended to the list
Override Behavior
Section titled “Override Behavior”YAML Fields vs Markdown Content
Section titled “YAML Fields vs Markdown Content”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---# SystemYou are a security expert # Does NOT override parent's system YAML fieldOverride Rules Summary
Section titled “Override Rules Summary”- 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
Section titled “Package References”Package references can appear in any YAML field and must include the full file path:
---id: comprehensive-security-auditusing: - 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"---Working Examples
Section titled “Working Examples”Basic Local Inheritance
Section titled “Basic Local Inheritance”base-security-audit.prmd:
---id: base-security-auditname: "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 verificationsecurity-audit.prmd (child):
---id: security-auditname: "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 %}Package Inheritance
Section titled “Package Inheritance”---id: fintech-security-auditname: "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: truecontext: - "@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 %}Advanced Patterns
Section titled “Advanced Patterns”Chained Inheritance
Section titled “Chained Inheritance”Create inheritance chains where each level adds specialization:
base-analysis.prmd├── security-analysis.prmd│ ├── web-security-audit.prmd│ └── api-security-audit.prmd└── performance-analysis.prmdKeep inheritance chains shallow - maximum 3-4 levels deep. Prefer composition over deep inheritance.
Supported File Types in References
Section titled “Supported File Types in References”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 YAMLBinary Files (Automatic Extraction):
context: - "./reports/analysis.xlsx" # Extracted as CSV/tabular data - "./docs/manual.docx" # Plain text extraction - "./documents/policy.pdf" # OCR text extractionSupported binary formats: Excel (.xlsx, .xlsm), Word (.docx), PowerPoint (.pptx), PDF (.pdf), Images (.png, .jpg, .gif, .bmp, .webp).
Troubleshooting
Section titled “Troubleshooting”Common Errors
Section titled “Common Errors”YAML Syntax Errors with Package References:
# WRONGinherits: @prompd.io/package@1.0.0/prompts/base.prmd
# CORRECTinherits: "@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.prmdinherits: "../base.prmd"Package Path Errors: Include the full file path within the package:
# WRONG - Missing file pathinherits: "@prompd.io/toolkit@1.0.0"
# CORRECT - Include full pathinherits: "@prompd.io/toolkit@1.0.0/prompts/base-tool.prmd"Testing Inheritance
Section titled “Testing Inheritance”# Compile the templateprompd compile ./child-template.prmd --to-markdown -o output.md
# Check parameter resolutionprompd show ./child-template.prmd
# Validate package referencesprompd deps ./child-template.prmd