From ai-devkit
Detect transitional comments, debug code, obvious comments, and commented-out code
How this skill is triggered — by the user, by Claude, or both
Slash command
/ai-devkit:cleanup [--all, --branch, --quiet, --fix][--all, --branch, --quiet, --fix]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Detect and optionally remove transitional comments, debug code, obvious comments, and commented-out code. Repository-agnostic: grep patterns cover the common languages, and the high-value pass — judging *obvious* comments — is purely semantic.
Detect and optionally remove transitional comments, debug code, obvious comments, and commented-out code. Repository-agnostic: grep patterns cover the common languages, and the high-value pass — judging obvious comments — is purely semantic.
$ARGUMENTS
--all: check all source files in the repo's source dirs.--branch: check files changed vs the base branch.--quiet: only output if issues are found.--fix: remove detected issues (prompts before each).Default (no scope flag): only check uncommitted changes (staged + unstaged).
Exception: a line tagged cleanup: intentional is always skipped.
| Category | Pattern (extend per language) | Example |
|---|---|---|
| Transitional comments | previously, was:, changed from, now, moved to, old:, before:, used to | // Padding now handled by X |
| Commented-out code | a comment that wraps a statement: `^\s*(// | #)\s*(let|var|const|func|def|class|fn|return|if|for|import) (excludes doc comments///, ##, """`) |
| Debug prints | console.log(, print(, println!, fmt.Print, System.out.print, dump(, debugPrint(, puts | console.log("debug", value) |
| Logger debug | log.debug(, logger.debug(, NSLog(, os_log( with debug text | logger.debug("state", state) |
| Completed TODOs | TODO.*(done|completed|fixed) | // TODO: done |
| Empty section markers | // MARK: -$, # region with nothing after | // MARK: - |
Comments that restate what the code already says add no value and become maintenance debt. These need semantic judgment — grep can't find them.
Remove comments that:
/* Feature for managing coins */ on class CoinsFeature// Set loading to true above isLoading = true/* the user client */ on userClient: UserClient// Check if user has enough coins above if balance >= priceKeep comments that explain:
// Defer setup to avoid blocking the main thread// O(n) search is fine — list is always < 50 items// Provider requires this entitlement check before unlock// Platform bug — force-unwrap is safe here (see TICKET-123)// 20% discount applies to bundle purchases# Base branch for --branch (auto-detected)
if git ls-remote --heads origin develop | grep -q .; then BASE_BRANCH=develop
else BASE_BRANCH=$(git remote show origin 2>/dev/null | sed -n 's/.*HEAD branch: //p'); BASE_BRANCH=${BASE_BRANCH:-main}; fi
# Discover the repo's source roots instead of hardcoding them
SRC_DIRS=$(git ls-files | sed -n 's#^\(src\|lib\|pkg\|app\|internal\|Sources\)/.*#\1#p' | sort -u)
if echo "$ARGUMENTS" | grep -q -- "--all"; then FILES=$(git ls-files $SRC_DIRS 2>/dev/null)
elif echo "$ARGUMENTS" | grep -q -- "--branch"; then FILES=$(git diff "$BASE_BRANCH..HEAD" --name-only)
else FILES=$({ git diff --name-only; git diff --cached --name-only; } | sort -u)
fi
Run the pattern table above over $FILES, excluding lines tagged cleanup: intentional:
PATTERNS=(
'// .*(previously|was:|changed from| now |moved to|old:|before:|used to)'
'^[[:space:]]*(//|#)[[:space:]]*(let|var|const|func|def|class|fn|return|if|for|import|public|private)[[:space:]]'
'console\.log\(|[^a-zA-Z]print\(|println!|fmt\.Print|System\.out\.print|debugPrint\(|dump\(|puts '
'(log|logger)\.debug\(|NSLog\(|os_log\('
'//[[:space:]]*TODO.*(done|completed|fixed|DONE|COMPLETED|FIXED)'
)
for p in "${PATTERNS[@]}"; do
grep -rnE "$p" $FILES 2>/dev/null | grep -v "cleanup: intentional"
done
After grep, read the actual git diff and identify obvious comments using the rules above. List each as file:line: comment → the code it restates.
--quiet: only show the count.--fix: remove grep-detected issues, then ask about each obvious comment.Checking uncommitted changes…
Phase 1 — grep-detectable
src/checkout/charge.ts:42 console.log("amount", amount)
src/checkout/charge.ts:88 // old: used the legacy gateway
Phase 2 — obvious comments (semantic)
src/cart/cart.ts:21 // add item to cart → cart.push(item)
src/cart/cart.ts:55 // the total → let total: number
Want me to remove these?
Called automatically by smart-commit as a pre-commit warning: it runs detection (report-only), shows warnings, offers to fix, and lets you continue anyway — issues are warnings, not blockers.
// cleanup: intentional.--fix applies removals with confirmation.detection-patterns.md — the full per-language pattern reference and edge cases.npx claudepluginhub alexandremorgado/ai-devkit --plugin ai-devkitGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.