clankerflow is a Rust CLI, drop-in OpenCode framework that allows you to run deterministic AI workflows in your repository using readable TypeScript.
Get the full power of OpenCode with the full power of a programming language. Workflows can be containerized for yolo mode or run directly on your machine.
Workflows are authored in TypeScript and executed by a managed Node runtime, while Rust owns orchestration, state, and OpenCode lifecycle calls.
Warning:
clankerflowis currently in beta. Expect rough edges, breaking changes, and fast iteration.
See more example workflows in our example document here
- Initializes a project-local workflow scaffold under
.agents/. - Runs workflows on host or in a containment container.
- Persists workflow runs/events in SQLite.
- Integrates with OpenCode sessions from Rust (run/messages/events/cancel/command).
- Opens the OpenCode web UI for the current project when you start a workflow.
- Rust toolchain (edition 2024 compatible).
- Node + npm (used during
clankerflow initto install runtime dependencies). - Docker (only if you use containment mode).
- OpenCode CLI (
opencode) installed and onPATH(workflow runs auto-startopencode serveon127.0.0.1:4096).
As Crate from crates.io:
cargo install clankerflowFrom source:
cargo install --git https://github.com/AlextheYounga/clankerflow.git clankerflowAfter build, the CLI binary is named clankerflow.
From the repository you want to automate:
clankerflow initThen run a workflow:
# Run the duos.js workflow
clankerflow work duosclankerflow work also opens the OpenCode manage URL in your browser automatically.
Workflows stay user-editable in .agents/workflows/*.ts and import the runtime surface as a normal module:
import type { WorkflowMeta, WorkflowContext, WorkflowTools } from "clankerflow";clankerflow init- initialize or refresh.agentsscaffold.clankerflow work <name>- run workflow.agents/workflows/<name>.ts.--env host|container--yolo--containment(shorthand for container + yolo)
clankerflow manage- open OpenCode sessions UI for current project.clankerflow make ticket- create a new ticket markdown file.clankerflow make worktree <branch>- create a git worktree under.agents/.worktrees/<branch>.clankerflow containment up|down- start/stop containment container.
Containment runs workflows inside a Docker container so agents can operate with full autonomy (--yolo) without touching your host filesystem directly.
# Start the container (idempotent — builds on first run)
clankerflow containment up
# Run a workflow inside the container with safety checks disabled
clankerflow work duos --containment
# Or use the flags separately
clankerflow work duos --env container --yolo
# Stop and remove the container when done
clankerflow containment downEach project gets its own persistent container named agent-{codebase_id}, derived from your project path. The container:
- Bind-mounts your project root as
/workspace(read-write). - Mounts
~/.config/opencoderead-only so the agent can reach your OpenCode server. - Rewrites
127.0.0.1URLs tohost.docker.internalautomatically. - Ships with git, build-essential, gitleaks, and the OpenCode CLI pre-installed.
- Stays alive between runs (
restart: unless-stopped) so subsequent workflows start instantly.
The Dockerfile and compose file are scaffolded into .agents/.clankerflow/docker/ during init. Since .agents/.clankerflow/ is gitignored, treat these as local runtime overrides.
Workflows can check their environment at runtime via ctx.runtimeEnv and ctx.yolo:
async function careful(ctx, { agent }) {
await agent.run({
title: ctx.yolo ? "Cowboy" : "Engineer",
prompt: ctx.yolo
? "You have full autonomy. Ship it."
: "Proceed carefully and explain each step.",
});
}- Workflow files live at
.agents/workflows/*.ts. - Runtime helpers and package metadata are scaffolded under
.agents/.clankerflow/lib. clankerflow initrunsnpm installinside.agents/.clankerflow/lib..agents/.clankerflow/is gitignored and treated as local runtime state.- Rust and Node communicate over structured JSON IPC.
- Run monitoring is done in the OpenCode web UI.
More short examples live in docs/examples.md.
Current workflow agent tool surface includes:
agent.run(...)agent.command(...)agent.messages(sessionId)agent.events(sessionId)agent.cancel(sessionId)
Example:
const started = await agent.run({ prompt: "Draft implementation plan" });
if (started.session_id) {
await agent.command({
session_id: started.session_id,
command: "/review",
});
}The embedded scaffold now comes directly from kit/. Update files there when you want to change what clankerflow init writes into .agents/.
Key source-of-truth paths:
kit/mirrors the emitted.agents/scaffold.kit/.clankerflow/lib/is the hidden runtime package installed duringinit.runtime/still exists for runtime-focused development and tests, butkit/is what gets embedded into the binary.
Run Rust tests:
cargo testRun runtime tests:
cd kit/.clankerflow/lib
npm test