Sign In

claude-mcp-workflow

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

claude-mcp-workflow

Structured workflow orchestration for AI agents via finite-state machines

latest
Source
npmnpm
Version
0.1.11
Version published
Weekly downloads
31
-50%
Maintainers
1
Weekly downloads
 
Created
Source

Claude Workflow

npm License TypeScript Claude Code Plugin

A Claude Code plugin that drives agents through YAML-defined state machines. The engine tracks state, enforces guards, manages nested sub-workflow stacks, and visualizes everything in a web dashboard.

Master workflow graph

Features

  • FSM-based state machines — define workflows in YAML with states, transitions, and prompts
  • Stack-based sub-workflows — states can push nested workflows (max depth 10), auto-pop on completion
  • Three-tier loading — bundled templates < global (~/.claude/workflows/) < project (.claude/workflows/)
  • Snapshot isolation — workflow definitions frozen at session start; hot-reloads don't affect running sessions
  • Runtime overlays — modify workflows on the fly without touching YAML files
  • Action statesexec runs shell commands, fetch makes HTTP requests, with auto-routing by exit code or HTTP status
  • Web dashboard — real-time session monitoring with DAG graph visualization
  • 19 bundled workflows — complete agent lifecycle from routing to reflection, including long-running batch orchestration
  • 20 bundled skills — reusable knowledge modules auto-provisioned on first run
  • SessionStart hook — auto-provisions missing skills and injects workflow context

Quick Start

The plugin is listed in the claude-plugins-community catalog:

/plugin marketplace add https://github.com/anthropics/claude-plugins-community
/plugin install workflow

From npm

Create a marketplace.json and add it as a source, or install directly:

# 1. Add a marketplace with this plugin
/plugin marketplace add <marketplace-with-workflow>

# 2. Install
/plugin install workflow@<marketplace-name>

See Creating a marketplace for how to set up an npm-based marketplace with this plugin:

{
  "name": "workflow",
  "source": { "source": "npm", "package": "claude-mcp-workflow" }
}

Manual (for development)

git clone https://github.com/AxGord/claude-workflow.git
cd claude-workflow
npm install
npm run build
claude --plugin-dir ./

Install channels

Supported marketplace sources: the npm package (claude-mcp-workflow) and a local directory. A marketplace entry that points at the git repository (git URL as a plugin source) is not supported — build/ is gitignored, so a git-sourced install has no compiled MCP server to run. (Cloning for development works — see above — because you run npm run build yourself.)

The engine only helps when the agent actually starts a workflow. Add this to your ~/.claude/CLAUDE.md:

- **ALWAYS** start every conversation by calling `mcp__plugin_workflow_wf__start()` (no arguments) before doing anything else, including answering the user
  - **EXCEPTION**: If you are a sub-agent spawned by the Task tool, do NOT call `start()` without arguments — the parent agent manages the workflow session. Follow the start instructions from the parent's preamble instead

Auto-allow the workflow tools so the agent is not interrupted with a permission prompt on every transition. In ~/.claude/settings.json:

{
  "permissions": {
    "allow": [
      "mcp__plugin_workflow_wf__list",
      "mcp__plugin_workflow_wf__start",
      "mcp__plugin_workflow_wf__status",
      "mcp__plugin_workflow_wf__transition",
      "mcp__plugin_workflow_wf__context_set",
      "mcp__plugin_workflow_wf__modify",
      "mcp__plugin_workflow_wf__create",
      "mcp__plugin_workflow_wf__delete",
      "mcp__plugin_workflow_wf__sessions"
    ]
  }
}

abort is deliberately not allowlisted: sub-agents inherit permissions, and an auto-allowed abort would let a sub-agent silently kill its parent's session. Keep it behind a manual prompt.

How It Works

Agent                       Engine                          Storage
  │                           │                               │
  ├── start() ───────────────►├─ snapshot workflows ─────────►├ session.json
  │◄── initial state prompt ──┤                               │
  │                           │                               │
  ├── transition() ──────────►├─ validate & advance ─────────►├ update JSON
  │◄── new state prompt ──────┤  (push/pop sub-workflows)     │
  │                           │                               │
  ├── transition() ──────────►├─ terminal state? ────────────►├ mark complete
  │◄── done ──────────────────┤  (auto-pop to parent)         │
  • start() — creates a session, snapshots all workflow definitions, returns the initial state prompt
  • transition() — validates the transition, advances state, handles sub-workflow push/pop, returns the new prompt
  • Every mutation is atomically persisted to JSON (temp file + rename + lockfile)
  • Dashboard visualizes sessions and workflow graphs at localhost:3100

