Using Linters to Direct Agents
By Alvin Sng - September 5, 2025 - 7 minute read
Product
Share
By Alvin Sng - September 5, 2025 - 7 minute read
Product
Share
Linters can encode your architecture, boundaries, and ergonomics directly into the code generation loop, exactly where LLM agents operate. When you do this, Agent‑Native Development switches from “back‑and‑forth with a robot intern” to “fast, deterministic collaboration with a compiler‑like partner.” Agents learn to self‑heal by obeying lint rules. You get consistent code, fewer human iterations, and a codebase that scales with your team and your agents.
The most effective agent-focused linters setups cover the following categories:
Linters turn human intent into machine-enforced guarantees that allow agents to plan, generate, and self-correct without waiting on humans. The flow is simple. Humans define standards in AGENTS.md, which explains the “why” and provides examples. Those guidelines are then encoded as lint rules with clear severity, autofix, and waiver policies. The same rules run on save, pre-commit, CI, PR bots, and inside agent toolchains. Achieving “lint green” becomes the definition of "Done".
AGENTS.md guide agent behavior; linters provide precise, automatic feedback that agents use to self‑heal until clean.This results in agents that generate code, get automatic feedback from linters, and self‑learn/iterate until clean. Then “lint passing” becomes a proxy for “conforms to architecture and best practices.” Linting is the executable spec that ties human intent to agent output, ensuring consistent, navigable code at scale.
LLMs scaffold features in minutes where a decade ago, the bottleneck was typing speed and library knowledge. The constraint is how quickly we can turn human conventions into machine‑checkable rules so agents can run without waiting on feedback. Pre-specify your standards as lint rules and wire them into the loop so that agents get automatic feedback, self-correct, and need fewer human interventions.
Quality now hinges on how well your standards are codified and how reliably agents can obey them. Linters, once “style cops,” become the authoritative, executable spec for “how we build here,” bridging human intent and agent execution.
Linters act as a migration engine. By encoding the “new way” as failing rules and the “old way” as detectable patterns with autofix, you gain a repo-wide detector, an execution plan, and a guardrail that ensures the change stays in place. This turns one-off rewrites into a continuous, agent-native process that finds every instance, fixes it safely, and prevents regressions.
AGENTS.md guidelinesAGENTS.md explains intent, patterns, and examples in human language so agents know what to aim for.
AGENTS.md = the “why” and the examples. It maps each guideline to a RuleID and links to rule docs/ADRs.Grep‑friendly code turns your repo into a reliable database for both humans and agents. It enables precise search, safe scripted refactors, and better retrieval for LLM context windows.
If you adopt only one category, adopt this one
Named exports and imports
export const Foo and all import { Foo } from ...Absolute import paths
../../.. hops@app/feature/... aliasesFilename and file‑organization conventions
enums live in enums.ts with only exportstypes live in types.ts and can import from enumsindex.ts re‑exports stable module surface.test.tsThese constraints make the codebase scriptable. Agents can combine ripgrep‑style queries with deterministic write locations to execute large, safe refactors, exactly how senior engineers batch‑edit at scale.
// src/users/helper.ts
import { UserRole } from '@/users/enums';
import { User } from '@/users/types';
// src/users/enums.ts
export enum UserRole {
Admin = 'admin',
Manager = 'manager',
Member = 'member',
}
// src/users/types.ts
export type User = {
id: string;
role: UserRole;
email: string;
};
export function canManage(user: User): boolean {
return user.role === UserRole.Admin || user.role === UserRole.Manager;
}Because it uses named exports, absolute imports, and deterministic file organization (enums.ts, types.ts, helper.ts), tools like ripgrep and agents can precisely find definitions/usages and perform safe, large‑scale refactors.
A tight, repeatable cycle that turns human insight into machine‑enforced policy and uses agents to erase drift at scale.
The result is that every observed issue becomes an executable constraint, agents clean up today’s debt, and the codebase self‑heals against future drift.
At Factory, linting is our first response, not an afterthought: when a bug or drift shows up in a review, test, or incident, we immediately codify it as a rule, wire it into local dev, pre‑commit, CI, PR bots, and our agent toolchains, and treat “lint green” as the merge gate. This turns every lesson into an executable constraint that agents obey by default and humans can’t accidentally bypass. Concretely, we maintain dozens of rules such as:
The result is a codebase that self‑heals: new issues become rules, agents mass‑fix violations, and the guardrails prevent the same problem from landing twice.
When guidelines become lint-enforced law, agent-native development stops being just a promise and begins to compound. Each rule you codify reduces review overhead, eliminates a class of regressions, and turns drift into an auto-fixed diff. Every lint-green merge makes the repo more searchable, easier to refactor, and more teachable. Each iteration transforms tribal knowledge into an executable specification that agents follow by default.
Over weeks, this results in smoother pull requests. Over quarters, it leads to faster lead times, safer large-scale changes, and fewer outages. Over years, it locks in architectural integrity while your teams can focus more on design, domain, and product. The end state is a self-healing codebase where consistency scales with both headcount and agent horsepower. Every new standard you encode continues to pay dividends indefinitely.
Start building