Unit vs. Feature: Why AI-Driven Development Demands a Complete Architectural Reset
We spent decades optimizing software for human units of work—functions, classes, and micro-services. When autonomous AI agents generate entire vertical features instantly, the unit of architecture shifts from code blocks to behavioral contracts.
For thirty years, the fundamental building block of enterprise software engineering has been the unit: the function, the class, the module, and the micro-service.
Our entire tooling ecosystem—from unit testing frameworks (Jest, JUnit) and dependency injection containers to code review checklists and pull request scopes—was meticulously designed around the cognitive limits of human developers working on isolated code units.
Then came autonomous AI coding agents and spec-driven workflows.
When you prompt an agent or run an AI-DLC pipeline, you don't ask it to write a single method; you ask it to implement an entire vertical feature (e.g., "Add Stripe webhook processing with automatic tier provisioning and receipt emailing"). In thirty seconds, the agent touches database migrations, api routes, frontend UI components, and notification services across fourteen files.
This exposes a profound architectural friction: We are trying to govern feature-level AI generation with unit-level software boundaries.
Let’s deep-dive into why the traditional "Unit" paradigm is breaking down, how AI shifts the gravity toward "Feature" contracts, and what open questions remain for the future of systems design.
1. The Death of the Isolated Unit in Agentic Workflows
In traditional software engineering, encapsulation was king. We isolated business logic inside pure functions and mocked external dependencies so we could unit-test every class in a vacuum.
In the AI era, human isolation of units breaks down for three reasons:
- AI Doesn't Think in Functions; It Thinks in Workflows: When an autonomous agent reasons about code, it does not analyze a single class in isolation. It constructs a mental graph of the entire feature workflow—tracing data from the UI input down to the Postgres JSONB column.
- Mocking Anti-Patterns: When developers instruct AI agents to write unit tests with heavy mocking, agents routinely generate brittle mocks that pass while failing real integration realities. The AI manufactures passing unit tests by mocking away the very integration points that usually break in production.
- The Granularity Mismatch: Asking an AI agent to operate at the level of a single unit is like driving a Ferrari in first gear. It stifles the model's ability to reason across architectural layers and maintain holistic system consistency.
2. The Rise of the Vertical Feature Contract
If the unit is no longer the primary architectural atomic element, what replaces it? The Vertical Feature Contract.
Instead of asking "Is this function pure and well-tested?", modern AI-driven engineering asks: "Does this vertical feature satisfy its behavioral invariants across the entire stack?"
The Anatomy of Feature-Driven AI Engineering:
- Behavioral Invariants Over Function Signatures: Code is ephemeral; what matters is the invariant (e.g., "A canceled subscription must immediately revoke API access while retaining invoice records for tax compliance").
- Contract-First Specifications (
spec.md): Rather than unit-testing classes, agents are bound by feature-level acceptance criteria and end-to-end integration tests that exercise the actual database, router, and client state. - Vertical Slicing: Architecture is organized around business domains (billing, authentication, inventory) rather than technical layers (controllers, services, repositories), allowing agents to execute complete user journeys safely.
3. The Danger of "Feature Goo"
Of course, moving away from units without proper guardrails creates a new danger: Feature Goo.
When AI agents are allowed to splatter code across fourteen files to satisfy a feature request without strict modular boundaries, you get monolithic spaghetti wrapped in modern syntax.
This is why foundational infrastructure like GLOSSARY.md, strict TypeScript type contracts, and immutable domain boundaries are non-negotiable. Features must be vertical, but they must remain modular.
Open Questions for Future Architectural Discourse
As agentic engineering matures and forces us past the unit-level mindset, several critical questions remain open for our industry:
- How do we perform semantic code reviews when a single pull request contains 50 changes across 12 architectural layers generated by an agent in one prompt?
- If unit tests lose their primacy, what replaces test coverage percentage as a metric for code health in AI-driven pipelines?
- How will legacy enterprise codebases (built entirely around strict unit mocking and layered architectures) successfully migrate to feature-driven agentic workflows?
- Does the concept of a "function" even matter when an AI agent treats code as a fluid, continuously refactored semantic stream?
The shift from units to features is the defining structural transition of the AI era. Code is no longer something we write line by line; it is something we govern feature by feature.