---
title: 'Context economy'
description: 'The way software and repository structure changes the amount, quality, and retrieval cost of context an agent needs for a correct change.'
canonical_url: 'https://darkfactory.dev/glossary/context-economy'
markdown_url: 'https://darkfactory.dev/glossary/context-economy.md'
collection: glossary
date_published: '2026-08-03T00:00:00-04:00'
date_modified: '2026-08-26T00:00:00-04:00'
---

# Context economy


## Definition

The way software and repository structure changes the amount, quality, and retrieval cost of context an agent needs for a correct change. A codebase with clear boundaries, local conventions, small interfaces, and durable decision records lets the agent find a compact, relevant working set. Tangled responsibilities, repeated logic, giant files, and stale documentation force it to read more while still increasing the chance that it misses the governing constraint.

Dark Factory Dev uses **context economy** for this relationship between structure and future inference burden. It is not a general claim that fewer tokens always produce better work. Removing relevant context is false economy. The aim is to reduce irrelevant reading and ambiguity while preserving the evidence needed to act correctly.

## How to observe it

Hold the task and agent setup constant, then compare input volume, retrieval steps, latency, retries, and accepted outcomes before and after a structural change. A 2026 Thoughtworks case study used that design while refactoring a 17,155-line data-access file. The author estimated that input tokens for the same representative change fell from 159,564 to 27,360, an 83 percent reduction. The token count was approximate and the study covered one codebase, so it is evidence of a mechanism rather than a universal rate.

## Distinguish it from nearby terms

Token price is what a provider charges. Context-window size is how much a model can accept. Context economy is how the system's structure affects what must be found and read for this change. Total lines of code can remain similar while better boundaries make the relevant context much smaller.

## Check your understanding

A refactor costs tokens today but makes every later change in the area cheaper to understand. Was it economical? Repeat a representative task against controlled snapshots and compare accepted results, not raw token reduction alone. A cheaper wrong change is not an improvement.

## Related factory areas

- [Architecture & technical strategy](https://darkfactory.dev/factory/architecture-strategy)
- [Economics, capacity & factory FinOps](https://darkfactory.dev/factory/economics-finops)

## Evidence and further reading

- [The Economic Benefit of Refactoring](https://martinfowler.com/articles/exploring-gen-ai/refactoring-economic-benefit.html)
- [How Claude Code Works in Large Codebases](https://www.claude.com/blog/how-claude-code-works-in-large-codebases-best-practices-and-where-to-start)
