review-code-complexity
Review Code Complexity
Use cyclomatic and cognitive complexity findings as cues for architectural assessment. Completion means an evidence-backed disposition for every reviewed symbol, not a lower score or a warning-free command.
Follow the user's tool choices when provided; otherwise use the standard tools available in the environment. Read and apply the codebase-design skill for assessment and the program-design skill when proposing substantial changes. Resolve these skills through the environment's available skills; report an unavailable required skill as a prerequisite gap instead of claiming to have applied it.
1. Establish the Review Batch
- Read the repository instructions and inspect the current worktree. Preserve existing changes and distinguish them from work authorized by this review.
- Discover the configured cyclomatic and cognitive complexity diagnostics, their scope, thresholds, exclusions, suppression conventions, and command behavior. Use the repository's existing configuration rather than introducing thresholds or installing tooling.
- Honor explicitly requested files, findings, or package scope. With no narrower request, obtain repository-wide findings, sort flagged files by repository-relative path, and select the first file awaiting review. Review every flagged symbol in that file; there is no per-symbol cap.
- Treat multiple metric findings for the same symbol as one assessment while retaining each diagnostic record. Identify anonymous callbacks and nested functions by their enclosing symbol and location.
- For explicitly named files, also inspect existing complexity suppressions and their underlying code. A clean diagnostic run does not replace that assessment. Bare invocation targets currently emitted findings rather than reopening existing suppressions.
- Maintain the reviewed-file dispositions and remaining queue in the conversation. On a subsequent bare invocation, refresh the findings and advance past files already reviewed against unchanged code and configuration. Reassess affected dispositions when their supporting evidence changes. A new conversation has no assumed review history.
If metrics are not configured, report the missing prerequisite and stop automatic selection. An explicitly named file can still receive a qualitative architectural assessment; label measured complexity as unavailable. Installing or configuring metrics requires a separate request. If configured diagnostics fail to run, record the exact failure and incomplete coverage; use available source evidence for an explicitly scoped review without claiming a measured baseline.
Complete this phase when the selected files, diagnostic coverage, existing-change ownership, and remaining queue are recorded, or the exact selection blocker is established. If a complete run yields no findings, report that result without claiming the repository has no architectural problems.