agent-cli-draft
v0.1.0
Published
Define reusable coding agents and coordinate their native harnesses through a local CLI.
Readme
Agent Draft
Define specialized agents in TypeScript and run them from your everyday coding assistant through the agent CLI. V1 connects installed Codex, Claude Code, and fx harnesses. Codex and Claude Code reuse eligible native subscription logins or explicit API access; fx connects through explicit Vercel AI Gateway access.
The library coordinates sessions, queues, and subagents. Harnesses own model execution, native tools, and context. You supply the working directory and any sandbox or worktree isolation.
Installation
Node.js 22.18 or newer is required. Install the SDK and CLI in your project:
npm install --save-dev agent-cli-draft
npx agent --helpThe package includes the agent command; npx agent runs your project's installed copy. For a global executable, use npm install --global agent-cli-draft. Definitions resolve their dependencies from their own location; global definitions in ~/.agents/agents/ also need access to the SDK package. Install and authenticate the native harness used by your definitions separately.
See package distribution for development checkouts, local tarballs, and package boundaries. Agent Draft uses the MIT license.
Define an agent
Create .agents/agents/developer.agent.ts in your repository:
import { agent, codex, claudeCode } from "agent-cli-draft";
export default agent({
name: "developer",
description: "Implements features and verifies changes.",
instructions: "Follow the repository's documented requirements and run its checks.",
harness: [
codex({ model: "CODEX_MODEL_ID", effort: "high" }),
claudeCode({ model: "CLAUDE_MODEL_ID", effort: "high" }),
],
});Replace the model placeholders with identifiers available through your native harnesses. Each file default-exports one definition. Global definitions live in ~/.agents/agents/; repository and global names never silently override one another.
Run and follow up
npx agent list
npx agent run repo:developer --cwd /path/to/worktree --prompt "Implement the documented feature."
npx agent send <session-id> --delivery queue --prompt "Add the integration tests."
npx agent send <session-id> --delivery steer --prompt "Keep the existing API compatible."
npx agent wait <task-id> --after <response-id>
npx agent status <task-id> --full
npx agent cancel <task-id>Commands print task/session identifiers and return one complete response with its response identifier and task state. Pending descendant work can continue after that command exits. Run or wait commands can use your assistant's background-task facilities. Native steering is used when supported; otherwise steer behaves as interrupt, cancels affected descendants, preserves independently queued tasks, and reports the effective mode.
Long prompts can use --prompt-file. Output is compact text by default; --format jsonl selects typed integration records without forwarding native token or tool streams.
Access
No project configuration is needed when an eligible native subscription login is available. Login remains with the native harness. Ambient API keys do not silently enable paid fallback.
Personal access preferences can be placed in the ignored .agents/agents.local.json. Linked worktrees read that file from the main checkout, while their agent definitions come from the selected worktree.
{
"access": {
"codex": [{ "type": "subscription" }],
"claudeCode": [{ "type": "vercel-api-key", "env": "AI_GATEWAY_API_KEY" }]
}
}Only credential references belong in that file. Access configuration also describes direct API keys, project OIDC, explicit connection fallback, and token-lifetime limits.
For fx, select a Gateway connection explicitly:
{
"access": {
"fx": [{ "type": "vercel-api-key", "env": "API_KEY", "envFile": ".env" }]
}
}Use fx({ model: "google/gemini-3.8-flash" }) in the agent's harness field. Native fx must select the supplied environment credential instead of a saved login. Gateway model and provider restrictions remain effective; catalog availability alone does not establish access for a particular team.
Tools and delegation
Agents can expose validated custom tools and declare subagents. A managed parent invokes its child with the same CLI:
agent run subagent:reviewer --cwd /path/to/worktree --prompt "Review the implementation."The library supplies the parent context. Declaring subagents authorizes their invocation. Claude Code receives permissions scoped to its session launcher, declared children, and coordination commands; native approval rules and sandbox restrictions still apply. Children receive explicit task context rather than a copy of the parent's transcript. Cancellation propagates through delegated descendants; a parent task completes after child results and its own continuation are handled.
This checkout includes five repository roles: architecture and design with Astra, implementation with Sol, independent review with Opus, research with Gemini, and visual and shader work with Fable 5.1 through fx. Reusable techniques live in .agents/skills/ and are read only when the task needs them; a new technique does not require another agent definition. Discover the roles with agent list and invoke them through repo:<name>. Skill loading, native capability limits, and the image-task execution path are documented with the team.
Boundaries
The local coordinator retains sessions and responses across command exits, but does not restore queues after coordinator or environment loss. External assistant reactivation depends on that assistant's host. Native requests needing interactive permission/input fail with actionable INPUT_REQUIRED; they are not automatically approved. CLI delegation requires the native shell to reach the coordinator over loopback HTTP; a sandbox that blocks local networking must be configured by the caller.
resume is available as a command, but v1 adapters report RECOVERY_UNSUPPORTED when prompt-free native recovery is unavailable. Failed work is not automatically replayed or migrated.
Live subscription checks with Codex and Claude Code cover execution, conversation follow-ups, custom tools, and queuing. Codex native steering and interruption preserve queued work. Claude's steer fallback also interrupts the active task, runs its replacement, and preserves queued work.
Live Claude checks also cover launching a declared child and sending follow-ups to that same child session. Explicit native approval rules remain effective. Codex nested delegation remains blocked by local network restrictions in the tested sandbox.
Live fx checks through an explicit Gateway API key cover execution, conversation follow-ups, and custom tools with Gemini 3.8 Flash and Kimi K3. Gemini checks also cover interruption, pending tool completion, and preservation of queued tasks. Native fx permissions remain unchanged. OIDC billing attribution has not been validated end to end. Automated tests use external-protocol fixtures and do not require model access.
Checks and contracts
The private apps/docs workspace contains the Geistdocs website. Its reference pages are generated from the authoritative sdk/ Markdown files; edit those originals rather than generated MDX.
npm run dev:site
npm run check:site
npm run build:siteThe website contracts describe the application boundaries, and the mascot asset documentation records the reproducible geometry conversion and poster rendering commands.
npm run check
npm run check:packagenpm run check builds the current SDK first, then runs TypeScript checking and behavioral tests. Building first lets repository agent definitions import the package's current exports on a clean checkout and prevents tests from exercising stale build output. Tests cover native protocol boundaries, credential selection, worktrees, task queues, cancellation races, nested CLI execution, and process lifetime.
npm run check:package packs the SDK and verifies installation, imports, and CLI agent discovery in a temporary consumer project. It downloads dependencies from the public npm registry with install lifecycle scripts disabled and does not run a coding model.
The SDK documentation describes the final contracts. AGENTS.md defines the project's documentation, TDD, and review workflow. Comparative research and review evidence are kept in the ignored .context directory.
