Documentation.
Install the CLI, connect a model provider, manage sessions, and add your own prompts, skills, themes, or extensions.
1. Installation
Draht requires Bun (v1.1+). Install globally:
Or run without installing:
Verify the installation:
2. First run
Set up an API key and start Draht:
Or use an existing subscription (Claude Pro/Max, ChatGPT Plus/Pro, Copilot, Gemini CLI):
Draht gives the model four tools by default: read, bash, edit, and write. Type a request and the model uses these to fulfill it.
3. Providers & models
Draht supports 42 providers via the @draht/ai package, carrying 1,529 chat models in the regenerated catalog. Each provider's model list is updated with every release.
Subscriptions (OAuth)
- Anthropic Claude Pro / Max
- OpenAI ChatGPT Plus / Pro (Codex)
- GitHub Copilot
- Google Gemini CLI
- Google Antigravity
API keys
- Anthropic
- OpenAI
- Azure OpenAI
- Google Gemini
- Google Vertex
- Amazon Bedrock
- Mistral
- Groq
- Cerebras
- xAI
- OpenRouter
- Vercel AI Gateway
- ZAI
- Hugging Face
- Kimi For Coding
- MiniMax
Switching models
Custom providers
Add providers via ~/.draht/agent/models.json if they speak a supported API (OpenAI, Anthropic, Google). For custom APIs or OAuth, use extensions.
Virtual models
An extension can register a virtual model: a selectable entry that picks a physical model for each request, for example to send quick questions to a small model and hard problems to a large one. It shows up in /model, --model, and settings like any other model; providers only ever receive the physical model.
Prompt cache warming
An idle session periodically re-sends its cached prefix so the next turn doesn't pay a cold-cache penalty. Tune retention with DRAHT_CACHE_RETENTION.
4. Interactive mode
The Draht TUI from top to bottom:
- Startup header — shortcuts, loaded AGENTS.md files, prompt templates, skills, extensions
- Messages — your messages, assistant responses, tool calls and results
- Editor — where you type; border color indicates thinking level
- Footer — working directory, session, token usage, cost, model
Editor features
| Feature | How |
|---|---|
| File reference | Type @ to fuzzy-search project files |
| Path completion | Tab to complete paths |
| Multi-line | Shift+Enter |
| Images | Ctrl+V to paste, or drag onto terminal |
| Bash commands | !command runs and sends output to LLM |
Key commands
| Command | Description |
|---|---|
/login, /logout | OAuth authentication |
/model | Switch models |
/settings | Thinking level, theme, message delivery |
/resume | Pick from previous sessions |
/new | Start a new session |
/tree | Navigate session tree |
/compact | Compress context window |
/copy | Copy last response to clipboard |
/export | Export session to HTML |
/share | Upload as private GitHub gist |
/thinking | Change the reasoning effort level mid-session |
/bug | Build a bug report (version, settings, provider errors, no API keys) and export it as a zip. Upload to the draht maintainers is planned but not live yet. |
Keyboard shortcuts
| Key | Action |
|---|---|
| Ctrl+C | Clear editor (twice to quit) |
| Escape | Cancel / abort (twice for /tree) |
| Ctrl+L | Model selector |
| Ctrl+P | Cycle scoped models |
| Shift+Tab | Cycle thinking level |
| Ctrl+O | Collapse / expand tool output |
| Ctrl+T | Collapse / expand thinking blocks |
| Ctrl+G | External editor |
Message queue
Submit messages while the agent is working:
- Enter — queues a steering message (interrupts remaining tools)
- Alt+Enter — queues a follow-up (delivered after agent finishes)
- Escape — aborts and restores queued messages
- Alt+Up — retrieves queued messages back to editor
5. Sessions & branching
Sessions auto-save as JSONL files with a tree structure. Each entry has an id and parentId, enabling in-place branching without creating new files.
Branching
/tree — navigate the session tree in-place. Select any previous point and continue from there. Search by typing, page with arrows. Filter modes with Ctrl+O. Press l to label entries as bookmarks.
/fork — create a new session file from the current branch point.
Compaction
Long sessions exhaust context windows. Compaction summarizes older messages while keeping recent ones.
- Manual:
/compactor/compact <instructions> - Automatic: triggers on context overflow or when approaching the limit
Compaction is lossy. The full history remains in the JSONL file; use /tree to revisit.
6. Context files
Draht loads AGENTS.md (or CLAUDE.md) at startup from:
~/.draht/agent/AGENTS.md— global- Parent directories (walking up from cwd)
- Current directory
Use these for project instructions, conventions, and common commands. All matching files are concatenated into the system prompt.
System prompt
Replace the default system prompt with .draht/SYSTEM.md (project) or ~/.draht/agent/SYSTEM.md (global). Append without replacing via APPEND_SYSTEM.md.
7. Prompt templates
Reusable prompts as Markdown files. Type /name to expand.
Place in ~/.draht/agent/prompts/, .draht/prompts/, or a Draht package.
8. Skills
On-demand capability packages following the Agent Skills standard. Invoke via /skill:name or let the agent load them automatically based on trigger descriptions.
Skill directories searched: ~/.draht/agent/skills/, ~/.agents/skills/, .draht/skills/, .agents/skills/ (walking up from cwd).
9. Extensions
TypeScript modules that extend Draht with custom tools, commands, keyboard shortcuts, event handlers, and UI components.
What extensions can do
- Custom tools (or replace built-in tools entirely)
- Sub-agents and plan mode
- Custom compaction and summarization
- Permission gates and path protection
- Custom editors and UI components
- Status lines, headers, footers
- Git checkpointing and auto-commit
- SSH and sandbox execution
MCP and codemode are built in — see §15 and §14 — not something an extension needs to add.
Place in ~/.draht/agent/extensions/, .draht/extensions/, or a Draht package.
10. Themes
Built-in: dark, light. Themes hot-reload: modify the active theme file and Draht immediately applies changes.
Place custom themes in ~/.draht/agent/themes/, .draht/themes/, or a Draht package.
11. Draht packages
Bundle and share extensions, skills, prompts, and themes via npm or git.
Use -l for project-local installs. Packages install to ~/.draht/agent/git/ (git) or global npm.
Creating a package
Add a draht key to package.json:
12. SDK & programmatic usage
Embed Draht in your own apps or scripts:
RPC mode
For non-Node.js integrations, use RPC mode over stdin/stdout:
13. Model router
Role-based model selection with ordered fallback chains. Direct API calls — no OpenRouter in the hot path.
Roles (architect, implement, boilerplate, quick, review, docs) map to a primary model with fallbacks, configured in .draht/router.json (project) or ~/.draht/router.json (global).
14. Codemode
For tasks that benefit from loops or branching over many tool results, the model can write a script against the active tool set instead of calling tools one at a time. The script runs in a QuickJS sandbox; nested tool calls and their results stay inside the script's execution and never enter the model's context — only the script's own output comes back.
Scripts can call every active direct, codemode, or deferred tool, carry state across calls with store()/load(), and reach the model catalog through models.*. See packages/codemode and packages/coding-agent/src/extensions/codemode.
15. MCP
A built-in Model Context Protocol client — no extension required. draht mcp configures servers and signs in to OAuth servers outside a session; running sessions pick up new credentials on their next turn.
Reads ~/.draht/agent/mcp.json (global) and, in trusted projects, .draht/mcp.json. MCP tools are exposed through codemode by default (--exposure also accepts deferred, direct, or hidden).
16. GSD workflow & built-in commands
Draht includes the GSD (Get Shit Done) workflow: slash commands, specialist subagents, and bundled skills for planning and shipping projects with TDD and DDD. The workflow is built in; it needs no separate installation.
Project lifecycle
| Command | Use |
|---|---|
/new-project <idea> | Greenfield: questioning → domain model → requirements → roadmap |
/init-project <goal> | Existing codebase: map → extract domain → roadmap |
/map-codebase | Standalone codebase analysis (parallel architect + verifier subagents) |
/next-milestone | Plan the next milestone after all current phases are verified |
Per-phase cycle
| Command | Use |
|---|---|
/discuss-phase N | Capture decisions and gray areas |
/plan-phase N | Atomic execution plans (parallel architect subagents) |
/execute-phase N | TDD red→green→refactor (parallel implementer subagents) |
/verify-work N | Parallel verifier + security-auditor + reviewer + quality gate |
Session continuity
| Command | Use |
|---|---|
/pause-work | Create handoff document |
/resume-work | Read handoff, verify state, continue |
/progress | Show current position in the roadmap |
Ad-hoc
| Command | Use |
|---|---|
/quick <task> | Small tracked task with TDD cycle |
/fix <bug> | Diagnose → reproducing test → minimal fix (debugger + implementer subagents) |
/review [scope] | Parallel code review + security audit |
/atomic-commit | Analyze diff, split into atomic conventional commits |
/orchestrate <task> | Decompose work and dispatch the right mix of specialist subagents |
Specialist subagents
All seven are invokable through the built-in subagent tool. Use /agent <name> to route your prompts through one, or call them directly via the tool with { agent, task }, { tasks: [...] } for parallel, or { chain: [...] } for sequential pipelines.
| Agent | Use |
|---|---|
architect | Reads codebase, produces structured implementation plans |
implementer | Writes code following TDD cycle from plan tasks |
reviewer | Reviews changes for correctness, types, conventions, domain language |
debugger | Reproduces and diagnoses bugs to root cause |
verifier | Runs lint + typecheck + tests, reports results without fixing |
git-committer | Stages and commits with conventional commit messages |
security-auditor | Scans for injection, auth, secrets, unsafe patterns |
Workflow skills
Auto-loaded when relevant; also invokable as /skill:<name>:
gsd-workflow— complete GSD methodology reference (directory structure, cycle, hooks, config)tdd-workflow— red→green→refactor discipline, commit conventions, cycle violationsddd-workflow— bounded contexts, ubiquitous language, aggregates, domain events
Quick start — greenfield
Draht asks about the problem, audience, and MVP scope, then generates .planning/PROJECT.md, .planning/DOMAIN.md, .planning/TEST-STRATEGY.md, .planning/REQUIREMENTS.md, .planning/ROADMAP.md, and .planning/STATE.md.
Quick start — existing codebase
Per-phase cycle in practice
Run /new between steps. Each cycle step is designed to start with a clean context.
Pause and resume
Configuration
Tune the workflow hooks via .planning/config.json:
tddMode: "strict"aborts ongreen:commits without a precedingred:;"advisory"logs a warningqualityGateStrict: truefails the gate on any lint/type/test/coverage misscoverageThreshold— minimum coverage percent required by the quality gate
Override a built-in
All commands ship as Markdown templates. Drop a same-named file into ~/.draht/agent/prompts/ or .draht/prompts/ to override the built-in for your user or for the project.
Also available in Claude Code
The same workflow ships as a Claude Code plugin via draht-claude: npx draht-claude install.
17. CLI reference
Basic usage
Modes
| Flag | Description |
|---|---|
(default) | Interactive mode |
-p, --print | Print response and exit |
--mode json | Output all events as JSON lines |
--mode rpc | RPC mode for process integration |
--export <in> [out] | Export session to HTML |
Model options
| Option | Description |
|---|---|
--provider <name> | Provider (anthropic, openai, google, etc.) |
--model <pattern> | Model pattern or ID (supports provider/id) |
--api-key <key> | API key (overrides env vars) |
--thinking <level> | off, minimal, low, medium, high, xhigh |
--models <patterns> | Comma-separated patterns for Ctrl+P cycling |
--list-models [search] | List available models |
Session options
| Option | Description |
|---|---|
-c, --continue | Continue most recent session |
-r, --resume | Browse and select session |
--session <path> | Use specific session file or partial UUID |
--no-session | Ephemeral mode (don't save) |
Tool & resource options
| Option | Description |
|---|---|
--tools <list> | Enable specific built-in tools (default: read,bash,edit,write) |
--no-tools | Disable all built-in tools |
-e, --extension <source> | Load extension (repeatable) |
--no-extensions | Disable extension discovery |
--skill <path> | Load skill (repeatable) |
--no-skills | Disable skill discovery |
File arguments
Prefix files with @ to include in the message:
Environment variables
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | Anthropic API key |
OPENAI_API_KEY | OpenAI API key |
GOOGLE_API_KEY | Google Gemini API key |
DRAHT_CODING_AGENT_DIR | Override config directory |
DRAHT_SKIP_VERSION_CHECK | Skip version check at startup |
VISUAL, EDITOR | External editor for Ctrl+G |