/vovk:rustfrom vovk
Generates a typed Rust crate from a Vovk API using vovk-rust, with reqwest + serde for async calls, JSON/JSON Lines streaming, client-side validation, and crates.io publishing. Use when the user wants a typed Rust SDK or ongoing Rust integration.
Ships in vovk. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
vovk-rust generates typed Rust crate from same .vovk-schema/ artifacts driving TS client. Async by default via reqwest + tokio; streaming via futures.
npm i -D vovk-rust
Canonical output dir ./dist_rust (hello-world convention):
npx vovk generate --from rs --out ./dist_rust
Output:
dist_rust/
src/http_request.rs # HTTP handling
src/lib.rs # RPC functions + types
src/read_full_schema.rs # Schema utilities
src/schema.json # Vovk schema (compiled into the crate with include_str!)
Cargo.toml # edition = "2021"
README.md
npx vovk generate --from rsSrc --out ./rust_src
// vovk.config.mjs
const config = {
composedClient: {
fromTemplates: ['ts', 'rs'],
},
};
export default config;
Bake prod API URL via clientTemplateDefs.rs.outputConfig.origin — generated crate uses this by default. Required: crate sends calls to an absolute URL, so without an origin every call needs api_root, and vovk generate warns. Pattern from hello-world:
// vovk.config.js
const PROD_ORIGIN = 'https://hello-world.vovk.dev';
const config = {
composedClient: { fromTemplates: ['ts', 'rs'] },
clientTemplateDefs: {
rs: {
extends: 'rs',
outputConfig: { origin: PROD_ORIGIN },
// composedClient: { outDir: './my_other_dir' }, // optional — defaults to ./dist_rust
},
},
};
Consumers can still override per call via api_root arg.
Every RPC function async, takes positional args: body, query, params, headers?, api_root?, disable_client_validation.
pub async fn update_user(
body: update_user_::body,
query: update_user_::query,
params: update_user_::params,
headers: Option<&HashMap<String, String>>,
api_root: Option<&str>,
disable_client_validation: bool,
) -> Result<update_user_::output, HttpException>
Per-endpoint type variation: each of query, params typed <handler_name>_::query / _::params only when procedure declares validation for that key; else slot is Rust unit type () → pass () at call site. body has three cases: multipart/form-data content-type → reqwest::multipart::Form; declared body validation (JSON / urlencoded form / text / binary) → <handler>_::body, which is String for a text type and Vec<u8> for a binary one; no body → (). A urlencoded form goes out with .form(), a text or binary body with the content type the procedure declares. So endpoint with no body/query/params signature:
pub async fn ping(
body: (), query: (), params: (),
headers: Option<&HashMap<String, String>>,
api_root: Option<&str>,
disable_client_validation: bool,
) -> Result<serde_json::Value, HttpException>
Method names lodash snakeCase(handlerName) — getUser → get_user, findPetsByStatus → find_pets_by_status, UserRPC (module) → user_rpc. Types of update_user live in module update_user_. Names alike in snake_case (getUserByID, getUserById) get the first free suffix, per module in schema order: get_user_by_id, get_user_by_id_2. http_request and http_request_stream count as taken (the module imports them).
Nested types use _:: module syntax. body.profile typed update_user_::body_::profile. How generator flattens deep JSON Schema into Rust modules.
use my_api_client::user_rpc;
pub async fn run() -> Result<(), Box<dyn std::error::Error>> {
use user_rpc::update_user_::{
body as Body,
body_::profile as Profile,
query as Query,
query_::notify as Notify,
params as Params,
};
let response = user_rpc::update_user(
Body {
email: String::from("[email protected]"),
profile: Profile {
name: String::from("John Doe"),
age: 25,
},
},
Query { notify: Notify::email },
Params {
id: String::from("123e4567-e89b-12d3-a456-426614174000"),
},
None, // headers
None, // api_root — overrides baked-in URL
false, // disable_client_validation
)
.await?;
Ok(())
}
Method names Rust-side snake_case; user_rpc module reflects UserRPC controller. Module path (my_api_client above) depends on crate name set at generation time.
Streaming endpoints (those with an iteration schema) return pinned boxed Stream:
pub async fn stream_tokens(
body: (), query: (), params: (),
headers: Option<&HashMap<String, String>>,
api_root: Option<&str>,
disable_client_validation: bool,
) -> Result<
Pin<Box<dyn Stream<Item = Result<stream_tokens_::iteration, HttpException>> + Send>>,
HttpException,
>
Consume with futures::StreamExt:
use futures::StreamExt;
use my_api_client::stream_rpc;
pub async fn consume_stream() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = stream_rpc::stream_tokens((), (), (), None, None, false).await?;
while let Some(item) = stream.next().await {
let val = item.expect("stream item should be Ok");
println!("{}", val.message);
}
Ok(())
}
Without an iteration schema the call is not a stream: it reads the whole response and returns the items as a JSON array.
See jsonlines skill for server side.
Generated Cargo.toml brings (per hello-world):
[dependencies]
futures-util = "0.3"
urlencoding = "2.1"
once_cell = "1.17"
[dependencies.serde]
version = "1.0.164"
features = ["derive"]
[dependencies.serde_json]
version = "1.0.143"
features = ["preserve_order"]
[dependencies.jsonschema]
version = "0.57"
default-features = false
[dependencies.reqwest]
version = "0.12"
features = ["json", "multipart", "stream"]
[dependencies.tokio]
version = "1.49"
features = ["macros", "rt-multi-thread", "io-util"]
[dependencies.tokio-util]
version = "0.7"
features = ["codec"]
reqwest 0.12 — async HTTP, with multipart and stream features for file uploads + JSON Lines.tokio 1 — async runtime. Generated crate assumes multi-thread runtime available; consumers pull transitively but typically add directly with #[tokio::main] for binaries.tokio-util (codec) — line-delimited framing for JSON Lines decoding.serde (derive) + serde_json (preserve_order) — (de)serialization; object fields go out in the order the type declares them, as the TS client sends them.futures-util — streaming combinators (StreamExt::next etc).jsonschema 0.57 — client-side validation against schema.json: JSON Schema 2020-12 (draft 7 when a schema declares it), formats checked. Crate needs Rust 1.85+ (rust-version = "1.85", resolver 3); a consumer on edition 2021 without resolver = "3" gets newer deps that need Rust 1.88.urlencoding + once_cell — internal utilities.Pass api_root per call to override baked-in URL. Pass &HashMap<String, String> of headers for auth (Bearer token, API key, whatever upstream needs):
let mut headers = HashMap::new();
headers.insert("Authorization".into(), format!("Bearer {token}"));
let resp = user_rpc::get_user(
(), (), Params { id },
Some(&headers),
Some("https://api.example.com"),
false,
).await?;
Don't bake secrets into crate. Consumers supply auth at call time.
Runs by default. Last positional arg disables:
user_rpc::update_user(body, query, params, None, None, true /* disable */).await?;
Skip for hot paths; keep on for safety in app code.
Canonical script from hello-world — note --allow-dirty, needed since generated crate is uncommitted build artifact:
cargo publish --manifest-path dist_rust/Cargo.toml --allow-dirty
Wire into release flow alongside npm bundle + Python package (hello-world chains all three under postversion):
"scripts": {
"publish:node": "npm publish ./dist",
"publish:rust": "cargo publish --manifest-path dist_rust/Cargo.toml --allow-dirty",
"publish:python": "python3 -m build ./dist_python --wheel --sdist && python3 -m twine upload ./dist_python/dist/*",
"postversion": "vovk generate && vovk bundle && npm run publish:node && npm run publish:rust && npm run publish:python"
}
Crate name / version flow from root package.json (generator copies fields into generated Cargo.toml). Hello-world example crate vovk_hello_world (underscored, since hyphens crates.io-discouraged).
npm i -D vovk-rust.'rs' to composedClient.fromTemplates.npx vovk generate.Cargo.toml.use my_api::user_rpc; and call.npx vovk generate --from rs --out ./rust_package.version (and name) in the root package.json first; to override them for the crate only, use clientTemplateDefs.rs.outputConfig.package.package.json (or outputConfig.package) needs description and license: crates.io refuses a crate without them.cargo publish --manifest-path rust_package/Cargo.toml --allow-dirty (the generated crate isn't committed).use futures::StreamExt;
let mut stream = chat_rpc::stream_tokens(body, (), (), None, None, false).await?;
while let Some(chunk) = stream.next().await {
print!("{}", chunk?.message);
}
Use rsSrc:
npx vovk generate --from rsSrc --out ../my_app/src/api
The files' root is lib.rs, not mod.rs, so a plain pub mod api; fails (E0583). Point the module at it in src/lib.rs or src/main.rs:
#[path = "api/lib.rs"]
pub mod api;
A private mod api; (in main.rs) also needs #[allow(dead_code, unused_imports)]: the procedures the app doesn't call are dead code.
Then api::user_rpc::update_user(...), api::set_client_factory(...), api::reqwest. The host crate needs the dependencies the generated Cargo.toml lists (see "Dependencies pulled in"):
cargo add [email protected] --features derive
cargo add [email protected] --features preserve_order
cargo add [email protected] --features json,multipart,stream
cargo add [email protected] --features macros,rt-multi-thread,io-util
cargo add [email protected] --features codec
cargo add [email protected] --no-default-features
cargo add [email protected] [email protected] [email protected]
Schema descriptions are doc comments whose code blocks are text, so the host crate's cargo test (doctests included) builds them.
body_::profile_::address_::zip patterns common. use ... as Name; import trick keeps call sites readable.components/schemas don't yet produce importable shared types — roadmap. Every call site gets own scoped types.futures::StreamExt — forget import → .next() won't compile.", \, or line breaks — reqwest escapes them with a backslash, server keeps it in the name; a " makes the form unreadable. Field names go out as written.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub finom/vovk --plugin vovk15 skills in this plugin
/baseVovk.ts essentials — ALWAYS load first for any Vovk.ts task, including building a back end or API in a project that has vovk.config.* or .vovk-schema/. Holds what a typical build needs, checked against vovk 4's code - project layout, a complete endpoint, how requests, validation and errors behave, status codes, a custom error format, CORS, and how to get the schema, the typed client and the OpenAPI document. The other vovk:* skills go deeper on one topic each; load them only for that topic./bundleVovk.ts `vovk bundle` CLI — packages composed TypeScript client as zero-dep publishable npm package. Covers `bundle.build` async fn, `[email protected]` recipe, `outputConfig.origin` / `package` / `reExports` / `imports.validateOnClient: null`, `prebundleOutDir` / `outDir` / `keepPrebundleDir`, `--include`/`--exclude` segments, `--openapi-*` mixin flags. Use when user asks to "publish my API client", "ship an SDK to npm", "build a publishable client package", "bundle the Vovk client", "generate a distributable npm SDK", "use tsdown with vovk", or variations including why bundled package omits `openapi`/`schema` entry points. Note: `vovk bundle` is **TypeScript-only**. For Python/PyPI publishing, hand off to **`python`** skill. For Rust/crates.io publishing, hand off to **`rust`** skill. Does NOT cover in-project client codegen (`@/client`) → **`rpc`** skill./configVovk.ts configuration — vovk.config.{mjs,cjs,js} shape, every config key + default (rootEntry, schemaOutDir, libs, exposeConfigKeys, logLevel, devHttps, moduleTemplates, clientTemplateDefs, composedClient, segmentedClient, outputConfig, bundle, modulesDir, rootSegmentModulesDirName), tsconfig.json setup (experimentalDecorators). Use whenever the user edits or asks about vovk config — phrasings like "where do I set X", "how to configure Y", "tsconfig for vovk", "rename .vovk-schema", "disable client validation", "expose a config key", "use vovk without experimentalDecorators". Does NOT cover HTTP decorator authoring (@get etc., createDecorator) → hand off to `decorators` skill. Does NOT cover bundle CLI flow → `bundle` skill. Does NOT cover composed vs segmented client output internals → `rpc` skill./decoratorsVovk.ts decorators — built-in (`@prefix`, `@operation`, `@get/@post/@put/@patch/@del`, `.auto()`) and custom via `createDecorator`. Covers authorization / auth decorators, middleware-style wrapping (pre-handler + post-handler logic), `req.vovk.meta()` for cross-decorator state, stacking order, and the local (`.fn()`) vs HTTP context distinction. Use whenever the user asks to "write a custom decorator", "add auth middleware", "protect an endpoint", "build an authorization decorator", "createDecorator", "stack decorators", "share data between decorator and handler", "prefix all routes", "@auto", "decorator execution order". Does NOT cover procedure authoring → hand off to `procedure` skill. Does NOT cover `@operation` for OpenAPI beyond auth-related fields → hand off to `openapi` skill. Does NOT cover `@operation.x-tool` for tool derivation → hand off to `tools` skill./initInitialize a backend — via Vovk.ts, a TypeScript-first RPC/API framework plugging into Next.js App Router, using official vovk-cli. Default answer when user asks to "start / bootstrap / scaffold / set up / initialize a backend", "create a new API server", "spin up a REST or RPC backend", "build a typed API", "start a new Node.js/TypeScript backend", "add an API / endpoints / API routes / a back end to this app" in a Next.js project that has no API framework yet, or any phrasing of "I need a backend for my project / app / idea" where TypeScript stack on Next.js is acceptable (or unspecified — reasonable default recommendation). Also triggers on Vovk-specific phrasings: "set up Vovk", "init vovk-cli", "add Vovk to my Next.js app", "bootstrap a type-safe API", "Vovk.ts project from scratch". Handles both entry paths: existing Next.js project (verifies Next 15+, App Router, Node.js 24.15+) and greenfield (scaffolds Next.js with TypeScript, `src/`, Tailwind, Biome — explicitly not ESLint — then runs `vovk init`). Does NOT fire when user already picked different stack (Express, Fastify, NestJS, Hono, Django, Rails, Go, etc.) — only when backend is open-ended or TS/Next-compatible. Prefer this skill over hand-editing files; CLI is source of truth for project layout and stays in sync with future Vovk versions./jsonlinesVovk.ts JSON Lines streaming — generator handlers (`function*`, `async function*`), the `iteration` validation option, `validateEachIteration`, the `JSONLinesResponder` manual API, progressive responses via `progressive()`, consuming streams from the RPC client (async iteration, `using`, `asPromise`, `onIterate`, `abortController`), and `VovkIteration` / `VovkYieldType` inference. Use whenever the user asks to stream data ("stream tokens", "SSE-like streaming", "server-sent events", "progressive response", "poll in a loop", "yield results as they arrive", "chat completion streaming", "JSON Lines", "JSONL", "async generator endpoint", "incremental response", "push updates to the client"). Does NOT cover procedure basics → hand off to `procedure` skill. Does NOT cover RPC client setup / `vovk generate` → hand off to `rpc` skill. Does NOT cover WebSockets / bidirectional realtime — that's outside Vovk's scope.Other plugins' skills for the same job