- Per-step prompts —
.mdxfiles with{props.*}interpolation, used as children of<Task>. - System prompt composition — A master
.mdxtemplate that assembles a system prompt from multiple markdown docs using JSX component injection.
Setup
Enable MDX imports in Bun with two files:Per-Step Prompts
Each step gets an.mdx file that serves as its prompt template. Props are interpolated at render time:
Auto-injected {props.schema}
When a <Task> has an outputSchema (either explicit or auto-resolved from createSmithers()), Smithers auto-injects a schema prop into the MDX component. This prop contains a human-readable JSON example generated from the Zod schema, so agents know exactly what structure to produce.
You do not need to pass schema manually — just use {props.schema} in your MDX and it will be filled in automatically.
System Prompt Composition
For large workflows, the system prompt needs to include project documentation, coding conventions, architecture notes, and more. MDX lets you compose this from standalone markdown files.Step 1: Write standalone docs
Keep domain knowledge in.md files that are reusable across workflows:
Step 2: Create component functions
Insystem-prompt.ts, read each doc file and wrap it in a component function:
Step 3: Write the master template
Thesystem-prompt.mdx uses those components as JSX tags:
Benefits
- Reusable docs — Each
.mdfile is standalone and can be used across multiple workflows or shared with human developers. - Composable — Add or remove context sections without editing prompt text. Just add/remove a component tag.
- Shared across agents — All agents in the workflow get the same system prompt, ensuring consistent behavior.
- Version-controlled — Prompts live in the repo and are tracked by git. Changes are visible in diffs.
Conditional Sections in Prompts
Use JavaScript ternary expressions for conditional prompt content:Array Rendering
Render arrays using.map() and .join():
Next Steps
- Production Project Structure — Full recommended file layout.
- Structured Output — How
outputSchemaand{props.schema}work together. - Patterns — Naming conventions and organizational patterns.