dataflow-operator-builder
GitHub用于生成符合生产标准的 DataFlow Operator 脚手架,支持交互采访或直接 Spec 模式,自动完成注册、CLI 封装及测试用例生成。
Trigger Scenarios
Install
npx skills add OpenDCAI/DataFlow-WebUI --skill dataflow-operator-builder -g -y
SKILL.md
Frontmatter
{
"name": "dataflow-operator-builder",
"description": "Build production-grade DataFlow operator scaffolds (generate\/filter\/refine\/eval) for Codex and coding agents. Trigger when users ask to create\/new\/scaffold operators, add OPERATOR_REGISTRY registration, generate DataFlowStorage-based CLI wrappers, or generate operator unit\/registry\/smoke tests."
}
DataFlow Operator Builder
Build production-ready DataFlow operator artifacts with either interactive interview mode or direct spec mode.
ZH: 通过“交互采访模式”或“直接 spec 模式”快速生成生产可用的 DataFlow Operator。
Usage
/dataflow-operator-builder
/dataflow-operator-builder --spec path/to/spec.json --output-root path/to/repo
/dataflow-operator-builder --dry-run --spec path/to/spec.json --output-root path/to/repo
Script Directory
Agent execution instructions:
- Resolve this
SKILL.mddirectory asSKILL_DIR. - Use
${SKILL_DIR}/scripts/build_operator_artifacts.py.
ZH:
- 将当前
SKILL.md所在目录作为SKILL_DIR。 - 使用
${SKILL_DIR}/scripts/build_operator_artifacts.py。
| Script | Purpose |
|---|---|
scripts/build_operator_artifacts.py |
Generate operator + CLI + tests from spec |
scripts/example_spec.json |
Example input spec with defaults |
Scope
This skill targets:
- DataFlow-style operator implementation (
DataFlowStorage+ dataframe flow) @OPERATOR_REGISTRY.register()registration- Separate CLI wrapper under
cli/ - Minimal but production-grade tests (
unit/registry/smoke)
ZH:
- 面向 DataFlow 风格的 operator 实现(
DataFlowStorage+ dataframe 流程) - 自动包含
@OPERATOR_REGISTRY.register()注册 - CLI 与 operator 逻辑分离
- 生成最小但可用的测试骨架(
unit/registry/smoke)
Default families:
generatefilterrefineeval
Two Working Modes
Mode A: Interactive Interview Mode
Use AskUserQuestion in batch mode with exactly two rounds:
Use structured questioning in batch mode with exactly two rounds:
- Round 1: structure fields
- Round 2: implementation fields
Important:
- In each question block, include recommended option + short reason.
- Ask follow-up questions only when high-impact fields are missing or contradictory.
- Do not ask one-by-one when the same round can be asked in one batch.
- Present all questions of one round in a single message to the user, grouped by round.
ZH:
- 使用 AskUserQuestion 且每轮“批量提问”,固定两轮。
- 使用结构化提问,固定两轮批量提问。
- 每个问题块给出“推荐选项 + 简短理由”。
- 仅在高影响字段缺失或冲突时追问。
- 直接向用户文字提问,将同一轮的问题合并为一条消息。
Interview schema:
references/askuserquestion-rounds.md
Mode B: Direct Spec Mode
When user already provides --spec, skip interview and run directly.
ZH: 用户已提供 --spec 时,直接执行,不再采访。
Required Workflow
Operator Builder Progress:
- [ ] Step 1: Load references
- [ ] Step 2: Choose mode (Interactive or Spec)
- [ ] Step 3: Build/validate spec JSON
- [ ] Step 4: Dry-run file plan
- [ ] Step 5: Confirm overwrite policy (light guardrail)
- [ ] Step 6: Generate files
- [ ] Step 7: Run validation (none/basic/full)
- [ ] Step 8: Write runtime log events
- [ ] Step 9: Report generated artifacts + validation results
Step 1: Load References
Read:
references/operator-contract.mdreferences/registration-rules.mdreferences/cli-shell-guidelines.mdreferences/gotchas.mdreferences/acceptance-checklist.md
Step 2: Interview or Direct Spec
- Interactive mode: follow
references/askuserquestion-rounds.mdstrictly. - Spec mode: parse user-provided spec directly.
Step 3: Build Spec JSON
Use:
scripts/example_spec.json
Required spec fields:
package_nameoperator_typeoperator_class_nameoperator_module_nameinput_keyoutput_keyuses_llm
Optional spec fields (with defaults):
cli_module_name(default:<operator_module_name>_cli)test_file_prefix(default:<operator_module_name>)overwrite_strategy(default:ask-each)validation_level(default:full)
Step 4: Dry-Run
python "${SKILL_DIR}/scripts/build_operator_artifacts.py" \
--spec <spec.json> \
--output-root <repo-root> \
--dry-run
--dry-run writes nothing at all — no output files, and no usage log.
Step 5: Light Guardrail (Required)
Before writing files, show:
- full create/update file list
- existing files
- selected overwrite strategy
Then get explicit confirmation.
You are running non-interactively. input() has no human to answer it, so the
script refuses rather than failing on EOF mid-write. Two consequences:
- Pass
--yesto confirm. Show the user the plan from--dry-runfirst, and only pass--yesonce they have agreed to it. - Pass an explicit
--overwritepolicy. The defaultask-eachneeds a terminal; without one, the script detects any existing target and refuses before it writes files.
Step 6: Generate
python "${SKILL_DIR}/scripts/build_operator_artifacts.py" \
--spec <spec.json> \
--output-root <repo-root> \
--overwrite skip-existing \
--yes
Useful flags:
--overwrite {ask-each,overwrite-all,skip-existing}— override the spec.skip-existingis the safe default for an agent;overwrite-allreplaces the user's files, so confirm before using it.--validation-level {none,basic,full}--yes— confirm without a prompt. Required non-interactively.--log— record a usage log. Off by default; nothing is written to the user's home directory unless asked.--log-dir <path>— where to log (implies--log)
Step 7: Validation
none: skip validationbasic: import + registry + test file existencefull:basic+ runtime smoke execution
Step 8: Runtime Logs (Light Memory, opt-in)
Logging is off by default. A scaffolding tool should not write into someone's
home directory unasked. Pass --log (or --log-dir <path>) to enable it, and say
so when you do.
When enabled, the log root is:
--log-dir <path>if you pass it — prefer this, it is the only location that does not depend on the environment; or${CLAUDE_PLUGIN_DATA}/dataflow-operator-builder/when that variable is set; or${USERPROFILE:-$HOME}/.codex_plugin_data/dataflow-operator-builder/
The script is shared by all agents and has no per-agent branch, so the fallback
is the same everywhere. Pass --log-dir if you want a predictable location.
A --dry-run never logs, even with --log.
JSONL events:
dry_rungenerate_startgenerate_donevalidate_donecancellederror
Step 9: Output Summary
Report:
- operator class
- generated/updated paths
- overwrite behavior
- validation level and pass/fail details
- suggested next test command(s)
File Layout Produced
<output-root>/
├── <package_name>/
│ ├── __init__.py
│ ├── cli/
│ │ └── <cli_module_name>.py
│ └── operators/
│ ├── __init__.py
│ └── <operator_type>/
│ ├── __init__.py
│ └── <operator_module_name>.py
└── test/
├── test_<prefix>_unit.py
├── test_<prefix>_registry.py
└── test_<prefix>_smoke.py
Notes
- Keep behavior-level customization after scaffold generation.
- Keep operator description contract bilingual (
get_desc(lang='zh'/'en')). - Runtime messages should remain clear English.
ZH:
- 建议先生成骨架,再做行为细化。
get_desc需保持中英文双语契约。- 终端输出信息应以英文为主,清晰可读。
Version History
- 2e95d40 Current 2026-08-27 09:04


