Skip to main content
Glama

claude-workflow

Graph build plan craft tools with a strict system of references.

A local web UI and two MCP servers that turn an AI agent's long build into a plan a human can read, check and steer. The agent reports its work as graphs of Work nodes, each with atomic tasks and the Reading references each task rests on. The human sees the plan on a canvas, answers open questions, records decisions and pauses or rejects work. A task can be ticked only after its references were actually read through the system of references (see the sibling repository system-of-references).

Everything runs on 127.0.0.1. There is no cloud service and no account.

What is in it

Area

What it does

Build Plan graphs

A project holds graphs of Work nodes. A graph must be layered: at least three levels, one connected component, no cycles, and every new node arrives with its edges. Loops (groups of four layers) are derived from the layers, and a loop budget bounds the depth.

Work nodes and atomic tasks

Each node states a change and a done-when. Its tasks carry Reading references. A task is ticked only when its references were read, and a tick needs the earlier nodes to be finished.

Loops

The layers of a graph are grouped into loops of at most four layers (a graph twelve layers deep has three). A graph's loop budget (1, 2 or 4) bounds its depth, a wire that climbs from one loop to a later one needs a short reason, and half of a lower loop must point into a higher one before the loop after next may start. The canvas draws each loop as a band with its node count and progress.

Sheets

A sheet is a saved set of graphs with plan items and weights; progress is computed per sheet and per plan item.

Prompts

Reusable prompt templates, with a record of every send.

Decisions and human references

The human records decisions, links them, and picks any part of the page (Ctrl+drag) as a human reference the agent can fetch later. These are the human's standing preferences.

Modes

Build-plan craft (everything halted, only the human enters it), Research and Execution. A tool is allowed or refused by its class in the current mode, with the reason and what to do instead.

Live updates

One server-sent update stream tells every open page when a project database changes; no polling.

Hooks

Small Node scripts for Claude Code: a mode gate that reports every tool call to the page and records the ones the mode does not allow, and a read gate (an agent with unread references may only read).

Related MCP server: ContextPact

Visualizations

All recordings come from the running UI on the demo project (npm run seed): nine graphs from a three-step chain to a 27-node branching graph that spans three loops.

Architecture

 agent (Claude Code)                     human (browser, 127.0.0.1)
        |  MCP over stdio                        |  HTTP + live update stream
        v                                        v
 node dist/mcp/main.js <workflow|graph>   node dist/http/main.js  ---> serves ui/ (vite build)
        |                                        |
        +--------------- ProjectHub -------------+
                              |
                      Store (one transaction per write)
                              |
                  project.db per project (SQLite, migrations/001_baseline.sql)
  • src/store/ is the write layer and the read model; every public method runs in one transaction, and rules live in the database as constraints and triggers as well as in code.

  • src/mcp/ registers the tools (workflow: projects, sheets, decisions, systems of references; graph: graphs, nodes, edges, tasks, traces, blockers, tags, prompts).

  • src/http/ is the Fastify app: Host and Origin checks on every request, a strict content-security policy, JSON routes, and the live update stream.

  • ui/ is the Web UI: a Cytoscape canvas, a left panel of graphs, node cards, hover cards for edges, pop-ups for plan, prompts, decisions and activity. Every database string is rendered as text, never as HTML.

Run

Requirements: Node.js 20.19 or newer.

npm ci
npm run build          # server (tsc), UI (tsc + vite, bundled locally, no CDN)
npm run seed           # optional: a fictional project "pizza-delivery": simple chains and large branching graphs with loops, sheets and tasks
npm start              # UI on http://127.0.0.1:18640
npm test               # server tests (vitest)
npm run test:ui        # UI tests

Environment: CW_PORT (default 18640), CW_REGISTRY (registry file, default data/registry.json). CW_HOST may only be 127.0.0.1; any other value stops startup.

Add the MCP servers to your agent's configuration, one entry per group:

{
  "mcpServers": {
    "manage_workflow": { "command": "node", "args": ["/path/to/claude-workflow/dist/mcp/main.js", "workflow"] },
    "manage_workflow_graph": { "command": "node", "args": ["/path/to/claude-workflow/dist/mcp/main.js", "graph"] }
  }
}

Tools

Two MCP servers share one build (node dist/mcp/main.js workflow|graph), 37 tools in all. Each tool writes something the Web UI shows, or reads something the page lets a human change:

Server

Tool

Where it shows in the UI

manage_workflow

create_project, delete_project

the project list and the top bar

upsert_sheet

Plan: sheets, plan items and their weights

record_decision, search_decisions, link_decisions

the Chain of decisions tab

get_human_decisions, get_human_reference, list_human_references

Human references (Ctrl+drag) and the human's standing preferences

get_agent_open_questions, answer_agent_question

