Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions skills/rig/references/claude-workflow-conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,39 @@ export default audit;
human decision should return a structured `needs_human` result and be re-run
with the answer in its input.

## Incremental migration with rig/globals

When doing a first-pass port, keep the flat module structure by importing
`call`, `pipeline`, and `parallel` from `"rig/globals"` instead of
destructuring them from `workflow({ body })`. The launcher runs every program
inside a workflow context, so ambient calls are live at module top level:

```ts
import { agent, phase, log, s } from "rig";
import { call, pipeline } from "rig/globals";

// Agent role: summarize one file.
const summarize = agent({
model: "small",
input: s.object({ file: s.path }),
output: s.object({ summary: s.string }),
instructions: "Summarize the file.",
});

phase("Discover");
log("listing source files");
const raw = await call.text("List TypeScript source files, one per line.");
const files = (raw ?? "").split("\n").map((f) => f.trim()).filter(Boolean);

phase("Summarize");
const summaries = await pipeline(files, (file) => call(summarize, { file }, { label: file }));
export default summaries;
```

Move `call` and `pipeline` calls inside `workflow({ body })` once the port is
stable — it enables unit testing and makes input typing explicit.
`"rig/globals"` is a stepping stone, not a final form.

## Example programs

These samples in `skills/rig/samples/` are direct ports of common Claude dynamic
Expand All @@ -162,6 +195,7 @@ workflow patterns — use them as starting points when converting a script:
| [310-workflow-audit-verify.md](../samples/310-workflow-audit-verify.md) | `args`→`input`, `parallel`, `pipeline`, `phase`, `call.json` — mirrors the canonical find-and-verify pattern |
| [320-budget-aware-crawler.md](../samples/320-budget-aware-crawler.md) | `log`, `budget.remaining()`, `until` convergence loop |
| [330-nested-workflow-composition.md](../samples/330-nested-workflow-composition.md) | `call.workflow` (rig equivalent of `workflow(ref, args)`) sharing the parent's limiter and budget |
| [360-parallel-branch-analysis-workflow.md](../samples/360-parallel-branch-analysis-workflow.md) | `parallel(thunks)` as a barrier — use instead of `Promise.all` when porting |

## Related references

Expand Down