2026-11-27 16:19 UTC

BoundaryML ships BAML agent guidelines and code-quality tooling

state: expiredheat: lowuncertainty: mediumrelevance: mediumcoding-agents software-maintenance agent-evaluationAvery TownsendBoundaryML

What is this?

BoundaryML, the team behind the BAML programming language and toolchain, announced on Nov. 5, 2026 that its latest BAML version includes a rewritten coding-agent skill and the `baml codequality` command. Avery Townsend’s first-party post says the skill now gives agents 27 best-practice and anti-pattern guidelines, while the command reports measures such as cognitive complexity, nesting and NPath. BoundaryML tested four skill setups across ten GPT-6.1-Sol/Codex runs for each of four BAML tasks. The post reports generally lower complexity scores with the new skill and especially with the command, but acknowledges that these metrics are only proxies and can be gamed or improve when code is split into smaller functions. The evidence is the company’s own evaluation; no independent replication or adoption evidence is supplied.

Why it matters

This is a practical example of improving coding-agent output without changing the underlying model: task-specific guidance and an in-workflow quality tool appear to steer agents toward more idiomatic, maintainable code in a language with a thinner human-written training corpus. If the approach generalizes, language and tool vendors may be able to improve agent-written software through skills, feedback loops and CI checks—not only through model training. The reported results are promising but limited to four tasks, one model/agent configuration and complexity-oriented proxies; they do not establish better correctness or maintainability in general.

Current assessment

New first-party release: BoundaryML says its latest BAML version ships the rewritten agent skill and `baml codequality`; its post also points to a GitHub Action that runs checks, formatting, tests and code-quality reporting on pull requests. The company evaluated four treatments—no skill, old skill, new 27-guideline skill, and new skill plus instruction to use the code-quality command—on regex, chess, Conduit API and GTFS tasks, with ten runs per treatment and task using GPT-6.1-Sol with Codex. BoundaryML reports that the combined new-skill-plus-command treatment beat the old skill on cognitive complexity, cyclomatic complexity, NPath and nesting for the worst function across all four tasks. Effects varied by task and metric: GTFS showed little change between old and new skill before the command; exits was the weakest measure and did not consistently favor the combined treatment. The article says nine of ten new-skill chess runs used an enum, versus none of ten with the old skill. These are vendor-reported results, not independent benchmarks; the article itself cautions that metrics are proxies, may encourage metric-hill-climbing, and can improve by splitting functions. It offers qualitative code examples as further support, while conceding that subjective quality is hard to quantify. Useful follow-up: test other models, languages and larger real-world projects, inspect correctness and human maintainability outcomes, and check independent adoption or replication. The supplied web results provide general BAML context but no corroborating evaluation.

Measured heat

now 0 pts/hpeak 0 pts/hcomments 0/hpeers p28momentum: steady2 platformsage 396h
points/hour across evidence · reading as of 2026-11-21 12:22:42.073878+11:00 · deterministic, not a model opinion

How the heat travelled

11-04 13:00⭐ origin echo-reconstructedBoundaryML describes a rewritten BAML skill with 27 guidelines, a code-quality command, and an evaluation of agent-generated code across fou
Avery Townsend on blog (echo) · attributed from hn.story.50400365
—
11-07 00:25first on hacker news · published · +59.4hTeaching Agents to Write Maintanable Code
aaronvg
—
11-07 00:25amplified on hacker news 👑hn.story.50400365
aaronvg
peak 3 · 0 comments · 99% of case engagement
11-07 01:20our radar first saw it · +60.3hdiscovery anchor: hn.story.50400365—

Evidence (2) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnTeaching Agents to Write Maintanable Code
Retrieved article excerpt

Open article · Retrieved 2026-11-07T01:22:35.719312+00:00

Nov 5, 2026·Avery Townsend·7 min read

# Teaching Agents to Write Maintainable Code

We rewrote our agent skill and built code quality metrics into the toolchain to help agents write better BAML

