KruschStack (krusch-stack)
krusch-stack (v1.3.1) is a local, zero-cloud control plane for AI coding agents (Claude Code, Cursor, Windsurf, Antigravity, Codex). It gives your agent persistent cross-session memory, Turn-0 workspace grounding, spin-loop protection, and two-phase commit (2PC) file safety backed by Node 22 native node:sqlite.
⚡ 30-Second Value Demo & Progressive Quickstart (Zero API Keys, Zero Docker)
Run the offline 3-act walkthrough in <1s inside an isolated temporary SQLite workspace before touching any project files:
npx krusch-stack demo
KruschStack v1.3.0 -- 3-Act Zero-Cloud Control Plane Walkthrough (<1s, node:sqlite WAL)
[Act 1] Cross-Session Memory
Session 1 saved invariant #1 ("Never use eval() in payment modules" @ src/pay.js)
Session 2 cold-restarted -> hydrated invariant #1 (SHA-256 drift_status: VALID)
[Act 2] Unsafe Edit, Spin-Loop & Output Defect Refusal
1. Proposed eval(payload) edit -> BLOCKED_INVARIANT (0 bytes written to disk)
2. Repeated failing tool call -> BLOCK_SPIN_LOOP (0 duplicate executions)
3. Emitted raw np.float64(0.015) -> REJECT_OUTPUT_DEFECT (caught before user reply)
[Act 3] Verified 2PC Atomic Apply
Staged unified diff -> write-ahead journal -> POSIX atomic rename -> APPLIED (src/pay.js)
Result: PASS (3/3 acts verified offline in 48ms)
Install Into Your Workspace
# 1. Configure Claude Code, Cursor, Windsurf & Antigravity (defaults to lean 19-tool coding-agent profile)
npx krusch-stack init
# 2. Verify Node >= 22, SQLite WAL health, and all 21 control-plane tables
npx krusch-stack doctor
# 3. Inspect any recent block, memoized read, or 2PC commit ("Why did the agent block that?")
npx krusch-stack explain
Prefer letting your coding agent set it up for you? Paste this prompt into Claude Code, Codex, Cursor, Windsurf, or Antigravity:
Read https://raw.githubusercontent.com/kruschdev/krusch-stack/main/INSTALL.md and set up krusch-stack on this machine.
Opinionated Profiles (Pick Only What You Need)
| Profile Flag |
Tools Exposed |
Approx. Schema Budget |
Best For & Included Capabilities |
--profile memory-only |
5 tools |
~350 tokens |
Persistent Memory Only: Decisions, invariants, pre-commit nudge, and SHA-256 line-span drift checks (krusch-context-mcp). |
--profile coding-agent |
19 tools (Default for init) |
~1,450 tokens |
Daily Coding Agents: Persistent memory + AST symbol/call-graph search (krusch-git) + 2PC staged file harness (+ krusch-grounded-harness in --modular mode). |
--profile core |
27 tools |
~2,100 tokens |
Backend & Systems Engineering: Adds bounded OS PageMemory (krusch-fs) and <25µs L1-L3 Cascade Router. |
--profile full |
39 tools (Default for mcp/serve) |
~3,100 tokens (~600 w/ --defer-tools) |
Full Ecosystem: Adds Frontend Design templates and Workspace Docs RAG (--include-extended or --modular adds the 23 extension tools; --defer-tools compresses any profile by -80.67% schema tokens via BM25 deferral). |
Need custom composition or Docker? Use npx krusch-stack mcp --components context,git,harness, npx krusch-stack init --modular (dedicated per-pillar MCP entries), or docker compose up -d (http://127.0.0.1:3780/health + companion PostgreSQL 16 db/init.sql).
📘 Focused 3-Minute Guides & Community:
🎬 Optional Watch: 100-Second Narrated Product Tour (1080p)

▶️ Stream 1080p HD Product Tour (01:40, with audio) | Interactive Player on krusch.dev | Local MP4 | WebM | Closed Captions (.srt)
🩹 Before vs. After: Three Agent Failure Modes Fixed
1. Agent Amnesia & Stale Rules
- Before (
CLAUDE.md / Stateless Chat): Your agent forgets last week's architectural constraint in a new session, or blindly follows an outdated rule in CLAUDE.md long after the underlying function moved or was refactored.
- After (
krusch-context-mcp): krusch_context_retrieve hydrates token-budgeted decisions and invariants at Turn 1, verifies anchored code spans via SHA-256 (VALID, HEALED_LINE_SHIFT, or STALE_DRIFT), and tracks explicit supersession lineage via krusch_context_revise.
2. Unsafe Direct File Writes & Torn Multi-File Edits
- Before (Unchecked
write_file): Your agent overwrites 4 files directly on disk, introduces a banned pattern or breaks imports, and leaves a half-written repository if the process crashes or hits a timeout mid-edit.
- After (
krusch-harness 2PC): krusch_run audits proposed edits against active invariants (krusch_context_nudge) before touching disk and stages a unified diff in SQLite. krusch_apply_diff commits changes through a <32ms write-ahead journal (harness_apply_journal) and POSIX atomic rename with automatic SIGKILL startup rollback.
3. Tool Spam, Spin Loops & CSV "NA" Traps
- Before (Raw Tool Loop): A local or cloud model burns 15 turns re-reading the same file with identical arguments, misparses literal
"NA" (North America) in a CSV as NaN, or leaks np.float64(0.015) / unresolved placeholders into its final answer.
- After (
grounded-harness): Injects zero-LLM Turn-0 workspace schema hazards (keep_default_na=False, JSON null/[] wildcards, SQLite DDL), memoizes repeat reads (MEMOIZED_PRIOR_READ), blocks spin loops in 0 re-executions (BLOCK_SPIN_LOOP), and gates objective output defects (REJECT_OUTPUT_DEFECT) while costing 0 extra turns when clean.
🧩 Adopt One Piece Without the Rest (Zero Ecosystem Lock-In)
You do not have to buy into all 10 pillars to use krusch-stack. Every subsystem ships as an independent MIT repository and as an isolated ESM subpath export:
| Capability Needed |
Standalone Repository |
Single-Piece CLI or ESM Import via krusch-stack |
Persistent Memory Only (5 MCP verbs) |
kruschdev/krusch-context-mcp |
npx krusch-stack mcp --profile memory-only |
| Turn-0 Grounding & Spin-Loop Gate |
kruschdev/grounded-harness |
import { createGroundedHarnessEngine } from 'krusch-stack/grounded-harness' |
| 2PC File & Tool-Action Harness |
kruschdev/krusch-coding-harness |
import { createActionHarnessEngine } from 'krusch-stack/action-harness' |
| Reusable Runtime Bricks (Node/TS & Python) |
kruschdev/toolkit |
@krusch/toolkit (40 JS/TS bricks) & krusch_toolkit (Python 3.11+) |
🏗️ Architecture: Deterministic Control Plane vs. Interchangeable LLM
krusch-stack keeps state, safety invariants, schema hazards, and atomic file commits inside a deterministic local database (node:sqlite WAL by default, with 21-table PostgreSQL 16 + pgvector DDL parity in db/init.sql), so you can swap local open-weights models and frontier cloud APIs without losing memory or safety guarantees:
IDE / Agent Host (Claude Code, Cursor, Windsurf, Antigravity, Codex, HTTP Client)
│
▼
┌───────────────────────────────────────────────────────────────────────────────────┐
│ DETERMINISTIC LOCAL CONTROL PLANE (SQLite WAL / PostgreSQL 16 DDL) │
│ │
│ ┌─────────────────────────┐ ┌─────────────────────────┐ ┌───────────────────┐ │
│ │ 1. Working Memory │ │ 2. AST & Graph Context │ │ 3. Grounded Gate │ │
│ │ • Invariants & lineage │ │ • Symbol & call graphs │ │ • Turn-0 schemas │ │
│ │ • SHA-256 span drift │ │ • Bounded OS PageMemory │ │ • Spin-loop block │ │
│ │ • git blame co-change │ │ • Temporal ADR graph │ │ • Defect-only gate│ │
│ └─────────────────────────┘ └─────────────────────────┘ └───────────────────┘ │
│ ┌─────────────────────────────────────────┐ ┌────────────────────────────────┐ │
│ │ 4. Two-Phase Commit (2PC) Harness │ │ 5. Observability & Routing │ │
│ │ • Pre-disk invariant nudge │ │ • `explain` & `GET /telemetry` │ │
│ │ • <32ms write-ahead journal + rename │ │ • <25µs L1-L3 Cascade Router │ │
│ └─────────────────────────────────────────┘ └────────────────────────────────┘ │
└────────────────────────────────────────┬──────────────────────────────────────────┘
│ Bounded prompts + verified tool calls
▼
┌───────────────────────────────────────────────────────────────────────────────────┐
│ INTERCHANGEABLE LLM WORKER │
│ Local 12-48 GB Ollama (`$0.00`: Gemma 4 31B, Qwen3-Coder 30B MoE, 7B/8B) │
│ or Frontier Cloud API (Gemini 4 Argon, Claude, GPT, DeepSeek, OpenRouter) │
└───────────────────────────────────────────────────────────────────────────────────┘
Complete 10-Pillar Reference Table
| Capability (Internal Module Name) |
Standalone Repo |
Key Tools & Subpath Surfaces |
Default Storage |
Persistent Working Memory & Git Alignment (krusch-context-mcp) |
krusch-context-mcp |
krusch_context_retrieve, remember, revise, nudge (git blame -w -M + co-change), health (krusch-stack/git-alignment) |
node:sqlite (db/init.sql PG parity) |
Codebase AST & Call-Graph Search (krusch-git) |
krusch-git |
krusch_git_search_symbols, file_symbols, dependency_graph, semantic_search (2-hop git_edges bridge), read_tree, read_blob, list_repos |
node:sqlite (db/init.sql PG parity) |