magus v0.4.3 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
2 min read

Clear is better than clever

Keep it simple, and write to the need in front of you. Build what the current goal needs, ship it good enough, and iterate. Do not add a second code path, a mode, an option or an abstraction for a need nobody has yet. Each one doubles what a reader has to hold, and the need it guessed at usually arrives in a shape nobody guessed.

Clever code scratches a real itch. It is satisfying to write and feels like proof you are good at this. It is also, almost by definition, a departure from convention, so the next person has to work out what you did and why before they can safely touch it. Good code is code someone else can maintain. That cost is not abstract: it is the bill you hand whoever works on this after you, and more and more often that is an agent reading it cold. Buzz is the evidence here: a language with close to one way to say a thing gets better agent output than the most-trained languages on earth, and explicitness is the only variable in sight.

This is not YAGNI taken whole. magus is aimed at the largest monorepos that exist (Built for the largest monorepos), and some of what that takes is engineering no sane person does for a small repository. The rule is not "never optimize". It is: clear by default, and clever only where a measurement says the clear version is too slow, with the measurement and the trade-off written beside the code.

Enforced by

  • The benchbeside analyzer in libs/conventions fails an // optimization: comment, or a Cache or Memo type, in a package whose tests hold no benchmark.
  • The // optimization: comment carries the measurement and the trade-off, so the clever line names its price.
  • Review against Capability is not a reason: a second path needs a failure it removes.

Good

Clever where it was measured, with the numbers and the cost beside it, from cmd/magus/helpers.go:

// optimization: run the first second of every process under loadGCPercent, not only the load.
//
//	measured: median wall, interleaved runs, n=60: commit-msg hook 74.1->61.6ms, tool-call hook
//	          89.7->78.1ms, describe targets 240.8->233.9ms; one fewer GC each.
//	trade-off: a long-lived process grows its heap 5x live for its first second.

Bad

// Load reads the config. legacy selects the old reader; lazy defers parsing until
// first use; both exist in case a future store needs them.
func Load(path string, legacy, lazy bool) (*Config, error)

Two flags for needs nobody has make four states, three of them untested. The reader pays for all four on every call site, and the store they guessed at will not look like the guess.

See also

designprinciplecodesimplicity
Last updated (2df714e8)
Glossary

Target

A named operation (build, test, ...) you invoke with magus run <target>; it may compose a spell's tool-native operations and depend on other targets. Target in full.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). Op in full.

Buzz

The language magusfiles are written in (the .buzz engine). Buzz in full.

Engine

The interpreter a magusfile runs on; magus embeds the Buzz engine. Engine in full.

Cache

The content-addressed store magus consults before running a target, so unchanged work is skipped. Cache in full.

CI

An ordinary target you compose yourself with ctx.needs; magus does not hardcode its stages. It is the anchor magus affected ci keys off, and ci strips the rw charm. CI in full.

Agent

A model working through an agent host such as Claude Code, Codex, Cursor or OpenCode. magus treats an agent as one more caller of its CLI, MCP tools and console, held to the same checks as a person. Agent in full.

Tool

An action a model can call through its host: a name, a description, a typed input and a result. magus serves its tools over MCP, each a read of the workspace model or a run of the CLI it already has. Tool in full.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate. Run in full.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.