ADR 0014 — Agent-first code principles
Status: accepted, with conditions for reassessment. Date: 2026-12-03.
Context
Fellow is AI-first: most changes to Fellow applications will be made by coding agents. The question was whether classic methodologies (DRY, SOLID, KISS, YAGNI, Clean Code) should be adopted, and whether they reduce token usage and make agents more efficient. Those methodologies were designed for people maintaining code for years. For an agent, cost is dominated by correction cycles, the number of files read to understand one behaviour, and ambiguity.
Alternatives considered
- Adopt the classic methodologies as they are: parts of them work against agents. Code-level DRY produces shared abstractions that force an agent to read many files for one behaviour; dependency inversion through containers and decorators hides where implementations come from; very small functions fragment logic.
- No stated principles: each application drifts into its own shape, and agents explore every variation.
- Principles derived from agent costs, enforced where they can be checked: chosen.
Decision
- Publish
fellow docs principles: one way to do each thing (KISS), locality of behaviour, explicitness, YAGNI through task scope, verifiability, searchable names and “why” comments. DRY applies to knowledge (contracts, manifests), not to code shape; SOLID’s single responsibility applies to files, inversion to module boundaries. - Enforce the checkable part in the Architecture Validator, in
packages/core/src/project/code-shape.ts: FW-CODE-001 (files over 400 lines, warning), FW-CODE-002 (decorators, error), FW-CODE-003 (DI containers, error), FW-CODE-004 (barrels outsidepublic.ts, warning), FW-CODE-005 (pass-through wrappers, warning), FW-CODE-006 (services not reached by a test, directly or through a tested route, warning). - Errors are reserved for constructs that hide behaviour; size and structure are warnings, so
fellow check --strictcan make them blocking where a team wants it. - The generated
AGENTS.mdand thefellow-reviewskill point to the principles.
Consequences
- Generated code and the example application already comply; the rules cost nothing for code written the Fellow way.
- Libraries that require decorators (some ORMs, NestJS-style frameworks) cannot be used inside modules.
- The rules are textual (regular expressions over source without comments), like the SQL rules: unusual formatting can escape them. They guide; tests and review remain the guarantee.
Evidence
packages/core/tests/validator.test.ts covers every rule with a fixture (fixtures/shape), including the
exceptions: public.ts may re-export, comments are not decorators, a function that adds behaviour is not a
pass-through, services reached only through other services count as reached.
Conditions for reassessment
Real-agent runs of the benchmark, with and without the rules, measuring tokens, tool calls and correction cycles. If a rule does not reduce cost or increases correction cycles, it is relaxed or removed before 1.0.0-beta.