Compounding Engineering: Turn Your Repo into a Self-Improving DSPy Agent

Published: (December 28, 2025 at 05:50 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Beyond Single-Shot DSPy: Repo-Scale Reasoning That Compounds

I’ve been experimenting with DSPy beyond one‑off prompt optimization. Traditional DSPy shines at optimizing prompts for isolated tasks, but what if your AI agent could learn from your entire codebase over multiple iterations?

Enter Compounding Engineering: a local‑first DSPy agent that turns any Git repo into a persistent learning environment. It runs review → triage → plan → learn cycles, building a knowledge base from your code, issues, and past optimizations. No context‑window limits—improvements compound across sessions.

Core Innovation

  • Repo as Memory – Indexes your full codebase (Python, JS, configs) into a local vector store. Agents reason over real project context, not toy examples.
  • Compounding Cycles – Each run reviews changes, triages issues, plans fixes, executes via DSPy programs, and learns—storing successes/failures for next time.
  • DSPy‑Native – Leverages DSPy signatures, optimizers (BootstrapFewShot, etc.), and metrics. Plug in your LM (OpenAI, local models via Ollama).
  • Local‑First – Runs offline with FAISS/Chroma for storage. No cloud dependencies.

High‑level flow

git clone your-repo
ce init      # Indexes repo, sets up DSPy LM
ce run       # Full cycle: review → triage → plan → learn
ce optimize my_module.py  # Targeted optimization

Why This Matters for AI Engineers

  • Long‑Horizon Planning – Handles repo‑scale tasks like “refactor auth module for security” across multiple files.
  • Self‑Improvement – Metrics track progress; failed plans become few‑shot examples for retries.
  • Open‑Source Ready – Integrates Git, DSPy teleprompters, and custom signatures into existing workflows.

Quick Start

pip install dspy-compounding-engineering
git clone https://github.com/Strategic-Automation/dspy-compounding-engineering
cd dspy-compounding-engineering
ce init --lm openai/gpt-5.2   # Or your local LM
ce run

Full docs and examples are in the README.

Get Involved

  • ⭐ Star the repository if this sparks ideas!
  • Open issues/PRs for features (Rust optimizer? Multi‑repo?).
  • Share feedback on agentic workflows, long‑context reasoning, or DSPy extensions.

Built by Strategic Automation—automating engineering at scale. Let’s compound!

Back to Blog

Related posts

Read more »

Coding Rust with Claude Code and Codex

Why Rust Makes AI‑Assisted Development Feel Like a Real‑Time Code Review For a while now, I’ve been experimenting with AI coding tools, and there’s something f...