Workflow YAML

name: my-workflow
description: "Example workflow"
initial: start
max_transitions: 50

states:
  start:
    prompt: "Analyze the task and decide on approach"
    transitions:
      implement: write_code
      explore: research

  research:
    sub_workflow: explore        # pushes nested workflow
    on_complete: write_code      # returns here on success
    on_fail: start               # returns here on failure

  write_code:
    prompt: "Write the implementation"
    transitions:
      done: finish

  finish:
    terminal: true
    outcome: complete            # or "fail"

Action States

States can run shell commands or HTTP requests automatically — the agent doesn't participate, the engine handles execution and routes to the next state based on the result.

exec — run a shell command

run_tests:
  type: exec
  command: "npm test"
  cwd: "{{context.cwd}}"
  timeout: 30000
  on_success: analyze
  on_error: fix
  success_prompt: "Tests passed:\n{{stdout}}"
  error_prompt: "Tests failed (exit {{exit_code}}):\n{{stderr}}"

fetch — make an HTTP request

check_api:
  type: fetch
  url: "http://localhost:8888/ping"
  method: GET
  timeout: 5000
  retry:
    max: 60
    interval: 500
  on_success: ready
  on_error: wait
  success_prompt: "API ready: {{body}}"
  error_prompt: "Not responding: {{error}}"

Routing

Action states route via on_success/on_error, or by specific codes using cases:

run_tests:
  type: exec
  command: "npm test"
  cases:
    "0": all_passed
    "1": tests_failed
    "2": no_tests_found
  default: unknown_error

Template variables

All prompts support {{mustache}} templates. Context values are available everywhere via {{context.key}}. After action execution, result variables are also available:

SourceVariables
exec{{stdout}}, {{stderr}}, {{exit_code}}, {{pid}} (background)
fetch{{status}}, {{body}}, {{error}}

Action states can be chained — execexecfetchprompt — up to 20 steps without agent involvement.

Three-Tier Loading

Workflows load from three sources in ascending priority — later tiers override earlier ones:

TierPathPurpose
Bundledtemplates/ (plugin root)Base workflows shipped with the plugin
Global~/.claude/workflows/User customizations shared across projects
Project.claude/workflows/Project-specific workflows

A project workflow named coding overrides the bundled coding template. Same-name global workflows sit in between.

Bundled Workflows

WorkflowDescription
masterSingle entry point — analyzes task, loads skills, routes to sub-workflows
codingCode writing pipeline: think → delegate → write → review → verify
bug-fixStandard bug fix: classify → diagnose → fix → verify
new-featureNew feature implementation with planning and testing
debuggingDiagnose first, fix never (until diagnosed)
code-reviewCode review with per-file deep analysis
exploreCodebase exploration — understand structure, trace code, find patterns
investigateResolve unknowns before deciding on action
planningExplore, design plan, record workflow context
testingTesting verification — unit tests first, then integration
web-researchCheck existing knowledge, then delegate to web subagents
reflectionSelf-reflection after significant tasks — evaluate, classify, act
subagentLightweight routing for sub-agents (no chat/plan/reflect)
file-codePer-file coding — spawned by coding/bug-fix for each file
file-reviewPer-file deep review — spawned by code-review for each file
review-pushReview uncommitted changes, then commit and push to GitHub
github-initInitialize git repo and create private GitHub repository

Coding workflow graph

Bundled Skills

Skills are reusable knowledge modules loaded by workflows via Skill(). Auto-provisioned to ~/.claude/skills/ on first run if missing. Edit your local copy to override the bundled version — the hook never overwrites existing files.

Methodology

SkillDescription
preferencesTemplate for personal coding preferences (fill in your own)
architectureSimplicity-first architecture decisions
task-delegationWhen and how to delegate to subagents
coding-skill-selectorSelect and load coding skills by file extensions and domains
workflow-authoringReference for creating workflows with exec/fetch action states

Languages

SkillDescription
lang-haxeHaxe language gotchas (incl. macros, null safety, hxcpp)
lang-pythonPython language gotchas
lang-as3AS3 / AIR 51 language gotchas

