🧩
Fragment Composition
Build prompts from reusable, composable pieces.
The Challenge
Large prompts often repeat common sections. Copy-pasting leads to drift. Updating one section means finding and updating every copy.
The Solution
Break your prompts into reusable fragments. Reference them by name. The compiler composes them into a single prompt.
composed.prompt
init do@version: 1.0@major: 1params:@skills: list[str]@tone: enum[formal, casual, friendly] = friendly@context: strfragments:{skill_context}: static from: skillsmatch: @skills{tone_guide}: static from: prompts/tonematch: @tone{{user_context}}: dynamicend init# Compose from fragments{skill_context}{tone_guide}Context: @context{{user_context}}response do{"skills_applied": @skills,"tone_used": "@tone"}end response
Fragment Types
Static Fragments {name}
Cached at compile time. Loaded from files or folders. Perfect for skills, tone guides, and other reusable content.
Dynamic Fragments {{name}}
Fetched fresh each request. Useful for user-specific context that changes with every call.
Collections
Load multiple fragments from a folder. Composite them in order. Great for building skills libraries.
Key Benefits
- Update once, apply everywhere
- Static fragments are cached for performance
- Fragments can be versioned independently