fuck-u-code-analysis
它能做什么
这个技能运行代码质量分析工具,并用通俗的语言解释结果。适合在提交或发起拉取请求之前,想找出混乱代码和技术债务的开发者。
适用场景
- ✓代码修改完成后,你想在提交前做一次质量检查的时候。
- ✓你想在项目中找出技术债务或难以阅读的代码的时候。
- ✓你想在发起拉取请求之前,要求对代码质量进行审核的时候。
技能链接
https://github.com/Done-0/fuck-u-code/blob/main/skills/fuck-u-code-analysis/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我项目的代码质量,并告诉我哪些文件需要先清理。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体运行分析工具,它会在多个方面为代码打分。然后,它会阅读得分最低的文件,并根据既定标准提出具体的修改建议。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
fuck-u-code Code Quality Analysis & Review
Prerequisites
Install fuck-u-code globally before using this skill:
npm install -g eff-u-code
Verify installation:
fuck-u-code --version
Requires Node.js >= 18.0.0.
Overview
Run fuck-u-code analyze to obtain quantitative code quality metrics across 7 dimensions (11 metrics), then interpret results and provide actionable refactoring recommendations based on the standards defined in this skill.
The tool produces a 0-100 overall score and per-file scores. Higher = better quality. The skill teaches you how to interpret every metric, judge severity, and prescribe specific fixes.
Workflow
digraph workflow {
rankdir=LR;
node [shape=box];
"Run fuck-u-code analyze" -> "Read JSON output";
"Read JSON output" -> "Identify critical files (score < 60)";
"Identify critical files" -> "Drill into per-metric details";
"Drill into per-metric details" -> "Apply review standards (Section 4)";
"Apply review standards" -> "Write actionable remediation report";
}
Step 1: Run Analysis
# Basic analysis
fuck-u-code analyze . -f json -o /tmp/fuc-report.json
# Verbose with top 20 worst files
fuck-u-code analyze . -v -t 20 -f json -o /tmp/fuc-report.json
# Exclude generated/test files
fuck-u-code analyze . -e "**/*.test.ts" -e "**/generated/**" -f json -o /tmp/fuc-report.json
Read the JSON output file to get structured data.
Step 2: Identify Problem Areas
From the JSON report, extract:
- overallScore: Project-wide score (0-100). Weighted average by code line count.
- aggregatedMetrics: Per-metric averages, medians, min/max across all files.
- files[]: Per-file results, sorted by score ascending (worst first).
Focus on files with score < 60 (the "shit mountain" zone).
Step 3: Drill into Metrics
For each problem file, examine the metrics[] array. Each metric has:
| Field | Meaning |
|---|---|
name |
Metric identifier (see Section 3) |
category |
Dimension group (complexity/size/duplication/structure/error/documentation/naming) |
normalizedScore |
0-100, higher = better |
severity |
info / warning / error / critical |
details |
Human-readable summary |
locations[] |
Specific line/function-level issue locations |
Prioritize metrics with severity >= error.
Step 4: Write Remediation Report
Follow the output format in Section 5.
Scoring System
The overall score is a weighted average across 7 categories. The default weights are calibrated to industry research (SonarQube, NASA, Microsoft studies on defect correlation):
| Category | Weight | Rationale |
|---|---|---|
| Complexity | 32% | Strongest correlation with defects (0.7-0.8 Pearson) |
| Duplication | 20% | Direct maintenance cost multiplier |
| Size | 18% | Code volume and function granularity |
| Structure | 12% | File organization and coupling |
| Error Handling | 8% | Robustness and reliability |
| Documentation | 5% | Long-term maintainability |
| Naming | 5% | Readability and convention compliance |
Metrics Reference (11 Metrics)
Each metric uses a 4-tier threshold system: excellent / good / acceptable / poor. Thresholds are language-specific. See references/thresholds.md for the full per-language table.
3.1 Complexity Metrics (weight: 32% total, split 3 ways)
cyclomatic_complexity (CC)
Formula: CC = 1 + decision points (if/for/while/case/catch/&&/||/ternary)
Measures the number of independent execution paths through code. High CC means more test cases needed and higher defect probability.
Generic thresholds (most languages):
| Level | CC Range | Score |
|---|---|---|
| Excellent | ≤ 5 | 100 |
| Good | 6-10 | 80-100 |
| Acceptable | 11-15 | 50-80 |
| Poor | > 15 | 0-50 |
Common patterns & fixes:
- Long if-else chains → Replace with strategy pattern, lookup table, or polymorphism
- Nested conditionals → Extract guard clauses, flatten with early returns
- God functions (CC > 20) → Decompose into single-responsibility functions
cognitive_complexity
Formula: CC + nestingDepth × 2 (approximation)
Measures how difficult code is to understand. Unlike cyclomatic, it penalizes nesting exponentially.
Generic thresholds:
| Level | Range | Score |
|---|---|---|
| Excellent | ≤ 7 | 100 |
| Good | 8-15 | 80-100 |
| Acceptable | 16-25 | 45-80 |
| Poor | > 25 | 0-45 |
**Common patterns
常见问题
它支持哪些编程语言?
技能说明它涵盖 14 种语言,包括 Go 和 JavaScript。
使用前我需要准备什么?
你需要安装一次分析工具,并且需要 Node.js 18 或更新版本。
分数代表什么?
工具会给出 0 到 100 的总分,分数越高,代码质量越好。
详情
作者的原始描述
Use when code changes are complete and ready for quality review, before committing or creating PRs. Triggers after implementing features, fixing bugs, or refactoring code. Also use when user asks to check code quality, analyze technical debt, review code smell, or mentions "fuck-u-code", "code quality", "shit mountain", "code review", "static analysis". Covers all 14 supported languages (Go, JS, TS, Python, Java, C, C++, Rust, C#, Lua, PHP, Ruby, Swift, Shell).
repo: Done-0/fuck-u-code
热度
- GitHub 星标
- 7.3k
- 排名
- #13307
- 许可证
- MIT
- 更新时间
- 2026/9/7
评论
- …