Domain-Driven Agents
TL;DR Highlight
Putting a bounded-context map and glossary in each repo made agents guess less in legacy code
Who Should Read
A backend developer whose coding agent invents wrong names and structures in a legacy codebase
Core Mechanics
- Why agents fail in legacy code
- In a four-year-old system the model invents a fourth spelling of a concept that already exists three times.
- It calls straight through where an adapter was needed, or adds an adapter where a call was fine.
- The system never answers these questions anywhere, so the model guesses and often guesses wrong.
- Upgrade the code, not the model
- The author says the model is not what needs upgrading, the code is.
- Readiness can be built incrementally, piece by piece.
- Humans strategize, agents execute
- Strategic work is reading the system and deciding what to change and why.
- Tactical work is carrying that decision into files, which the author says got cheap.
- The author files GitHub issues for the strategic part and reviews agent-made PRs.
- A .workflow.json and CONTEXT.md per repo
- The domain block in .workflow.json lists the project, bounded contexts, glossary location, subdomain type, and edges to neighboring contexts.
- Each edge has to, direction, owner, pattern, shape, and note.
- CONTEXT.md is a living glossary with precise term meanings and deliberately rejected synonyms.
- The context map is generated, not written
- A script walks every repo, unions the domain blocks, and emits one CONTEXT-MAP.md.
- The map is disposable and regenerable.
- With no separate registry, nothing can drift out of sync.
- Edges are declared on both sides so conflicts are mechanical
- A supplier names its own stance such as published-language, a consumer names conformist or anticorruption-layer.
- The generator cross-checks pairs with a pairing table and reports each mismatch as a finding.
- One flag files each as a DDD issue on the repo with the wrong side, and a fingerprint updates the same issue on re-runs and closes it when the finding disappears.
- Next: migrate each context's inside to a domain model
- The author plans to migrate one context at a time to value objects, aggregates, and domain services.
- The full set of skills is promised soon.
Community Reactions
- Per-entity md files were enough
- One commenter keeps Author.md next to Author.ts and gave agents a skill to read and write those files.
- It has been useful so far in a 350k LOC TypeScript monolith, with agent-written md updates appearing in PRs.
- A per-folder docs.md is simpler
- A commenter had success having agents maintain a docs.md in each folder, reading and updating it on every change.
- They argued the article overcomplicates things and no special format or manifest is needed.
- Early DDD boundaries kept agent development stable
- One commenter said defining bounded contexts and ubiquitous language early kept a growing service from getting messy while Claude kept developing it.
- They also worried that existing legacy services without DDD can't even be refactored.
- Pushback on the greenfield premise
- One commenter's experience was the opposite: LLMs do better on existing projects thanks to established structure and conventions.
- They said new projects go worse unless it is simple vibe coding.
- Criticism of the article and AI reliance
- One commenter called most of the article AI slop and asked about HN policy.
- Another said relying on AI can raise productivity but is hard to systematize.
How to Apply
- Create one CONTEXT.md glossary
- Pick a repo where the agent often goes wrong and add CONTEXT.md at the root.
- Write precise meanings of key terms and the synonyms not to use.
- Tell the agent to read this file before starting work.
- Write your repo neighbors as edges
- Pick a calling repo and a called repo and write to, direction, and owner on each side.
- Set owner to decide whose model wins when terms conflict.
- Compare both declarations by hand and file issues where they disagree.
- Split analysis into issues and implementation into agent PRs
- Analyze what needs to change and why, and record it as a GitHub issue.
- Hand implementation to a skill or sub-agent and focus on PR review.
- Check who consumes the code you touch before merging.
Try It
# Paste into Claude Code or ChatGPT (simplified version of the article's method: glossary and edge check)
You are an assistant analyzing a legacy codebase. Read the code and docs below and draft a CONTEXT.md.
[Input]
- Target concept: {{concept name, e.g. job offer status}}
- Related code: {{file paths or code}}
- Integration code with neighboring systems: {{API client/adapter code}}
[Instructions]
1. Find every spelling that refers to the same concept and list them in a table.
2. Below the table, propose which spelling is canonical and which synonyms to reject.
3. Describe the relationship with the neighboring system as to, direction, owner, pattern, note. If unsure, set pattern to unclassified and explain in note.
4. Do not guess items without evidence in the code; mark them 'unknown'.
Next step: save the result as CONTEXT.md and tell the next agent run to read this file first.Terminology
Related Papers
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques