The 31 vs 11 median lines up with what I've seen too — the fix itself is usually small, and the rest is the agent tidying things it touched along the way. The pre-commit budget is the part I'd steal first: a hard 10-file/300-line ceiling beats asking the agent nicely to keep things small. Have you tried checking the staged spread mid-session, after each agent turn, or do you only catch it at commit time?
Building ForAgent (private phone numbers for AI coding agents over MCP: foragent.io) & ClevAgent (desktop guardrails: clevagent.io). Sharing AI agent workflows, MCP & runtime security.
Mid-session checks catch drift way earlier than a pre-commit hook, because an agent that wanders into three extra helpers on turn two can still pause right there before editing ten more files.
A lightweight diff stat check in a turn-end hook nudges the session to stop and checkpoint the current fix early, before unrelated edits accumulate by commit time.
That turn-end hook idea is the most concrete part for me — catching the drift at turn two instead of at commit time makes a lot of sense. Do you use a threshold for the diff-stat check, like a number of files or lines added, to decide when it nudges the session to checkpoint?
Building ForAgent (private phone numbers for AI coding agents over MCP: foragent.io) & ClevAgent (desktop guardrails: clevagent.io). Sharing AI agent workflows, MCP & runtime security.
A soft warning at roughly half the commit ceiling works well mid-session, since nudging around five modified files leaves room to finish the current fix before hitting a hard 10-file or 300-line pre-commit block.
Directory spread is an even cleaner signal in that same hook. Multiple edits inside one feature folder usually belong together, whereas changes crossing into unrelated top-level directories almost always mean the agent wandered into unrequested cleanup.
That directory-spread signal is a neat addition — five modified files as the soft nudge, and edits crossing into unrelated top-level directories as the drift tell, feels very usable. Do you find the 10-file / 300-line hard block ever fires on a legitimate large refactor, or does the mid-session warning usually keep sessions small enough that it rarely triggers?
Larger commits from agents make sense, they don't feel the pain of a messy diff the way a reviewer does. Asking the agent to commit after each passing test, and keeping refactors in their own commits, seems to help reviewers the most.
Building ForAgent (private phone numbers for AI coding agents over MCP: foragent.io) & ClevAgent (desktop guardrails: clevagent.io). Sharing AI agent workflows, MCP & runtime security.
Explicit file staging helps there too, since agents still tuck unrelated helper renames into a passing-test commit when staging the whole tree at once. Scoping git add by path keeps each checkpoint focused on the actual behavior change.
Good point, scoping git add per file is the simplest fix for that. A passing test can hide an unrelated rename in the same commit, and explicit staging makes the agent say what it meant to change.
Splitting mechanical commits from behavior commits helps whoever checks the work against the story too. I'd ask each fix: commit to name the acceptance criterion it changes. Then a commit that touches behavior but names no criterion is either scope creep or a missing requirement, and either way it's a question before merge, not after.
Building ForAgent (private phone numbers for AI coding agents over MCP: foragent.io) & ClevAgent (desktop guardrails: clevagent.io). Sharing AI agent workflows, MCP & runtime security.
Generic commit messages like "fix validation" often mask speculative fallback logic or extra cleanup tucked inside a coding-agent diff. Asking each behavior commit to name the exact acceptance criterion it satisfies forces unmapped edits into the open right away.
Once a change sits outside every listed criterion, you know immediately whether to drop the extra hunk or open a ticket for an undocumented edge case before merge.
The 31 vs 11 lines number stuck with me because it's exactly what I've been seeing — the actual fix is maybe 20 lines and then there's a pile of import cleanup and formatting around it that makes the diff look scary for no reason. The pre-commit budget is the part I'll actually try, 10 files / 300 lines feels strict enough to force a split without me just turning it off after a day. My only worry is a legit big refactor tripping it all the time, do you just bump the numbers for those or split anyway?
Building ForAgent (private phone numbers for AI coding agents over MCP: foragent.io) & ClevAgent (desktop guardrails: clevagent.io). Sharing AI agent workflows, MCP & runtime security.
Most large refactors still split cleanly into two phases without raising the 10-file limit: move shared types or module renames first, then migrate callers a slice at a time. Each checkpoint stays fast to verify and leaves automated formatting noise outside the behavioral change.
For single-shot changes that truly cannot be sliced, like a database migration or generated schema update, gating the hook with a one-off skip environment variable beats raising the budget globally. Once people raise the threshold past 300 lines, they rarely turn it back down.
We're a place where coders share, stay up-to-date and grow their careers.
The 31 vs 11 median lines up with what I've seen too — the fix itself is usually small, and the rest is the agent tidying things it touched along the way. The pre-commit budget is the part I'd steal first: a hard 10-file/300-line ceiling beats asking the agent nicely to keep things small. Have you tried checking the staged spread mid-session, after each agent turn, or do you only catch it at commit time?
Mid-session checks catch drift way earlier than a pre-commit hook, because an agent that wanders into three extra helpers on turn two can still pause right there before editing ten more files.
A lightweight diff stat check in a turn-end hook nudges the session to stop and checkpoint the current fix early, before unrelated edits accumulate by commit time.
That turn-end hook idea is the most concrete part for me — catching the drift at turn two instead of at commit time makes a lot of sense. Do you use a threshold for the diff-stat check, like a number of files or lines added, to decide when it nudges the session to checkpoint?
A soft warning at roughly half the commit ceiling works well mid-session, since nudging around five modified files leaves room to finish the current fix before hitting a hard 10-file or 300-line pre-commit block.
Directory spread is an even cleaner signal in that same hook. Multiple edits inside one feature folder usually belong together, whereas changes crossing into unrelated top-level directories almost always mean the agent wandered into unrequested cleanup.
That directory-spread signal is a neat addition — five modified files as the soft nudge, and edits crossing into unrelated top-level directories as the drift tell, feels very usable. Do you find the 10-file / 300-line hard block ever fires on a legitimate large refactor, or does the mid-session warning usually keep sessions small enough that it rarely triggers?
Larger commits from agents make sense, they don't feel the pain of a messy diff the way a reviewer does. Asking the agent to commit after each passing test, and keeping refactors in their own commits, seems to help reviewers the most.
Explicit file staging helps there too, since agents still tuck unrelated helper renames into a passing-test commit when staging the whole tree at once. Scoping git add by path keeps each checkpoint focused on the actual behavior change.
Good point, scoping git add per file is the simplest fix for that. A passing test can hide an unrelated rename in the same commit, and explicit staging makes the agent say what it meant to change.
Splitting mechanical commits from behavior commits helps whoever checks the work against the story too. I'd ask each fix: commit to name the acceptance criterion it changes. Then a commit that touches behavior but names no criterion is either scope creep or a missing requirement, and either way it's a question before merge, not after.
Generic commit messages like "fix validation" often mask speculative fallback logic or extra cleanup tucked inside a coding-agent diff. Asking each behavior commit to name the exact acceptance criterion it satisfies forces unmapped edits into the open right away.
Once a change sits outside every listed criterion, you know immediately whether to drop the extra hunk or open a ticket for an undocumented edge case before merge.
The 31 vs 11 lines number stuck with me because it's exactly what I've been seeing — the actual fix is maybe 20 lines and then there's a pile of import cleanup and formatting around it that makes the diff look scary for no reason. The pre-commit budget is the part I'll actually try, 10 files / 300 lines feels strict enough to force a split without me just turning it off after a day. My only worry is a legit big refactor tripping it all the time, do you just bump the numbers for those or split anyway?
Most large refactors still split cleanly into two phases without raising the 10-file limit: move shared types or module renames first, then migrate callers a slice at a time. Each checkpoint stays fast to verify and leaves automated formatting noise outside the behavioral change.
For single-shot changes that truly cannot be sliced, like a database migration or generated schema update, gating the hook with a one-off skip environment variable beats raising the budget globally. Once people raise the threshold past 300 lines, they rarely turn it back down.