code-analysis

bejranonda's avatarfrom bejranonda

Provides methodologies, metrics, and best practices for analyzing code structure, complexity, and quality

⭐8stars🔀5forks📁View on GitHub🕐Updated Dec 4, 2025

When & Why to Use This Skill

This Claude skill provides a comprehensive framework for analyzing code structure, complexity, and quality. It leverages industry-standard metrics like Cyclomatic and Cognitive complexity to identify technical debt and provides actionable refactoring strategies to improve maintainability and performance across various programming languages.

Use Cases

  • Identifying complex functions that require refactoring to improve testability and reduce potential bugs.
  • Detecting common code smells such as 'God Objects', 'Long Methods', or 'Deep Nesting' during the code review process.
  • Assessing the overall maintainability and technical debt of legacy codebases before major migrations or updates.
  • Establishing standardized code quality assessments and best practices for development teams to ensure long-term project health.
namecode-analysis
descriptionProvides methodologies, metrics, and best practices for analyzing code structure, complexity, and quality
version1.0.0

Overview

This skill provides comprehensive knowledge for code analysis including complexity metrics, anti-pattern detection, refactoring strategies, and code quality assessment across multiple programming languages.

Complexity Metrics

Cyclomatic Complexity

  • Low: 1-10 (simple, easy to test)
  • Medium: 11-20 (moderate complexity, acceptable)
  • High: 21-50 (complex, needs refactoring)
  • Very High: 51+ (critical, must refactor)

Cognitive Complexity

Measures how difficult code is to understand based on nesting, control flow breaks, and recursion.

Code Smells to Detect

  • Long Methods: >50 lines
  • Large Classes: >300 lines
  • Duplicate Code: Repeated blocks
  • Long Parameter Lists: >5 parameters
  • Deep Nesting: >4 levels
  • God Objects: Classes doing too much
  • Dead Code: Unused functions/variables

Refactoring Strategies

  • Extract Method: Break long methods into smaller ones
  • Extract Class: Split large classes by responsibility
  • Replace Conditional with Polymorphism
  • Simplify Conditional Expressions
  • Remove Duplicate Code

When to Apply

Use when analyzing codebase structure, identifying refactoring opportunities, or assessing code quality.