# Beagle — a typed authoring layer for Clojure, built as a Racket #lang

**URL:** <https://racket.discourse.group/t/beagle-a-typed-authoring-layer-for-clojure-built-as-a-racket-lang/4218>\
**Category:** Show & Tell\
**Created:** [May 18, 2026, 7:53am UTC](https://racket.discourse.group/t/beagle-a-typed-authoring-layer-for-clojure-built-as-a-racket-lang/4218 "2026-05-18T07:53:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tompassarelli](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/tompassarelli/32/2647_2.png) [@tompassarelli](https://racket.discourse.group/u/tompassarelli)\
**Post date:** [May 18, 2026, 7:53am UTC](https://racket.discourse.group/t/beagle-a-typed-authoring-layer-for-clojure-built-as-a-racket-lang/4218/1 "2026-05-18T07:53:39Z")

</div>

This isn't really "Clojure with types beats Clojure."

It's "an agent with a typed repair protocol beats an agent without one."

> **[GitHub - tompassarelli/beagle: an agent-native programming language](https://github.com/tompassarelli/beagle)**
>
> an agent-native programming language

Beagle works like this:

```scheme
Beagle source
  → Racket reader/parser
  → custom type checker
  → emitted plain .clj
  → normal Clojure runtime

```

No Typed Racket. The type system is hand-rolled in `racket/base` .

- Custom reader that preserves `[]` vs `()` because Clojure vectors matter
- Full pipeline inside `#%module-begin` : parse → check → emit → display generated Clojure
- ~666 pre-typed Clojure stdlib functions
- LSP server
- Typed REPL
- Daemon using `filesystem-change-evt` for reactive checking The main experiment was whether this helps coding agents repair Clojure programs. I ran 15 agentic coding head-to-head experiments that feature beagle, clojure, and python. Notably in one experiment at ~8,500 LOC with 35 injected bugs:

```scheme
Beagle: 3/3 full correctness
Clojure: 0/3 full correctness

```

Beagle can turn runtime failures into ranked, machine-readable repair patches. That means the agent spends basically zero tokens on mechanical bugs and can focus on actual semantic repair. Still early, but the results are interesting (correctness, wall-time, etc). Next step is designing more robust experiments with larger programs, cleaner baselines, and harder repair cases.

This is the second version of a pattern I first tested with Nisp for Nix: use Racket as a source-aware authoring/checking layer, then emit ordinary code for the target ecosystem. While Beagle targets Clojure, the underlying machinery such as type-driven repair, oracle synthesis, and reactive diagnostics are not Clojure-specific.

I think Racket itself could benefit from the same kind of agent-facing repair/compiler infrastructure.
