ops-crate
Generate a new ops/xxx crate for an external service integration. Identifies the right pattern (A=wrapper, B=HTTP direct, C=macro), scaffolds the full structure, and runs the quality checklist. Trigger on "ops crate", "new ops", "creer un crate ops", "add ops/xxx", "nouveau crate ops", "ironflow ops".
- License 许可
- MIT
- 最近更新
- 2026-11-04
- Stars
- ★ 2
- Forks
- 1
01 前言 Front Matter
- name
- ops-crate
- description
- Generate a new ops/xxx crate for an external service integration. Identifies the right pattern (A=wrapper, B=HTTP direct, C=macro), scaffolds the full structure, and runs the quality checklist. Trigger on "ops crate", "new ops", "creer un crate ops", "add ops/xxx", "nouveau crate ops", "ironflow ops".
- argument-hint
- <service-name> [pattern-a|pattern-b|pattern-c]
02 资源文件 4
- 参考文档references/common-helpers.md3.6 KB
- 参考文档references/pattern-a-wrapper.md4.4 KB
- 参考文档references/pattern-b-http.md9.5 KB
- 参考文档references/pattern-c-macro.md6.8 KB
03 SKILL.md 正文
ops-crate -- Generate a new Ironflow ops crate
Arguments
$ARGUMENTS -- expected: <service-name> and optionally a pattern override.
Parse the arguments:
- First word: the service name (e.g.
datadog,pagerduty,cloudflare) - Second word (optional):
pattern-a,pattern-b, orpattern-c
If no service name is given, ask for one.
Step 1: Check if the crate already exists
test -d "ops/$SERVICE" && echo "EXISTS" || echo "NEW"
If EXISTS: warn the user and ask whether to continue (extend) or abort.
Step 2: Identify the pattern
Read the reference files to understand each pattern:
references/pattern-a-wrapper.md-- Pattern Areferences/pattern-b-http.md-- Pattern Breferences/pattern-c-macro.md-- Pattern Creferences/common-helpers.md-- Shared helpers
If a pattern was specified in arguments
Use it directly.
If no pattern was specified
Ask the user with AskUserQuestion:
| Criterion | Pattern A (Wrapper) | Pattern B (HTTP direct) | Pattern C (Macro) |
|---|---|---|---|
| Rust crate exists on crates.io? | Yes, with uniform trait | No | Yes, with typed methods 1:1 |
| HTTP handled by | Underlying crate | ironflow-ops-common's HttpApiClient | Underlying crate |
| Operation granularity | Generic Op<E> for all endpoints |
One struct per endpoint | Macro-generated per method |
| Boilerplate | Minimal | Medium (one struct per operation) | Minimal (macro generates) |
| Reference crates | ops/gitlab, ops/k8s | ops/grafana, ops/loki, ops/tempo, ops/mimir | ops/slack |
Recommend Pattern B if unsure -- it is the most common and self-contained.
Step 3: Scaffold the crate
Follow the structure from the chosen pattern's reference file.
3a. Create directory
mkdir -p ops/$SERVICE/src
3b. Create Cargo.toml
Use cargo add after creating the basic file. The template is in
references/common-helpers.md (Pattern B) or adapt for A/C.
Pattern B dependencies:
ironflow-core(path = "../../ironflow-core")ironflow-ops-common(path = "../common")async-traitreqwestwith features ["json", "query"]serdewith features ["derive"]serde_json- Dev:
tokiowith features ["full"],wiremock
Pattern A dependencies:
ironflow-core(path = "../../ironflow-core")async-trait- The underlying Rust crate
serde_json- Dev:
tokiowith features ["full"]
Pattern C dependencies:
ironflow-core(path = "../../ironflow-core")async-trait- The underlying Rust crate
serde,serde_json- Dev:
tokiowith features ["full"]
3c. Create source files
Follow the exact structure from the reference file for the chosen pattern.
Pattern B files:
src/lib.rs-- crate-level doc, pub modules,pub use client::XxxClientsrc/client.rs-- XxxClient wrapping HttpApiClient (copy structure from reference)- One example module with 1-2 operations to demonstrate the pattern
tests/directory with wiremock integration tests
Pattern A files:
src/lib.rs-- crate-level doc, re-exports,pub use underlying_cratesrc/client.rs-- XxxClient with from_context + op()src/operation.rs-- XxxOp<E> generic Operation wrapper
Pattern C files:
src/lib.rs-- crate-level doc, re-exportssrc/client.rs-- XxxClient with from_context, session()src/error.rs-- error conversionsrc/macros.rs-- xxx_op! macro- One example module using the macro
3d. Register in workspace
Add "ops/$SERVICE" to the members list in the root Cargo.toml.
Step 4: Quality checklist
Run these commands and fix any issues:
cargo clippy --all-targets -p ironflow-ops-$SERVICE
cargo doc --no-deps -p ironflow-ops-$SERVICE
cargo test -p ironflow-ops-$SERVICE
Verify no duplication with ops/common
Check that the new crate does NOT re-implement any of these helpers:
check_response/check_response_jsonvalidate_path_segmentsend_requestparse_json_bodyto_value(Pattern B must useironflow_ops_common::helpers::to_value)reqwest_err
Exception: Pattern C's macros.rs has its own to_value with a
service-specific error origin -- this is intentional.
Mandatory tests (all patterns)
Every ops crate MUST include at minimum:
Client tests:
from_context_fails_when_token_missing-- fast, no networknewtrims trailing slash on base URL (Pattern B only)newrejects empty tokendebug_does_not_leak_token-- format with Debug, assert token absent
Operation tests (Pattern B with wiremock):
- URL constructed correctly (mock matches on
path) - Auth header sent (mock matches on
bearer_token) - Body sent correctly (POST/PUT/PATCH)
- 4xx/5xx returns OperationError::Http
input()does NOT contain secretskind()returns the correct service name
Operation tests (Pattern A -- mostly #[ignore]):
kind()returns the correct service nameinput()returns endpoint metadata
Operation tests (Pattern C):
to_valueserializes a structto_valueserializes unit to null
Documentation requirements
Every public item needs rustdoc:
//!for crate-level and module-level docs///for structs, enums, traits, functions, methods# Exampleswithno_runfor anything needing network# Errorsfor everyResult-returning function
Step 5: Suggest next steps
After generation, tell the user:
- Add the actual operations for the target API
- Run the full test suite:
cargo test -p ironflow-ops-$SERVICE - Consider adding the crate to the
ironflow-opsmeta-crate if one exists
Conventions
- All code follows the project's CLAUDE.md rules (imports at top, no inline paths)
- Use
?operator for error propagation, returnOperationErrorvariants Debugimplementations MUST redact secretsinput()implementations MUST NOT include secrets- Crate names follow the pattern
ironflow-ops-$SERVICE - Package names use hyphens:
ironflow-ops-xxx - Module names use underscores in Rust:
ironflow_ops_xxx
04 同仓库更多 Skills
workflow
Write an Ironflow WorkflowHandler - typed input schema, steps (shell, http, agent, approval, human input, signal, decision, sub-workflow, parallel), registration in handlers(). Loaded by the ironflow hub for the workflow verb.
upgrade
Upgrade the Ironflow crates of a project and migrate its code, or audit existing code against the current Ironflow idioms. Reads the changelog between the installed and the target release, maps every change to the project's code, then proposes or applies the migrations. Loaded by the ironflow hub for the upgrade and audit verbs.
test
Write an end-to-end test for an Ironflow workflow handler - real Engine, InMemoryStore, RecordReplayProvider fixtures, assertions on run status and step names. Loaded by the ironflow hub for the test verb.
setup
Scaffold a new Ironflow project - a Cargo workspace with a workflows lib, an API server binary, a worker binary, a hello workflow and its end-to-end test. Loaded by the ironflow hub for the setup verb.
operation
Write a custom Ironflow Operation - an integration (GitLab, Slack, any HTTP API) executed as a tracked step through ctx.operation(). Loaded by the ironflow hub for the operation verb.
ironflow
Entry point for building on the Ironflow workflow engine. Use for setting up an Ironflow project (server + worker), writing a WorkflowHandler, writing a custom Operation, testing a workflow end to end, reviewing a handler, upgrading the ironflow crates and migrating the code, or auditing existing code against the current Ironflow idioms. Trigger on "ironflow", "workflow handler", "ironflow setup", "ctx.shell", "ctx.agent", "approval gate", "upgrade ironflow", "bump ironflow", "créer un workflow ironflow", "mettre en place ironflow", "mettre à jour ironflow", "migrer ironflow".