Prompt

Need prompt templates with variables and inheritance

Artificial Intelligence / MLOps1 observationLast seen Nov 4, 2026

Latest observation

Nov 4, 2026OpenAI APIWeb search: off

Here are practical prompt template patterns that support variables and inheritance. I’ll show a clean base approach first, then a few concrete formats you can adapt.


1) Simple variable template

Use placeholders like {{variable_name}}.

Template

You are a {{role}}.

Task:
{{task}}

Context:
{{context}}

Constraints:
{{constraints}}

Output format:
{{output_format}}

Example values

{
  "role": "helpful support agent",
  "task": "Answer the customer's billing question",
  "context": "The customer was charged twice this month",
  "constraints": "Be polite, concise, and do not mention internal policies",
  "output_format": "A short apology + explanation + next steps"
}

2) Base template + inherited child template

Inheritance means a child prompt reuses a parent prompt and adds or overrides sections.

Base template

[ROLE]
You are {{role}}.

[STYLE]
{{style}}

[GENERAL RULES]
{{general_rules}}

Child template

{{parent}}

[DOMAIN]
You are working in {{domain}}.

[TASK]
{{task}}

[OUTPUT REQUIREMENTS]
{{output_requirements}}

How it works

  • Parent/base contains reusable defaults.
  • Child includes {{parent}} conceptually, or your system merges fields from parent and child.
  • Child can override variables from parent if needed.

3) Structured inheritance using YAML

This works well for prompt management systems.

Base prompt

name: base_assistant
variables:
  role: assistant
  style: clear, concise
  tone: professional
template: |
  You are a {{role}}.
  Style: {{style}}
  Tone: {{tone}}

Child prompt

name: customer_support
extends: base_assistant
variables:
  role: customer support agent
  tone: friendly and empathetic
  domain: billing support
template: |
  {{parent}}

  Domain: {{domain}}
  Handle the user's request with care.

Result after merge

You are a customer support agent.
Style: clear, concise
Tone: friendly and empathetic

Domain: billing support
Handle the user's request with care.

4) Hierarchical prompt layers

A common inheritance model:

  1. System/base
  2. Role/domain
  3. Task-specific
  4. Instance/input data

Example

Layer 1: Base

You are a reliable AI assistant.
Always be accurate, safe, and concise.

Layer 2: Role

You are a legal research assistant.
Prefer citations and mention uncertainty when needed.

Layer 3: Task

Summarize the following case in plain English.

Layer 4: Variables

Case text: {{case_text}}
Audience: {{audience}}

5) Example inheritance with overrides

Parent

Tone: {{tone}}
Format: {{format}}
Do not use jargon.

Child

Tone: {{tone | default("friendly")}}
Format: {{format | default("bullet points")}}
Use examples where helpful.

If your engine supports defaults, you can specify them. If not, handle defaults in code.


6) Recommended variable set

Typical reusable variables:

  • role
  • task
  • audience
  • domain
  • tone
  • style
  • constraints
  • examples
  • input
  • output_format
  • success_criteria

7) A robust reusable template

You are {{role}}.

Goal:
{{goal}}

Audience:
{{audience}}

Context:
{{context}}

Instructions:
{{instructions}}

Constraints:
{{constraints}}

Examples:
{{examples}}

Output format:
{{output_format}}

Child variant

You are a {{role}} specialized in {{domain}}.

Goal:
{{goal}}

Audience:
{{audience}}

Context:
{{context}}

Additional instructions:
- {{domain_specific_rule_1}}
- {{domain_specific_rule_2}}

Constraints:
{{constraints}}

Output format:
{{output_format}}

8) Inheritance pattern in code terms

If you’re building a prompt system, inheritance often means:

  • Parent template fields are loaded first
  • Child template fields overwrite matching keys
  • Final prompt is rendered from the merged data

Merge logic example

final_vars = {**parent_vars, **child_vars, **runtime_vars}

Priority:

  • runtime variables override child
  • child overrides parent
  • parent provides defaults

9) Best practices

  • Keep base prompts generic and reusable
  • Put domain/task specifics in children
  • Avoid too many nested inheritance levels
  • Use clear variable names
  • Support defaults for optional values
  • Keep output format explicit

If you want, I can also give you:

  1. a prompt inheritance schema in JSON/YAML,
  2. a Python implementation for rendering inherited templates, or
  3. examples for LangChain / Jinja2 / OpenAI prompt management.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.