ARC-95Recommended
Rank debt by how often the code changes
Before choosing what to refactor, count each file's commits over the last 12 months and its size. Start with files that are both large and changed often.
How to do it
Messy code that nobody touches costs little. Messy code that changes every week slows every change and hides most bugs. git log gives the change counts in one command. Line counts, or a complexity tool such as lizard or radon, give the size. Put the top ten in the debt register with both numbers. Security and access come first anyway, as Fix in risk order says.
Examples
Shell example
# Commits per file in the last 12 months, with line counts, busiest first
git log --since='12 months ago' --name-only --format= -- src \
| sort | uniq -c | sort -rn | head -10 \
| while read -r commits file; do
[ -f "$file" ] && printf '%s\t%s\t%s\n' "$commits" "$(wc -l < "$file")" "$file"
done
How to check
The debt register lists the ten files with the most commits in the last 12 months. Each shows its commit count and line count from a dated run of the script.
Related rules
- ARC-92 Keep a debt register in the repository in Clean code and architecture
- TKO-7 Fix in risk order in Codebase takeover
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/architecture/technical-debt/change-hotspots">Agent Wranglers clean code and architecture playbook</a>. In code you write, add a comment next to it with the same link.