code-metrics-analysis

Analyze code complexity, cyclomatic complexity, maintainability index, and code churn using metrics tools. Use when assessing code quality, identifying refactoring candidates, or monitoring technical debt.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "code-metrics-analysis" with this command: npx skills add aj-geddes/useful-ai-prompts/aj-geddes-useful-ai-prompts-code-metrics-analysis

Code Metrics Analysis

Table of Contents

Overview

Measure and analyze code quality metrics to identify complexity, maintainability issues, and areas for improvement.

When to Use

  • Code quality assessment
  • Identifying refactoring candidates
  • Technical debt monitoring
  • Code review automation
  • CI/CD quality gates
  • Team performance tracking
  • Legacy code analysis

Quick Start

Minimal working example:

import * as ts from "typescript";
import * as fs from "fs";

interface ComplexityMetrics {
  cyclomaticComplexity: number;
  cognitiveComplexity: number;
  linesOfCode: number;
  functionCount: number;
  classCount: number;
  maxNestingDepth: number;
}

class CodeMetricsAnalyzer {
  analyzeFile(filePath: string): ComplexityMetrics {
    const sourceCode = fs.readFileSync(filePath, "utf-8");
    const sourceFile = ts.createSourceFile(
      filePath,
      sourceCode,
      ts.ScriptTarget.Latest,
      true,
    );

    const metrics: ComplexityMetrics = {
      cyclomaticComplexity: 0,
      cognitiveComplexity: 0,
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
TypeScript Complexity AnalyzerTypeScript Complexity Analyzer
Python Code Metrics (using radon)Python Code Metrics (using radon)
ESLint Plugin for ComplexityESLint Plugin for Complexity
CI/CD Quality GatesCI/CD Quality Gates

Best Practices

✅ DO

  • Monitor metrics over time
  • Set reasonable thresholds
  • Focus on trends, not absolute numbers
  • Automate metric collection
  • Use metrics to guide refactoring
  • Combine multiple metrics
  • Include metrics in code reviews

❌ DON'T

  • Use metrics as sole quality indicator
  • Set unrealistic thresholds
  • Ignore context and domain
  • Punish developers for metrics
  • Focus only on one metric
  • Skip documentation

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

code-review-analysis

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

ios-swift-development

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

android-kotlin-development

No summary provided by upstream source.

Repository SourceNeeds Review