Author Claude Code workflow scripts as
modular, type-checked TypeScript — then build them into a single .mjs that
satisfies the workflow harness contract.
Workflow scripts run in a vm sandbox: one self-contained file, no import/require,
no Node builtins, meta must be a pure-literal first statement, and a handful of
globals (Date.now, Math.random, argless new Date()) throw. That makes large
scripts painful to maintain as one hand-written file. qcwf lets you split the logic
across typed modules and bundles them down to one compliant file.
npm i -D quick-claude-workflow-builder
# or globally
npm i -g quick-claude-workflow-builderqcwf init # scaffold types + lint env into the current project
qcwf new my-flow # create workflows/my-flow/{meta.ts,index.ts}
qcwf build # bundle all → .claude/workflows/<name>.mjs
qcwf build my-flow # bundle one
qcwf check # bundle in memory + verify the harness contract (no write)Then invoke the built workflow in Claude Code as /my-flow.
workflows/
my-flow/
meta.ts # export const meta = {...} satisfies WorkflowMeta (import-free)
index.ts # export async function run(): ... (the orchestrator)
_shared/ # helpers, imported freely — inlined by the bundler
types/
qcwf-globals.d.ts # ambient types for agent()/parallel()/pipeline()/...
tsconfig.workflows.json
eslint.config.mjs
.claude/workflows/ # build output (invocable as /<name>)
A workflow is any folder under workflows/ containing meta.ts + index.ts
(or workflow.ts). Folders starting with _ are treated as shared helpers.
meta.tsis bundled and evaluated in isolation, then re-emitted viaJSON.stringifyas the literal first statement (esbuild would otherwise rewriteexport const metaintovar meta; export {meta}, which the harness rejects).index.tsis bundled with esbuild (--format=esm --platform=neutral), inlining all helpers and stripping types; theexportkeywords are stripped andreturn await run();is appended.- A build-time guard greps the emitted file for
import/require/node:/Date.now/Math.random/arglessnew Date(), checks the 512 KiB cap, and verifies the structural rules. It fails the build on any violation.
Three layers of enforcement: the controlled type environment (types: [], no
@types/node) flags Node builtins at author time; ESLint flags the sandbox-illegal
patterns; the build-time guard is the authoritative backstop on the emitted output.
Published to npm by GitHub Actions on a v* tag:
npm version patch # bumps package.json + creates the tag
git push --follow-tagsThe Publish workflow verifies the tag matches package.json, builds, and runs
npm publish via OIDC trusted publishing — no token or secret. Provenance is
generated automatically (requires a public repo). Configure the trusted publisher
once in the package's settings on npmjs.com (repo + release.yml).
MIT