draht logo draht   /dʁaːt/
· built in Dortmund · MIT N° 001 / MONOREPO · 14 PACKAGES HANDGEFERTIGT — OSKAR FREYE, MMXXVI
Handbuch · Reference and setup

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:

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

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.

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

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
/thinkingChange the reasoning effort level mid-session
/bugBuild 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

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:

  • 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.

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.

  • Manual: /compact or /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.

~/.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

  • 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.

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

Role-based model selection with ordered fallback chains. Direct API calls — no OpenRouter in the hot path.

draht router show
draht router set implement anthropic/claude-sonnet-4-6 --fallback openai/gpt-5.2,deepseek/deepseek-v3
draht router test
draht router cost

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.

draht mcp add server --url https://example.com/mcp
draht mcp add server -- npx -y some-mcp-server
draht mcp list
draht mcp login server
draht mcp logout server

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

CommandUse
/new-project <idea>Greenfield: questioning → domain model → requirements → roadmap
/init-project <goal>Existing codebase: map → extract domain → roadmap
/map-codebaseStandalone codebase analysis (parallel architect + verifier subagents)
/next-milestonePlan the next milestone after all current phases are verified

Per-phase cycle

CommandUse
/discuss-phase NCapture decisions and gray areas
/plan-phase NAtomic execution plans (parallel architect subagents)
/execute-phase NTDD red→green→refactor (parallel implementer subagents)
/verify-work NParallel verifier + security-auditor + reviewer + quality gate

Session continuity

CommandUse
/pause-workCreate handoff document
/resume-workRead handoff, verify state, continue
/progressShow current position in the roadmap

Ad-hoc

CommandUse
/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-commitAnalyze 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.

AgentUse
architectReads codebase, produces structured implementation plans
implementerWrites code following TDD cycle from plan tasks
reviewerReviews changes for correctness, types, conventions, domain language
debuggerReproduces and diagnoses bugs to root cause
verifierRuns lint + typecheck + tests, reports results without fixing
git-committerStages and commits with conventional commit messages
security-auditorScans 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 violations
  • ddd-workflow — bounded contexts, ubiquitous language, aggregates, domain events

Quick start — greenfield

draht
/new-project a team calendar with slot-based booking

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

draht
/init-project refactor the billing module

Per-phase cycle in practice

/discuss-phase 1
capture decisions
/new
/plan-phase 1
parallel architect subagents produce atomic plans
/new
/execute-phase 1
parallel implementer subagents run TDD cycles
/new
/verify-work 1
parallel verifier + security + reviewer + quality gate

Run /new between steps. Each cycle step is designed to start with a clean context.

Pause and resume

/pause-work
creates .planning/CONTINUE-HERE.md
/resume-work
reads handoff, checks state, continues

Configuration

Tune the workflow hooks via .planning/config.json:

{
"hooks": {
"coverageThreshold": 80,
"tddMode": "advisory",
"qualityGateStrict": false
}
}
  • tddMode: "strict" aborts on green: commits without a preceding red:; "advisory" logs a warning
  • qualityGateStrict: true fails the gate on any lint/type/test/coverage miss
  • coverageThreshold — 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

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
© MMXXVI Oskar Freye · MIT licensed · set in Instrument Serif & Geist Mono · Dortmund · Gemeinnützig im Geist