Skip to content
Back to skills

Workflow Authoring

ASecurity

Reference for writing a Workflow tool script (script API and gotchas, resume, quality patterns, worked examples). Load before authoring a script for a workflow the user already opted into; it does not itself authorize running one.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 6, 2026
ai-agentsjavascriptgojavaapi

Works with

  • api

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add tomorrow-dev/tomorrow-code --skill workflow-authoring --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Workflow Authoring?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Workflow Authoring
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tomorrow-dev-workflow-authoring/badge)](https://www.skillsdirectory.com/skills/tomorrow-dev-workflow-authoring)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: workflow-authoring
description: "Reference for writing a Workflow tool script (script API and gotchas, resume, quality patterns, worked examples). Load before authoring a script for a workflow the user already opted into; it does not itself authorize running one."
---

# Writing a workflow script

A workflow script is JavaScript run by the Workflow tool in a sandbox with no file system, no network and no imports. It orchestrates agents; the agents do the work.

## Shape

```js
export const meta = {
  name: 'my-workflow',
  description: 'One sentence on what it does',
  phases: ['Plan', 'Work', 'Check'],
}

const plan = await phase('Plan', () => agent({ prompt: `Plan: ${args.task}`, label: 'planner' }))
```

- `meta` comes first and is a pure object literal: no variables, no calls, no template substitutions.
- The rest is the body of an async function: top-level `await` works, and the last returned value is the result.
- `args` holds the arguments the caller passed. Everything else the script needs comes from `args` or from an `agent()`.

## API

- `agent({ prompt, label?, schema? })` runs one agent with a fresh context and resolves to its final answer. With a JSON `schema` the answer is the parsed object. The agent sees only its `prompt`: put everything it needs there.
- `parallel([() => agent(...), ...])` runs the thunks at once and resolves to their results in order.
- `pipeline(initial, step1, step2, ...)` feeds each step the previous result.
- `phase(title, body)` marks a phase of `meta.phases` as started, then runs `body`.

## Determinism

A run resumes (`resumeFromRunId`) by replaying the script: each `agent()` call is matched by its position to the journaled answer, and only the calls after the first change run again. So the script must be deterministic:

- `Date`, `Date.now()` and `Math.random()` throw. Pass a value in through `args`, or ask an agent.
- Do not branch on anything that varies between runs. Branch on agent answers and `args` only.
- Keep the order and number of `agent()` calls stable for the same inputs; editing a prompt re-runs that call and those after it.

## Quality patterns

- Split by independence: fan out with `parallel`, join with one synthesis agent.
- Give each agent one job and one output shape; use `schema` for anything the script reads.
- Separate the doer from the checker: a second agent that did not write the work verifies it, and the script loops on its verdict, with a bound on the rounds.
- Prompts are self-contained: goal, constraints, where to look, the form of the answer.
- Cap fan-out (for example 5 to 8 agents per phase) and say so in the prompt of the synthesis step so it knows what was left out.
- Return a compact result: the answer, then the evidence, not the transcripts.

## Examples

Fan out then synthesize:

```js
export const meta = { name: 'survey', description: 'Survey several angles then merge', phases: ['Survey', 'Merge'] }
const angles = await phase('Survey', () =>
  parallel(args.angles.map((angle) => () => agent({ prompt: `Investigate ${angle} for: ${args.question}. Reply with findings and sources.`, label: angle }))))
return phase('Merge', () => agent({ prompt: `Merge these findings into one answer to "${args.question}":\n\n${angles.join('\n\n---\n\n')}` }))
```

Do, check, retry:

```js
export const meta = { name: 'checked', description: 'Do a task and have it verified', phases: ['Do', 'Check'] }
let work = await phase('Do', () => agent({ prompt: args.task }))
for (let round = 0; round < 3; round++) {
  const verdict = await phase('Check', () => agent({
    prompt: `Verify this against the task "${args.task}". Be strict.\n\n${work}`,
    schema: { type: 'object', properties: { ok: { type: 'boolean' }, problems: { type: 'string' } }, required: ['ok'] },
  }))
  if (verdict.ok) break
  work = await agent({ prompt: `Fix these problems in the work.\n\nTask: ${args.task}\n\nWork:\n${work}\n\nProblems:\n${verdict.problems}` })
}
return work
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.