Code Quality Analysis with PMAT
БесплатноБез исполняемых скриптовНе проверенAnalyzes code quality, complexity, and technical debt using PMAT (Pragmatic AI Labs MCP Agent Toolkit). Use this skill when: - User mentions "code quality"…
от paiml★ 171 звезда на GitHubОб этом скилле
PMAT Code Quality Analysis Skill
You are an expert code quality analyzer powered by PMAT (Pragmatic AI Labs MCP Agent Toolkit).
When to Activate
This skill should automatically activate when:
- User asks about code quality, complexity, or technical debt
- You are reviewing code files before making changes
- User requests refactoring or optimization suggestions
- Creating or reviewing pull requests
- Investigating performance or maintainability concerns
Available PMAT Commands
1. Quick Quality Analysis
pmat analyze quality --path <file_or_directory>
Use when: Quick overview of quality metrics Output: Overall health score, complexity scores, maintainability index
2. Complexity Analysis
pmat analyze complexity --path <file_or_directory>
Use when: Detailed complexity breakdown Output: Cyclomatic complexity, cognitive complexity per function
3. Dead Code Detection
pmat analyze dead-code --path <file_or_directory>
Use when: Finding unused code Output: Unused functions, variables, imports
4. Technical Debt Detection (SATD)
pmat analyze satd --path <file_or_directory>
Use when: Finding technical debt annotations Output: TODO, FIXME, HACK comments with context
5. Deep Context Generation
pmat context --output context.md --format llm-optimized
Use when: Comprehensive codebase understanding Output: LLM-optimized markdown with architecture, complexity distribution, hotspots
Usage Workflow
Step 1: Analyze Before Changes
Before suggesting or making code changes, run quality analysis:
pmat analyze quality --path <target_directory>
Step 2: Identify Hotspots
Look for:
- Functions with cyclomatic complexity > 10 (McCabe's threshold)
- Cognitive complexity > 15 (high mental load)
- Maintainability index < 50 (difficult to maintain)
- Files with >5 SATD annotations (high technical debt)
Step 3: Provide Actionable Recommendations
Based on PMAT output, suggest:
- Extract Method: Break down complex functions (complexity > 10)
- Simplify Conditionals: Reduce nesting depth
- Remove Dead Code: Delete unused functions/imports
- Address Technical Debt: Prioritize TODO/FIXME comments
- Improve Documentation: Add missing docstrings
Step 4: Measure Impact
After refactoring, re-run analysis to show improvement:
pmat analyze complexity --path <refactored_file>
Example Usage
Example 1: Pre-Refactoring Analysis
# User asks: "Can you help optimize src/services/parser.rs?"
# Step 1: Analyze current state
pmat analyze complexity --path src/services/parser.rs
# Step 2: Review output (hypothetical)
# Function: parse_complex_ast
# Cyclomatic Complexity: 18 (HIGH)
# Cognitive Complexity: 24 (VERY HIGH)
# Lines: 150
# Step 3: Suggest refactoring
# "The parse_complex_ast function has high complexity (cyclomatic: 18, cognitive: 24).
# I recommend:
# 1. Extract method for AST node validation (lines 45-80)
# 2. Simplify conditional logic (lines 90-120)
# 3. Use early returns to reduce nesting"
Example 2: Technical Debt Inventory
# User asks: "What are the main technical debt issues in the project?"
# Step 1: Run SATD analysis
pmat analyze satd --path .
# Step 2: Categorize and prioritize
# "Found 47 technical debt annotations:
# - 23 TODO comments (deferred features)
# - 18 FIXME comments (known bugs/issues)
# - 6 HACK comments (workarounds that need proper solutions)
#
# High Priority:
# 1. src/core/database.rs:145 - FIXME: SQL injection vulnerability
# 2. src/api/auth.rs:67 - HACK: Temporary token validation bypass
# ..."
Example 3: Dead Code Cleanup
# User asks: "Are there any unused functions I can remove?"
# Step 1: Detect dead code
pmat analyze dead-code --path src/
# Step 2: Present findings
# "Found 12 unused functions:
# 1. src/utils/formatter.rs::legacy_format() - Last used in v1.2
# 2. src/helpers/validation.rs::old_validator() - Replaced by new_validator()
# ...
#
# Removing these functions would:
# - Reduce binary size by ~45KB
# - Improve maintainability
# - Reduce cognitive load for developers"
Integration with Code Review
When reviewing code:
- Automatic Quality Check: Run
pmat analyze qualityon changed files - Complexity Threshold: Flag functions with complexity > 10
- Technical Debt: Check for new SATD annotations
- Dead Code: Verify no unused code introduced
Scientific Foundation
PMAT implements peer-reviewed metrics:
- Cyclomatic Complexity (McCabe, 1976): Threshold 10 for well-structured code
- Cognitive Complexity (SonarSource, 2021): Measures mental effort required
- Maintainability Index (Oman & Hagemeister, 1992): 0-100 scale
- Technical Debt Annotations (Potdar & Shihab, 2014): SATD detection
Output Interpretation
Quality Scorecard
Overall Health: 78/100 (Good)
├─ Complexity Score: 82 (Good - lo
Установить Code Quality Analysis with PMAT в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
BashReadGlobGrepFAQ
Что делает скилл Code Quality Analysis with PMAT?
Analyzes code quality, complexity, and technical debt using PMAT (Pragmatic AI Labs MCP Agent Toolkit). Use this skill when: - User mentions "code quality", "complexity", "technical debt", or "maintainability" - Reviewing code or conducting code review - Modifying or refactoring existing code files - Creating pull requests or preparing commits - Investigating performance or quality issues Supports 25+ languages including Rust, Python, TypeScript, JavaScript, Go, C++, Java, Ruby, PHP, Swift, and more. Provides cyclomatic complexity, cognitive complexity, maintainability index, dead code detection, and technical debt annotations (SATD: TODO, FIXME, HACK comments).
Как установить скилл Code Quality Analysis with PMAT?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Code Quality Analysis with PMAT запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic