Primitive of the day · 2026-10-03
chunk-refactor-trigger-thresholds
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
- The file's line count, concern mix, and test-cycle time are known or quickly measurable
Do this
Assess the four 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.
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.
Buy only the primitives you need
Each primitive is 1 credit (≈ €0.10). Pick them from the list above — the button is next to each one.
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