Skip to content

Pattern

Metaprompt Variable Injection

One template. N agents. Zero hand-edits when the team changes.

The shape

Template → resolver → prompt

1. Templatechecked in

# planning-lead.md

You are the Planning Lead.

Expertise:

{{EXPERTISE_BLOCK}}

Skills:

{{SKILLS_BLOCK}}

Team:

{{MEMBERS_BLOCK}}

Log: {{CONVERSATION_LOG}}

boot

2. Resolverruns once

1 read frontmatter

2 inline expertise

3 inline skills

4 inline roster

5 sub session paths

6 return prompt

resolved

3. Promptfixed for lifetime

You are the Planning Lead.

Expertise:

- First Principles...

- Systems Thinking...

Skills:

- docx, pdf, pptx...

Team:

- Research Lead

- Writing Lead

Log: /sessions/s-42/log.md

Per-turn overhead: zero. The prompt is resolved once at boot and never rebuilt.

The vocabulary

Six placeholders. Shared by contract.

{{EXPERTISE_BLOCK}}

Serialized mental-model files

+ use-when guidance

all agents

{{SKILLS_BLOCK}}

Serialized skill list

+ use-when guidance

all agents

{{TEAMS_BLOCK}}

Team roster: leads + members

who's on which team

orchestrator

{{MEMBERS_BLOCK}}

Member roster for one lead

who reports to me

leads only

{{SESSION_DIR}}

Absolute path to session directory

session

{{CONVERSATION_LOG}}

Absolute path to shared log

session

Extending the vocabulary is possible. Doing so unilaterally is not — every resolver and every consumer must agree.

Why static composition fails

The team just gained a member. Now what?

Copy-paste compositionO(N) edits

Add "QA Reviewer" to roster

  • planning-lead.md
  • research-lead.md
  • writing-lead.md
  • editor.md
  • synthesizer.md
  • ...and 7 more
  • fact-checker.md — missed

One missed file silently diverges. Fact-checker still thinks the team is the old team. The N-agent discipline becomes 1-agent discipline repeated N times — and drift is guaranteed by the first human mistake.

Runtime injectionO(1) edit

Add "QA Reviewer" to team.json

  • team.json — updated
  • planning-lead.md — unchanged
  • research-lead.md — unchanged
  • writing-lead.md — unchanged
  • editor.md — unchanged
  • ...all 12 agents — unchanged

Every agent sees the new roster at next boot. No agent can silently hold a stale view — there's no copy to forget to update. The template can't drift from the config.

The decoupling

Prompt structure lives in the template.

Context lives in the config.

Same Planning Lead prompt works in a 3-team or 10-team system with no edits. The template describes the role; the config supplies the world it operates in.