Spend 80% Fewer Tokens with TOCA

by

this post has been formatted by AI

Software architecture is about to become an AI cost optimization problem.

For decades, software architects have optimized for maintainability, scalability, deployment complexity, fault isolation, and human cognitive load. Good architecture has never been about clever code—it’s about reducing the amount of information required to safely make a change.

AI-assisted development adds a new architectural constraint that most engineering organizations have not yet begun to optimize for: context.

Every file an AI coding agent reads costs time and money. Every dependency it must understand consumes tokens. Every architectural decision it must infer increases the cost of development.

If your AI agent must understand your entire codebase to change a button color, you’ve already lost.

The good news? Software engineering has largely solved this problem before. We simply haven’t been thinking about it in terms of AI agents and token consumption.

The Pain Point

For Engineers

Today’s AI coding agents are incredibly capable, but they are expensive when forced to reason about large, tightly coupled systems.

Common pain points include:

  • AI agents that read hundreds of files to make a simple change.
  • Feature requests that require understanding multiple unrelated subsystems.
  • Excessive coupling between frontend, backend, and business logic.
  • Poor parallelization of engineering tasks.
  • AI agents that repeatedly rediscover architectural decisions.

For Engineering Leadership

AI-assisted development introduces real economic costs.

Poorly architected systems result in:

  • Increased token consumption.
  • Longer AI task completion times.
  • Reduced engineering throughput.
  • Higher AI development costs.
  • Increased human onboarding costs.
  • Greater architectural risk and change blast radius.

The organizations that learn to minimize context requirements will build software faster, cheaper, and more reliably than those that do not.

Introducing TOCA

TOCA (Token Optimized Component Architecture) is an architectural philosophy that minimizes the amount of context required for humans and AI agents to safely understand, modify, test, and deploy software components.

The goal of TOCA is simple:

Minimize the context required to perform an engineering task.

Reducing token consumption is merely the economic benefit of following that principle.

Haven’t We Always Known This?

Yes.

The funny thing about TOCA is that it isn’t really a new idea.

Software engineering best practices have been telling us for decades to:

  • Separate concerns.
  • Minimize coupling.
  • Maximize cohesion.
  • Create explicit interfaces.
  • Write testable code.
  • Design for maintainability.

Humans understand these concepts intellectually, but we are notoriously bad at enforcing them consistently. AI coding agents are no different.

TOCA simply formalizes these principles through the lens of AI-assisted development.

The difference is that context is now measurable and expensive.

TOCA Is Implementation Agnostic

TOCA is NOT:

  • A microservices framework.
  • A deployment model.
  • A repository structure.
  • A programming paradigm.

A TOCA component may be:

  • A microservice.
  • A module within a modular monolith.
  • A library.
  • A frontend application.
  • An API.
  • A package.
  • An entire repository.

Microservices are simply one implementation of context isolation.

The question TOCA asks is not:

Is this a microservice?

The question is:

How much context is required to safely modify this component?

If the answer is “very little,” you’re probably doing TOCA well.

The Six TOCA Principles

1. Single Responsibility

Components should do one thing well.

2. Explicit Contracts

Components should expose clear and trustworthy interfaces.

3. Context Minimization

Components should require the minimum amount of context necessary to safely modify them.

4. Independent Verification

Components should be independently testable whenever practical.

5. AI Parallelization

Multiple AI agents should be able to work on separate components simultaneously.

6. Token Optimization

Architectural decisions should consider AI token consumption as an engineering cost.

Context Isolation Is the Goal

Imagine asking an AI agent to implement a feature.

A TOCA-compliant system allows the agent to say:

I understand exactly what this component does. I know its interfaces, dependencies, and tests. I do not need to understand anything else.

The benefits are immediate:

  • Lower token consumption.
  • Faster AI task completion.
  • Better human comprehension.
  • Lower engineering costs.
  • Easier onboarding.
  • Better architectural boundaries.
  • Improved task parallelization.

Enforcing TOCA with Speckit

TOCA is particularly well suited to constitutional engineering frameworks such as Speckit.

Simply add TOCA as a constitutional principle for every new project.

Architectural reviews should ask:

  • How much context is required to make this change?
  • Does this increase or decrease context isolation?
  • Can this component be tested independently?
  • Can an AI agent safely work here without understanding unrelated components?
  • Is token consumption being unnecessarily increased?

Over time, TOCA becomes less about token costs and more about creating software that is naturally easier for both humans and machines to understand.

The Future of Software Architecture

Software architecture has always evolved in response to changing constraints.

Today’s constraint is AI context size.

Tomorrow’s engineering leaders will not simply ask:

Is this scalable?

They will ask:

How expensive is this component to understand?

The winning architectures of the next decade will not necessarily be those that process the most requests per second. They will be those that require the least amount of context to safely make a change.

Spend fewer tokens.

Build TOCA compliant apps. Download TOCA.md and ask your AI to read it and then ask it to rate how TOCA compliant your app is.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *