draht: open source coding agent for the terminal
draht is an open source (MIT) AI coding agent that runs in your terminal, published on npm as @draht/coding-agent, for developers who want to work with Anthropic, OpenAI, Google, GitHub Copilot and other models from one extensible CLI. It is a fork of the pi coding agent by Mario Zechner and adds features such as duet mode (two models in one session), Polyphase multi-agent workflows, RLM for inputs larger than the context window, and optional opinionated workflow prompts for agentic engineering (TDD, DDD and GSD).
Quickstart
Requires Node.js ^22.23.4, ^24.22.1 or ^26.12.1 (from engines in packages/coding-agent/package.json).
Run without installing:
npx @draht/coding-agent
Or install globally and start the draht command:
npm install -g @draht/coding-agent
draht
Authenticate with an API key:
export ANTHROPIC_API_KEY=sk-ant-...
draht
Or use an existing subscription from inside draht:
/login
Then describe what you want. By default the model gets four tools: read, write, edit and bash.
What is draht
draht is a terminal coding agent plus the libraries it is built on. This repository is a monorepo. The coding agent lives in packages/coding-agent, which has the full user documentation.
The supported Draht product is a local agent stack for building and running AI agents, with selected public extensions and deployment tools. Private workspaces and examples in this monorepo are not hosted-service or release claims. See the product and package support map for the authoritative scope and evidence gates.
Features
- Many providers and models: log in with subscriptions (Anthropic Claude Pro/Max, OpenAI ChatGPT Plus/Pro (Codex), GitHub Copilot, Google Gemini CLI, Google Antigravity) or use API keys for Anthropic, OpenAI, Azure OpenAI, Google Gemini, Google Vertex, Amazon Bedrock, Mistral, Groq, Cerebras, xAI, OpenRouter, Vercel AI Gateway, ZAI, OpenCode Zen, OpenCode Go, Hugging Face, Kimi For Coding and MiniMax. See providers.
- Duet mode: use two or more models in one session, either alternating turns or with a lead model that delegates read-only investigations. See duet mode.
- Polyphase: live oversight of subagents and model-written multi-phase
workflowscripts. See Polyphase. - Session tree: sessions are stored as trees, so you can branch and continue from any earlier point. See sessions.
- MCP servers over stdio or streamable HTTP (
draht mcp add). See MCP. - Compaction of long sessions. See compaction.
- Extensible without forking: TypeScript extensions, skills, prompt templates and themes, shareable as Draht Packages via npm or git. See extensions, skills and packages.
- Four modes: interactive, print or JSON, RPC for process integration, and an SDK for embedding. See RPC and SDK.
- RLM (Recursive Language Models):
draht rlm --input <path|glob|url> --query "..."answers a question about an input larger than the model's context window. The root model writes Python that inspects, chunks and searches the input inside a sandboxed REPL, optionally calling smaller sub-models, and returns a final answer. Runs are recorded under.draht/rlm/and can be replayed withdraht rlm replay <trajectory-id>. Based on Zhang, Kraska, Khattab, Recursive Language Models (arXiv:2512.24601). See packages/rlm and the CLI docs. - Codemode: an optional
codemodetool where the model writes a JavaScript script, run in a QuickJS sandbox, that calls draht's other tools; only the script's output reaches the model. Enable with"defaultTools": ["+codemode"]. See codemode.md. - Specialist subagents: bundled agent definitions in packages/coding-agent/agents: advisor, architect, debugger, git-committer, implementer, investigator, reviewer, security-auditor, spec-reviewer, verifier.
- Virtual models: a selectable model, registered from an extension, that picks a physical model per request (for example by task or cost). See virtual-models.md.
- Attachable sessions. See attachable-sessions.md.
- Drahtbank: compares Draht prompt snapshots on small, repeatable tasks (ten cases in the first suite), grading baseline and candidate prompts independently. See drahtbank.md.
- Claude Code and Codex plugins: the same workflows, commands and subagents for other agents via
npx draht-claude install(draht-claude) andnpx draht-codex install(draht-codex). - Workflow skills in skills/, for example
tdd-workflow,ddd-workflowanddebugging-workflow. See Opinionated prompts for agentic engineering.
Installation
npm install -g @draht/coding-agent
The package installs the draht command. Platform notes: Windows, Termux (Android), tmux, terminal setup.
Usage
draht [options] [@files...] [messages...]
Examples from the CLI reference:
draht "List all .ts files in src/" # interactive with an initial prompt
draht -p "Summarize this codebase" # non-interactive
draht --thinking high "Solve this complex problem"
Inside a session, /model (or Ctrl+L) switches models and /duet starts duet mode. See the coding agent README for commands, keyboard shortcuts and settings.
Opinionated prompts for agentic engineering
draht ships prompt templates (slash commands), skills and subagent prompts that encode a specific way of working with coding agents. They are plain Markdown files, so you can read, copy or override them.
Slash commands (packages/coding-agent/prompts/commands), invoked as /name in a session:
- Project lifecycle (GSD, "Get Shit Done"):
/new-project,/init-project,/map-codebase,/discuss-phase,/plan-phase,/execute-phase,/verify-work,/next-milestone,/progress,/pause-work,/resume-work - Everyday work:
/quick,/fix(4-phase debugging protocol with TDD discipline),/review(parallel reviewer and security-auditor),/atomic-commit,/resolve-conflicts,/why(cited investigation of why code is the way it is) - Thinking and coordination:
/brainstorm,/grill,/orchestrate(dispatch specialist subagents),/orchestrate-loop(fresh subagent iterations until a deterministic check passes),/triage(classify an external issue report),/create-verification-skill
Skills (skills/ and packages/coding-agent/skills), loaded by the model when a task matches, or forced with /skill:name:
tdd-workflow: write a behavior-focused test, confirm it fails for the right reason, make the smallest complete change, then refactor. Optional. Use TDD where a regression contract helps; do not manufacture tests for docs, config or mechanical changes.ddd-workflow: optional. Model concepts, invariants and context boundaries with the project's own language. Do not add aggregates, events, repositories or adapters without a concrete need.gsd-workflow: optional. The milestone, phase, plan, task hierarchy stored in.planning/. Only used when you explicitly choose it.- Others include
debugging-workflow,verification-gate,atomic-commit,blast-radius,epistemics,typescript-disciplineandunslop.
Subagent prompts (packages/coding-agent/agents): for example, the implementer prompt asks for the smallest complete change, reading code before editing, matching existing patterns, and never silencing failing checks.
TDD, DDD and GSD are all optional; draht does not require any of them for ordinary coding. Opinions these files encode, from the files themselves: tests and verification as evidence rather than ritual, small atomic changes and commits, explicit planning artifacts when you opt in, and parallel specialist review before work is called done. Drahtbank exists to measure changes to these prompts.
The workflow skills ship both in the @draht/coding-agent npm package and in the draht-claude and draht-codex plugins.
Configuration, models and providers
- Config directory:
~/.draht/agent(override withDRAHT_CODING_AGENT_DIR). Project config lives in.draht/. - Custom providers and models:
~/.draht/agent/models.jsonfor providers that speak a supported API (OpenAI, Anthropic, Google). See models and custom providers. - Settings: settings. Environment variables: environment variables.
Packages
The table lists supported public packages, not every workspace. In particular, @draht/infra, @draht/invoice, @draht/compliance, and @draht/workflows are examples; @draht/ci, @draht/landing, and @draht/x-markdown are internal tools. They are private and excluded from public package releases.
How draht differs from pi
draht is built on pi, the coding agent by Mario Zechner, and is periodically synced with it (see .upstream-sync). pi is MIT licensed; its copyright notice is kept in this repo's LICENSE. The minimal core and the extension model come from pi.
The @draht/router and @draht/chord packages are also forks of pi code.
Differences documented in this repo:
- Renamed packages and CLI:
@draht/*packages, thedrahtcommand,~/.drahtconfig. - Duet mode, Polyphase, RLM, codemode, built-in MCP support, documented in duet.md and polyphase.md.
- Additional workflow skills, slash commands and subagent prompts (see Opinionated prompts for agentic engineering), plus Drahtbank and the Claude Code and Codex plugins.
FAQ
What is draht?
An open source AI coding agent for the terminal, installed from npm as @draht/coding-agent.
How do I install draht?
Run npx @draht/coding-agent, or npm install -g @draht/coding-agent and then draht.
Which models does draht support?
Models from the built-in providers listed under Features, plus custom providers through ~/.draht/agent/models.json.
Can I use my Claude or ChatGPT subscription instead of an API key?
Yes. Run /login and choose Anthropic Claude Pro/Max, OpenAI ChatGPT Plus/Pro (Codex), GitHub Copilot, Google Gemini CLI or Google Antigravity.
Is draht a fork of pi?
Yes. draht, including @draht/router and @draht/chord, is based on pi by Mario Zechner and keeps its MIT copyright notice.
Does draht support MCP?
Yes. draht connects to MCP servers over stdio or streamable HTTP, for example draht mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem .. See mcp.md.
Can I use draht from my own program?
Yes, through the SDK or RPC mode. See sdk.md and rpc.md.
Why is the npm package not called draht?
The name draht was already taken on npm, so the package is @draht/coding-agent. The installed command is still draht.
What is RLM in draht?
RLM (Recursive Language Models) is a draht rlm command for questions about inputs too large for a model's context window. The model writes Python that inspects the input in a sandboxed REPL instead of reading it all into the prompt. For inputs that fit in context, a normal read is faster and cheaper.
Does draht require TDD, DDD or GSD?
No. All three are optional workflows shipped with draht. GSD is a planning workflow (/new-project, /plan-phase, /execute-phase, /verify-work) with files in .planning/. tdd-workflow and ddd-workflow are skills the model loads when a task calls for them, or you force them with /skill:tdd-workflow and /skill:ddd-workflow.
Can I use draht's prompts in Claude Code or Codex?
Yes. npx draht-claude install and npx draht-codex install install the commands, subagents and workflows as plugins.
Contributing
See CONTRIBUTING.md for contribution guidelines and AGENTS.md for project-specific rules (for both humans and agents).
Development
bun install --frozen-lockfile --ignore-scripts --linker hoisted # Reproducible canonical install
npm run build # Build all packages
npm run check # Lint, format, and type check
./test.sh # Run tests (skips LLM-dependent tests without API keys)
./pi-test.sh # Run draht from sources (can be run from any directory)
Use the exact Bun canary package and revision declared by packageManager and drahtReleaseBunRevision in the root package.json. Dependency lifecycle scripts stay disabled during installation; run required build, check, and test steps explicitly.
Note:
npm run checkrequiresnpm run buildto be run first. The web-ui package usestscwhich needs compiled.d.tsfiles from dependencies.
License
MIT. See LICENSE. Copyright (c) 2026 Oskar Freye (Draht) and (c) 2025 Mario Zechner.