Domains

SkillDescription
domain-yoloYOLO object detection model selection
domain-pixiPixi.js v8 masking and graphics gotchas
domain-reidPerson re-identification ML gotchas
domain-gamedevGame dev precision and physics gotchas

Platforms & Tooling

SkillDescription
target-openfl-nativeOpenFL/hxcpp native target gotchas
build-cmakeCMake build system gotchas
ci-github-actionsGitHub Actions workflow gotchas
aws-lambdaAWS Lambda .NET deployment gotchas
mcp-setupMCP server setup and troubleshooting
claude-code-configClaude Code configuration gotchas

Utility

SkillDescription
mathMath overflow boundary gotchas
web-readingFetch web content via subagents

MCP Tools

All tools are registered under the wf server. Full tool prefix: mcp__plugin_workflow_wf__.

ToolDescriptionKey Parameters
listList all available workflow definitions
startStart a workflow, return initial promptworkflow, actor, parent_session_id
statusGet current state, stack, transitions, historysession_id
transitionAdvance to next state (auto push/pop sub-workflows)session_id, transition
context_setSave key-value data in session contextsession_id, key, value
modifyRuntime overlay — add/change/remove states and transitionssession_id, add_state, add_transition
createCreate new workflow definition (saves YAML)name, definition, scope
deleteDelete a workflow definitionname, scope
abortAbort workflow, pop all stack framessession_id
sessionsList all sessions (active first)

Dashboard

The web dashboard runs on localhost:3100 and provides real-time monitoring:

  • Sessions panel — active sessions plus the most recent finished ones (terminal history is capped)
  • Workflow list — all loaded workflows with state counts
  • Session detail — state history, stack depth, context data
  • Workflow graphs — interactive DAG visualization rendered with dagre

REST API

MethodEndpointDescription
GET/api/sessionsList all sessions
GET/api/session/:idGet session detail
POST/api/session/:id/abandonAbandon a session
GET/api/workflowsList all workflow definitions

Configuration

VariableDefaultPurpose
WORKFLOW_DIR~/.claude/workflows/Global workflow YAML directory
STATE_DIR~/.claude/workflow-state/Session JSON persistence
DASHBOARD_PORT3100Web dashboard HTTP port
DASHBOARD_HOST127.0.0.1Web dashboard bind address

Status Line

Show the active workflow and state in Claude Code's status bar:

Status line showing coding:think

Add this snippet to your statusline script:

# Workflow status — add to your ~/.claude/statusline-command.sh
wf_state_dir="$HOME/.claude/workflow-state"
if [ -d "$wf_state_dir" ]; then
  for f in "$wf_state_dir"/*.json; do
    [ -f "$f" ] || continue
    slen=$(jq -r '.stack | length' "$f" 2>/dev/null)
    if [ "$slen" -gt 0 ]; then
      cpid=$(jq -r '.context.claude_code_pid // 0' "$f" 2>/dev/null)
      [ "$cpid" != "$PPID" ] && continue
      wf=$(jq -r '.stack[.active_frame].workflow // ""' "$f" 2>/dev/null)
      st=$(jq -r '.stack[.active_frame].current_state // ""' "$f" 2>/dev/null)
      printf "\033[96m\xE2\x9A\x99 %s:%s\033[0m" "$wf" "$st"
      break
    fi
  done
fi

Then in ~/.claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "bash ~/.claude/statusline-command.sh"
  }
}

Development

npm run build    # tsc → compiles src/ to build/
npm run dev      # tsc --watch
npm start        # node build/index.js
npm test         # vitest run

Architecture

FileResponsibility
src/index.tsEntry point — resolves dirs, wires components, starts stdio transport
src/engine.tsFSM core — start, transition, abort, context, stack push/pop
src/loader.tsYAML loading + Zod validation + fs.watch hot-reload
src/storage.tsJSON persistence with atomic writes and lockfile mutex
src/modifier.tsRuntime overlays + create (YAML writer)
src/tools.tsMCP tool registrations + response formatting
src/executor.tsAction state execution — shell commands (exec) and HTTP requests (fetch)
src/template.tsMustache-style {{var}} template rendering for action parameters
src/dashboard.tsExpress REST API + static file serving
src/types.tsZod schemas, TypeScript types, constants

License

MIT

FAQs

Package last updated on 18 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts