A regression is an unintended loss or degradation of previously correct software behavior. Performance work makes the risk visible: a change intended to accelerate AccountFinder can instead increase runtime substantially. section 7.1.2 section 5.3.2
Treat regression prevention as an evidence and ownership problem:
- Benchmark competing implementations under representative data sizes rather than trusting a simple parallelization change. section 7.1.2
- Compare results as well as timing; the benchmark verifies that alternative methods return consistent results. section 7.1.2
- Keep deterministic checks as the real gate and use AI review as advisory coverage, not independent verification. section 5.3.2
- Assign narrowly scoped detectors to accountable owners, such as a platform team for performance regressions. section 5.3.2
When optimization becomes regression
AccountFinder's custom benchmark measured single-threaded execution at 25 ms, parallel streams at 63 ms, concurrent execution at 30,398 ms, and an optimized variant at 406 ms. The intended performance improvement produced slower implementations, so the benchmark exposed the regression before deployment. section 7.1.2
Listing 5.4 Pre-commit hook example
#!/bin/bash
# .git/hooks/pre-commit
set -euo pipefail
DIFF=$(git diff --cached)
[ -z "$DIFF" ] && exit 0
# Deterministic checks block. This is the real gate.
gitleaks protect --staged --redact || exit 1
# The model advises. It cannot block on its own.
VERDICT=$(printf '%s' "$DIFF" | claude -p "Review this diff against our
conventions: error handling, test coverage for new public functions,
naming. Reply with exactly one line of JSON and nothing else:
{\"verdict\":\"clean\"} or {\"verdict\":\"concerns\",\"notes\":\"...\"}")
if [ "$(printf '%s' "$VERDICT" | jq -r '.verdict')" = "concerns" ]; then
echo "AI reviewer raised concerns (advisory, not blocking):"
printf '%s' "$VERDICT" | jq -r '.notes'
fi
exit 0Use the pre-commit pattern to separate blocking deterministic checks from advisory model feedback when guarding changes against regressions. section 5.3.2










