Planner transports
Prose flows compile to IR via a pluggable LLM transport. There are four of them — pick whichever matches the credentials you already have.
| Transport | When to use |
|---|---|
api | You have an ANTHROPIC_API_KEY and want the most direct route |
via-cli | You already pay for claude / codex / gemini on the CLI |
manual | Air-gapped CI, paste-once, or quick experiments with any chat LLM |
via-mcp | An MCP server exposes plan_flow (klera’s own, or a third party) |
All four produce a bit-identical SemanticPlan — same Zod gate, same
cache shape, same _meta envelope (only the model tag differs).
ANTHROPIC_API_KEY is gated only on the api transport.
Pick a transport
klera init writes the chosen transport into .klera/config.yaml.
Adopters edit the file to switch later:
planner:
transport: via-cli # api | via-cli | manual | via-mcp
cli: claude # for via-cli onlyPer-invocation overrides:
--planner-cli <name>— overrideplanner.clifor one run.--via-cli <name>— explicitvia-clitransport onklera planorklera compile.--manual— explicitmanualtransport.--via-mcp <command>— explicitvia-mcptransport, spawn the given MCP server and routeplan_flowthrough it.
klera doctor reports the active transport with a “subscription-paid”
hint when via-cli is active — useful confirmation that you are not
about to burn API credit unnecessarily.
Auto-detection rules
When you run klera plan or klera compile and no transport is
explicitly configured, the resolver walks this order:
Explicit per-invocation flag
--via-cli, --manual, --via-mcp win unconditionally.
.klera/config.yaml planner.transport
Whatever the file says, with planner.cli honoured for via-cli.
ANTHROPIC_API_KEY set
The api transport activates. No CLI probe runs.
PATH probe for adapter CLIs
The detector walks every PATH directory and probes for executables
named claude, then codex, then gemini, in that order. The first
hit wins; the resolved absolute path is recorded for the spawn. On
Windows, .exe / .cmd / .bat suffixes are tried in turn.
Failure
No transport — klera plan / klera compile errors out with the list
of options and tells you which env var or file edit unlocks each.
The four transports
api
Direct call to the Anthropic API. The most straightforward path when you have a key.
export ANTHROPIC_API_KEY=sk-ant-...
klera plan flows/login.flow.md --snapshot snapshots/login.jsonThe CLI compiles the prose against the snapshot, validates the
SemanticPlan, and writes the cache to flows/login.flow.json.
_meta.model records the model tag — claude-sonnet-4-6 or
whichever model the planner version pinned.
Token usage is whatever your account is metered on. Adopters who
care about CI cost typically pair api with klera compile --all --check so CI never compiles — it only verifies the local cache
is up to date.
Same plan, four routes
Whichever transport you pick, the resulting .flow.json cache validates
against the same SemanticPlan Zod schema. The _meta envelope tags
which transport produced it:
{
"name": "Login smoke",
"steps": [ /* identical IR */ ],
"_meta": {
"schemaVersion": 1,
"promptHash": "…",
"snapshotHash": "…",
"model": "claude-sonnet-4-6", // api
// "model": "via-cli:claude", // via-cli
// "model": "manual", // manual
// "model": "mcp:host", // via-mcp
"plannerVersion": "0.1.0",
"generatedAt": "2026-05-01T10:30:00.000Z"
}
}The cache hash combines prose body + element-graph snapshot + planner version. Switching transports does not invalidate the cache — same inputs, same hash. Bumping the planner version does invalidate it, which is what you want when the prompt itself has been refined.
Hallucination resilience
The planner does not blindly trust the LLM. After the response parses,
a semantic check walks the IR against the snapshot using a light matcher
ladder. If a target does not resolve, the check returns nearestCandidates
and the planner retries with that feedback injected into the next prompt.
Default retry budget is 3. Each retry escalates: strict-JSON preamble,
then Zod errors, then semantic-check errors with candidate suggestions.
On the final failure, the CLI raises a PlannerHallucinationError
carrying every attempt’s response — no half-baked cache writes hit
disk.
See also
- MCP server — klera’s own MCP server, the home for the
via-mcptransport. - Editor support — JSON Schema autocomplete for the YAML escape hatch.