---
title: "Templates"
description: "Opt-in showcase agents bundled with the MastraKit scaffold"
source: "/docs/templates"
---


Overview [#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 [#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 [#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 [#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 [#patterns-it-demonstrates]

* **Supervisor delegation** — the supervisor exposes the two subagents via the `agents` map and decides which to call. Subagents have no overlapping tools, so the routing decision stays clean.
* **Background tasks** — `research-agent` is opted into background dispatch. The supervisor's first response ("I'm gathering your briefing now…") streams immediately while research fans out across multiple `http-fetch` calls.
* **Per-user workspace** — every user gets an isolated filesystem under `users/{userId}/` backed by Turso, exposed to the agent as `/skills/`, `/drafts/`, and `/briefings/`. See [`workspace.ts`](https://github.com/Mastrakit/MastraKit/blob/main/apps/mastra/src/mastra/lib/workspace.ts) for 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.md` file under `/skills/`. Skills auto-load on every future run, even from a fresh chat.
* **BM25 search** — the supervisor can `search` over 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 the `approve-draft` tool.
* **Guardrails** — `PromptInjectionDetector` on URL content, `PIIDetector` redaction on the final digest, `TokenLimiterProcessor` to cap cost.
* **SSRF hardening** — `http-fetch` blocks loopback, private, and cloud-metadata addresses (full `fe80::/10` and `fc00::/7` ranges) before issuing the request.

Usage [#usage]

After scaffolding, start the stack with `pnpm dev`, open the web chat, and pick the **briefing-supervisor** agent.

```text
> Summarise https://news.ycombinator.com and https://simonwillison.net for me
```

The supervisor will:

1. Confirm the sources
2. Dispatch `research-agent` in the background — first chunk arrives in \~1s
3. Wait for research to complete (\~30s–2min depending on source count)
4. Delegate to `writer-agent` for the final markdown digest
5. Archive the digest at `/briefings/{date}T{time}Z.md` in the user's workspace
6. Stream the result back

Skills flow [#skills-flow]

Mid-conversation:

```text
> 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 [#search-flow]

```text
> 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 [#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](/docs/scheduled-tasks)).

> **Note:** scheduled ticks currently route through the default `assistant-agent`, not `briefing-supervisor`. Tracked for V1 polish — see [MAK-242](https://linear.app/themakers-labs/issue/MAK-242).

Customization [#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_ID` in `apps/mastra/src/mastra/lib/guardrails.ts`
* **Source tools** — `http-fetch` is intentionally minimal. Add a Tavily search tool, RSS reader, or Browserbase-driven browser tool to give `research-agent` richer 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](https://linear.app/themakers-labs/issue/MAK-244))

Standalone vanilla template [#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/`](https://github.com/Mastrakit/MastraKit/tree/main/templates/briefing-agent) in the MastraKit repo. It's published to [mastra.ai/templates](https://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 [#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.
