/vovk:pythonfrom vovk
Generates a typed Python SDK from a Vovk API using vovk-python, producing TypedDict shapes, JSON/JSON Lines client, and PyPI-ready packages. Use when the user wants a typed Python client, not one-off HTTP calls.
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-python generates typed Python package from same .vovk-schema/ artifacts driving TS client. One source of truth, multi-language.
npm i -D vovk-python
Emits complete Python package (PyPI-ready). Canonical output dir ./dist_python (hello-world convention):
npx vovk generate --from py --out ./dist_python
Output:
dist_python/
src/<package_name>/__init__.py # RPC functions + TypedDict definitions
src/<package_name>/api_client.py # HTTP client
src/<package_name>/py.typed # Type-hint marker
src/<package_name>/schema.json # Generated schema
pyproject.toml # hatchling build backend
setup.cfg
README.md
Emits .py files only — drop into existing Python project:
npx vovk generate --from pySrc --out ./python_src
Wire Python into vovk generate → runs alongside TS:
// vovk.config.mjs
const config = {
composedClient: {
fromTemplates: ['ts', 'py'],
},
};
export default config;
Bake prod API URL via clientTemplateDefs.py.outputConfig.origin — generated client uses this by default. Required: client 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', 'py'] },
clientTemplateDefs: {
py: {
extends: 'py',
outputConfig: { origin: PROD_ORIGIN },
// composedClient: { outDir: './dist_python' }, // override output dir if needed
},
},
};
After this, every npx vovk generate (+ every vovk dev regen) refreshes Python client — PROD_ORIGIN baked in for consumers, overridable per-call via api_root.
Types follow [PascalCaseMethodName][Body|Query|Params|Output] as TypedDict. Methods static, snake_case. Positional arg order: the generator only emits slots where validation declared, in this order: body, files (multipart only, sits between body and query), query, params, then always-present trailing kwargs headers, api_root, disable_client_validation. After them, optional: body for a POST, PUT or PATCH without a body schema, query without a query schema, and files for a multipart record body.
from my_api_client import UserRPC # whatever package the generator wrote
body: UserRPC.UpdateUserBody = {
"email": "[email protected]",
"profile": {"name": "John Doe", "age": 25},
}
query: UserRPC.UpdateUserQuery = {"notify": "email"}
params: UserRPC.UpdateUserParams = {
"id": "123e4567-e89b-12d3-a456-426614174000",
}
# Keyword args work for clarity at call sites:
response = UserRPC.update_user(body=body, query=query, params=params)
Method names snake_case. Type names PascalCase. Names alike in snake_case (getUserByID, getUserById) get the first free suffix, per RPC class in schema order: get_user_by_id, get_user_by_id_2.
filesProcedures with multipart/form-data accept files kwarg — pass Dict[str, Any] matching requests upload format:
with open("avatar.png", "rb") as f:
response = UserRPC.upload_avatar(
params={"id": user_id},
files={"avatar": ("avatar.png", f, "image/png")},
)
Procedures with iteration schemas (server-side async function* handlers — see jsonlines skill) generate sync Python generators client-side. Return type Generator[<MethodName>Iteration, None, None]. Generator only emits slots for validation declared on procedure — for an iteration-only endpoint with no body / query / params, signature is just trailing kwargs:
@staticmethod
def stream_tokens(
headers: Optional[Dict[str, str]] = None,
api_root: Optional[str] = None,
disable_client_validation: bool = False,
) -> Generator[StreamTokensIteration, None, None]:
...
Add body: StreamTokensBody, query: StreamTokensQuery, params: StreamTokensParams to the signature only when the procedure declares validation for them (same rule as JSON endpoints).
Yielded items typed against procedure's iteration schema — StreamTokensIteration is TypedDict → editors autocomplete fields.
from my_api_client import StreamRPC
for item in StreamRPC.stream_tokens():
print(item["message"], end="", flush=True)
Sync generators support usual idioms:
# Manual pull
stream = StreamRPC.stream_tokens()
first = next(stream)
second = next(stream)
# Collect into a list (drains the stream)
all_items = list(StreamRPC.stream_tokens())
# Comprehensions
messages = [item["message"] for item in StreamRPC.stream_tokens()]
# Early termination — break out of the for-loop
for item in StreamRPC.stream_tokens():
if item["message"] == "STOP":
break
handle(item)
# The underlying HTTP connection closes when the generator goes out of scope.
Streaming endpoints accept same input shape as JSON:
from my_api_client import ChatRPC
for token in ChatRPC.complete(
body={"messages": [{"role": "user", "content": "hello"}]},
query={"model": "gpt-4"},
):
print(token["text"], end="", flush=True)
HTTP fail or iteration validation fail → generator raises on next next(). Wrap in try/except to recover:
try:
for item in StreamRPC.stream_tokens():
handle(item)
except Exception as exc:
log.error("stream failed mid-iteration: %s", exc)
Generator sync — backed by requests, no async API. For asyncio, run iteration in thread pool (asyncio.to_thread or loop.run_in_executor) or wrap each next() call. Native async streaming not in current Python client.
See jsonlines skill for server-side handler.
Validation runs against schema.json by default — same Zod/Valibot shapes server enforces, cross-compiled to JSON Schema.
Skip for hot paths or server-only enforcement:
response = UserRPC.update_user(
params=params, body=body, query=query,
disable_client_validation=True,
)
Generated pyproject.toml declares (per hello-world):
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
requires-python = ">=3.9"
dependencies = ["requests", "jsonschema[format-nongpl]", "typing_extensions>=4.0.0; python_version < '3.12'"]
requests — HTTP client; picks its own urllib3.jsonschema[format-nongpl] — client-side validation; the extra checks formats such as uri and date-time without GPL libraries. A pattern Python's re can't compile (\p{L}) is left to the server.typing_extensions — NotRequired and TypeAlias before Python 3.11.Build backend hatchling, no runtime overhead past deps above.
Generated client targets URL baked at generate time. Override per call via api_root kwarg — fully replaces baked-in value for that call. Auth: pass headers per call, or set them once on the module-level client, whose session every call shares:
from my_api import client
client.session.headers["Authorization"] = "Bearer ..."
client.timeout = 30 # seconds, or a (connect, read) tuple; None waits forever
Don't bake secrets into generated package. Consumers supply API keys at runtime.
Canonical script from hello-world (build wheel + sdist, upload via twine):
python3 -m build ./dist_python --wheel --sdist && python3 -m twine upload ./dist_python/dist/*
Both python3 -m build and python3 -m twine invoke modules directly — works with any Python env that has them installed (pip install build twine). Run twine with creds via ~/.pypirc or TWINE_USERNAME / TWINE_PASSWORD env vars.
Wire into release flow alongside npm bundle + Rust crate (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"
}
Version / package name flow from root package.json (generator copies whitelisted fields — name, version, description, license, author, contributors, repository, homepage, bugs, keywords — into generated pyproject.toml). Set version in root package.json, npm version patch propagates to all three targets.
Name transform — pin before publishing. Python package name = root name with the scope's @ dropped and every other character Python can't import → underscore (my-api → my_api, @acme/web-app → acme_web_app). Same name used for filesystem path (src/<name>/), pyproject.toml name, pip install command in README. Set a different distribution name than npm (e.g., npm my-api, PyPI acme_client) with outputConfig.package.py_name:
// vovk.config.mjs
const config = {
composedClient: { fromTemplates: ['ts', 'py'] },
clientTemplateDefs: {
py: {
extends: 'py',
outputConfig: {
origin: 'https://api.example.com',
package: { py_name: 'acme_client' }, // PyPI name + filesystem path
},
},
},
};
npm i -D vovk-python.'py' to composedClient.fromTemplates in vovk.config.mjs.npx vovk generate.pip install -e ./dist_python (or wherever generator wrote it).from vovk_hello_world import UserRPC and call (editable install exposes the package directly — no dist_python.src. prefix).npx vovk generate --from py --out ./python_package.version (and name) in the root package.json before generating; to override them for this package only, use clientTemplateDefs.py.outputConfig.package (see above).python3 -m build && twine upload dist/* from python_package/.Server defines procedure({ iteration }) with async function* handler (see jsonlines). Client iterates:
for item in StreamRPC.stream_tokens():
handle(item)
Use pySrc:
npx vovk generate --from pySrc --out ./my_project/vovk_client
Then import from my_project.vovk_client....
TypedDict, not classes. Generated shapes dict-based for JSON interop; treat as plain dicts with type hints, not Pydantic models.updateUser server → update_user(...) Python, UpdateUserBody etc.jsonschema — small import + runtime cost. Disable per-call for speed or server-only enforcement.api_root kwarg overrides the URL baked at generate time. Headers, timeout and cookies go on the module-level client (client.session.headers, client.timeout).vovk generate before Python client reflects. CI should regen as part of build.components/schemas don't yet produce shared importable types. Each call site gets own scoped TypedDict instead of single UserSchema reused across methods. Roadmap item — until fixed, expect duplicated type definitions.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