Context Foundry

A self-hosted build loop that runs AI agents against your codebase and improves them over time.

Rust CLI · v0.6.1 · MIT License

What it does

Context Foundry takes a task queue (TASKS.md) and processes each task through a four-stage pipeline:

Scout reads the codebase -- file structure, imports, existing patterns -- and writes a report of what exists and what matters for the current task.

Plan reads the scout report and writes a step-by-step implementation plan with exact file operations, function signatures, and verification commands.

Implement executes the plan: creates and modifies files, runs the build, runs tests, and records what it claims to have done in build-claims.md.

Doubt is a fresh-context reviewer that audits the builder's claims against the actual code. It reads build-claims.md, re-runs verification, and fixes issues it finds. If everything passes, the task ships as a git commit.

Input: a task description. Output: a verified git commit.

How it works

TASKS.md Scout Plan Implement Doubt git commit patterns

After each successful task, the system extracts patterns -- recurring issues and their solutions -- and stores them as JSON. Before planning the next task, matching patterns are injected into the planner's context. The more tasks it completes, the fewer mistakes the reviewer catches.

The builder stage can run two models in parallel (e.g., Claude and Codex) in isolated git worktrees. The fastest passing build wins. If one model rate-limits or fails, the other continues. You configure this with builder_models in .foundry.json.

Why it matters

Pattern learning. Most AI coding tools treat every task as if it's the first. Context Foundry accumulates institutional knowledge -- patterns extracted from past builds are fed back into future plans. The system gets better at your codebase over time.

Dual-model arena. Run two different models against the same task. Compare outputs. Pick the winner automatically or manually. No single-vendor lock-in.

Self-hosted, CLI-native. Rust binary with a TUI. Your code stays on your machine. No cloud service, no API proxy, no telemetry. Swap providers per pipeline role (planner=opus, builder=codex, reviewer=sonnet) via config.

Configuration

Everything lives in .foundry.json at your project root:

{
  "builder_models": ["claude:opus", "codex:"],
  "dual_selection": "first",
  "planner_model": "opus",
  "reviewer_model": "sonnet",
  "agent_timeout_secs": 900,
  "run_mode": "auto"
}

Per-role provider and model. Dual-build selection. That's it.