Sanity copilot
- Slack
- Sanity
- Notion
A Slack-based Sanity copilot that queries and edits content with GROQ, inspects and shapes schemas, manages drafts and releases, and drafts long-form pieces into Notion.
- Slack
- Sanity
- Notion
agent/agent.tstypescriptimport { defineAgent } from "eve";
/**
* Root agent runtime configuration.
*
* @remarks
* Sets the model and the session budget for the Sanity copilot; the rest of the agent's surface
* (channels, connections, tools, skills, subagents) is discovered from the filesystem under
* `agent/`. Conversation history is compacted once it reaches 75% of the context window, and the
* per-session token limits cap runaway sessions. Raise them if long content work hits the caps.
*/
export default defineAgent({
compaction: { thresholdPercent: 0.75 },
limits: {
maxInputTokensPerSession: 500_000,
maxOutputTokensPerSession: 20_000,
},
model: "anthropic/claude-sonnet-5",
});
Sanity Copilot eve Template
A Slack-based Sanity copilot built on eve. Team members @mention it in Slack and it manages their Sanity project: querying and editing content with GROQ, inspecting and shaping schemas, creating and editing drafts, managing releases, and drafting content pieces into Notion. Long-form drafts are shared as Notion pages.
- Lives in Slack. Answers @mentions and DMs, replies in threads, and renders approvals as buttons.
- Works on your Sanity project. Each user signs in to Sanity through Vercel Connect, so queries and edits run as the real person with their own permissions, and destructive operations (patching, publishing, deploying schemas) pause for approval before they run.
- Drafts in Notion. Long-form pieces are created as Notion pages through the same user-scoped OAuth flow, with page updates and moves gated on approval.
- Stores files in Vercel Blob. Export drafts, save images and attachments, and read them back, authenticated by the project's OIDC token.
Deploy
Deploying with the button provisions everything the agent needs and wires it up for you:
- a Slack connector (sets
SLACK_CONNECTOR, with the event trigger pointed at/eve/v1/slack), - a Sanity connector (sets
SANITY_CONNECTOR), - a Notion connector (sets
NOTION_CONNECTOR), - a Vercel Blob store for the asset tools.
Once deployed, @mention the bot in your Slack workspace to start working on your Sanity project.
Tech stack
Zero static keys. Authentication runs entirely on Vercel Connect (Slack, Sanity, and Notion) and Vercel OIDC (Vercel Blob and AI Gateway). There are no API keys or client secrets to manage in code or .env files: Sanity and Notion are authorized per user in the browser, and Blob and the model authenticate with the project's OIDC token.
Quick start with an AI coding agent
If you're working with an AI coding agent like Claude Code or Cursor, you can use this prompt to have it help you with building your agent:
What's inside
All of the skills except writing-quality come from Sanity's Agent Toolkit; the sanity-best-practices references are also the canonical content behind the Sanity MCP server's rules tools.
Pairing with the content agent template
The eve content agent template is a full content assistant: per-surface style skills (blog, LinkedIn, X, release notes, newsletters), a house voice, and a style lint. Instead of merging all of that into this copilot, you can deploy it as its own agent and let the copilot delegate to it through eve's remote agents feature.
- Deploy the content agent template as its own Vercel project.
- Add a remote subagent file to this repo. The filename is the tool name, and
vercelOidc()handles deployment-to-deployment auth with no shared secret:
- Set
CONTENT_AGENT_URLin this project's environment and mention the new subagent inagent/instructions.mdso the copilot knows when to hand off.
The remote agent runs in its own deployment with its own skills and connections, and it never sees this copilot's conversation history, so the copilot packs everything the writer needs into the call message. The result comes back as a normal tool result, the same shape as the local researcher and reviewer subagents.
Local development
Link the project you deployed (or a fresh one) and pull its environment:
Then run the development server and link a model provider with /model in the TUI:
You can chat with the agent directly in the dev TUI to test the Sanity, Notion, and Blob flows. The Slack surface itself only runs against a deployment. Ship changes with:
Linting and formatting
This project uses Ultracite (a Biome preset) for linting and formatting:
Setting up the connectors by hand
The Deploy button provisions these for you. To set them up manually (for a project you didn't create with the button), use the Vercel CLI:
Customizing
- Behavior: edit
agent/instructions.md. It describes the whole workflow: load the right skill first, ground work in the real project with GROQ and schema reads, work in drafts and publish only on approval, draft long pieces into Notion, and get a fresh-eyes review before proposing a draft. - Approval gates: edit the
APPROVAL_REQUIRED_TOOLSlists inagent/connections/sanity.tsandagent/connections/notion.tsto change which MCP tools pause for a human decision. - Skills: edit or add skills in
agent/skills/. Each folder holds aSKILL.mdplus its reference files. The reviewer subagent keeps its own copy ofwriting-qualityunderagent/subagents/reviewer/skills/. - Model: edit
agent/agent.ts(or run/modelin the dev TUI). - Tools: add or change tools in
agent/tools/. The filename is the tool name.
The agent auto-updates as you edit these files.
Learn more
- eve documentation: the framework powering this agent.
- Vercel Connect: manages the Slack, Sanity, and Notion credentials.
- Sanity documentation: the CMS the copilot manages.
- Sanity Agent Toolkit: the source of every skill here except
writing-quality. - Vercel Blob: object storage for the asset tools.