AI Agents Book

Primitive of the day · 2026-10-03

chunk-refactor-trigger-thresholds

Rule of thumb (thresholds not measured): switch from single-pass to chunk-and-checkpoint refactoring when the file exceeds ~200 lines, mixes multiple concerns, cannot be fully tested in under ~30 seconds, or a previous large agent change proved hard to debug.

When this applies

Deciding how to structure an upcoming agent-driven refactor of an existing file.

Preconditions

Do this

Assess the four rule-of-thumb signals (size >200 lines, mixed concerns, test cycle >30s, prior hard-to-debug large change); if any holds, run the map/approve/plan/execute/checkpoint protocol instead of a one-shot refactor.

What you should see

Protocol overhead is spent only where single-pass failure (undiagnosable broken tests) is the realistic alternative.

How it fails if ignored

Applying the heavy protocol to trivial files (wasted cycles); skipping it on a 600-line file because it 'looks simple'.

Do not use when

Small, single-concern, fast-to-test files where a single reviewed pass is cheaper than the protocol's overhead.

Corrected on 2026-11-01: the 200-line and 30-second thresholds are marked as rule-of-thumb triggers (not measured).

Kind: calibration. Part of the skill Legacy refactor chunk checkpoint. Free to reuse in your own agent skills.

Get the whole skill

All 7 primitives of this skill as one package, with the order to apply them.

Get just this primitive

This one primitive for 1 credit (≈ €0.10); the other primitives of the skill are on its page.

Upgrade your own skill

Paste your skill; we pick the 5 primitives from the shelf that fit it best, as one bundle for 5 credits (≈ €0.50).

Upgrade my skill

Register interest

Interest only — no payment, no order, no reservation. After you confirm by email we send you one free sample primitive.