[BAML quickstart](https://boundaryml.com/quickstart)Install the toolchain and give your agent the BAML skill.

function chess\_candidates(position: ChessPosition) -> ChessCandidate[] { while (from < 64) { let piece = board[from]; if (chess\_color(piece, position.white)) { let kind = piece.to\_lower\_case(); if (kind == "p") { chess\_pawn\_candidates(position, from, candidates); } else { for (let direction in directions) { if ((kind != "b" || diagonal) && (kind != "r" || !diagonal)) { while (chess\_inside(x, y)) {Cognitive complexity50Beforefunction candidates(self, from: int) -> ChessPly[] { let piece = self.board[from] ?? return []; match (piece.kind) { ChessKind.Pawn => self.pawn\_moves(from), ChessKind.Knight => CHESS\_KNIGHT\_STEPS.flat\_map(…), ChessKind.Bishop => CHESS\_DIAGONALS.flat\_map(…), ChessKind.Rook => CHESS\_STRAIGHTS.flat\_map(…), ChessKind.Queen => CHESS\_RAYS.flat\_map(…), ChessKind.King => CHESS\_RAYS.flat\_map(…), }}Cognitive complexity2After

Over the last few months we've been putting final polish on the BAML language and prepping for a 1.0 release. We've spent over a year designing the core language, and on that front consider BAML to be nearly complete. But, work remains in making sure BAML meshes well with coding agents, since they are a major part of engineering workflows today.

As it stands, agents can write BAML code that solves problems and passes tests. It is a real turing complete language with a compiler, bytecode VM, formatter, etc. The remaining problems with BAML lie not in the BAML language itself, but in the BAML code that the agents produce. We, and a lot of our testers, noticed that the quality of BAML code written by agents is noticeably worse than what the same agents produce in TypeScript or Rust. For instance, here's part of a chess move generator an agent (GPT-6.1-Sol with Codex) wrote with our current skill installed:

```
function chess_candidates(position: ChessPosition) -> ChessCandidate[] {
    let board = position.board;
    let candidates: ChessCandidate[] = [];
    let from = 0;
    while (from < 64) {
        let piece = board[from];
        if (chess_color(piece, position.white)) {
            let kind = piece.to_lower_case();
            if (kind == "p") {
                chess_pawn_candidates(position, from, candidates);
            } else {
                let directions = if (kind == "n") {
                    CHESS_KNIGHTS
                } else {
                    CHESS_RAYS
                };
                for (let direction in directions) {
                    let dx = direction[0];
                    let dy = direction[1];
                    let diagonal = dx != 0 && dy != 0;
                    if ((kind != "b" || diagonal) && (kind != "r" || !diagonal)) {
                        let x = from % 8 + dx;
                        let y = from / 8 + dy;
                        while (chess_inside(x, y)) {
                            let to = y * 8 + x;
                            if (chess_color(board[to], position.white)) {
                                break;
                            }
                            candidates.push(chess_candidate(from, to));
                            if (board[to] != "" || kind == "n" || kind == "k") {
                                break;
                            }
                            x += dx;
                            y += dy;
                        }
                    }
                }
                if (kind == "k") {
                    chess_castling_candidates(position, from, candidates);
                }
            }
        }
        from += 1;
    }
    candidates
}
```

This is a single function, nested seven levels deep. Chess pieces are stored as strings, so a knight is `kind == "n"`, and a typo still compiles. It works, but it doesn't make good use of BAML's rich feature set and nobody would want to maintain code like this. We need some way to improve this, or else it is hard to justify the use of BAML when most people are writing their code with agents.

It stands to reason that existing languages don't suffer as much from this problem, as there is plenty of good code written by humans in the training corpus. Not to mention that the big AI labs are likely optimizing on code quality metrics in these languages. So, without BAML code in the training data, or the support of a large lab, our only real knob for improving code quality is to improve the skill that we ship with the BAML toolchain.

Our current skill mostly just lists out BAML's features: we have `match`, we have type unions, we have reflection, etc. It does have a small "best practices" section, but most entries just explain what a feature does, and say nothing about when or how to use it; an agent learns that enums exist without ever being told in what context it should use one.

This approach clearly wasn't working; out of ten Codex runs for this chess move generator in BAML, not a single agent opted to use an enum. So, we chose to rewrite most of our skill to focus on best practices and anti-patterns collected from human review of agent-generated BAML code.

## What's in the new skill

The new skill describes how to (and how not to!) write BAML, instead of just what features it has. It adds 27 guidelines agents are told to always follow, each with a bad and a good example. These were modeled somewhat after the format of the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines). Here's a couple examples relevant to the chess move generator example:

**Use a closed type for fixed sets of values.** `string` accepts typos. Use an enum or a literal union.

```
// Bad
class Ticket {
    status: string,
}

// Good
enum Status {
    Open,
    Closed,
}

class Ticket {
    status: Status,
}
```

**Use `match` instead of `if` chains.** `match` is exhaustive, so a new variant is a compile error instead of a silent fallthrough.

```
// Bad
function hex(c: Color) -> string {
    if (c == Color.Red) {
        "#f00"
    } else {
        "#0f0"
    }
}

// Good
function hex(c: Color) -> string {
    match (c) {
        Color.Red => "#f00",
        Color.Green => "#0f0",
    }
}
```

With these new guidelines, nine of ten Codex runs with the new skill declared at least one enum in a chess move generator.

## Measuring it

This new skill definitely made us feel better, but we wanted to see if we could find some quantitative measure of its effect. So, we brought in a few relatively simple metrics from the literature:

- **Cognitive complexity** (SonarSource): every `if`, loop, and `match` adds one point, plus one for each level of nesting it sits in, and `else` adds one
- **Cyclomatic complexity** (McCabe) is the number of independent paths through a function
- **NPath** (Nejmeh) is the number of possible execution paths. Branches in a row multiply
- **Nesting** is the deepest stack of `if`s, loops, and lambdas
- **Exits** counts each `return` and `throw`, plus finishing normally

Examples

**Cognitive complexity**

```
// Cognitive 9
function cost_bad(o: Order) -> int {
    if (o.paid) {
        if (o.in_stock) {
            if (o.express) {
                20
            } else {
                5
            }
        } else {
            0
        }
    } else {
        0
    }
}

// Cognitive 4
function cost_good(o: Order) -> int {
    if (!o.paid || !o.in_stock) {
        return 0;
    }
    if (o.express) {
        20
    } else {
        5
    }
}
```

**Cyclomatic complexity**

```
// Cyclomatic 5
function days_bad(month: string) -> int {
    if (month == "jan") {
        31
    } else if (month == "feb") {
        28
    } else if (month == "mar") {
        31
    } else if (month == "apr") {
        30
    } else {
        0
    }
}

// Cyclomatic 2
const DAYS = { "jan": 31, "feb": 28, "mar": 31, "apr": 30 };

function days_good(month: string) -> int {
    DAYS.get(month) ?? 0
}
```

**NPath**

```
// NPath 8
function badges_bad(o: Order) -> string[] {
    let badges: string[] = [];
    if (o.paid) {
        badges.push("paid");
    }
    if (o.in_stock) {
        badges.push("in stock");
    }
    if (o.express) {
        badges.push("express");
    }
    badges
}

// NPath 1
function badges_good(o: Order) -> string[] {
    [
        Badge { name: "paid", on: o.paid },
        Badge { name: "in stock", on: o.in_stock },
        Badge { name: "express", on: o.express },
    ]
        .filter((b) -> {
            b.on
        })
        .map((b) -> {
            b.name
        })
}
```

**Nesting**

```
// Nesting 3
function fragile_bad(carts: Cart[]) -> string[] {
    let names: string[] = [];
    for (let cart in carts) {
        for (let item in cart.items) {
            if (item.fragile) {
                names.push(item.name);
            }
        }
    }
    names
}

// Nesting 1
function fragile_good(carts: Cart[]) -> string[] {
    carts
        .flat_map((cart) -> {
            cart.items
        })
        .filter((item) -> {
            item.fragile
        })
        .map((item) -> {
            item.name
        })
}
```

**Exits**

```
// Exits 4
function label_bad(status: Status) -> string {
    if (status == Status.Open) {
        return "open";
    }
    if (status == Status.Paused) {
        return "paused";
    }
    return "closed";
}

// Exits 1
function label_good(status: Status) -> string {
    match (status) {
        Status.Open => "open",
        Status.Paused => "paused",
        Status.Closed => "closed",
    }
}
```

No metrics will ever objectively measure code quality, but we felt that these metrics encouraged the type of BAML code that we wanted to see: preference for `match` statements over `if` statements, no gigantic functions, a functional style, etc.

We built these into the toolchain with the `baml codequality` command. By default it prints a summary of the project, and `--files` and `--functions` break it down further. On the chess project above:

```
$ baml codequality --functions
Functions, worst cognitive first
  cognitive  cyclomatic  nesting  npath  exits  lines  function                   location
         50          17        7     59      1     46  chess_candidates           baml_src/chess_impl.baml:218
         44          22        5  1,472      5     51  chess_attacked             baml_src/chess_impl.baml:156
```

## The Eval

With a way to quantify the code quality (or at least a metric related to it), we ran an eval. We had agents (GPT-6.1-Sol with Codex) implement four program skeletons in BAML, each with a public test suite for the agents to work against. Two are routine algorithmic problems:

- a POSIX extended regex engine
- chess move generation

And, the other two are intended to be more practical and make use of the standard library:

- the RealWorld "Conduit" blogging API
- next-departure lookups over GTFS transit feeds

We ran each task ten times for each of four different skill treatments:

1. No skill provided.
2. The old skill
3. The new skill (with guidelines)
4. The new skill, plus an instruction to run `baml codequality` while working

## Results

### Cognitive complexity

Cognitive complexity of the worst function in each run, tick at the mean. Lower scores are simpler by this metric.

- No skill
- Old skill
- New skill
- New skill + codequality

Regex

No skill: 59No skill: 62No skill: 63No skill: 64No skill: 66No skill: 67No skill: 67No skill: 69No skill: 89No skill: 95

Old skill: 31Old skill: 31Old skill: 32Old skill: 34Old skill: 37Old skill: 37Old skill: 38Old skill: 41Old skill: 43Old skill: 62

New skill: 17New skill: 20New skill: 21New skill: 24New skill: 25New skill: 27New skill: 30New skill: 33New skill: 36New skill: 44

New skill + codequality: 11New skill + codequality: 1
aaronvg30
🟧 echo.blog ⭐BoundaryML describes a rewritten BAML skill with 27 guidelines, a code-quality command, and an evaluation of agent-generated code across fouAvery Townsend——

Interpretation history

Decision trace