workflow-artifacts
Skill9 starsChanged 30 days agoMITView on GitHub
Use to create, update, and read durable workflow state under .mtk/workflows/ so orchestration survives compaction, crash, and session handoff.
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- batch-fixSkill
- brainstormingSkill
- code-review-and-qualitySkill
- code-simplificationSkill
- context-engineeringSkill
- fixSkill
- handoffSkill
- implementSkill
- incremental-implementationSkill
- instructionsSkill
- lessonsSkill
- mtk-doctorSkill
- mtk-setupSkill
- mtkSkill
- planning-and-task-breakdownSkill
- pre-commit-reviewSkill
- prior-work-checkSkill
- promote-lessonSkill
- repo-healthSkill
- research-contextSkill
- security-and-hardeningSkill
- setup-auditSkill
- setup-bootstrapSkill
- setup-refreshSkill
- spec-drift-detectionSkill
- spec-driven-developmentSkill
- subagent-implementationSkill
- tech-stack-dotnetSkill
- tech-stack-pythonSkill
- tech-stack-typescriptSkill
- verification-before-completionSkill
- writing-skillsSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
When resuming after compaction, restart, or handoff — list active workflows before starting fresh work.
- Distinctive: line 53
Persist anchors as soon as they exist: When the spec, plan, and todo files are written, record their paths — in the same call as the next …
- Very specific: line 68
Record gate decisions: Every named gate (plan_trust_gate, phase_exit_gate, failure_stop_gate, memory_sync_gate) must be persisted via:
- Distinctive: line 86
If a single active workflow matches the requested type, offer resume.
- Very specific: line 87
If multiple, ask via AskUserQuestion which uuid to resume.
- Very specific: line 88
If none, init a new one (init TASK for a lightweight one with no other workflow).
- Very specific: line 115
All writes go through workflow-artifact.sh.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Workflow Artifacts
Overview
Orchestration state that lives only in chat is lost on compaction or restart. This skill stores it on disk under .mtk/workflows/{uuid}.json plus an append-only event log, using a small bash helper. implement (a BUILD workflow) and setup-audit / setup-bootstrap create workflows; the skills implement composes (incremental- and subagent-implementation, verification, review) write to the active one at phase boundaries and gate decisions. fix and batch-fix do not create a workflow. The helper also accepts DEBUG, REVIEW, PLAN and FIX types, but no shipped skill initialises them today.
When To Use
- At the start of every
/mtk implement(BUILD) run, and ofsetup-audit/setup-bootstrap. - At every phase transition inside
/mtk implement. - Whenever a named orchestration gate is evaluated (see
.claude/references/orchestration-gates.md). - When resuming after compaction, restart, or handoff — list active workflows before starting fresh work.
When NOT To Use
- Throwaway exploration where no commit will happen.
- Single-turn read-only questions ("what does file X do?").
- Inside subagents — only the orchestrator (main implement loop) writes artifacts. Subagents return structured output; the orchestrator decides what to persist.
Workflow
- Resolve helper path once into
$WFA. The script ships atscripts/workflow-artifact.shin this repo and at the same path in target installs, but a plugin install has it only under the plugin root — written${CLAUDE_PLUGIN_ROOT}(braces), which Claude Code substitutes into this text at load time; it is never set in the Bash environment. Resolve it once with the same three-tier idiomspec-driven-developmentuses forlearnings.sh—MTK_HELPER_ROOTfirst (a checkout you pin; seeCLAUDE.md), then the project copy, then the plugin copy — and call"$WFA"everywhere below instead of a bare path:
SetWFA="$([ -n "${MTK_HELPER_ROOT:-}" ] && echo "$MTK_HELPER_ROOT/scripts/workflow-artifact.sh" || ([ -f scripts/workflow-artifact.sh ] && echo scripts/workflow-artifact.sh || echo "${CLAUDE_PLUGIN_ROOT}/scripts/workflow-artifact.sh"))"MTK_HELPER_ROOT=<toolkit checkout>to force the scripts from that clone — the reliable path when dogfooding MTK from a separate checkout, or to pin one version out of a multi-version plugin cache. State is project-anchored: the script writes.mtk/workflows/under$CLAUDE_PROJECT_DIR(falling back to the git top-level, then cwd), so when MTK skills live outside the target project (plugin/marketplace install), exportCLAUDE_PROJECT_DIR=<project root>or run from the project root — otherwise state lands in the wrong tree. - Init at workflow start. Prune expired workflows, capture the returned uuid into a session variable
MTK_WF_UUID, and emit the first phase marker, all in the same call:"$WFA" prune --older-than 30 >/dev/null; MTK_WF_UUID=$("$WFA" init BUILD --goal "<one-line user goal>") && "$WFA" event "$MTK_WF_UUID" phase_started --data '{"phase":"phase-0"}'prunedeletes finished workflows (completed/abandoned) and any workflow not updated for 30 days, with their event logs; it never touches an active workflow updated within the window. Preview with--dry-run. Run it beforeinit, never after, so it cannot touch the workflow being started. A prune failure must not block the init, hence;. Bookkeeping rides along, never alone. Every artifact write below goes in the same Bash call as the action it records — appended with&&to the checkpoint command, the lint, the sidecar write — or several writes go in one"$WFA" batchcall. A standalone"$WFA" set …turn costs a full model round-trip for one line of JSON; a 65-call run spends a quarter of its turns on bookkeeping. Thebatchform takes ordinary subcommand argv without the uuid, separated by a bare--:dotnet build --nologo -v q && "$WFA" batch "$MTK_WF_UUID" \ gate phase_exit_gate pass --reason "batch B2 green" -- \ set results.batches_completed=2 -- \ event agent_returned --data '{"agent":"batch:B2"}'event … --ts <iso8601>replays a timestamp captured elsewhere (a dynamic workflow's per-batch dispatch/return times); tag such events"source":"workflow-replay"in--data. - Persist anchors as soon as they exist. When the spec, plan, and todo files are written, record their paths — in the same call as the next command that runs anyway (the context-pack build, the manifest pre-flight, the EARS lint in extended mode):
bash scripts/build-context-pack.sh "$MTK_WF_UUID" docs/specs/2026-05-07-foo.json && "$WFA" set "$MTK_WF_UUID" \ results.spec_path=docs/specs/2026-05-07-foo.md \ results.plan_path=docs/plans/2026-05-07-foo.md \ results.todo_path=tasks/todo.md - Emit phase events. At the start and end of every phase, in one call with the gate that closes it:
A"$WFA" batch "$MTK_WF_UUID" \ gate phase_exit_gate pass --reason "all batch tests green" -- \ event phase_completed --data '{"phase":"phase-3"}' -- \ event phase_started --data '{"phase":"phase-3.5"}'phase_startedevent carrying aphaseauto-advances the artifact'sphase_cursorto that phase — no separateset phase_cursor=call is needed, and the resume protocol (step 7) can trustphase_cursorrather than replaying the event log. - Record gate decisions. Every named gate (
plan_trust_gate,phase_exit_gate,failure_stop_gate,memory_sync_gate) must be persisted via:"$WFA" gate "$MTK_WF_UUID" phase_exit_gate pass --reason "all batch tests green"failon any gate is a hard stop — seefailure_stop_gatesemantics. - Carry a trap list across phases. A trap is a written, specific gotcha a phase learned the hard way (a stale generated contract, an analyzer that fires only under
format, a fixture that silently seeds the wrong state). A 2026-09 six-phase field run found this hand-carried list was the one mechanism that demonstrably worked — the final phase had zero repair cycles — and that it survived only because the driver remembered to paste it. Persist each trap the moment it is learned, riding along in the call that runs anyway (trapis batchable):
At the start of every phase, and in every implementer brief the orchestrator builds, inject the accumulated list:"$WFA" batch "$MTK_WF_UUID" trap add --title "OpenAPI spec goes stale between phases" \ --body "Regenerate the contract from a running API each phase — build/tests miss uncallable routes." \ --phase phase-1 --severity high -- event phase_completed --data '{"phase":"phase-1"}'
Adding a trap whose title already exists refreshes it in place. Traps are orchestrator-owned like every other artifact write: an implementer reports candidate traps in its result ("$WFA" trap list "$MTK_WF_UUID" # paste into the brief's "Known traps" blocktraps[], see.claude/references/subagent-implementer-prompt.md) and the orchestrator records them (S5.2). - Resume protocol. On entry to a workflow with no explicit uuid:
- Run
"$WFA" list. - If a single active workflow matches the requested type, offer resume.
- If multiple, ask via
AskUserQuestionwhich uuid to resume. - If none, init a new one (
init TASKfor a lightweight one with no other workflow). - To continue a checkpointed workflow,
"$WFA" resume <uuid>prints a read-only RESUME block (drift since the checkpoint,next_command, open questions). "$WFA" checkpoint <uuid> --next … --decision … --verify …re-renders the one canonical note and snapshots the tree; it is batchable as the LAST op (exit 3 =--nextnames a finished unit). Schema:.claude/references/workflow-artifact-schema.md.
- Run
- Close the workflow. At end of phase 7, one call:
On unrecoverable failure, close with the failure pair instead:"$WFA" batch "$MTK_WF_UUID" gate memory_sync_gate pass --reason "lessons captured" -- \ set status=completed -- event workflow_completed --data '{"summary":"<short>"}'"$WFA" batch "$MTK_WF_UUID" set status=failed -- event workflow_failed --data '{"reason":"<short>"}'
Viewing Progress (Dashboard)
For a visual, read-only view of all workflows — status, phase, gate decisions, results, and event timeline — render the HTML dashboard:
scripts/workflow-dashboard.sh # render once -> .mtk/workflows/dashboard/index.html, open it
scripts/workflow-dashboard.sh --watch # regenerate + serve over http://127.0.0.1:8787/ (auto-refresh)
scripts/workflow-dashboard.sh --watch 10 --port 9000 # custom interval/portThe dashboard reads the same {uuid}.json + {uuid}.events.jsonl files this skill writes — it never mutates them, so it is safe to run during an active workflow. --watch regenerates on an interval and serves a static page (meta-refresh, no WebSocket) so a tech lead can watch a multi-batch run live. To share with non-CLI stakeholders, expose the served port with any tunnel tool (ngrok, cloudflared, ...) — the script intentionally stays a self-contained static renderer and does not embed a tunnel. Requires python3 (the same dependency the helper already uses).
Rules
- All writes go through
workflow-artifact.sh. NeverEditorWrite{uuid}.jsondirectly — the event log would desync. - Bookkeeping never gets its own turn: append
"$WFA"calls to the command they record with&&, or group them withbatch. The only standalone calls areinit(with itspruneprefix),list,read, andverify-seal. - Subagents do not write workflow artifacts. The orchestrator persists subagent results via
event agent_returned. - Traps are carried, not re-derived. Record a trap the moment a phase learns it (
trap add) and injecttrap listinto every subsequent phase brief — a trap that lives only in a phase report is lost the moment that report scrolls out of context. .mtk/is gitignored by default. Treat artifacts as local diagnostic state, not committed history.- A
failure_stop_gate: failevent terminates the workflow. Do not emit further events afterworkflow_failed.
Verification
"$WFA" list(resolved per step 1) shows the current workflow with the expected type and phase- The event log ends with the most recent gate or phase event (no orphan state)
- On a fresh session,
listplus reading the artifact reproduces the workflow's current state without chat history - No direct
Edit/Writecalls were made against.mtk/workflows/*.json - Traps discovered in a phase were recorded via
trap add, andtrap listwas injected into the next phase's brief (not left in a phase report)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

