cargo-cdk
Original:🇺🇸 English
Translated
Define an entire Cargo workspace in code — connectors, models, plays, tools, agents, MCP servers, context, capacities, territories, segments, folders, files, workers, apps — and deploy it declaratively with `cargo-ai cdk` (init → types → plan → deploy), the way you'd manage cloud infra with Pulumi or the AWS CDK. Use when the user wants to manage Cargo resources as code: reproducibly, version-controlled, in git, from a template, or across environments. Routes to authoring/deploy/typing guides (Level 2), recipes (Level 2.5), and references. For one-off imperative operations (create one connector, read a model, run a workflow), use the matching capability skill instead.
6installs
Sourcegetcargohq/cargo-skills
Added on
NPX Install
npx skill4agent add getcargohq/cargo-skills cargo-cdkTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Cargo CDK — declarative workspace-as-code
Use this skill to define a Cargo workspace in TypeScript ( builders from
) and reconcile it to live infrastructure with .
It is the declarative counterpart to the imperative capability skills: instead
of running one CLI command per resource, you write the whole graph once and deploy
it repeatably, with a committed linking your code to what Cargo
created.
define*@cargo-ai/cdkcargo-ai cdk deploycargo.state.json1) What this skill governs
- Authoring every Cargo resource with a builder that returns a handle; wiring resources by passing handles to each other (the dependency graph is your variable graph).
define* - Deploying the graph: (offline diff) →
plan(create/update, write state) →deploy(tear down). Plus drift (destroy), adoption (refresh), and recovery (import).rollback - Typing the config against your workspace's real integration schemas
().
cargo-ai cdk types
The CDK spans every resource kind — so it overlaps every imperative capability
skill (, , , ,
, , …). Which to reach for is the first decision:
cargo-connectioncargo-storagecargo-aicargo-orchestrationcargo-contentcargo-hosting2) CDK or the CLI? — the routing decision
Declarative (this skill) vs imperative (a capability skill).
Use the CDK when the user is managing resources as an artifact:
- "Set up / stand up / bootstrap a whole workspace (as code / from a template)."
- "Make this reproducible / version-controlled / in git / repeatable across environments (dev → prod)."
- "Deploy these connectors + models + agents together" (a multi-resource graph wired by dependency).
- Anything that should be re-runnable and diffable, where losing the definition would be a problem.
Use the matching capability skill (imperative ) when the
user is doing a one-off operation or exploring:
cargo-ai <domain>- "Create one connector", "add a column to this model", "list connectors", "run this workflow", "query storage", "read this agent's memory."
- Any read, ad-hoc query, or single mutation that doesn't need to live in code.
When unsure, ask whether the result should be committed and re-deployable. If yes
→ CDK. If it's a quick action or a read → the capability skill (see the
router to pick the right domain).
cargo3) The lifecycle
cargo-ai cdk init <dir> scaffold a project from a template (blank | full)
│
cargo-ai cdk types generate per-workspace types for typed config (optional)
│
(author define* files) importing a .ts file IS registration — no manifest
│
cargo-ai cdk plan offline: compile the graph, diff against cargo.state.json
│
cargo-ai cdk deploy create/update resources in dependency order, write state
│
cargo-ai cdk destroy tear down resources recorded in stateSide branches: (read-only drift report) ·
(re-apply code over out-of-band edits) · (delete resources removed
from code) · (bind an existing live resource into
state) · (restore the pre-deploy state snapshot).
cargo-ai cdk refreshdeploy --refreshdeploy --prunecargo-ai cdk import <id> <uuid>cargo-ai cdk rollback4) Documentation hierarchy
- Level 1 — (this file): the decision model, lifecycle, critical rules, and routing.
SKILL.md - Level 2 — Guides:
,
guides/authoring-resources.md,guides/deploy-and-state.md.guides/typed-config.md - Level 2.5 — Recipes: — step-by-step playbooks to follow as your execution plan.
recipes/*.md - References — (the full builder catalog),
references/resources.md(everyreferences/commands.mdsubcommand + flags),cargo-ai cdk, andreferences/troubleshooting.md.references/examples/full-workspace.md
5) Read behavior — match the task to a doc and READ IT
| When the task involves… | Read this first | What it gives you |
|---|---|---|
Writing | | The builder catalog, the handle/ref model, secrets, and how workflow bodies compile. |
| | The deploy lifecycle, |
Typed config, | | What |
| A field/spec/output for a specific builder | | Every builder → spec fields → which ref each takes → outputs. |
| Exact command flags | | Every |
| A deploy error / footgun | | The known failure modes and fixes. |
Recipes — follow step-by-step when one matches
| Recipe | Use when… |
|---|---|
| Standing up a new workspace from scratch ( |
| Adding a data source + a model sourced from it, wired by handle. |
| Composing a model + tool + agent (with |
| Bringing an already-live workspace under CDK management via |
| Deploying non-interactively from CI (token auth + committed state). |
6) Critical rules
- Commit . It is the link from your code to the resources Cargo created — and the only handle on a deployed play or agent (they have no slug). Lose it and those resources orphan; recover a link with
cargo.state.json. It records onlycargo-ai cdk import— never secret values. Git-ignore the working files ({hash, uuid, outputs}scaffolds this):cdk initgitignore.cargo-ai/ cargo.state.lock cargo.state.bak.json cargo.state.audit.jsonl - Secrets: wire credentials with (often
secret("ENV_VAR")). The value is read from the environment at deploy time, kept out of the content hash and out of state, so rotating a token doesn't read as drift. Export the env var before deploying — a missing one fails the deploy with an unresolvedsecret("HUBSPOT_API_KEY")placeholder.${ENV_VAR} - Wire by handle, never by . Pass a
.uuidhandle directly (define*,dataset: hubspot), ortools: [enrich]for a resource you didn't define in code (xxRef("uuid"),connectorRef,modelRef,folderRef,toolRef, …). Where a reference needs per-call options, wrap it asagentRef(e.g.{ ref, …options }).models: [{ ref: contacts, readOnly: true }] - Run after workspace integrations change — it regenerates
cargo-ai cdk typesso.cargo-ai//defineConnectorconfig (anddefineModelin workflow bodies) type-check against the real schemas. Typing is a bonus, never a gate: deploy works without it.integrations.* - Run commands from the project root.
cdk/npxresolve from the nearestcargo-ai; run elsewhere andpackage.jsonand.cargo-ai/land in the wrong directory. Usecargo.state.jsonto be explicit.--dir <path> - in CI.
--yesanddeployprompt for confirmation; non-interactive runs must passdestroy.--yes
Prerequisites
Standard Cargo CLI setup (install, login, output conventions) is shared across all
skills — see .
../cargo/references/prerequisites.mdTwo CDK-specific extras:
- The project needs as a dependency (for the
@cargo-ai/cdkbuilders you import).define*scaffolds acargo-ai cdk initwith it — then runpackage.json.npm install - The domain ships with the CLI. Confirm with
cargo-ai cdk; ancargo-ai cdk --helpmeans the CLI is too old —unknown command.npm install -g @cargo-ai/cli@latest
Help
- and
cargo-ai cdk --helpfor the live flag surface.cargo-ai cdk <subcommand> --help - When a documented command/flag/response doesn't match what you observe, file a
report: (see
cargo-ai workspaceManagement report create).../cargo-workspace-management/SKILL.md