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: skillsmatch: @skill_names{tone_guide}: static from: prompts/tonematch: @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: skillsmatch: @skill
Multiple Values (list)
{skills}: static from: skillsmatch: @skill_names
Regex Pattern
{pattern}: static from: skillsmatchRe: @skill_pattern
All Files in Folder
{all}: static from: skillsmatch: alllimit: 10order: ascending
Using Fragments
Reference fragments in your prompt:
init doparams:@skills: list[str]fragments:{context}: static from: skillsmatch: @skillsend 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.promptCollection Manifest
Each folder can have an _index.prompt that defines metadata:
init do@version: 1.0@major: 1def:type: collectiondescription: Communication skillsend init
Caching
- Static fragments — Cached at compile time by path
- Dynamic fragments — Fetched fresh each request
- Collections — Cached and composited
Next Steps
- Response Contracts — Define output schemas
- Versioning — Manage fragment versions