create-workflow
Create a Datagrok Compute2 workflow (pipeline configuration with steps, links, and actions)
SKILL.md.claude/skills/create-workflow/SKILL.md
GitHubCreate a Compute2 workflow
The user wants a PipelineConfiguration — a Datagrok Compute2 workflow that wires
multiple scripts together with reactive data links, validators, and metadata handlers.
The authoritative reference lives in the docs. This skill is a working procedure; when you need to know what something is or how a field behaves, read the docs.
Reading order
Read these before you write any configuration:
help/compute/workflows/overview.mdx— terms (node, link, controller, action, FuncCall, nqName, RichFunctionView).help/compute/workflows/configuration.mdx— every field ofPipelineConfiguration, the workflow types, states, custom exports, and the constraints / review checklist (consult the section before publishing).help/compute/workflows/link-types.mdx— link/action types, controller methods, handler signatures.
Read on demand:
help/compute/workflows/links-spec.mdx— Link Query Language grammar. Needed only when the workflow uses tag selectors, template queries, or relative (base/@base) refs.help/compute/workflows/examples.mdx— Wine Quality walkthrough end-to-end.help/compute/workflows/code-usage.mdx— only if the workflow will be launched programmatically.
Reference examples (also linked from examples.mdx):
| File | Use when |
|---|---|
examples/minimal-static.ts |
Fixed sequence of scripts, no links, user fills inputs manually. |
examples/dynamic-with-links.ts |
User can add/remove steps; outputs propagate to all downstream instances. |
examples/validators-and-meta.ts |
Cross-field validation, conditional input visibility, user-triggered actions. |
Setup (install + dayjs/timezone imports) is covered in examples.mdx#dependencies.
Instructions
Phase 1: Understand the requirements
Ask the user:
- What scripts (Datagrok functions) should the workflow connect?
- What data flows between them? (which outputs feed which inputs)
- Is the set of steps fixed (static) or user-configurable (dynamic)?
- Are there validation rules? (required fields, value ranges, cross-field checks)
- Should any inputs be visually customized? (hidden, readonly, dropdowns)
Verify that every referenced script exists. A script may be deployed, scaffolded locally but not yet published, or only an idea in the user's head. Check each location and stop searching once you find a match:
- Deployed on the server:
grok s functions list --filter "<nqName>". A non-empty result means the script is live and thenqNameis correct. - Local
package.ts: grep for//name:\s*<FunctionName>insrc/package.ts(and anysrc/package-*.tsentries). Each annotated export becomes a function withnqName: <PackageName>:<FunctionName>once published. - Local
scripts/directory: grep for^#name:\s*<scriptName>inscripts/**/*.{py,r,js,jl,m,sql}. Each#name-annotated file becomes a function withnqName: <PackageName>:<scriptName>once published.
If a script is found locally but not on the server, note it as "scaffolded — will be published with this workflow". If a script is missing in all three places, ask the user whether to scaffold it (and follow the appropriate skill: see
/initor the scripting docs) or to drop it from the workflow.- Deployed on the server:
Present a plain-language summary of the workflow for approval before coding. Mark each step as deployed, scaffolded, or to be created so the user can see the integration surface at a glance.
Phase 2: Design the configuration
- Choose the workflow type. See
configuration.mdxfor the discriminated union ofstatic/dynamic/action/ref. - Sketch the
PipelineConfigurationobject: steps withidandnqName; data links withfrom/to; validators and meta links if needed; actions for user-triggered operations. - If any link uses tag selectors, template queries, or relative references, consult
links-spec.mdx. - Present the configuration skeleton for approval. Do not implement handlers yet.
Phase 3: Implement
- Create the provider function in the package:
import type {PipelineConfiguration} from '@datagrok-libraries/compute-api'; //name: MyWorkflow //description: Description of the workflow //tags: model //editor: Compute2:TreeWizardEditor //input: object params //output: object result export function myWorkflow(): PipelineConfiguration { return { id: 'my-workflow', nqName: 'MyPackage:MyWorkflow', version: '1.0', /* approved configuration */ }; } - Implement link handlers using the controller methods documented in
link-types.mdx. - Register the function in
package.tsif not already there. - Run
grok apito regenerate wrappers.
Phase 4: Review
Validate the configuration against the constraints and review checklist. Spawn a sub-agent for an independent pass if the configuration is non-trivial. Fix anything that fails before proceeding.
Phase 5: Build and verify
grok check --soft— verify function signatures.webpackornpm run build— build the package.grok publish --release—--releaseis mandatory; debug-mode packages are only visible to the publishing user.- Tell the user where to open the workflow: Apps → Compute → ModelHub.
Behavior
- Do not invent scripts. Only reference functions that exist on the server or in the package.
- Present config for approval before writing handler code. Handlers are the expensive part.
- Use simple LQL paths unless the user needs dynamic matching. Prefer
in1:step1/aover complex selectors. - Keep handlers pure. Handlers should transform data, not perform side effects. Use actions for user-triggered operations.
- One data link per script input. Each input of a downstream node should receive data from at most one data link. Use validators or meta links for additional concerns.
- Import from
@datagrok-libraries/compute-api. This is the public API. Do not import from@datagrok-libraries/compute-utilsdirectly — those are internal paths. - Always publish with
--release. - Use the
/uiskill only in two cases: (1) an action needs to show custom inputs inline (e.g. a confirmation form with extra fields), or (2) a script's output viewer needs tweaks applied through itsDG.ViewerJS API inside aviewersHook. Workflow scaffolding, links, validators, and meta-driven UI changes do not need/ui.