Using the WAT Framework: Writing Sanity MCP Workflows That Make Claude Consistent and Reliable
Last updated: 15.03.2026
Using the WAT Framework: Writing Sanity MCP Workflows That Make Claude Consistent and Reliable
Audio Narration

The text explains why open-ended AI instructions like “write a blog post about TypeScript” lead to inconsistent results. Because models are probabilistic, they vary structure, miss fields, and overlook edge cases, which is problematic for repetitive, structured tasks such as publishing to a CMS. To solve this, it introduces the WAT framework: Workflows, Agents, Tools. Workflows are plain-language markdown SOPs that encode domain knowledge and specify steps. Agents (Claude) handle reasoning and decisions. Tools are deterministic scripts or APIs, like the Sanity MCP, that execute actions. This separation narrows the decision space and keeps behavior consistent across sessions. A concrete example is the draft_blog_post workflow, which fetches authors and categories from Sanity, requires outline approval, and strictly defines document shape and constraints, including a 5000-byte body limit. Workflows evolve through a self-improvement loop: each failure adds new rules and edge cases. To get started, you document repeatable tasks, inputs, tools, steps, and edge cases, store them in .claude/wat/workflows/, and reuse them for faster, cheaper, and more reliable AI-assisted work.
The Problem With Asking AI to "Just Figure It Out"
When you give Claude an open-ended task like "write a blog post about TypeScript," you get a different result every time. The structure varies. Fields get missed. Edge cases are ignored. That's not a bug — it's the nature of probabilistic reasoning. Without constraints, the model explores a wide solution space. For repetitive, structured tasks like publishing content to a CMS, that's a liability.
What the WAT Framework Is
WAT stands for Workflows, Agents, Tools. It's a three-layer architecture that separates concerns: Workflows are plain-language markdown SOPs that define what needs to happen and how. Agents — Claude — handle reasoning, sequencing, and decision-making. Tools are deterministic scripts or APIs (like the Sanity MCP) that do the actual execution. Each layer does what it does best. The workflow encodes your domain knowledge. Claude handles judgment calls. The tools handle the mechanics.
Why Workflows Make AI Better
A workflow narrows the decision space. Instead of reasoning from scratch each time, Claude follows a defined path: collect inputs, fetch context, draft an outline, get approval, write content, create the document. Every step is explicit. Edge cases are handled in advance. The result is consistent, repeatable behavior — more like a reliable colleague following a process than a creative generalist making it up as they go. If each step is 90% accurate and you have five steps, an improvised chain lands at 59% success. A workflow keeps you close to 90% at every step.
Building a Sanity MCP Workflow
The draft_blog_post workflow is a practical example. It starts by fetching authors and categories from Sanity via GROQ so references are always valid. It requires outline approval before writing — a quality gate that prevents wasted effort. The document shape is specified exactly: the Portable Text body structure, SEO fields, what not to set (autoSummary is generated on publish). Discovered constraints get documented too, like the 5000-byte body limit imposed by the audio narration pipeline.
The Self-Improvement Loop
Workflows are not static. When you hit a slug conflict, you add a rule: append -draft. When you discover the body size limit, you document it and add a trimming instruction. Each failure makes the workflow stronger. Over time it accumulates hard-won knowledge about your specific setup — knowledge that would otherwise live only in your head or get rediscovered every session.
Getting Started With Your Own Workflows
A good workflow starts with a repeatable task you find yourself explaining more than once. Write down the inputs, the steps, which tools to call, and the expected output. Add an edge cases table as you encounter them. Store it in .claude/wat/workflows/ and reference it by name when you start a task. The payoff compounds: every session that follows the workflow is faster, more consistent, and cheaper than one that improvises from scratch.

I Fed Brewfather's API to Claude and Built My Own MCP Server
Brewfather is a comprehensive app for homebrewers that manages recipe design, batch tracking, fermentation logs, water chemistry, and ingredient inventory, making it a central hub for homebrew recipes. An MCP (Model Context Protocol) server acts like a plugin that exposes local tools and data to an AI such as Claude, letting it call a locally run server without any cloud intermediary or custom UI. Using Brewfather’s REST API, the author fed the documentation to Claude and quickly generated a local MCP server that connects Brewfather to Claude Code. This setup enables three key capabilities: browsing and inspecting real Brewfather recipes, checking the brew schedule and batch stages, and verifying whether the ingredient inventory is sufficient for an upcoming brew day. The main benefit is turning brewing data into a conversational interface, so users can simply ask questions like whether they are ready to brew on a given day. Future extensions could include logging fermentation readings, auto-creating batches from recipes, and sending notifications as batches progress through stages.
Read post
Serving Your Blog as Markdown So AI Agents Can Actually Read It
The article explains how to serve clean Markdown versions of blog posts so AI agents can consume content without HTML noise like navigation, scripts, and cookie banners. It recommends two access patterns: appending .md to post URLs, or using an Accept: text/markdown header for content negotiation. In Next.js, rewrites in next.config.ts route both patterns to an internal /md/posts/[slug] handler. That route fetches the post from Sanity, converts it to Markdown, and returns it with a text/markdown Content-Type and short caching headers. A buildPostMarkdown helper constructs the Markdown document with a title, canonical URL, optional hero image, auto-generated summary, and body converted from Portable Text via @portabletext/markdown. Code blocks stored in Sanity as _type: "code" are correctly rendered as fenced Markdown code blocks with language tags, making them ideal for AI agents and syntax highlighters. A /posts.md index provides a machine-readable sitemap listing all posts with metadata and links, enabling agents to discover and traverse content efficiently using either the .md suffix or Accept header approach.
Read post