Skip to content

External CLI SubAgents Guide

External CLI subagents let you run an existing coding-agent CLI as a DotCraft one-shot subagent. Compared with native, external CLIs typically expose stage-level progress rather than tool-by-tool execution details.

This page covers SubAgent runtime profiles. For agentRole, tool policy, and recursion depth, read SubAgent Configuration Guide.

Built-in Profiles

NameRuntimeDefault binHeadless entry point
nativenative-DotCraft native runtime
codex-clicli-oneshotcodexcodex exec
cursor-clicli-oneshotcursor-agentcursor-agent --print --output-format json --mode ask
custom-cli-oneshotcli-oneshot-Template profile; override with same name and set bin to make it usable

If a cli-oneshot profile binary cannot be resolved on your machine, DotCraft hides that profile from the system prompt automatically and logs the reason at startup (e.g. binary 'cursor-agent' was not found on PATH).

Quick Configure

Profiles are configured in config.json under SubAgentProfiles.

  • Global: ~/.craft/config.json
  • Workspace: <workspace>/.craft/config.json

Workspace config overrides global profiles with the same name.

json
{
  "SubAgentProfiles": {
    "my-cli": {
      "runtime": "cli-oneshot",
      "bin": "my-cli",
      "workingDirectoryMode": "workspace",
      "inputMode": "arg",
      "outputFormat": "text"
    }
  }
}

Field Reference

FieldDescription
runtimeRuntime type. External one-shot profiles use cli-oneshot
binExecutable name or absolute path
argsFixed argument list
workingDirectoryModeworkspace / specified
inputModestdin / arg / arg-template / env
inputArgTemplateArgument template used by arg-template mode
inputEnvKeyEnvironment variable key used by env mode
envFixed environment variables injected into the subprocess
envPassthroughEnvironment variable names copied from the parent process
outputFormattext or json
outputJsonPathFinal-result extraction path in JSON mode
readOutputFilePrefer output-file content as final result
outputFileArgTemplateOutput-file argument template, supports {path}
timeoutPer-run timeout in seconds
maxOutputBytesMaximum captured output bytes

Vendor Headless References

cursor-cli

Vendor docs: CLI Parameters, Headless CLI.

DotCraft ships cursor-cli with --print --output-format json --mode ask --trust --approve-mcps. For non-interactive auth, set CURSOR_API_KEY; DotCraft copies it to the subprocess when present.

codex-cli

Vendor docs: Codex CLI, codex exec reference.

DotCraft invokes codex-cli as codex exec "<task>", plus --skip-git-repo-check --json --output-last-message {path} for the output-file contract. When resume is enabled and a prior external session exists, DotCraft switches to codex exec resume {sessionId} "<task>". Interactive and restricted launches add --sandbox read-only; auto-approve launches add --dangerously-bypass-approvals-and-sandbox.

For authentication, DotCraft automatically passes through CODEX_API_KEY and OPENAI_API_KEY to the subprocess. If you use codex login, its auth state is also reused via ~/.codex under HOME/USERPROFILE.

Inspect Profiles On Your Machine

DotCraft validates every profile at startup and prints the hidden built-in profiles (with the concrete reason) to the log, so you can quickly tell whether a profile is missing bin, whether the binary is not on PATH, or whether a required field is misconfigured. Check the startup log to know which profiles are visible to the model.

Apache License 2.0