/ai-devkit:cmk:testcontainersfrom ai-devkit
Starts and shares throwaway service containers (Postgres, Redis, MinIO, etc.) from Rust test code via the testcontainers crate with retry/backoff and lifetime management.
Ships in ai-devkit. 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.
Mechanics for starting and sharing a throwaway service container from Rust test code via the testcontainers crate (with testcontainers-modules for common services), wired into the sharing shapes cmk:test-resources defines and the test-runner wiring cmk:rust sets up. This skill is the Rust-crate-specific layer under both — it assumes their principles and adds nothing generic of its own.
Init (default) — wire a new container-backed test resource: retry/backoff, guard lifetime, host/port readback, and which of cmk:test-resources' two shapes applies.
Update — add a service module, or migrate an existing container-starting helper onto the retry/backoff idiom.
Verify — report-only audit against the checks under ## Verify; never mutates.
Docker image pulls and container startup are the flakiest part of a test run — a bare .start() call with no retry turns a transient pull hiccup into a spurious test failure. Wrap it in a bounded retry with a per-attempt timeout and backoff, and fail loud once attempts are exhausted rather than returning a value that looks like success:
async fn start_postgres() -> ContainerAsync<Postgres> {
const ATTEMPTS: u32 = 3;
const PER_ATTEMPT: Duration = Duration::from_secs(90);
for attempt in 1..=ATTEMPTS {
match tokio::time::timeout(PER_ATTEMPT, Postgres::default().start()).await {
Ok(Ok(container)) => return container,
Ok(Err(_)) | Err(_) if attempt < ATTEMPTS => {
tokio::time::sleep(Duration::from_secs(2 * u64::from(attempt))).await;
}
Ok(Err(_)) | Err(_) => panic!("start Postgres testcontainer after {ATTEMPTS} attempts"),
}
}
unreachable!()
}
ContainerAsync owns the container's lifetime through Drop — the container stops the moment its last handle drops. Bundle it inside whatever shared struct carries the connection info, not alongside it as a separate value someone could drop early:
struct SharedPostgres {
_container: ContainerAsync<Postgres>, // never read directly — its Drop is the point
base_url: String,
}
In the lock-across-startup singleton shape (cmk:test-resources), the Arc<SharedPostgres> — not the bare container — is what every caller holds; the container only stops once every caller has dropped its Arc.
The runner maps each exposed container port to an ephemeral host port, which differs across runs and across containers running concurrently:
let host = container.get_host().await.expect("read container host");
let port = container.get_host_port_ipv4(5432).await.expect("read mapped port");
let base_url = format!("postgres://postgres:postgres@{host}:{port}");
cmk:test-resources — testcontainers is only one branchTestcontainers implements cmk:test-resources' "same process" shape (start once, share via a lock-across-startup singleton) and replaces itself entirely for the "same external resource" shape — when a genuinely shared server exists (CI providing one Postgres for the whole job), that path connects to it directly instead of starting a container, selected by the two-flag override guard that skill describes. The two branches are alternatives, not layers: a test process either starts its own throwaway container or connects to the shared external one, never both.
A container-backed test suite requires Docker (or an equivalent OCI runtime) on whatever runs it. State that requirement in the CI job definition itself — a runner image without it fails every container-backed test with an opaque connection error, which reads as a flaky suite rather than a missing prerequisite.
Report-only — never mutate:
.start() call.cmk:test-resources' two shapes applies per test path — a test never both starts its own container and connects to a shared external one.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (commandosslabs/ai-devkit) — no native marketplace selected
npx claudepluginhub p/commandosslabs-ai-devkit36 skills in this plugin
/cmk:adrUse when the user asks to "record this decision", "we decided to use X over Y", "document why we chose this approach", "record an ADR", "update ADR-0003", or needs to create or update architecture decision records for system-level technical choices like choosing a database, communication protocol, or infrastructure pattern./cmk:agent-instructionsUse when the user asks to "set up CLAUDE.md", "set up AGENTS.md", "agent instructions", "add engineering rules", "make the instructions thinner", or needs to establish or maintain a thin, multi-vendor root instruction file backed by on-demand engineering rules under docs/rules/./cmk:agent-vendorsUse when the user asks to "vendor the kit's skills into this repo", "set up agent adapters", "add a coding-agent vendor", "wire skills for Claude Code / Codex / OpenCode / Grok Build / Cursor", or whenever a repo needs one canonical skill set discoverable by multiple coding agents.