npx skills add ...
npx skills add datex/skills --skill function-creator
Use when creating or modifying Datex Studio functions (configurationTypeId=9) on a Datex Studio branch. Covers the full lifecycle: requirements, intellisense, code authoring, validation, and upload. Trigger for: "create a function", "modify a function", "update xxx_flow", "write a function that does X", "add a parameter to xxx_flow", "change the function code".
npx skills add datex/skills --skill function-creator
Create new Datex Studio functions or modify existing ones on a Datex Studio branch.
See also:
db-query—$dbpredicate DSL and storage access patterns for flow code that reads/writes from*-storage.jsoncomponents. function-creator owns the function lifecycle (dxs function generate/validate/dxs configuration upsert flow); db-query owns the$dbpredicate mechanics.
dxs function commands with examplesconfigurationTypeId=9, parameter-descriptor boilerplate, UI→action bridge, runtime globals, invocation contractrequirements-gathering skill — invoked to produce a requirements brief if one doesn't already exist in the conversation contextimpact-analysis skill — invoked when modifying input/output parameters of an existing functionrequirements-gathering or another calling skill)
requirements-gathering skill first. This ensures the agent understands what the function should do (create) or what changes are needed (modify) before touching code.Create flow (continued):
4. Determine reference name (valid JS identifier — must end with _flow suffix, e.g., sum_flow, process_order_flow)
5. Determine input/output parameters from the requirements brief
Modify flow (continued):
4. Fetch the existing function: dxs function get <ref_name> --branch <id>
5. Extract the current code from stepConfig.executeCodeConfig.code in the response JSON
6. Write the code to a temporary .ts file for editing
7. Note the current input/output parameters for signature change detection
See context-navigation.md for the full guide on retrieving and reading context responses, including the backend vs frontend symbol filtering rules. To quickly confirm a $types.<Package>.* custom type or enum member exists (e.g. before referencing $types.Utilities.e_awi_scopes.Cartonization in flow code) without parsing the full context blob, use the nomenclature registry described there.
For create: Run dxs function generate --code-file <placeholder.ts> -r <name> -t "<title>" -d "<desc>" --in-param <params> --out-param <params> -o <config.json> with a placeholder code file (e.g., containing just // placeholder), then run context on the resulting JSON to get the type system before writing actual code.
For modify: The fetched config JSON from dxs function get can be saved to a file and used directly with the context command.
Retrieval:
Read defaultContext.imports to determine which $-symbols are actually available — not every symbol in appContext.vars is usable in backend function code. Look up type definitions in appContext.text for imported symbols only. The global_context provides ambient utilities ($utils, enums).
If the modification changes input or output parameters:
Write or update the TypeScript code in a temp .ts file. Use the intellisense data from Phase 2 to:
$flow.inParams.* and $flow.outParams.* correctly$utils, $services, etc.)See code-patterns.md for common patterns.
dxs function validatedoes not gate on its exit code.dxs configuration validateanddxs datasource validateexit 1 when they report errors;dxs function validatestill exits 0 and reportsvalidation_errorsin its output (verified against the CLI source, 0.4.18). An agent that has learned "validate fails loudly" from the other skills will read this command's success exit as a green light and upload a broken function. Always inspect the output, not the exit status. Full exit-code matrix: ../datex-studio-shared/configuration-roundtrip.md.
_/$, no spaces/hyphens)_flow suffix (e.g., sum_flow, validate_order_flow, boolean_array_to_mask_flow)-t) is a human-readable display name — can differ from reference name| Mistake | Fix |
|---|---|
Using return to set output | Assign to $flow.outParams.* instead — functions don't use return values |
Wrong scoping on $datasources or $flows | Module code requires module prefix ($datasources.ModuleName.ds_name). App code referencing its own configs does not ($datasources.ds_name). Always check the appContext types from dxs function context to determine the correct path. |
| Changing params without checking callers | Always invoke impact-analysis skill first when modifying input/output params |
| Guessing available services from memory | Always run dxs -O json function context and read defaultContext.imports — see context-navigation.md. |
Referencing a frontend-only symbol ($shell, $frontendFlows) | Functions are backend-only. If a symbol is not in defaultContext.imports, you cannot use it — see context-navigation.md. |
Using $item instead of $entity | The expression variable is $entity in Datex Studio |
| Code file exceeding 512 KB | Split logic into multiple functions or extract helpers |
New flow fails to save (DXS-API-500 / DbUpdateException) even though validate passes | Check description length first — over 256 characters produces exactly this error on every configuration type, and validate does not catch it (bisected 2026-08-13; see configuration-roundtrip.md). If the description is within the cap, fall back to the wide-signature bug observed 2026-08-11 (PrintManager, ~19 inParams + 8 outParams + code in one body): the single-shot create/update 500s while every subset saves fine — and a failed save deletes the flow from the branch. Workaround: compose incrementally — upsert a minimal body (referenceName + placeholder code, no params), then add inParams + code, then add outParams a few at a time, re-upserting each step; verify the final branch state with a fresh get afterwards. |
After your edit, invoke post-edit-verification to surface description/JSON/schema violations. For a final review, invoke component-validator.
dxs -O json function context <config.json> --branch <id># Generate the config (local file operation — does not take --branch)
dxs function generate \
--code-file <file.ts> \
-r <reference_name> \
-t "<title>" \
-d "<description>" \
--in-param <name>:<type> \
--out-param <name>:<type> \
-o <config.json>
# Validate. NOTE: unlike `dxs configuration validate`, this command exits 0 even when it
# finds errors — a zero exit means "the command ran", NOT "the function is valid".
# Read the payload: proceed only on `status: "valid"`; a `validation_errors` list means stop.
dxs function validate <config.json> --branch <id>
# Upload
dxs configuration upsert flow -D <config.json> --branch <id>