Documentation
From zero to hero with Draht.
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 17+ providers via the @draht/ai package. 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.
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 |
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 server integration
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 Under Construction
Role-based model selection with automatic fallback. Architect tasks use Claude Opus, boilerplate uses DeepSeek. Direct API calls with no OpenRouter latency.
The router inspects task characteristics (complexity, domain, cost sensitivity) and routes to the appropriate model. Fallback chains ensure availability.
14. Invoicing Under Construction
Lexoffice API integration for German invoicing. Toggl time tracking. Generate invoices from your terminal.
Built for German freelancers: proper VAT handling, Lexoffice sync, and legally compliant invoice templates.
15. Compliance Under Construction
Automated compliance checks for GDPR and EU AI Act requirements.
- GDPR PII scanner — detects personal data in code and config
- EU AI Act documentation — checks required documentation for AI systems
- German legal templates — Impressum, Datenschutzerklaerung, AGB
16. Deploy Guardian Under Construction
Pre-deploy validation and rollback automation. Runs checks before deployment and automatically rolls back on failure.
17. Orchestrator Under Construction
Multi-agent task decomposition using the GSD (Get Shit Done) methodology. Breaks complex projects into phases, then decomposes phases into tasks for parallel execution.
18. 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 |