Documentation

From zero to hero with Draht.

1. Installation

Draht requires Bun (v1.1+). Install globally:

bun add -g @draht/coding-agent

Or run without installing:

bunx @draht/coding-agent

Verify the installation:

draht --version

2. First Run

Set up an API key and start Draht:

Set your API key (Anthropic, OpenAI, Google, etc.)
export ANTHROPIC_API_KEY=sk-ant-...
Start draht in your project directory
cd my-project
draht

Or use an existing subscription (Claude Pro/Max, ChatGPT Plus/Pro, Copilot, Gemini CLI):

draht
/login

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)

API Keys

Switching Models

Interactive model selector
Ctrl+L
Cycle through scoped models
Ctrl+P / Shift+Ctrl+P
From CLI
draht --model openai/gpt-4o "Help me refactor"
draht --model sonnet:high "Complex problem"

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:

Editor Features

FeatureHow
File referenceType @ to fuzzy-search project files
Path completionTab to complete paths
Multi-lineShift+Enter
ImagesCtrl+V to paste, or drag onto terminal
Bash commands!command runs and sends output to LLM

Key Commands

CommandDescription
/login, /logoutOAuth authentication
/modelSwitch models
/settingsThinking level, theme, message delivery
/resumePick from previous sessions
/newStart a new session
/treeNavigate session tree
/compactCompress context window
/copyCopy last response to clipboard
/exportExport session to HTML
/shareUpload as private GitHub gist

Keyboard Shortcuts

KeyAction
Ctrl+CClear editor (twice to quit)
EscapeCancel / abort (twice for /tree)
Ctrl+LModel selector
Ctrl+PCycle scoped models
Shift+TabCycle thinking level
Ctrl+OCollapse / expand tool output
Ctrl+TCollapse / expand thinking blocks
Ctrl+GExternal editor

Message Queue

Submit messages while the agent is working:

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.

draht -c
Continue most recent session
draht -r
Browse and select from past sessions
draht --no-session
Ephemeral mode (don't save)

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.

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:

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.

~/.draht/agent/prompts/review.md
Review this code for bugs, security issues, and performance.
Focus on: {{focus}}

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.

~/.draht/agent/skills/my-skill/SKILL.md
# My Skill
Use this skill when the user asks about X.
## Steps
1. Do this
2. Then that

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.

export default function (draht: ExtensionAPI) {
draht.registerTool({ name: "deploy", ... });
draht.registerCommand("stats", { ... });
draht.on("tool_call", async (event, ctx) => { ... });
}

What extensions can do

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.

draht install npm:@foo/draht-tools
draht install git:github.com/user/repo
draht install https://github.com/user/repo
draht remove npm:@foo/draht-tools
draht list
draht update
draht config

Use -l for project-local installs. Packages install to ~/.draht/agent/git/ (git) or global npm.

Security: Draht packages run with full system access. Extensions execute arbitrary code, and skills can instruct the model to perform any action. Review source code before installing third-party packages.

Creating a Package

Add a draht key to package.json:

{
"name": "my-draht-package",
"keywords": ["draht-package"],
"draht": {
"extensions": ["./extensions"],
"skills": ["./skills"],
"prompts": ["./prompts"],
"themes": ["./themes"]
}
}

12. SDK & Programmatic Usage

Embed Draht in your own apps or scripts:

import { createAgentSession, SessionManager } from "@draht/coding-agent";
const { session } = await createAgentSession({
sessionManager: SessionManager.inMemory(),
});
await session.prompt("What files are in this directory?");

RPC Mode

For non-Node.js integrations, use RPC mode over stdin/stdout:

draht --mode rpc

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.

draht router show
draht router set architect anthropic/claude-opus-4-6
draht router set boilerplate deepseek/deepseek-coder

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.

draht invoice create --client "Acme GmbH" --hours 40
draht invoice send --id INV-2026-042
draht toggl sync

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.

draht compliance scan
draht compliance report

16. Deploy Guardian Under Construction

Pre-deploy validation and rollback automation. Runs checks before deployment and automatically rolls back on failure.

draht deploy check
draht deploy push --stage production

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.

draht init
draht create-project "My App"
draht create-requirements
draht create-domain-model
draht create-roadmap

18. CLI Reference

Basic Usage

draht [options] [@files...] [messages...]

Modes

FlagDescription
(default)Interactive mode
-p, --printPrint response and exit
--mode jsonOutput all events as JSON lines
--mode rpcRPC mode for process integration
--export <in> [out]Export session to HTML

Model Options

OptionDescription
--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

OptionDescription
-c, --continueContinue most recent session
-r, --resumeBrowse and select session
--session <path>Use specific session file or partial UUID
--no-sessionEphemeral mode (don't save)

Tool & Resource Options

OptionDescription
--tools <list>Enable specific built-in tools (default: read,bash,edit,write)
--no-toolsDisable all built-in tools
-e, --extension <source>Load extension (repeatable)
--no-extensionsDisable extension discovery
--skill <path>Load skill (repeatable)
--no-skillsDisable skill discovery

File Arguments

Prefix files with @ to include in the message:

draht @prompt.md "Answer this"
draht -p @screenshot.png "What's in this image?"
draht @code.ts @test.ts "Review these files"

Environment Variables

VariableDescription
ANTHROPIC_API_KEYAnthropic API key
OPENAI_API_KEYOpenAI API key
GOOGLE_API_KEYGoogle Gemini API key
DRAHT_CODING_AGENT_DIROverride config directory
DRAHT_SKIP_VERSION_CHECKSkip version check at startup
VISUAL, EDITORExternal editor for Ctrl+G