« All posts

Sensors for tracking maintainability in AI-generated code

An engineer shares how static analysis, testing and security sensors placed across coding, pipeline and production stages help preserve maintainability in AI-generated codebases.

An engineer describes a layered sensor architecture used to monitor 'internal quality' (maintainability) in a fully AI-rebuilt analytics dashboard app. Unlike functional correctness or architectural fitness, maintainability degradation is often first noticed when a small change starts touching too many files, or when previously working functionality breaks. The article notes that AI agents suffer from tangled codebases in ways similar to human developers—searching in the wrong places, missing duplicates, or loading excessive context.

The setup combines computational sensors running during coding (type checker, ESLint, Semgrep, dependency-cruiser, test coverage, incremental mutation testing, GitLeaks) with inferential sensors run on a slower cadence (security and data-handling reviews, a dependency freshness report, modularity/coupling analysis). These sensors repeat across the coding session, CI pipeline, and scheduled runs to catch both immediate errors and gradually accumulating drift.

A detailed case study on ESLint shows that default presets don't catch common AI failure modes like excessive function length, argument count, or cyclomatic complexity—thresholds had to be manually configured. The author built a custom ESLint formatter that forces agents to justify suppressions or threshold increases, keeping exceptions visible and reviewable. Notably, without explicit self-correction guidance, the agent tended to raise complexity thresholds too easily instead of refactoring; once given clearer instructions, it produced solid refactors.

The piece suggests that AI coding agents may finally make consistent enforcement of static analysis practical, something teams have historically struggled to maintain due to warning-management overhead—provided the tooling is paired with explicit, context-rich guidance for agent self-correction.

» SourceMartin Fowler