← all repositories
Hmbown/CodeWhale

A coding agent with a written Constitution

CodeWhale wraps DeepSeek V4 in a formal hierarchy of rules so the model knows which instruction wins when everything conflicts.

CodeWhale
Velocity · 7d
+268
★ / day
Trend
steady
star history

What it does

CodeWhale is a terminal-native coding agent built in Rust around DeepSeek V4. It streams reasoning blocks, edits your local workspace behind approval gates, and can auto-select model and thinking depth per turn. The dispatcher codewhale command hands off to a codewhale-tui companion binary for the interactive ratatui session.

The interesting bit

The project treats prompt authority as a jurisdiction problem. It ships a “Constitution” (prompts/base.md) — a formal nine-tier hierarchy of law where user intent outranks stale instructions, live tool output outranks assumptions, and verification outranks confidence. DeepSeek V4’s prefix caching makes this cheap after the first turn (the README claims ~100× cost reduction once cached), so the model can reference its own rulebook recursively rather than memorizing it.

Key highlights

  • Auto mode routes each turn through a cheap deepseek-v4-flash call to pick model (Flash vs Pro) and thinking level (off/high/max) before the real request
  • Sub-agents run concurrently (default 10, up to 20) with non-blocking launch; parents get completion sentinels and bounded transcript handles
  • Every turn snapshots the workspace to a side-git repo; /restore or revert_turn rolls back
  • LSP diagnostics (rust-analyzer, pyright, tsserver, gopls, clangd, jdtls, vue) feed back into context after edits
  • Sandboxing: macOS Seatbelt active; Linux Landlock detected but not yet enforced; Windows “not yet advertised”

Caveats

  • Requires Rust 1.88+ if building from source (2024 edition); older toolchains hard-fail
  • Homebrew formula still uses the legacy deepseek-tui name; README calls this “legacy compatibility only”
  • DeepSeek API key required; no local model support mentioned

Verdict

Worth a look if you want a terminal-first agent with explicit, inspectable reasoning rules and don’t mind paying per-turn API costs. Skip if you need fully offline operation or mature Windows/Linux sandboxing.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.