Trailblazes: One-Line Marks That Give Coding Agents a Memory
How a trail-craft practice from the age of axes solves a very modern problem: AI agents that re-derive the same hard-won knowledge, over and over, in codebases too large for any context window.
The agent that forgets, in an estate that sprawls#
If you run infrastructure as code at any real scale, your “codebase” is not a codebase. It is an estate: a Terraform/OpenTofu repo (or five) holding modules and stacks, an ArgoCD app-of-apps repo pinning chart versions, a Helm charts repo, a configuration-management repo (Salt, Ansible, take your pick), CI pipeline definitions, and a scattering of values and config repos — often across more than one git host. The repos are separate for good reasons: different owners, different release cadences, different blast radii, different credentials. Nobody is going to monorepo their way out of it.
The cost of that structure is that the knowledge which actually matters lives between the repos. “If you rename this module output, three consumers in two other repos break.” “This chart’s image tag comes from a repo-wide release tag, not the service’s own version file, so the default will point at an image that never existed.” “This upload path buffers whole files into pod RAM, so the size cap must stay below the memory limit.” None of these facts is written in any one file. Each was derived, painfully, by somebody — usually while something was on fire.
Now put a coding agent in that estate. Modern agents are genuinely good at the work: they read Terraform, write Helm templates, open PRs, chase CI failures. But they have two structural handicaps:
-
A limited context window. Even a large window fills fast in a multi-repo estate. Every file the agent reads to rediscover a constraint is context not available for the actual task. Exploration doesn’t just cost tokens; past a threshold it costs quality, because the conversation gets compacted and the agent starts reasoning over summaries of summaries.
-
A memory that cannot scale to the spread of the code. Agent memory files (the CLAUDE.md / AGENTS.md pattern, per-project notes) work beautifully for a project’s top twenty facts. They collapse at estate scale. You cannot load every trap in forty repos into every session; and a searchable memory only helps if the agent knows to search — which it doesn’t, because the whole point of a trap is that the code looks innocent.
That second point is the one that bites. Retrieval-augmented memory answers the questions you ask. Nobody asks “is there something subtle about this YAML value?” while editing what looks like a plain YAML value. The knowledge exists; the trigger doesn’t. So the agent re-derives the constraint from first principles — twenty files, a git-log excavation, maybe a failed PR — or worse, doesn’t, and ships the failure your team already paid for once.
What trail crews figured out centuries ago#
Before “trailblazer” was a LinkedIn word, a blaze was a physical object: a pale mark cut or painted onto a tree at eye height by the first person to walk a route. “To blaze a trail” bundles two acts — doing the hard first traversal, and marking it as you go. The mark is nearly free to make: seconds with a hatchet. It is worth nothing to the person who cuts it; they already know the way. Its entire value accrues to travelers the trailblazer will never meet.
Notice what the blaze is not. It is not a map (kept somewhere else, needs consulting deliberately). It is not a guidebook (goes stale, nobody carries it). It is a mark at the exact point where the decision must be made — at the fork, on the confusing ridge — and it carries almost no information itself. It just says: a route passes here; the finding-out has been done; look up the route notes.
That is precisely the missing trigger from the agent-memory problem.
The convention: a linked pair#
The practice, transplanted to an IaC estate, is a one-line comment planted in source at the exact spot a durable piece of knowledge applies:
# trailblaze: chart-image-tag-repo-wide-release
The mark is half of a linked pair. The other half is a finding: a short prose record in a searchable knowledge store, keyed by that same slug, holding the why / the trap / the pattern / the not-yet-done. The two halves carry strictly different content, and that split is load-bearing:
- Code holds what IS — the current value, the current flow. It is authoritative; it is what runs.
- The finding holds what does NOT change when the value changes — “the image tag comes from the repo-wide release tag, so a chart default seeded from the service’s own version file points at an image that will never exist,” not “the tag is 0.12.17.”
The rationale is never copied into both places. Duplicated prose is a second copy that drifts: the code changes in next week’s PR, the comment or wiki page doesn’t, and now the trusted copy is the stale one. A knowledge base that drifts is worse than none, because it is believed. The blaze dodges this entirely by carrying no prose at all — only the slug. There is nothing in the mark to go stale.
Two kinds of mark, same mechanics:
- Back-blaze: the hard change has been made; the finding records the trap that was navigated, so nobody re-derives it.
- Forward-blaze: the change is not made yet. The finding holds the intended approach and its constraints; the mark stands at the trailhead in the code where the work will begin. This is the neglected, highest-value half — it is how design context survives between sessions, between agents, between quarters.
The authoring rule is a standing reflex, not a ceremony: on every substantive PR, ask “did I just learn something a future agent would want surfaced at this exact spot?” If yes — write the finding, plant the mark, same PR, two minutes.
Design and implementation#
The whole system is deliberately small. Ours is a few hundred lines of glue around boring, proven components; you could rebuild it in a week.
The store. A Postgres database with the pgvector extension. One table of
findings: prose content, a human-chosen dedup_key (the slug), tags, a
sensitivity tier, and provenance links (issue/PR/file URLs). Every row is
embedded with a locally-served embedding model at write time, stamped with the
model version so vectors stay comparable.
The write path. Agents write findings through a tool call — we expose the
store over MCP (Model Context Protocol), so any agent framework can use it.
The critical design choice: writes are idempotent by dedup_key.
Re-writing a finding under the same slug updates it rather than spawning a
near-duplicate. However many times a trail is re-walked and its notes
improved, there is exactly one mark and one set of route notes. Without this,
the store silts up with almost-identical rows and retrieval quality decays.
The read path. Two complementary motions:
- Semantic search (embed the query, nearest-neighbor over the findings) for the deliberate “what do we know about X?” question.
- Blaze resolution for the point-of-need trigger: the agent hits a
# trailblaze: <slug>line while editing, searches the slug’s words, and accepts only the row whosededup_keymatches the slug exactly. Not the top hit — the exact key. A guessed or mistyped slug therefore resolves to nothing, loudly, instead of silently resolving to a plausible neighbor. Prose comments fail the other way: subtly, and only when someone acts on them.
The sweep. Because every mark has one grep-clean shape, one ripgrep pass
enumerates every blazed spot across every checked-out repo:
rg -n '^\s*(#|//|--|;|/\*|<!--)\s*trailblaze:\s*([a-z0-9][a-z0-9-]*)' .
The comment lead is part of the pattern (so a real config key like
trailblaze: false can’t false-positive), and the mark must sit on its own
line. The sweep turns the estate’s trail network into a queryable artifact —
“show me every marked spot in the repos I’m about to touch” is a one-liner in
an agent’s preamble, not tribal knowledge.
Access control. Findings carry a sensitivity tier, enforced with Postgres row-level security keyed to the caller’s identity (agents authenticate to the MCP server as themselves via OIDC). Retrieval filters before ranking. This matters the moment your store outgrows one team: an agent backed by a cloud LLM should simply never see rows above its clearance, and that has to be a database property, not an application promise.
The discipline that keeps it honest. One rule above all: a finding is a lead, never an authority. Recall reflects write-time state; the code at the mark is what runs. The agent verifies against the code before acting. This is also why the store tolerates imperfection gracefully — a slightly outdated finding still points you at the right three files, which is 95% of the value.
And one meta-lesson we earned the hard way: make the discovery path itself fail loudly. We once found that our documentation-search indexer had been silently dropping pages whose names it couldn’t fetch — including, with perfect irony, the page explaining the blaze convention. The marks were there; the map had a hole it didn’t report. A knowledge surface that can lose entries silently will eventually lose the entry explaining why it loses entries. Instrument your retrieval like you instrument production.
What a week of this is worth#
Numbers, with assumptions on the table so you can re-run them for your shop. Take one engineer driving agents hard for a week across a multi-repo estate:
| Assumption | Value |
|---|---|
| Agent tasks per week | 50 (10/day) |
| Tasks crossing a previously-derived trap or cross-repo invariant | ~30% -> 15 encounters |
| Re-derivation cost per encounter (read siblings, git archaeology, cross-repo greps, dead ends) | 30k-120k tokens, 10-30 min |
| Same encounter with a blaze (grep hit + one exact retrieval + verify) | ~2k-3k tokens, ~1 min |
| Traps missed without a mark, shipping a bad PR | 1-2 per week |
| Cost of each bad PR (CI cycles, human review, revert, re-do) | 1-3 hours wall-clock |
| Cost to author a finding + mark | ~1k tokens, ~2 min |
Direct token savings: 15 encounters x (~70k avg - 3k) is roughly 1M tokens per week for that one seat. At current frontier-model prices that is single to low-double-digit dollars — real, but not the headline.
The headline is the other two lines:
-
Context is the scarcer currency. 70k tokens of spelunking inside a 200k window isn’t a linear cost; it crowds out the task, forces compaction, and measurably degrades the quality of everything that follows in that session. Blazes don’t just make the agent cheaper — they keep it smart for the work you actually asked for. Three to eight hours of agent wall-clock a week come back too, which matters when a human is babysitting the loop.
-
The avoided bad PRs dominate. One or two prevented trap-shipped-to-review incidents a week, at 1-3 hours of human + CI time each, is worth more than all the tokens combined. These are exactly the failures your team has already paid for once; the blaze’s whole job is to make that a one-time purchase.
Against all of that, the authoring cost — a comment line and a paragraph, ~15-30 minutes a week in total — is noise. It is the hatchet-mark asymmetry: seconds for the person who already knows the way, compounding returns for everyone who follows. And unlike most documentation, the economics improve with agent traffic: every additional agent-hour run against the estate is another traveler on marked trails.
Start smaller than feels serious#
You don’t need the vector database on day one. The convention is the asset; the infrastructure just scales it.
- Pick a slug format and a mark:
# trailblaze: <kebab-slug>, own line, ASCII, grep-clean. - Start with findings as markdown files in a
findings/repo, one file per slug. A ripgrep sweep plus exact filename match is the resolution mechanism. This alone captures most of the value. - Wire the reflex into your agents’ operating instructions: before editing a marked spot, resolve the mark; after navigating anything hard, write the finding and plant the mark in the same PR. Forward-blazes included.
- When search-by-meaning starts mattering (it will, around a few hundred
findings), graduate to Postgres + pgvector behind an MCP tool, keep the
idempotent
dedup_keysemantics, and add row-level security when the store crosses a team boundary.
The trail crews had it right: the cheapest possible mark, at the exact point of need, backed by route notes kept somewhere durable. Your agents are walking the same woods every day. Stop making them scout it fresh each morning.
The mark format, the linked-pair rule, and the loud-failure discipline described here are running in production against a multi-repo Terraform/ArgoCD/Helm estate driven by coding agents daily. The numbers above are estimates from that experience — instrument your own week and check.