Fragments

Fragments let you compose prompts from reusable pieces. Break common content into fragments and reference them throughout your prompts.

Fragment Types

Static Fragments {name}

Cached at compile time. Loaded from files or folders. Perfect for skills, tone guides, and other reusable content.

fragments:
  {skill_context}: static from: skills
    match: @skill_names
  {tone_guide}: static from: prompts/tone
    match: @tone

Dynamic Fragments {{name}}

Fetched fresh each request. Useful for user-specific context.

fragments:
  {{user_context}}: dynamic

Match Patterns

Single Value (enum)

{skill}: static from: skills
  match: @skill

Multiple Values (list)

{skills}: static from: skills
  match: @skill_names

Regex Pattern

{pattern}: static from: skills
  matchRe: @skill_pattern

All Files in Folder

{all}: static from: skills
  match: all
  limit: 10
  order: ascending

Using Fragments

Reference fragments in your prompt:

init do
  params:
    @skills: list[str]

  fragments:
    {context}: static from: skills
      match: @skills

end init

{context}

Now answer the user's question.

Folder Structure

priv/prompts/
├── main.prompt
├── skills/
│   ├── _index.prompt      # Collection manifest
│   ├── milton_model.prompt
│   └── meta_model.prompt
└── tone/
    ├── _index.prompt
    ├── formal.prompt
    └── casual.prompt

Collection Manifest

Each folder can have an _index.prompt that defines metadata:

init do
  @version: 1.0
  @major: 1

  def:
    type: collection
    description: Communication skills

end init

Caching

  • Static fragments — Cached at compile time by path
  • Dynamic fragments — Fetched fresh each request
  • Collections — Cached and composited

Next Steps