
build-workflow
by steven-levey-rt
SKILL.md
name: build-workflow description: Build Temporal workflows from JSON spec files. Use when (1) a JSON workflow spec file needs to be converted to working Temporal code, (2) implementing a workflow from a designer export, (3) generating workflow code with activities, types, and proper registration. Handles the full pipeline from JSON spec to integrated, type-checked workflow.
Build Workflow
Generate complete Temporal workflow implementations from JSON specification files using the CLI code generator and codebase patterns.
Quick Start
# 1. Transform designer export (if needed)
python ~/.claude/skills/build-workflow/scripts/transform-spec.py designer-export.json transformed.json
# 2. Generate workflow code
pnpm --filter @repo/temporal generate transformed.json --name my-workflow
# 3. Register in Temporal (workflows/index.ts, workers/worker.ts)
# 4. Type check Temporal
pnpm --filter @repo/temporal typecheck
# 5. Add UI (definition, form, detail view, registry, route)
# 6. Type check UI
pnpm --filter @repo/ui typecheck
Workflow
Step 1: Transform Designer Export
The workflow designer exports a different format than the generator expects. Run the transform script (do not read it):
python ~/.claude/skills/build-workflow/scripts/transform-spec.py <input.json> <output.json>
Designer export format:
{
"metadata": { "title": "My Workflow" },
"nodes": [{ "id", "type", "label", "config", "position" }]
}
Generator expected format:
{
"name": "my-workflow",
"nodes": [{ "id", "type", "position", "data": { "label", "config" } }]
}
Key transformations:
metadata.title→name(kebab-cased)node.label,node.config→node.data.label,node.data.configloop-container→loop
Step 2: Validate and Preview
Preview generated code before writing:
pnpm --filter @repo/temporal generate ./transformed.json --dry-run
Check for:
- Validation errors (missing nodes, invalid edges)
- Generated file structure
- TODO comments requiring attention
Step 3: Generate Code
pnpm --filter @repo/temporal generate ./transformed.json --name my-workflow
Options:
-n, --name <name>- Workflow name in kebab-case (defaults to spec name)-o, --output <dir>- Output directory (default:packages/temporal/use-cases)--dry-run- Preview without writing files--skip-typecheck- Skip TypeScript validation--force- Overwrite existing directory
Output structure:
packages/temporal/use-cases/<workflow-name>/
├── workflow.ts # Main workflow with withWorkflowTracking()
├── types.ts # TypeScript input/output types
├── activities/
│ └── index.ts # Activity implementations
└── README.md # Auto-generated documentation
Step 4: Review Generated Code
Check for TODO comments and verify:
- workflow.ts - Flow logic and data passing
- types.ts - Input/output type definitions
- activities/index.ts - Activity implementations
See references/workflow-patterns.md for expected patterns.
Step 5: Register Workflow
Export the workflow in packages/temporal/workflows/index.ts:
export * from "../use-cases/<workflow-name>/workflow";
Register activities in packages/temporal/workers/worker.ts:
import * as myWorkflowActivities from "../use-cases/<workflow-name>/activities/index";
// In Worker.create() activities:
activities: {
...existingActivities,
...myWorkflowActivities,
}
See references/post-generation.md for detailed integration steps.
Step 6: Type Check Temporal
pnpm --filter @repo/temporal typecheck
Step 7: UI Integration
Integrate the workflow into the Next.js UI. See references/ui-integration.md for detailed patterns.
7.1 Add Workflow Definition in packages/ui/src/lib/workflow-definitions.ts:
{
slug: "<workflow-slug>", // URL: /start/{slug}
workflowType: "<workflowType>", // camelCase, matches API
title: "<Title>",
description: "<Description>",
command: "<workflow-slug>",
requiresHumanInLoop: false,
}
7.2 Create Form Component at packages/ui/src/components/<WorkflowName>Form.tsx
- Use
AIGreetingBasicForm.tsxas template - POST to
/api/workflows/startwithworkflowType,workflowName,workflowArgs
7.3 Create Detail View at packages/ui/src/workflows/<workflow-slug>/<WorkflowName>Workflow.tsx
- Implement
WorkflowComponentPropsinterface - Handle both kanban and detail views
- Use
AIGreetingBasicWorkflow.tsxas template
7.4 Register in UI:
- Add to
WORKFLOW_REGISTRYinpackages/ui/src/workflows/registry.ts - Import form, add to
SLUG_TO_META, add switch case inpackages/ui/src/app/start/[slug]/page.tsx
7.5 Type Check UI:
pnpm --filter @repo/ui typecheck
Spec Format Reference
See references/spec-format.md for full schema details.
Supported node types:
| Designer Type | Generator Type | Description |
|---|---|---|
start | start | Entry point |
end | end | Exit point |
condition | condition | Branching |
loop-container | loop | Iteration |
http-request | http-request | API calls |
ai-generate-text | ai-generate-text | AI text |
ai-generate-object | ai-generate-object | AI structured |
data-transform | data-transform | JSONata |
data-validate | data-validate | JSON Schema |
human-approval | human-approval | HITL |
Workflow Patterns
See references/workflow-patterns.md for:
withWorkflowTrackingwrapper usage- Activity configuration and timeouts
- Primitive activities (HTTP, AI, data, human)
- Signals and queries for human-in-the-loop
- Database synchronization patterns
Troubleshooting
"Cannot read properties of undefined (reading 'replace')"
- Spec missing
namefield - run transform script first or provide--nameoption
"Spec file not found" - Verify the file path is correct
"Validation failed" - Check for:
- Missing start or end nodes
- Disconnected nodes
- Invalid node types (e.g.,
loop-containerinstead ofloop) - Condition nodes without true/false edges
"Directory already exists" - Use --force to overwrite or --name for different name
"Type check failed" - Use --skip-typecheck to generate anyway, then fix manually
Worker won't find workflow - Verify exports in workflows/index.ts and activities in worker.ts
"Workflow failed: non-deterministic" - Workflow imports a module that touches database/filesystem. Use /workflow subpath for primitives (e.g., primitives/human/workflow not primitives/human). See references/workflow-patterns.md for determinism rules.
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon