From aj-geddes-useful-ai-prompts-4
Analyzes code complexity, cyclomatic complexity, maintainability index, and code churn using metrics tools. Use when assessing code quality, identifying refactoring candidates, or monitoring technical debt.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:code-metrics-analysisThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Measure and analyze code quality metrics to identify complexity, maintainability issues, and areas for improvement.
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)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| TypeScript Complexity Analyzer | TypeScript Complexity Analyzer |
| Python Code Metrics (using radon) | Python Code Metrics (using radon) |
| ESLint Plugin for Complexity | ESLint Plugin for Complexity |
| CI/CD Quality Gates | CI/CD Quality Gates |
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4Analyzes code complexity metrics including cyclomatic, cognitive, Halstead, maintainability index, and nesting depth. Reports per-function/file details, top issues, and refactoring recommendations.
Analyzes code structure, complexity, and quality using cyclomatic and cognitive complexity metrics, detects code smells like long methods and god objects, and suggests refactoring strategies.
Scans codebase health by identifying hotspots, risky files, and coupling patterns. Prescribes prioritized refactoring actions with ROI-based guidance. Invoke via /Vitals or rely on auto-activation when discussing code quality.