A function body that needs a mental outline before it can be read — multiple concerns interleaved, or chunks of statements that share a single domain purpose without a name. The reader's comprehension cost rises because every read reconstructs the outline; small edits to one concern require holding all the others in working memory.
A function whose token cost exceeds the agent's reliable chunk-reasoning budget; verifying behavior preservation requires re-reading the entire span on every edit. The context-window load of the unstructured body crowds out other reasoning, and the reasoning step count rises as the agent re-derives the function's internal structure on each read.
Each function reads as a single named domain step — what it does, not how. The calling code becomes a sequence of named intentions; readers verify the workflow at the top level and drill into helpers only when the named step's body is the point of interest, supporting separation of concerns at the procedural level.
Each function is a verifiable unit small enough that the agent reasons about its full behavior in a single reasoning step. The agent's context window holds the relevant helper and its signature; verifying behavior touches one named unit, and the reasoning-step cost of any edit drops because the agent doesn't re-derive structure on each read.
Before the refactoring
function invoiceTotal(invoice) {let total = 0;for (const line of invoice.lines) {total += line.qty * line.unitPrice;if (line.qty >= 100) total -= line.qty * line.unitPrice * 0.05;}total += total * invoice.taxRate;return Math.round(total * 100) / 100;}
After the refactoring
function invoiceTotal(invoice) {const subtotal = subtotalAfterBulkDiscount(invoice);const withTax = subtotal * (1 + invoice.taxRate);return roundToCents(withTax);}
Every reader pays the outline cost on every read; small edits to one concern require holding all the others in working memory, and PRs touch the same function for unrelated reasons. The team's verification cost compounds across reviewers who must re-derive the function's structure each time; merge conflicts collect at the same body.
Every edit pays full re-read cost; chained changes compound context usage and increase the chance of missing a cross-statement invariant. The agent's verification-surface cost multiplies with body length — verifying any single change requires scanning every other statement to confirm it didn't shift, and the agent's retrieval cost on chained edits compounds.
Over-eager extraction can produce a fan-out of one-line functions; aim for extractions that earn their name with at least one decision or transformation. The team's maintenance cost can rise rather than drop if the extractions don't carry domain meaning, because every helper becomes a name to find, load, and verify on every traversal.
Each extracted helper inflates the agent's context-window load by one definition the next reasoning step must load; over-extracting saturates the agent's effective context-window capacity. The agent's completeness-check cost rises during the extraction itself — every reference to the body must be confirmed to route through the new helper rather than continuing to inline what's left.
Calling code becomes a sequence of named intentions; bugs concentrate inside the now-named subroutines because the reader can localize the failure to one named step. The team's enhancement cost drops because adding a new step is one new function rather than a new branch inside an already-cluttered body, and tests target the helper directly.
Each extracted helper fits inside one read; the agent verifies behavior against one signature instead of loading the entire original procedure into context to detect what changed. The agent's token cost per edit drops because the relevant unit is the helper, not the parent — and helper boundaries surface cross-statement invariants through type-checker visibility rather than runtime drift.
Tiny one-line helpers where the workflow can no longer be read linearly — extraction that doesn't earn its name fragments the procedure into pieces too small to mean anything. The fan-out adds accidental complexity to the call graph; readers carry the cognitive load of jumping between trivial helpers to reconstruct the original procedure.
Forces the agent to chase a dozen function definitions to follow what was once a 20-line procedure — context cost inflates and cross-function invariants disappear. The agent's retrieval cost across the call graph rises faster than the per-helper context-window load drops; tiny helpers cost more to assemble than to inline.