function-creator
Original:🇺🇸 English
Translated
Use when creating or modifying Wavelength 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".
4installs
Sourcedatex/skills
Added on
NPX Install
npx skill4agent add datex/skills function-creatorTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Function Creator
Create new Wavelength functions or modify existing ones on a Datex Studio branch.
References
- ../shared/branch-setup.md -- Branch & connection selection (shared across skills)
- references/command-syntax.md -- All commands with examples
dxs function - references/flag-guide.md -- When/why/how for each flag
- references/code-patterns.md -- Common patterns for function code
- ../shared/context-navigation.md -- How to retrieve & navigate designer context responses
Dependencies
- skill — invoked to produce a requirements brief if one doesn't already exist in the conversation context
requirements-gathering - skill — invoked when modifying input/output parameters of an existing function
impact-analysis
Workflow
[Phase 1: Setup + Requirements]
Follow branch-setup.md for branch/connection selection
|
[requirements brief in context?]
+-----+-----+
| |
YES NO
| |
use it invoke `requirements-gathering` skill
| |
+-----+------+
|
[determine intent: create or modify?]
|
+-----+-----+
| |
CREATE MODIFY
| |
determine dxs function get <ref> --branch <id>
ref name extract code from stepConfig.executeCodeConfig.code
+ params write to temp .ts file
| |
+------+------+
|
[Phase 2: Intellisense]
dxs function context <config.json> --branch <id>
|
[Phase 3: Signature Safety -- modify only]
If input/output params are changing:
invoke impact-analysis skill
only continue if no callers or user approves
|
[Phase 4: Code]
Write or update TypeScript code in temp .ts file
|
[Phase 5: Generate + Validate + Upload]
dxs function generate ... --code-file <file.ts> -o <config.json>
dxs function validate <config.json> --branch <id>
dxs function upsert <config.json> --branch <id>Phase Details
Phase 1: Setup + Requirements
- Follow branch-setup.md for branch/connection selection
- Check whether a requirements brief already exists in the conversation context (produced by or another calling skill)
requirements-gathering- Requirements brief exists — use it. The brief provides the intent, expected inputs/outputs, and business rules.
- No requirements brief exists — invoke the skill first. This ensures the agent understands what the function should do (create) or what changes are needed (modify) before touching code.
requirements-gathering
- Determine intent: create new or modify existing?
Create flow (continued):
4. Determine reference name (valid JS identifier — must end with suffix, e.g., , )
5. Determine input/output parameters from the requirements brief
_flowsum_flowprocess_order_flowModify flow (continued):
4. Fetch the existing function:
5. Extract the current code from in the response JSON
6. Write the code to a temporary file for editing
7. Note the current input/output parameters for signature change detection
dxs function get <ref_name> --branch <id>stepConfig.executeCodeConfig.code.tsPhase 2: Intellisense
See context-navigation.md for the full guide on retrieving and reading context responses, including the backend vs frontend symbol filtering rules.
For create: Run with a placeholder code file (e.g., containing just ), then run context on the resulting JSON to get the type system before writing actual code.
dxs function generate --code-file <placeholder.ts> -r <name> -t "<title>" -d "<desc>" --in-param <params> --out-param <params> -o <config.json>// placeholderFor modify: The fetched config JSON from can be saved to a file and used directly with the context command.
dxs function getRetrieval:
bash
dxs -O json function context <config.json> --branch <id>Read to determine which -symbols are actually available — not every symbol in is usable in backend function code. Look up type definitions in for imported symbols only. The provides ambient utilities (, enums).
defaultContext.imports$appContext.varsappContext.textglobal_context$utilsPhase 3: Signature Safety (modify only)
If the modification changes input or output parameters:
- Invoke the impact-analysis skill with the function's reference name
- If callers exist, present them and ask the user whether to proceed
- If proceeding, the agent must update all affected callers after modifying the function
Phase 4: Code
Write or update the TypeScript code in a temp file. Use the intellisense data from Phase 2 to:
.ts- Reference other functions, datasources, reports, etc. with correct types
- Use and
$flow.inParams.*correctly$flow.outParams.* - Access runtime services (,
$utils, etc.)$services
See code-patterns.md for common patterns.
Phase 5: Generate, Validate, Upload
bash
# 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
dxs function validate <config.json> --branch <id>
# Upload
dxs function upsert <config.json> --branch <id>Naming Convention
- Reference names must be valid JS identifiers (start with letter//
_, no spaces/hyphens)$ - Must end with suffix (e.g.,
_flow,sum_flow,validate_order_flow)boolean_array_to_mask_flow - Title () is a human-readable display name — can differ from reference name
-t
Common Mistakes
| Mistake | Fix |
|---|---|
Using | Assign to |
Wrong scoping on | Module code requires module prefix ( |
| Changing params without checking callers | Always invoke impact-analysis skill first when modifying input/output params |
| Guessing available services from memory | Always run |
Referencing a frontend-only symbol ( | Functions are backend-only. If a symbol is not in |
Using | The expression variable is |
| Code file exceeding 512 KB | Split logic into multiple functions or extract helpers |