Analyze technical debt indicators in the repository
Scans repository for technical debt indicators including TODO comments, stale branches, large files, and commit activity patterns.
/plugin marketplace add openshift-eng/ai-helpers/plugin install git@ai-helpersgit:debt-scan
/git:debt-scan
The git:debt-scan command provides a comprehensive analysis of technical debt indicators in the current Git repository. It scans for common code health signals including TODO/FIXME comments, stale branches, large files, uncommitted changes, and recent development activity patterns. This command is designed to give developers quick insights into areas that may need attention without making any modifications to the repository.
It provides essential information for developers including:
The spec sections is inspired by https://man7.org/linux/man-pages/man7/man-pages.7.html#top_of_page
Implementation logic:
# Search for technical debt comments
echo "=== Technical Debt Comments ==="
FILE_PATTERNS="*.{js,ts,go,py,java,rb,c,cpp,h,hpp,cs,php,swift,kt}" && for marker in TODO FIXME HACK XXX; do echo "$marker comments: $(grep -r "$marker" --include="$FILE_PATTERNS" . 2>/dev/null | grep -v '.git/' | wc -l | xargs)"; done
# Show top 10 files with most debt comments
echo -e "\n=== Files with Most Debt Comments ==="
grep -r 'TODO\|FIXME\|HACK\|XXX' --include="*.{js,ts,go,py,java,rb,c,cpp,h,hpp,cs,php,swift,kt}" . 2>/dev/null | grep -v '.git/' | cut -d: -f1 | sort | uniq -c | sort -rn | head -10
# Check for stale branches on openshift remotes (excluding main, master, release branches)
echo -e "\n=== Stale Branches (not updated in 30+ days) ===" && bash -c 'OPENSHIFT_REMOTES=$(git remote -v | grep -E "github\.com[:/]openshift/" | grep fetch | awk "{print \$1}" | sort -u); if [ -z "$OPENSHIFT_REMOTES" ]; then echo "(No openshift GitHub remotes found)"; else for remote in $OPENSHIFT_REMOTES; do git ls-remote --heads "$remote" | awk "{print \$2}" | sed "s|refs/heads/||" | grep -vE "^(main|master|develop|release-.*|gh-pages)$" | while read branch; do commit_info=$(git log -1 --format="%cr|%an" "$remote/$branch" 2>/dev/null || echo ""); if [ -n "$commit_info" ]; then date=$(echo "$commit_info" | cut -d"|" -f1); author=$(echo "$commit_info" | cut -d"|" -f2); echo "$date" | grep -qE "years? ago|months? ago|[4-9] weeks ago|[0-9]{2,} weeks ago" && echo "$branch - Last commit: $date by $author"; fi; done | head -10; done; fi'
# Find large files (only git-tracked files)
echo -e "\n=== Large Files (>1MB, tracked by git) ==="
git ls-files | xargs ls -lh 2>/dev/null | awk '$5 ~ /M$/ && $5+0 > 1 {print $9 " - " $5}' | head -10
# Check uncommitted changes
echo -e "\n=== Uncommitted Changes ==="
git status --porcelain | head -20
# Recent commit activity
echo -e "\n=== Commit Activity ===" && echo "Commits in last week: $(git log --since='1 week ago' --oneline 2>/dev/null | wc -l | xargs)" && echo "Commits in last month: $(git log --since='1 month ago' --oneline 2>/dev/null | wc -l | xargs)" && bash -c 'count=$(git log --since="30 days ago" --oneline 2>/dev/null | wc -l | xargs); if command -v bc >/dev/null 2>&1; then avg=$(echo "scale=1; $count / 30" | bc 2>/dev/null); echo "Average commits per day (last 30 days): ${avg:-0}"; else echo "Average commits per day (last 30 days): ~$((count / 30))"; fi'
Clean repository with minimal debt:
/git:debt-scan
Output:
=== Technical Debt Comments ===
TODO comments: 5
FIXME comments: 1
HACK comments: 0
XXX comments: 0
=== Files with Most Debt Comments ===
3 ./src/api/users.ts
2 ./src/utils/helpers.js
1 ./tests/integration.test.ts
=== Stale Branches (not updated in 30+ days) ===
feature/old-experiment - Last commit: 3 months ago by Alice
bugfix/minor-issue - Last commit: 2 months ago by Bob
=== Large Files (>1MB, tracked by git) ===
data/seed.json - 2.1M
=== Uncommitted Changes ===
=== Commit Activity ===
Commits in last week: 12
Commits in last month: 48
Average commits per day (last 30 days): 1.6
Repository with technical debt to address:
/git:debt-scan
Output:
=== Technical Debt Comments ===
TODO comments: 47
FIXME comments: 23
HACK comments: 8
XXX comments: 5
=== Files with Most Debt Comments ===
12 ./src/legacy/payment-processor.js
9 ./src/controllers/auth.ts
7 ./src/services/notifications.py
5 ./src/utils/data-transformer.go
4 ./tests/e2e/checkout.test.js
=== Stale Branches (not updated in 30+ days) ===
feature/refactor-database - Last commit: 5 months ago by Carol
feature/new-ui - Last commit: 4 months ago by Dave
bugfix/memory-leak - Last commit: 6 weeks ago by Eve
=== Large Files (>1MB, tracked by git) ===
src/legacy/monolith.js - 5.3M
dist/bundle.min.js - 3.2M
data/migrations.sql - 2.8M
=== Uncommitted Changes ===
M src/api/routes.ts
?? temp/debug-logs.txt
?? scripts/experimental.sh
=== Commit Activity ===
Commits in last week: 3
Commits in last month: 15
Average commits per day (last 30 days): 0.5
Active development repository:
/git:debt-scan
Output:
=== Technical Debt Comments ===
TODO comments: 18
FIXME comments: 4
HACK comments: 2
XXX comments: 0
=== Files with Most Debt Comments ===
6 ./src/features/new-feature.ts
4 ./src/api/v2/endpoints.go
3 ./tests/unit/service.test.js
=== Stale Branches (not updated in 30+ days) ===
(no stale branches found)
=== Large Files (>1MB, tracked by git) ===
docs/api-reference.pdf - 1.2M
=== Uncommitted Changes ===
M src/features/new-feature.ts
M tests/unit/service.test.js
=== Commit Activity ===
Commits in last week: 28
Commits in last month: 89
Average commits per day (last 30 days): 3.0
Technical Debt Comments:
Stale Branches:
Large Files:
Commit Activity: