Skip to content
Greenware
Esc
↑↓navigate↵open⌘Jpreview
On this page

Design brief

The original concept for Greenware, written before the build: the thesis, why now, and the factory discipline it borrows.

Status: the original design brief, drafted 2026-11-26 before the build. Names, commands and stage numbers changed as Greenware was built; the rest of these docs and gw --help describe the current system. This doc keeps the reasoning behind it. One line: a rough client brief goes in. A planned, cost-estimated, verified Clay build comes out, together with the client deliverables. You run it from Claude Code, and you are the person who signs off at two gates.


1. The thesis

GTM engineers on X talk about “software factories.” For a Clay team or agency, speed is not the useful part. Typing prompts faster than a human just gets you more unreviewed Clay tables. The useful part is the factory discipline:

  1. The spec is the product. Every build starts as a written Play Spec: ICP, signals, sources, destinations, budget and success criteria. The spec can be reviewed before any credits are spent.
  2. Agents build and separate agents verify. The verifier never reads the builder’s reasoning. It reads the spec, the built graph and real run outputs.
  3. Verification uses held-out truth. Each client has gold accounts (closed-won customers, known bad fits and known good contacts). A build passes when it scores those correctly, not when it “looks right.”
  4. Every solved problem becomes reusable. A fix becomes a Clay Function, a blueprint or a skill amendment. Output grows faster than headcount because the library compounds.
  5. Humans own consequences. A person approves the plan and approves going live. Everything between those two gates can run unattended.

The effect is multiplicative. Throughput is roughly parallel clients × reuse rate × first-pass verification rate. Typing speed is not a term in that formula.

2. Why now: Clay shipped the factory floor

Clay’s official surface changed a lot in 2026. The npm package @clay-run/cli v1.23.0, updated 2026-11-23, and the clay-run/agent-plugins repo, with about 40 official skills for Claude Code, Codex and Cursor, map almost one-to-one onto software-factory primitives:

