Templates
Opt-in showcase agents bundled with the MastraKit scaffold
Overview
Templates are opt-in showcase agents the scaffold can drop into your project alongside the default assistant-agent. Each one demonstrates a specific Mastra pattern — supervisor delegation, durable scheduling, workspace + skills — wired all the way through MastraKit's auth, multi-tenancy, and observability so you can see the pattern running end-to-end before adapting it.
You pick templates during npx mastrakit (each is a separate prompt, default off). They install into apps/mastra/src/mastra/ next to your other agents and tools — no separate runtime, no extra deploy.
Available templates
| Template | What it demonstrates |
|---|---|
| Daily Briefing demo agent | Supervisor + research/writer subagents, per-user workspace, skills, BM25 search, background research dispatch, drafts approval flow |
More templates ship over time. The list above tracks what's wired into the current CLI release.
Daily Briefing demo agent
A supervisor that decomposes a briefing request — "summarise these sources for me each morning" — into two specialised subagents and produces a polished markdown digest archived in the user's workspace.
What gets installed
When you answer yes to the "Include the Daily Briefing demo agent?" prompt, the scaffold adds:
apps/mastra/src/mastra/
├── agents/
│ ├── briefing-supervisor.ts # orchestrator
│ ├── research-agent.ts # subagent: URL → bullet-point facts
│ └── writer-agent.ts # subagent: bullets → markdown digest
├── lib/
│ └── workspace.ts # per-user AgentFS over Turso
└── tools/
├── http-fetch.ts # SSRF-hardened HTTP fetch
└── approve-draft.ts # promotes a draft into /briefings/The supervisor registers as briefing-supervisor in the Mastra agents map, so it shows up in the agent picker at http://localhost:4111 and in your web chat UI.
Patterns it demonstrates
- Supervisor delegation — the supervisor exposes the two subagents via the
agentsmap and decides which to call. Subagents have no overlapping tools, so the routing decision stays clean. - Background tasks —
research-agentis opted into background dispatch. The supervisor's first response ("I'm gathering your briefing now…") streams immediately while research fans out across multiplehttp-fetchcalls. - Per-user workspace — every user gets an isolated filesystem under
users/{userId}/backed by Turso, exposed to the agent as/skills/,/drafts/, and/briefings/. Seeworkspace.tsfor the per-user prefix logic. - Skills — when the user expresses an ongoing preference ("write in Dutch", "skip crypto"), the supervisor persists it as a
SKILL.mdfile under/skills/. Skills auto-load on every future run, even from a fresh chat. - BM25 search — the supervisor can
searchover indexed/briefings/to answer "what did you tell me about X last week?" with a grounded summary. - Drafts approval flow — for sensitive deliveries, the supervisor writes to
/drafts/first, asks for confirmation, and only promotes to/briefings/after the user approves via theapprove-drafttool. - Guardrails —
PromptInjectionDetectoron URL content,PIIDetectorredaction on the final digest,TokenLimiterProcessorto cap cost. - SSRF hardening —
http-fetchblocks loopback, private, and cloud-metadata addresses (fullfe80::/10andfc00::/7ranges) before issuing the request.
Usage
After scaffolding, start the stack with pnpm dev, open the web chat, and pick the briefing-supervisor agent.
> Summarise https://news.ycombinator.com and https://simonwillison.net for meThe supervisor will:
- Confirm the sources
- Dispatch
research-agentin the background — first chunk arrives in ~1s - Wait for research to complete (~30s–2min depending on source count)
- Delegate to
writer-agentfor the final markdown digest - Archive the digest at
/briefings/{date}T{time}Z.mdin the user's workspace - Stream the result back
Skills flow
Mid-conversation:
> From now on, write briefings in Dutch and keep them under 5 bullets.The agent will skill_search for an existing match → no result → write_file two skills (/skills/language-dutch/SKILL.md and /skills/short-format/SKILL.md) → confirm. The next briefing applies both preferences automatically.
Search flow
> What did you tell me about Anthropic last week?The agent calls search over the indexed /briefings/, reads the matching files, and answers with citations to the actual archived briefings.
Scheduled briefings
The supervisor exposes schedule_briefing and list_scheduled_briefings tools so users can ask "send me this digest every weekday at 9am". Scheduled tasks are gated by plan (see Scheduled Tasks).
Note: scheduled ticks currently route through the default
assistant-agent, notbriefing-supervisor. Tracked for V1 polish — see MAK-242.
Customization
The most useful starting points for tweaks:
- Model selection — swap providers in
apps/mastra/src/mastra/lib/models.ts - Guardrail thresholds — raise the PII threshold or change
GUARDRAIL_MODEL_IDinapps/mastra/src/mastra/lib/guardrails.ts - Source tools —
http-fetchis intentionally minimal. Add a Tavily search tool, RSS reader, or Browserbase-driven browser tool to giveresearch-agentricher inputs - Delivery — the digest streams to chat. Wire it to email/Slack by intercepting the supervisor's final response, or by adding a workflow that calls a delivery tool after archiving (V1 polish, MAK-244)
Standalone vanilla template
If you want the briefing pattern without MastraKit's auth/billing/observability — for example, to publish your own variant or run it standalone — there's a vanilla extract at templates/briefing-agent/ in the MastraKit repo. It's published to mastra.ai/templates and runs as a single Mastra dev server with a local SQLite workspace, no auth, no scheduling.
The vanilla template is not a drop-in equivalent of the MastraKit-installed variant — it deliberately ships a smaller surface area. The two differ on purpose:
| Capability | Vanilla (templates/briefing-agent/src/mastra/tools/) | MastraKit-installed (apps/mastra/src/mastra/tools/) |
|---|---|---|
http-fetch.ts (SSRF-hardened) | ✓ | ✓ |
approve-draft.ts (drafts approval flow) | ✗ | ✓ |
schedule-briefing.ts (cron-style scheduling) | ✗ | ✓ |
| Multi-tenant per-user workspace | single shared workspace | ✓ via JWT-derived userId |
| Auth, billing, observability | ✗ | ✓ |
If you only need the supervisor-with-subagents pattern, the vanilla template is the right starting point. If you need the full drafts/skills/scheduling experience documented above, scaffold with the MastraKit CLI and answer "yes" to the prompt instead.
Skipping a template later
If you scaffolded with a template and want to remove it, delete the agent files, drop the briefing-supervisor entry from the agents map in apps/mastra/src/mastra/index.ts, and remove any related env vars from .env. There's no programmatic uninstall — templates are plain TypeScript once they're in your repo.