Code Metrics Analysis

Code Metrics Analysis

Guides an AI agent to measure code complexity, maintainability and churn with TypeScript, ESLint and Radon tooling to find refactoring candidates and set CI quality gates.

Skill files7 files

references/

scripts/

templates/

SKILL.md97 lines
1
---
2
name: code-metrics-analysis
3
description: >
4
Analyze code complexity, cyclomatic complexity, maintainability index, and
5
code churn using metrics tools. Use when assessing code quality, identifying
6
refactoring candidates, or monitoring technical debt.
7
---
8
9
# Code Metrics Analysis
10
11
## Table of Contents
12
13
- [Overview](#overview)
14
- [When to Use](#when-to-use)
15
- [Quick Start](#quick-start)
16
- [Reference Guides](#reference-guides)
17
- [Best Practices](#best-practices)
18
19
## Overview
20
21
Measure and analyze code quality metrics to identify complexity, maintainability issues, and areas for improvement.
22
23
## When to Use
24
25
- Code quality assessment
26
- Identifying refactoring candidates
27
- Technical debt monitoring
28
- Code review automation
29
- CI/CD quality gates
30
- Team performance tracking
31
- Legacy code analysis
32
33
## Quick Start
34
35
Minimal working example:
36
37
```typescript
38
import * as ts from "typescript";
39
import * as fs from "fs";
40
41
interface ComplexityMetrics {
42
cyclomaticComplexity: number;
43
cognitiveComplexity: number;
44
linesOfCode: number;
45
functionCount: number;
46
classCount: number;
47
maxNestingDepth: number;
48
}
49
50
class CodeMetricsAnalyzer {
51
analyzeFile(filePath: string): ComplexityMetrics {
52
const sourceCode = fs.readFileSync(filePath, "utf-8");
53
const sourceFile = ts.createSourceFile(
54
filePath,
55
sourceCode,
56
ts.ScriptTarget.Latest,
57
true,
58
);
59
60
const metrics: ComplexityMetrics = {
61
cyclomaticComplexity: 0,
62
cognitiveComplexity: 0,
63
// ... (see reference guides for full implementation)
64
```
65
66
## Reference Guides
67
68
Detailed implementations in the `references/` directory:
69
70
| Guide | Contents |
71
|---|---|
72
| [TypeScript Complexity Analyzer](references/typescript-complexity-analyzer.md) | TypeScript Complexity Analyzer |
73
| [Python Code Metrics (using radon)](references/python-code-metrics-using-radon.md) | Python Code Metrics (using radon) |
74
| [ESLint Plugin for Complexity](references/eslint-plugin-for-complexity.md) | ESLint Plugin for Complexity |
75
| [CI/CD Quality Gates](references/cicd-quality-gates.md) | CI/CD Quality Gates |
76
77
## Best Practices
78
79
### ✅ DO
80
81
- Monitor metrics over time
82
- Set reasonable thresholds
83
- Focus on trends, not absolute numbers
84
- Automate metric collection
85
- Use metrics to guide refactoring
86
- Combine multiple metrics
87
- Include metrics in code reviews
88
89
### ❌ DON'T
90
91
- Use metrics as sole quality indicator
92
- Set unrealistic thresholds
93
- Ignore context and domain
94
- Punish developers for metrics
95
- Focus only on one metric
96
- Skip documentation
97

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…