File contents 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:
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
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
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1 --- 2 name: aj-geddes-useful-ai-prompts-code-metrics-analysis 3 description: Code Metrics Analysis 4 --- 5 6 # Code Metrics Analysis 7 8 ## Table of Contents 9 10 - [Overview](#overview) 11 - [When to Use](#when-to-use) 12 - [Quick Start](#quick-start) 13 - [Reference Guides](#reference-guides) 14 - [Best Practices](#best-practices) 15 16 ## Overview 17 18 Measure and analyze code quality metrics to identify complexity, maintainability issues, and areas for improvement. 19 20 ## When to Use 21 22 - Code quality assessment 23 - Identifying refactoring candidates 24 - Technical debt monitoring 25 - Code review automation 26 - CI/CD quality gates 27 - Team performance tracking 28 - Legacy code analysis 29 30 ## Quick Start 31 32 Minimal working example: 33 34 ```typescript 35 import * as ts from "typescript"; 36 import * as fs from "fs"; 37 38 interface ComplexityMetrics { 39 cyclomaticComplexity: number; 40 cognitiveComplexity: number; 41 linesOfCode: number; 42 functionCount: number; 43 classCount: number; 44 maxNestingDepth: number; 45 } 46 47 class CodeMetricsAnalyzer { 48 analyzeFile(filePath: string): ComplexityMetrics { 49 const sourceCode = fs.readFileSync(filePath, "utf-8"); 50 const sourceFile = ts.createSourceFile( 51 filePath, 52 sourceCode, 53 ts.ScriptTarget.Latest, 54 true, 55 ); 56 57 const metrics: ComplexityMetrics = { 58 cyclomaticComplexity: 0, 59 cognitiveComplexity: 0, 60 // ... (see reference guides for full implementation) 61 ``` 62 63 ## Reference Guides 64 65 Detailed implementations in the `references/` directory: 66 67 | Guide | Contents | 68 |---|---| 69 | [TypeScript Complexity Analyzer](references/typescript-complexity-analyzer.md) | TypeScript Complexity Analyzer | 70 | [Python Code Metrics (using radon)](references/python-code-metrics-using-radon.md) | Python Code Metrics (using radon) | 71 | [ESLint Plugin for Complexity](references/eslint-plugin-for-complexity.md) | ESLint Plugin for Complexity | 72 | [CI/CD Quality Gates](references/cicd-quality-gates.md) | CI/CD Quality Gates | 73 74 ## Best Practices 75 76 ### ✅ DO 77 78 - Monitor metrics over time 79 - Set reasonable thresholds 80 - Focus on trends, not absolute numbers 81 - Automate metric collection 82 - Use metrics to guide refactoring 83 - Combine multiple metrics 84 - Include metrics in code reviews 85 86 ### ❌ DON'T 87 88 - Use metrics as sole quality indicator 89 - Set unrealistic thresholds 90 - Ignore context and domain 91 - Punish developers for metrics 92 - Focus only on one metric 93 - Skip documentation 94 95 --- 96 > Converted and distributed by [TomeVault](https://tomevault.io/claim/aj-geddes) — claim your Tome and manage your conversions. 97 <!-- tomevault:4.0:skill_md:2026-04-11 -->
tomevault-io/skills-registry/tree/main/aj-geddes--useful-ai-prompts--code-metrics-analysis commit 70803dea27
Frequently asked questions How do I install the Aj Geddes Useful AI Prompts Code Metrics Analysis skill? Run npx skillmds@latest add tomevault-io/aj-geddes-useful-ai-prompts-code-metrics-analysis in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Aj Geddes Useful AI Prompts Code Metrics Analysis skill do? Code Metrics Analysis It is listed under Coding & Dev Tools on SkillMD.
Is Aj Geddes Useful AI Prompts Code Metrics Analysis safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Aj Geddes Useful AI Prompts Code Metrics Analysis? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Aj Geddes Useful AI Prompts Code Metrics Analysis free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Aj Geddes Useful AI Prompts Code Metrics Analysis? tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.