Your own harness: pipelines and graphs around vibe coding
This is an advanced topic. If you haven’t built a single project with a terminal agent yet (see “CLI and terminal AI agents”), do that first. Everything below solves problems that only show up on your second or third project. The main one sounds like this: “yesterday the agent did great, today it made a mess of the same kind of task, and I don’t know why.” The answer is almost never the model or the wording of the prompt. It’s whatever surrounds the model, that is, the harness.
Up to now this guide has taught you to use someone else’s harness. Claude Code, Cursor, v0 are ready-made harnesses that someone else built. This topic is about designing your own. First without a single line of code, out of files in the project folder. Then as an overview, at the level of SDKs and graphs, so you know what to ask an agent or a developer for.
What a harness is made of
On its own, a model can do one thing: take text and continue it. Everything else that makes it an agent is the harness, and every harness has six parts. Learn to see them in every tool. “Setting up an agent” always means changing one of them.
| Part | What it’s responsible for | Where it lives in Claude Code |
|---|---|---|
| Instructions | What the agent knows about the project and its rules before the first task | CLAUDE.md, .claude/rules/ |
| Tools | What the agent can physically do: read and edit files, run commands, reach external services | built-in tools, MCP servers |
| Procedures | How to do recurring tasks. Loaded only when needed | skills: .claude/skills/<name>/SKILL.md |
| Roles | Separate workers with their own context and a narrow task | subagents: .claude/agents/<name>.md |
| Control | What’s allowed without asking, what needs confirmation, what’s forbidden; automatic checks on events | permissions and hooks in .claude/settings.json |
| Memory | What survives the end of a session | files in the repository: README, ROADMAP, the agent’s notes |
A reminder from “Terminal agents: making them yours”: commands and skills are the same thing, and the standard is a skill folder with SKILL.md. And hooks have far more events than the four named there: SubagentStop, SessionStart, UserPromptSubmit and dozens more.
This whole structure is just files in the .claude/ folder inside the repository. That means the harness is versioned in git along with the code, moves to a colleague along with the project, and gets edited like any other text.
Three levels of complexity, and a rule for choosing between them
Once you learn the words “multi-agent system,” it’s tempting to build something complex right away. The working rule is the opposite: don’t move to the next level until the current one hits a specific, named problem. Each level adds cost, latency and places where things can break.
- One agent with good context. Rules in
CLAUDE.md, a couple of skills, sensible permissions. That’s enough for most of a designer’s projects: a landing page, a prototype, a small product. If the result is unstable, fix the context first instead of adding agents. - A pipeline: a fixed chain of steps. The task goes through the same stages in the same order: spec → plan → implementation → review → tests. Each stage is a separate call with a narrow task and a clean context. You need it when one agent “loses the thread” on a long task or keeps approving its own work.
- A graph: steps with branches and loops. Same as a pipeline, but the route depends on the result. A request goes to different branches by type. Text goes back for another pass until it passes the check. Several branches run in parallel and then merge. You need it when you can no longer describe the “if… then…” logic in words in one prompt and have it actually followed.
Apart from this ladder sits the autonomous agent. You give it a goal and it builds the plan itself (Manus from “Automating workflows with AI”, deep research modes). It’s good where the path isn’t known in advance and bad where you need a predictable, repeatable result. Pipelines and graphs exist precisely to take freedom away from the model where it isn’t needed.
Five patterns almost everything is built from
These patterns are described in Anthropic’s article “Building effective agents” and have since become a shared vocabulary. Recognizing them helps for the same reason the UX patterns from “UX patterns for AI features” do: you agree with a developer faster and give an agent a sharper task.
- Chain (prompt chaining). The output of one step is the input of the next. You can put a check between steps. Example: brief → landing page structure → copy → layout.
- Router (routing). The first step only classifies the input and sends it to the right branch with its own prompt. Example: incoming request → “new project” / “changes to a current one” / “billing question.”
- Parallel branches (parallelization). One task is split into independent parts. Or one result is judged by several narrow critics at once. This is that same trick with three reviewer subagents: accessibility, budget, brand.
- Orchestrator and workers (orchestrator-workers). The main agent decides how to split the task, hands the parts to workers and assembles the result. Example: “build a site with six sections.” The sections are built in parallel while the orchestrator keeps the overall style consistent.
- Generator and critic (evaluator-optimizer). One step creates, another scores it against a rubric and sends it back for another pass until it passes or runs out of attempts. It’s the automated version of the “draft → critique → revision” loop from “Writing content and UX copy”.
Plus a sixth element. It’s not a pattern but a required part of any of them: a human in the loop. A point where the pipeline stops before an irreversible or expensive action and waits for confirmation.
It helps to sketch the diagram before you build anything. Arrows in a text file are enough:
request → [router] → new project → [brief questions] → brief → HUMAN: ok? → to the sheet
→ changes → [check vs. mockup] → task list → to the tracker
→ other → HUMAN
A pipeline around vibe coding, no frameworks
Everything you need for level two is already in earlier topics, just in separate pieces. Put together, it is your own harness. A working setup for a project that lives longer than a week:
- The input is a spec, not a prompt. The task is written up as
spec.mdwith acceptance criteria (spec-driven development from “Vibe coding: interfaces”). The reviewer will judge against those acceptance criteria later, so without them the pipeline is blind. - Implementation is the main agent with rules from
CLAUDE.mdand design system tokens (see “AI-first design systems”). - Review is a separate subagent with a clean context. It didn’t see how the code was written, so it doesn’t defend its own decisions. Its description has one task: check the result against
spec.mdand the rules, and return a list of mismatches without fixing anything itself. - The check is deterministic. Tests, linter, build, not “the model’s impression.” A hook on the
Stopevent won’t let the agent declare the task finished until the check passes. “Done” stops being an opinion. - The safety net is a
PreToolUsehook that blocks dangerous commands (see “Securing a vibe-coded project”), plus a permission list where deploys and file deletion always need confirmation. - Memory is files. At the end of a task, the agent updates
ROADMAP.mdand a short decision log. The next session starts by reading them instead of from a blank page. - Launch is one skill that walks the task through all the steps in order. That way you don’t have to remember the sequence every time.
The reviewer subagent is a plain markdown file:
---
name: spec-reviewer
description: Checks finished work against the spec. Call after implementation is complete, before committing.
tools: Read, Grep, Glob
---
You are a reviewer. You did not write this code and you don't have to defend it.
Read specs/<task>/spec.md and the changed files. For each acceptance criterion, answer: met / not met / can't verify — with the file and line.
Separately, list violations of the rules in CLAUDE.md: colors and spacing not from tokens, inline styles, duplicate components.
Don't fix anything. If there isn't enough data to judge, say so; don't guess.
Notice the tools line: the reviewer only gets read tools. Limiting permissions is as much a part of the role as the instruction text. And it’s more reliable than any “please don’t change anything.”
You don’t have to build all this by hand. It’s a typical task for the agent itself; there’s an example prompt at the end of the topic. But you have to design the diagram: which steps, where the check is, where it stops and waits for a human.
Context is the harness’s main resource
The intuition “give the agent more information and it’ll be smarter” works backwards. The context window is finite, and everything in it competes for the model’s attention. In a long session, early instructions get pushed out, and quality drops long before the window is formally full. So designing a harness is largely deciding what to keep in context all the time, what to load on demand, and what to move into a separate context.
- All the time: only what every task needs. A short
CLAUDE.mdwith the stack, rules and prohibitions. If it grows to several screens, the agent stops following it. - On demand: procedures and references. Skills (loaded when needed). Documentation via MCP (that’s exactly why Astryx from “AI-first design systems” has a compact output flag). Files the agent opens itself when it needs them.
- In a separate context: everything bulky and secondary, such as searching the codebase, digging through logs, reviews. A subagent does the dirty work in its own space and returns only the conclusion to the main conversation.
- Between sessions: nothing but files. “The agent remembers” means “the agent read what was written down.” Whatever isn’t written to the repository doesn’t exist in the next session.
A practical sign that context is in trouble: the agent starts breaking a rule it followed an hour ago. Repeating the rule in caps won’t help. The fix is a new session with a clean context and a written summary of the previous one.
Evals: how to tell the harness got better, not just different
Any edit to CLAUDE.md or a skill improves something and breaks something, and you can’t see it by eye. Today’s good generation says nothing about tomorrow’s. Evals (short for evaluations) replace gut feeling with measurement. They’re a set of reference tasks with a success criterion known in advance, run after every change to the harness.
For a design project, a modest version is enough:
- Collect 10–20 real tasks from the project’s history. Typical ones and the ones the agent used to get wrong: “add a pricing section,” “make a form with validation,” “fix the card padding on mobile.”
- Write a check for each. Ideally an objective one: the build passes, tests are green, the changed files have no colors outside the tokens, no new dependencies appeared. Where you can’t be objective, a rubric for a judge model works, as in “Evaluating and critiquing AI output”, scoring each criterion separately.
- Run the whole set after every harness edit and record the pass rate. Terminal agents can work without a conversation; in Claude Code that’s running with the
-pflag. So the agent can write the run script itself. But in that mode nobody is there to answer permission requests: without--permission-mode acceptEditsand an--allowedToolslist, edits will be rejected or the run will stall on the first file change. And cap the cost:--max-turnsfor the number of steps,--max-budget-usdfor money. One task from the set looks like this:
claude -p "Do the task in evals/01.md" --permission-mode acceptEdits --allowedTools "Read,Edit,Bash(npm test)" --max-turns 30 --max-budget-usd 2
- Add every new failure from real work to the set. After a month, the set becomes the most valuable file in the project: it records everything that has ever gone wrong.
One key detail: a single run proves nothing, because the model is probabilistic (see “Foundations”). A task counts as solved if it passes consistently, two or three times in a row.
When you do need code: SDKs and graphs
Files in .claude/ are enough as long as the harness is just for you, inside the terminal. Code comes in two cases. The agent has to work without you: on a schedule, on an event, inside a product for other people. Or the route branches so much that you have to describe it explicitly and keep it under control. Here it’s enough to know the map.
- Agent SDKs (Claude Agent SDK, OpenAI Agents SDK, Google ADK) are libraries for Python and TypeScript. They give you the same agent loop, tools and context management as a ready-made agent, but as a part for your own program. The Claude Agent SDK is literally Claude Code as a library: the same skills, subagents, hooks and MCP get picked up from the
.claude/folder. It runs on an API key with pay-per-token billing, not a subscription (see “AI as a feature inside a prototype”, where unit economics are covered). - Graph frameworks (LangGraph and similar) are a way to describe level three explicitly. Step nodes, transitions between them, a shared state passed along the graph, stopping points for a human, the ability to resume from the point of failure. People pick them when they need strict control of the route rather than agent freedom.
- Visual builders (n8n, Make; see “Automating workflows with AI”) are the same graph without code: nodes on a canvas, some of which are AI steps. For a request router or a weekly report, that’s often enough. For a designer, it’s the shortest path to a working graph.
You can build an SDK prototype with the same vibe coding. Give the agent the task as a diagram from the patterns section: “router, three branches, generator and critic in the changes branch, human confirmation before writing to the tracker.” The words “make a smart agent” won’t work.
Where it breaks
- Cost and time. Five steps means five model calls, and a “critic sent it back” loop multiplies them further. A pipeline that takes twenty minutes and two dollars for what one agent did in three minutes has to pay for itself in quality. A cap on attempts in any loop is a must.
- Errors compound. If each step is 90% reliable, a chain of five steps is about 60% reliable. That’s why you put checks between steps instead of hoping for the final review.
- A critic on the same model is blind where the author is. A reviewer on the same model misses the same mistakes. Deterministic checks help, and for important things, a different model as the judge.
- Autonomous branches read other people’s text. Any step that goes online or reads incoming email is an attack surface for prompt injection (see “CLI and terminal AI agents”). Never give such a step tools with irreversible actions.
- Nothing to debug. When the result is bad, you need to find the step where it went wrong. Every step should leave a trail: what it received, what it returned. Without logs, a multi-step setup can’t be fixed, only rewritten.
- The harness goes stale. A rule that made up for a model’s weakness six months ago may only get in the way with a new version. Every couple of months, try removing something from
CLAUDE.mdand watch the evals. A good harness gets shorter over time.
Command examples for practice
Look at this project and the history of recent tasks. Propose a minimal harness in the .claude folder: what to put in CLAUDE.md, which 2–3 skills to set up for recurring tasks, what reviewer subagent is needed and which hooks. Show the plan and file structure first; don’t create anything without my confirmation
Set up a spec-reviewer subagent: read-only tools, its task is to check the changes against specs/<task>/spec.md and the rules in CLAUDE.md and return a list of mismatches without fixing anything
Set up a hook on the Stop event: the task doesn’t count as finished until a quick build and the linter pass. If the check fails, the hook exits with code 2 and writes the error to stderr so you see it and keep working. Check stop_hook_active so you don’t loop foreverA full build on every Stop will slow down every reply, so put a quick check in the hook and the full one before committing.
Build a /ship skill that walks a task through the steps: read spec.md → implement → call spec-reviewer → fix what it found → run the checks → update ROADMAP.md → show me the summary and wait for confirmation before committing
Build an evals folder: 10 tasks from this project’s history, each with a check a script can run. Write a script that runs all the tasks in non-interactive mode (claude -p with --permission-mode acceptEdits, --allowedTools, --max-turns and --max-budget-usd) and prints a pass / fail table
Here’s a process I want to automate: [description]. Break it into steps and tell me which level I need: one agent, a pipeline or a graph — and why not the next level up. Draw the diagram with arrows and mark where a human must confirm
Here’s my CLAUDE.md (paste it). It has grown to three screens and the agent stopped following it. Split it up: what to keep as permanent rules, what to move into skills, what to delete as obvious to a modern modelTake your most active vibe-coded project and build a minimal harness for it. A CLAUDE.md no longer than one screen. One skill for a task you’ve already explained to the agent more than twice. A reviewer subagent with read-only permissions. And one hook: for dangerous commands or for a check before finishing. Then write five reference tasks with checks and run them twice. If the two runs give different results, that’s the most useful discovery of the task: you’ve found a place where the harness isn’t strict enough.
Sources: Building effective agents, Anthropic
Sources
- Building effective agentsanthropic.com
five patterns of agentic systems
- Hooks reference — Claude Code Docscode.claude.com
hook events, Stop with exit code 2, stop_hook_active
- CLI reference — Claude Code Docscode.claude.com
the -p, --permission-mode, --allowedTools, --max-turns and --max-budget-usd flags
- Subagents — Claude Code Docscode.claude.com
subagents in .claude/agents and the tools field
- Agent SDK overview — Claude Code Docscode.claude.com
Claude Code as a library, running on an API key
Found a mistake or an outdated fact? Write to hey@iskra.guide