the Interviews button: questions the agent asks the human

get_mode, switch_mode

the Mode chip and its pop-up

add_system_of_refs, remove_system_of_refs

External references

manage_workflow_graph

upsert_graph, upsert_node, add_edge, remove, set_loop_budget

the canvas: graphs, nodes, edges and loop bands

upsert_checklist_item

the atomic tasks of a node and their Reading references

fetch_graph_details, fetch_node_details, search_graph, filter_nodes

the left panel, node cards, search and filters

report_action_trace, get_action_traces, log_attempt, add_comment

Activity, the "Working on" line of a graph, comments

open_blocker, close_blocker

the Stuck button and blocked nodes

add_target

recovery pointers (out-of-plan work pointing at a build-plan node)

upsert_tag, set_optional

tag filters and the Optional list

split_sheet_plan, upsert_prompt

sheets and the Prompts dock button

attach_web_img_reference

image references on a node

A drift test fails when a registered tool has no mode class, and another pins the exact tool list of each server. Tools for features this edition does not have (handing work to other sessions, stacks, definitions, research budgets, CI rule sets) are not registered.

Loops

A graph is layered: every node sits one layer below the deepest node it depends on. Layers are grouped into loops of four. The page draws each loop as a band labelled with its node count and progress, and marks the nodes at both ends of a wire that climbs from one loop to the next.

  • Loops are derived, never typed: a graph d layers deep has ceil(d / 4) loops, at most four, and the budget (set_loop_budget: 1, 2 or 4) is the most it may use.

  • A node has at most three outgoing and four incoming edges.

  • A wire that climbs to a later loop carries a reason of at most five words.

  • Before a third loop may start, at least half of the first loop's nodes must already point into a higher loop; the database refuses the edge that breaks this and says why.

npm run seed builds nine graphs on purpose: two straight chains, a graph with three parallel payment paths that merge, and a 27-node kitchen graph twelve layers deep with fan-out, merges and skip edges across three loops (src/seed/demo-graphs.ts).

Security model

  • The server listens on 127.0.0.1 only and checks the Host and Origin of every request.

  • Every write the human makes needs a page token that is set as an HttpOnly, SameSite=Strict cookie only when the HTML page is loaded; an API answer never carries it, so an agent with curl cannot act as the human.

  • A strict content-security policy blocks inline and generated styles and scripts and any external font or script; the bundle is built locally.

  • Every string that comes from the database is rendered as text, never as HTML.

  • Refusals name the rule and what to do next, so an agent can correct itself.

Tests

npm test runs the server suite against real SQLite databases built from the baseline migration (about 1,000 tests: store rules, database constraints and triggers, every tool through the MCP SDK's in-memory transport, the HTTP guards, hooks). The tests that run a real qr (the reference-system script) are skipped unless CW_REAL_QR=/absolute/path/to/system-of-references/qr is set. npm run test:ui runs the pure parts of the UI (layout, filters, wiring checks that read the source). The browser itself is not driven by automated tests in this repository.

Limitations

  • Single user, single machine, by design. The server refuses any host but 127.0.0.1.

  • The Web UI is not covered by browser-level tests; its checks are pure functions and source-wiring assertions.

  • The hooks and some tool messages are written for Claude Code sessions and assume its settings-file format.

  • A qr: Reading reference is confirmed by running the reference-system script from the system-of-references repository (put it on PATH, or set CW_QR_SCRIPT to its absolute path); other address kinds, such as url:, pass without it.

  • The store still holds the code of the full product's delegation of work to other sessions, and hooks/ still carries three scripts for it (lease-gate.mjs, stuck-on-idle.mjs, peer-search.mjs). No registered tool reaches them, so they are inert here; removing them is a separate clean-up.

  • The baseline schema was produced by applying an earlier history of 147 migrations and keeping the tables this edition uses; it starts at version 1 and is not an upgrade path from that history.

Layout

Path

What

src/

Server: store, MCP tools, HTTP app, search, seed, hooks guard

ui/

Web UI source and its build config

hooks/

The Claude Code hook scripts

migrations/

001_baseline.sql, the whole schema

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents and tools to share durable, approved knowledge, current decisions, task ownership, and handoffs from a local-first workspace kept outside any single AI product. Markdown holds human-readable rules, goals, and narratives while SQLite tracks agents, sessions, tasks, leases, and audit events behind one transport-independent core.
      2
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables coding agents to run persistent, budgeted work sessions with dependency graphs, human decision queues, required validation, and clean handoffs for autonomous or human-in-the-loop execution.
      16
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables a fleet of AI agents to connect over MCP to a local-first hub, where they can read time-ordered project feeds, keep session-scoped memory that survives compaction and resume, exchange artifacts, and send finished work or approval requests to a human inbox.
      MIT