Factory primitive What Clay now provides (verified from clay --help and the official skills)
Programmatic build target clay workflows create, nodes create/insert/update, triggers, groups, publish
Tables are not a build target Official skill: “you cannot create tables programmatically”. Tables are read/query only (Enterprise).
Reusable modules Functions (GA) and Routines (`clay routines create function
Digital twin / sandbox clay workflows test-data seed/add/run: up to 50 real source rows, run against the draft with no publish
Unit tests clay workflows nodes test (one node), clay workflows code test (Python sandbox)
Cost model clay workflows estimate-credits [--node] [--published], clay credits balance, clay budgets list
Version control clay workflows snapshots list/get/restore (git-style autosave before every edit), versions
Human gates Server-side approval_required holds, plus clay approvals approve/deny. Standing rules via --always-allow
Observability clay workflows runs, analysis (sampled step inputs/outputs, node traffic), alerts, runs export
Diagrams for deliverables clay workflows diagram outputs Mermaid
Shared context clay knowledge-hub business-context get/propose, knowledge-hub skills create (100 skills per workspace)
Multi-tenant clay workspaces list/switch. Several workspace logins live side by side, and CLAY_CONFIG_HOME isolates config
Agent-safe I/O JSON on stdout, typed error codes, deterministic exit codes (2 validation, 3 auth, 4 rate limit, 6 not found)

Clay’s own skills already encode several factory rules. Before any run of more than 100 records, test about 10 first. Ask before any operation that would spend 10% or more of the balance. Verify on a real record before hand-off. Never say a run is free when its price is unknown.

The gap Clay leaves is the factory itself: intake, client context, the blueprint library, independent QA against holdouts, deliverables, multi-client orchestration and the learning loop. That is what we build.

Decision: the factory builds Workflows

Clay says it plainly: Workflows were “designed so agents can build for you … headlessly through the Clay CLI”, and “agents work more easily with graphs than with grids” (the story of Clay Workflows). Tables, custom Functions and table columns cannot be created through the CLI or API, and Clay has “no current plans” to change that (Clay University: API & CLI).

So the factory’s build target is a Clay Workflow. Everything else plays a supporting role:

  • Existing tables are read sources (clay tables columns/rows/query). An agent can also rebuild a table’s logic as a workflow. That is a rebuild, not a migration.
  • Functions are buildable after all, as workflow functions. The factory can create them itself: build the logic as a canvas node group, then run clay workflows groups publish-as-function <wf> <group> (beta, approval-held). That publishes a new function and replaces the group with a call to it. Table-based custom Functions still need the UI. Existing Functions and Routines are reused as tool → clay_function nodes. Promote a group when both of the two tests pass: you’d build it more than once, and only its input and output matter.
  • Audiences is where records live and where the escalation order starts. It is free to read, and workflows write back to it.
  • Signals and schedules are triggers. Sequences are destinations.
  • When a play truly needs a table (for a one-off analysis or a client’s preference), the factory produces a build sheet for a human. It does not try to automate table building.

3. What goes in and what comes out

In: any of these

  • A call transcript or meeting notes (“client wants closed-won lookalikes routed to AEs”)
  • A Linear issue, Slack thread, email or a one-line note
  • An existing Clay table URL plus “make this production”. The factory rebuilds the table’s logic as a Workflow.

Out: a deliveries/<play-id>/ folder plus live Clay objects

  • spec.md: the approved Play Spec
  • plan.md: primitive choices, Mermaid graph and the credit estimate per run and per month
  • The built Clay Workflow (draft, then published), with every snapshot ID recorded and a Mermaid diagram
  • verification.md: holdout scorecard, a sample of real run outputs, failures and the cost actually measured
  • Client deliverables: overview, how it works (diagram), SOP or runbook, cost model, prompts, a “how to change it” rebuild guide and a Loom script
  • ops.md: alerts configured, the schedule, owners and the review cadence
  • A lessons entry that feeds the library

4. The pipeline: raw idea to live workflow

 raw idea ─▶ [1 Decompose] ─▶ [2 Clarify] ⇄ you ─▶ [3 Research] ─▶ [4 Spec + Contract] ─▶ [5 Plan]
  "lookalikes off     job, trigger,   only what blocks   client pack, Audiences,   spec.md +         blueprint, graph,
   closed-won → AEs"  outputs, unknowns  the plan          catalog, prior builds     contract.json     cost estimate
                                                                                                     │
                                                                          ◆ GATE A: approve spec + plan + budget
                                                                                                     ▼
              ┌──────────── [6 Build] (clay workflows create/nodes/triggers — draft only) ◀── fix list ──┐
              ▼                                                                                          │
        draft + snapshotId ─▶ [7 Verify] (separate agent: test-data on real rows, holdouts, contract) ────┘
                                     │ pass
                                     ▼
                              [8 Audit] credits · simplify · prompt hygiene · house style
                                     ▼
                     ◆ GATE B: approve go-live for snapshotId (outside writes, sequences)
                                     ▼
          [9 Publish] ─▶ [10 Document] ─▶ [11 Operate] (runs analysis, alerts, weekly report) ─▶ [12 Learn]
# Stage What the agent does Writes Key tools
1 Decompose Splits the raw idea into job, trigger, inputs, decisions, outputs and destinations. Matches it to the closest blueprint. Lists the unknowns. idea.md, breakdown.md blueprint classifier
2 Clarify Asks only the questions that block a plan, at most about 5 per round. Every question gets a recommended default. It answers itself where it can from the client pack, Audiences, Knowledge Hub or the CRM. questions.md (asked / auto-answered / assumed) client pack, clay audiences, clay knowledge-hub business-context get
3 Research Grounds the plan in fact. What data the client already has (Audiences first, since it’s free), which actions and functions exist in this workspace, what prior builds and lessons say, and what the corpus says about this play. research.md clay workflows actions list/schema, clay functions list/get, clay routines list, knowledge/
4 Spec + Contract Writes testable acceptance criteria, then turns them into contract.json (assertion IDs plus the evidence each one requires). spec.md, contract.json —
5 Plan Picks primitives in Clay’s escalation order (Audiences → Search → Function/Routine → Workflow). Lays out the node graph (Mermaid), the gates (suppression before paid steps, QA before sends) and the cost estimate. plan.md blueprint, cost model
A Gate A You approve the spec, plan and budget in one click, via Linear or Slack. approval record
6 Build Creates the draft workflow: trigger, nodes, data passing and names. Records a snapshot ID after each step. Never publishes. build-log.jsonl, state.json clay workflows create, triggers create, nodes create/insert/update, graph validate, diagram
7 Verify Runs as a separate agent with a separate prompt and no access to the builder’s reasoning. Seeds test-data from the real source, tests nodes, and runs the draft on real records and on holdouts. Checks every contract assertion, measures cost, and returns a fix list. verification.md test-data seed/run, nodes test, runs get/steps, estimate-credits
8 Audit Looks for credit waste (company-first fan-out, run conditions, BYO keys), simplification and prompt hygiene, and applies the house style rules. audit section workflows-simplify, workflows-optimize-credits skills
B Gate B You approve go-live for a specific snapshot ID. Any outside write or sequence launch is approved here, never earlier. approval record clay approvals
9 Publish Publishes, then sets up alerts and schedules. ops.md publish, alerts, schedules
10 Document Produces the client pack: diagram, how it works, cost model, runbook and “how to change it”. deliverables/ clay workflows diagram
11 Operate On a schedule, checks run health, error sweeps, credit burn against the estimate and outcome metrics. weekly report runs analysis, alerts
12 Learn Turns each flawed, blocked or manual outcome into the smallest durable fix: a skill rule, a contract assertion, a blueprint field or a Function spec. PR to library session history

The Builder uses a mid-tier model. Decompose, Plan and Learn use strong models. Verify runs on a different model or prompt from the Builder. Bulk copy and normalization stay inside Clay nodes, never in Claude Code tokens.

Loop guards: a cap of 3 Build-Verify iterations, a credit ceiling per play taken from Gate A, and wall-clock limits. Any of these stops the loop and escalates to a human with the current state written to disk.

Borrowed directly from the factory playbooks (sources in the research landscape):

  • Validation contract before the build (Factory.ai Missions, Anthropic sprint contracts). The Architect writes contract.json with assertion IDs, for example A3: persona precision ≥ 90% on gold/good_contacts.csv and A5: zero rows from existing customers. The Builder can only mark an assertion passed with evidence attached. JSON is used because models edit it less freely than prose.
  • Holdouts the builder never sees (StrongDM scenarios). The gold/ folder can be read by the Verifier agent and is denied to the Builder.
  • Shadow mode for outside writes (Vercel dryRun). A Clay test run executes every step for real, including CRM writes and sequence enrollment. Verify tests the nodes upstream of a write with nodes test and checks the payload the write would receive. A real write happens only after Gate B.
  • Approval is bound to a snapshot (Vercel). Gate B approves a specific snapshotId. Any edit after that point needs a new approval.
  • Every run ends in one of four outcomes (Vercel AI SDK factory): success, flawed, blocked or manual. A flawed run becomes a new contract assertion or a skill fix. A blocked run (missing connection, seat or entitlement) becomes a setup checklist item. A manual run raises the question of whether that boundary can be removed.
  • Fresh context per stage (Ralph loop, Amp handoff, Anthropic harness). Each stage reads its inputs from disk and writes its outputs to disk. The process never relies on a single long session.
  • Approve instructions, not every output (Mastra). Hard human review applies to changes to blueprints and skills. Routine outputs pass on contract plus holdout evidence.

5. The three assets that compound

5a. Client context packs (clients/<slug>/)

clients/acme/
  CLAUDE.md          # who they are, what's sacred, tone, what never to touch
  company.md         # synced from/to Clay Knowledge Hub business-context
  icp.md             # firmographics, personas, disqualifiers, the 3 buckets
  stack.md           # Clay workspace id, CRM, sequencer, inboxes, owners
  gold/              # holdouts: closed_won.csv, known_bad.csv, good_contacts.csv
  budget.md          # monthly credit allowance, per-play ceilings
  plays/             # one folder per play: spec, plan, verification, deliverables
  ledger.jsonl       # append-only: every CLI call that spent or changed something

The gold folder is the moat. Five dozen labeled accounts per client turns “the ICP score looks fine” into “the ICP score gets 52 of 60 holdouts right, up from 41.”

5b. Workflow blueprints (blueprints/)

A blueprint is a parameterized workflow shape: raw-idea phrasings it matches, trigger type, node graph, required client inputs (the intake questions), gates, Functions it reuses, contract assertions, holdout metric and a cost model. Full catalog: knowledge/synthesis/03-workflow-blueprints.md. The first ones are the plays agencies build most often:

  • Closed-won lookalikes: last 45 days of closed-won, then find-similar or competitor search, then ICP filter, then decision-makers, then AE approve/deny
  • Outbound reply handling: classify each reply. “Wrong person” triggers a re-find on the same domain that excludes the original title. “Not now” snoozes 90 days and then re-sequences.
  • Inbound lead enrichment and routing (Clay’s own sweet spot for Workflows)
  • Signal stacking: hiring, funding, job changes, LinkedIn engagement via webhook, intent score and routing
  • CRM hygiene: required join keys (domain, LinkedIn URL), segment instead of delete
  • TAM build, ICP scoring, ABM and ad sync, champion tracking, meeting-prep briefs

5c. Function library

Each Clay Function that passes two tests (you’d build it more than once, and only its input and output matter) is promoted into a shared catalog. The factory can mint these itself by grouping proven nodes and running clay workflows groups publish-as-function, so the library grows as a side effect of building plays. Examples: domain → normalized account, person → verified email waterfall, company → ICP tier. The Architect must look in the catalog before it designs anything new. This is the DRY layer that makes the 20th client cheaper than the 2nd.

6. How you drive it

Phase 1: Claude Code plugin (start here). This repo becomes a plugin: skills, agents and hooks, installed next to Clay’s official clay plugin.

/factory:idea acme "lookalikes off last 45d closed-won, route to AEs in SFDC"   # stages 1-5, asks you questions
/factory:approve acme/lookalikes   # Gate A, then Build→Verify→Audit run unattended
/factory:status            # every play across every client, by stage
/factory:verify acme/lookalikes
/factory:ship acme/lookalikes     # Gate B
/factory:report acme --week

Phase 2: headless and parallel. claude -p or the Agent SDK runs Stages 1–5 unattended per play, in parallel across clients (one worktree or session per client). An issue tracker such as Linear is the queue. A factory label triggers runs, and Gate A and Gate B arrive as issue comments or Slack approvals. Phase 3: durable runtime (only if needed). Move orchestration into a durable runtime (Mastra workflows, Vercel Workflow) for suspend/resume at gates, retries and tracing. Do this only when Phase 2 shows the need. Files plus the issue tracker plus Clay’s own runs/snapshots already provide most of the durability.

7. Guardrails (non-negotiable for agency work)

  • The client owns the tools. Every play runs in the client’s Clay workspace (clay workspaces switch) and is recorded in the ledger. One client session can never read another client’s folder (permissions.blockReadsOutsideWorkingDirectories).
  • A single wrapper for side effects. bin/clay-guard (a PreToolUse hook) auto-allows read-only clay calls. It denies publish, credits top-up, sequence launches, api-keys and webhooks outside the Publish stage, and it denies raw curl to Clay. Clay’s own approve-cli.sh hook is a good model, and its gated list is already right.
  • Estimate before spend, sample before scale. estimate-credits runs before every run. Use about 10 records before any run of more than 100. Stop if actual spend outpaces the estimate.
  • Snapshots are the undo button. Record the snapshot ID before every build step and restore on a failed verify.
  • Never vibe-code into client CRMs. Clay is the safe execution layer. Claude Code designs, builds, verifies and documents.
  • Use cheap models for volume and strong models for judgment. Bulk copy and normalization run in Clay columns or nodes, never through Claude Code tokens.

8. Autonomy levels (where we aim)

Level Description Typical today → target
L0 Hand-built in the Clay UI most builds
L1 Claude drafts prompts, formulas and architecture common
L2 Claude builds through the CLI while you watch every step possible today
L3 Factory builds from an approved spec. You review the plan and the verification report. MVP target
L4 Brief in, two approvals, deliverables out, ops automated 90-day target
L5 Signals start new plays with no human. “Dark factory.” not for client data. Internal plays only.

8b. What the ingestion changed (2026-11-26)

These findings come from the synthesis files in knowledge/synthesis/:

  • Gates must be ours. Clay’s approval cards come from its managed sessions. Practitioner reports (Jeff Barg, Clay’s head of AI) say that flow doesn’t apply when Claude Code drives the CLI, while the CLI docs describe server-side approval_required holds. Gate A and Gate B live in the factory either way, and any Clay hold is a bonus. Verify on a real workspace.
  • Publish with --no-launch-sequences, always. By default publish launches any draft sequences the workflow enrolls people into.
  • Classify the request first: workflow, one-off search, Function or segment. The most common failure practitioners report is an agent asked for a workflow that runs a one-off search instead.
  • The gate order is fixed: exclusions/suppression, then cheap filters, then agent judgment, then paid enrichment, then writes. Check eligibility again right before sending. Formulas and code handle routing and scoring. Claygents only make judgment calls, they return fixed labels, and “not found” is always an allowed label.
  • Builder footguns are guarded mechanically.
    • nodes update replaces incomingEdges wholesale, so the builder must read the node back after every write.
    • Every conditional needs an isDefaultRoute edge.
    • graph validate and code test exit 0 even when they fail, so their JSON has to be parsed.
    • csv run isn’t idempotent.
  • Workflow limits that shape blueprints.
    • Delays cap at 45 days, so a 90-day snooze becomes a snooze_until field plus a scheduled trigger.
    • Each enroll node takes exactly one sequence.
    • Rep tasks don’t pause a run, so human approval inside a play needs a second trigger.
    • Web intent tracking setup and LinkedIn post-mention signals are not available through the CLI.
  • Functions can be minted by the factory with groups publish-as-function.
  • Shadow mode needs three tiers, because test runs perform outside writes for real:
    1. Test only up to the write node and check the payload it would receive.
    2. Point writes at sandbox destinations, then swap them before Gate B, with a snapshot diff proving only the destinations changed.
    3. Let a human approval step act as the first live check.

9. Open design questions

  1. Functions and tables. The factory only specs these, because they can’t be built through the CLI. Who builds them in the UI, and is browser automation ever acceptable on a client workspace?
  2. Workspace model. A client can own its Clay workspace and invite the builder in, or the builder can hold a workspace per client. The choice affects auth, budgets and Knowledge Hub.
  3. Plan tier. Table query and budgets need Enterprise or particular entitlements, which not every client has.
  4. Approval surface. Gates can live in issue comments, Slack, or both.
  5. Deliverable standard. The Document stage should match the team’s own format (a Notion page, a Google Doc, a Loom).
  6. First blueprint. Closed-won lookalikes and reply handling are both common and both fit Workflows.

10. Proposed MVP (2 weeks, one client, one blueprint)

  1. Scaffold the plugin. Skills: idea, clarify, research, spec, plan, build, verify, document. Agents: decomposer, researcher, planner, builder, verifier and documenter. Also the clay-guard hook, the client pack template, and knowledge/ wired in as reference files.
  2. Encode one blueprint end to end (recommended: closed-won lookalikes).
  3. Run it on one real client with a 50–60 account gold set.
  4. Measure: brief-to-draft time, human minutes, verify pass rate, credits per qualified account and the delta against the hand-built version.
  5. Promote whatever was reusable into the function library and write the second blueprint with what you learned.

See the research landscape for the landscape and sources, and knowledge/README.md for the ingested corpus and the synthesis files the agents read.

Was this page helpful?