Skip to content

About

Author Claude Code workflow scripts as modular TypeScript and build them into a single constraint-satisfying .mjs (CLI: qcwf).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

quick-claude-workflow-builder (qcwf)

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.

Install

npm i -D quick-claude-workflow-builder
# or globally
npm i -g quick-claude-workflow-builder

Usage

qcwf 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.

Project layout

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.

How it works

  1. meta.ts is bundled and evaluated in isolation, then re-emitted via JSON.stringify as the literal first statement (esbuild would otherwise rewrite export const meta into var meta; export {meta}, which the harness rejects).
  2. index.ts is bundled with esbuild (--format=esm --platform=neutral), inlining all helpers and stripping types; the export keywords are stripped and return await run(); is appended.
  3. A build-time guard greps the emitted file for import/require/node:/ Date.now/Math.random/argless new 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.

Releasing

Published to npm by GitHub Actions on a v* tag:

npm version patch   # bumps package.json + creates the tag
git push --follow-tags

The 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).

License

MIT

About

Author Claude Code workflow scripts as modular TypeScript and build them into a single constraint-satisfying .mjs (CLI: qcwf).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages