Compile natural-language specs into executable Prolog-style workflows with retries, branching, and tool use.
Documentation
DeepClause runtime, tools, and language docs.
DeepClause is a local-first agent system that compiles Markdown specs into DML, runs them in a Prolog-based runtime, and wraps that execution model with a fullscreen conductor TUI, a CLI, an embeddable SDK, editable system assets, and extensible tool routing.
What DeepClause ships today
DeepClause separates orchestration, execution, and guidance into distinct surfaces. The conductor owns the conversation, compiled skills do the work, recipes provide reusable workflow guidance, and the runtime stays inspectable through local files, execution logs, and editable prompt assets.
Run against the host shell by default or switch shell execution into AgentVM with --sandbox.
Override the conductor prompt, compiler prompt, and task harness from .deepclause/system/.
Keep per-session transcripts, execution logs, usage counters, recipes, and compacted memory on disk.
Feature surface
deepclause initseeds.deepclause/config.json, local tool folders, docs, system overrides, recipes, and default skills..deepclause/system/TASK_PROMPT.mdnow controls the task and prompt harness used during execution, not just the packaged default..deepclause/system/DML_COMPILER_PROMPT.mdand.deepclause/system/CONDUCTOR_PROMPT.mdlet you tune compile-time and conductor behavior locally.- The skill creator can generate helper assets under
.deepclause/tools/lib/<skill-or-tool-name>/, including per-skill.venvenvironments when Python helpers are needed. - Runtime shell execution can stay on the host or move into AgentVM; host isolation backends include clean-room,
bwrap, andsandbox-execwhen supported. - DeepClause can use built-in runtime tools and MCP-exposed tools.
deepclause list-toolsshows the resolved set. - Session and loop compaction are configurable with ordinary DML compactors bound to runtime hook points.
- Recipes live in
.deepclause/system/recipes/as searchable workflow guidance instead of executable worker code. - The conductor can answer directly, call local skills, consult recipes, create new skills, run shell tools, and delegate to research-oriented workers.
Workspace layout
.deepclause/
config.json
docs/
TUI.md
sessions/
<session-id>/
system/
CONDUCTOR_PROMPT.md
DML_COMPILER_PROMPT.md
TASK_PROMPT.md
conductor.dml
skill-creator.dml
recipes/
tools/
my-skill.dml
lib/
my-skill/
.venv/
helper.py
The fullscreen conductor interface
Running deepclause with no subcommand launches the fullscreen TUI. The left pane shows sessions,
the center pane holds the conversation, and the right side shows execution activity plus summarized context.
What the conductor does
- Loads the active session from
.deepclause/sessions/<session-id>/. - Builds a grounded system prompt from the conductor prompt, recipe library, session history, memory files, and skill catalog.
- Routes the turn to direct reasoning, an existing skill, a recipe-guided approach, or the skill creator.
- Streams child-skill activity into the execution pane and persists messages, usage, and execution logs back to disk.
Command bar inputs
| Input | Behavior |
|---|---|
plain text |
Sends a normal message to the conductor for the current session. |
/new |
Creates a fresh session. |
/sessions |
Shows or refreshes session navigation. |
/compile <spec> |
Compiles a Markdown specification into a local DML skill. |
/skill-creator <spec> |
Runs the built-in skill creator on a spec or edit request. |
/<skill> [args] |
Runs a compiled local skill directly from the TUI. |
/set-model <model> [--slot <slot>] |
Changes the model for all slots or just gateway, run, or compile. |
!<command> |
Runs an ephemeral shell command and streams output only into the execution pane. |
!!<command> |
Runs the command and appends both the command and its output to the session transcript so the conductor can see it next turn. |
/cancel |
Cancels the active shell command or child execution when possible. |
!! for shared shell state
!command is a temporary escape hatch. !!command is for shell output that should become part of the conversation state and influence the next conductor turn.
Why the TUI matters
- It keeps routing decisions in one place: the conductor, not a pile of disconnected prompts.
- It exposes execution logs and context summaries instead of hiding the runtime behind chat output alone.
- It works with the same session files and system assets as headless usage, so debugging a TUI turn and a CLI turn stays comparable.
- It is designed for local repo work: memory files, transcript files, recipes, and tools are all read from the workspace.
Headless runs, compiled skills, and embeddable execution
The CLI covers install, init, compile, run, tool introspection, model slot management, and headless conductor turns. The SDK exposes the same execution engine directly to TypeScript code.
Quick start
npm install -g deepclause-sdk
export OPENAI_API_KEY="sk-..."
deepclause init --model openai:gpt-4o
deepclause
CLI reference
| Command | Purpose |
|---|---|
deepclause init |
Seed .deepclause/ and its default config, prompts, recipes, and skills. |
deepclause compile <file.md> |
Compile one Markdown spec into DML with static analysis and LLM audit by default. |
deepclause compile-all <dir> |
Compile every Markdown spec in a directory. |
deepclause run <file.dml> [args] |
Execute a compiled skill directly. |
deepclause run -p "..." |
Compile a one-shot prompt to DML and run it immediately. |
deepclause -p "..." |
Run a single headless conductor turn with a fresh session. |
deepclause list-commands |
List compiled local skills. |
deepclause list-tools |
Show built-in runtime tools plus configured MCP tools. |
deepclause show-model |
Display resolved gateway, run, and compile model slots. |
deepclause set-model <model> |
Update all model slots or a single slot with --slot. |
Configuration and runtime knobs
providersconfigures OpenAI, Anthropic, Google, OpenRouter, or custom OpenAI-compatible endpoints.- Three model slots separate conductor routing (
gateway), worker execution (run), and compilation or skill creation (compile). shell.wrapperchooses the host isolation backend andshell.strictIsolationrequests a stricter host mode.agentvm.networkcontrols outbound network access when shell commands run with--sandbox.mcp.serversregisters external tool providers that become visible indeepclause list-tools.compaction.bindingsattaches DML compactors to hooks such asbefore_user_messageandbefore_model_call.
SDK entry points
import { createDeepClause } from 'deepclause-sdk';
const dc = await createDeepClause({
model: 'gpt-4o',
apiKey: process.env.OPENAI_API_KEY,
streaming: true,
});
for await (const event of dc.runDML(code, {
args: ['report.md'],
params: { max_results: 5, mode: 'brief' },
workspacePath: process.cwd(),
initialMessages: [
{ role: 'user', content: 'Use the repo conventions in memory.' },
],
})) {
console.log(event.type, event.content ?? '');
}
await dc.dispose();
Run options
runDML() accepts positional args, named params, workspacePath, gasLimit, initialMessages, compaction, onUserInput, and signal.
Extensibility
The SDK can registerTool(), setToolPolicy(), clearToolPolicy(), inspect tools with getTools(), and introspect memory with getMemory().
SDK event stream
| Event type | Meaning |
|---|---|
output, stream, answer |
Progress updates, streamed LLM text, and the final committed answer. |
tool_call |
Lifecycle updates for an external tool call, including backend, pid, exit code, and result. |
usage |
Token accounting for an LLM call. |
memory_compaction |
Compaction hook activity, including whether the binding was applied, skipped, or failed. |
input_required, error, finished |
User-input requests, runtime failures, and terminal completion metadata. |
Use the docs in two modes
The docs landing page is now paired with a dedicated examples page and a type-shaped SDK API reference. Use the examples page when you want runnable commands and the API page when you want exact option and event surfaces.
Examples guide
Validated commands for sdk-examples/, no-key smoke checks, and guidance on which sample to run first.
SDK API reference
Constructor, methods, run options, compile options, tool contracts, compaction types, and event fields.
The language surface behind compiled skills
DML is a Prolog-flavored language for agent orchestration. It mixes normal logic programming with LLM calls, runtime tools, backtracking, recursion, and scoped tool exposure. The reference page below tracks the current runtime, including the modern task harness and the actual built-in task-loop tools.
Entry points
agent_main is the required entry point. The runtime dispatches arities /0 through /3.
LLM calls
task() uses accumulated memory. prompt() runs with fresh memory. Both support typed outputs.
Direct execution
exec() calls built-in and MCP tools directly for deterministic work such as shell commands, fetches, and searches.
Task-loop tools
The core loop exposes finish(success) and set_result(variable, value), plus any tool wrappers available in scope.
tool(search(Query, Results), "Search the web for information") :-
exec(web_search(query: Query), Results).
agent_main(Topic) :-
system("You are a careful researcher."),
task("Research {Topic} and store a concise summary.", Summary),
prompt("Critique this summary: {Summary}", Critique),
answer(Critique).
agent_main, task, prompt, exec, tool wrappers, param, interpolation,
helper files, control flow, memory predicates, and common mistakes.