Skip to content

CodeComplexity Tool

Eshan Roy edited this page Jun 18, 2026 · 1 revision

CodeComplexity Tool

The CodeComplexity tool analyzes a Go codebase and produces a complexity report with file counts, line counts, top packages, and a complexity score.

Overview

Source: internal/tools/codecomplexity.go

Property Value
Risk Level safe
Schema {skip_dirs?: string[]}

Features

  • File scanning -- Recursively scans .go files in the project directory
  • Line counting -- Counts non-empty lines per file and per package
  • Package ranking -- Ranks packages by total lines of code
  • File ranking -- Ranks individual files by line count
  • Complexity score -- Classifies the codebase as low, medium, or high complexity
  • Skip directories -- Configurable directory skip list, merged with defaults (node_modules, vendor, etc.)

Usage

Slash Command

/complexity

Runs the CodeComplexity tool and displays the report inline.

Tool Call

The LLM can invoke the tool directly:

{
  "name": "CodeComplexity",
  "skip_dirs": ["testdata", "fixtures"]
}

Report Format

The report includes:

  1. Total files and lines -- Overall codebase size
  2. Top packages -- Packages ranked by total lines
  3. Top files -- Individual files ranked by line count
  4. Complexity score -- low (< 5K lines), medium (5K-50K), high (> 50K)

Complexity Score Thresholds

Score Lines of Code Description
low < 5,000 Small codebase
medium 5,000 - 50,000 Medium codebase
high > 50,000 Large codebase

Source Files

File Purpose
internal/tools/codecomplexity.go Tool implementation (308 lines)
internal/tools/codecomplexity_test.go Tests (342 lines)
internal/tui/commands/commands_analysis.go /complexity slash command handler

Clone this wiki locally