ln-624-code-quality-auditor by levnikolaevich/claude-code-skills
npx skills add https://github.com/levnikolaevich/claude-code-skills --skill ln-624-code-quality-auditorPaths: 文件路径(
shared/、references/、../ln-*)是相对于技能仓库根目录的。如果在当前工作目录未找到,请定位此 SKILL.md 文件所在的目录并向上返回一级以找到仓库根目录。如果缺少shared/目录,请通过 WebFetch 从https://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/{path}获取文件。
专门用于审计代码复杂度、方法签名、算法和常量管理的 Worker。
必读: 加载 shared/references/audit_worker_core_contract.md。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
接收包含以下内容的 contextStore:tech_stack、best_practices、principles、codebase_root、output_dir。
领域感知: 支持 domain_mode + current_domain(参见 audit_output_schema.md#domain-aware-worker-output)。
必读: 加载 shared/references/two_layer_detection.md 以了解检测方法。
scan_path(如果指定则为领域感知),提取 output_dirscan_path(而非 codebase_root)
* 示例:Grep(pattern="if.*if.*if", path=scan_path) 用于检测嵌套domain: domain_name(如果领域感知)shared/templates/audit_worker_report_template.md 在内存中构建完整的 Markdown 报告,通过单次 Write 调用写入 {output_dir}/624-quality-{domain}.md(或在全局模式下写入 624-quality.md)内容: 单个函数中决策点过多(> 10)
检测:
eslint-plugin-complexity、radon(Python)、gocyclo(Go)严重性:
建议: 拆分函数,提取辅助方法,使用提前返回
工作量: 中-大(取决于复杂度)
内容: 嵌套的 if/for/while 块过深
检测:
严重性:
建议: 提取函数,使用守卫子句,反转条件
工作量: 中(重构结构)
内容: 函数过长,承担过多职责
检测:
严重性:
建议: 拆分为更小的函数,应用单一职责原则
工作量: 中(提取逻辑)
内容: 承担过多职责的文件
检测:
严重性:
建议: 拆分为多个文件,应用关注点分离原则
工作量: 大(重大重构)
内容: 函数参数过多
检测:
严重性:
建议: 使用参数对象、构建器模式、默认参数
工作量: 小-中(重构签名 + 调用)
内容: 对集合进行低效的嵌套循环
检测:
for (i) { for (j) { ... } }arr.map(x => arr.filter(...))严重性:
建议: 使用哈希映射,通过单次遍历优化,使用更好的数据结构
工作量: 中(算法重新设计)
内容: ORM 延迟加载导致 N+1 查询
检测:
users.forEach(u => u.getPosts())严重性:
建议: 使用预加载、批量查询、JOIN
工作量: 中(更改 ORM 查询)
内容: 魔法数字/字符串、分散的常量、重复项
检测:
| 问题 | 模式 | 示例 |
|---|---|---|
| 魔法数字 | 条件/计算中的硬编码数字 | if (status === 2) |
| 魔法字符串 | 比较中的硬编码字符串 | if (role === 'admin') |
| 分散化 | 常量分散在多个文件中 | 5 个文件中的 MAX_SIZE = 100 |
| 重复项 | 相同值出现多次 | 3 个地方的 STATUS_ACTIVE = 1 |
| 缺少中心文件 | 缺少 constants.ts 或 config.py | 没有单一事实来源 |
严重性:
建议:
constants.ts、config.py、constants.go)const STATUS_ACTIVE = 1工作量: 中(提取常量、更新导入、合并)
内容: 降低可读性和可维护性的不佳方法契约
检测:
| 问题 | 模式 | 示例 |
|---|---|---|
| 布尔标志参数 | 签名中 >=2 个布尔参数 | def process(data, is_async: bool, skip_validation: bool) |
| 过多可选参数 | >=3 个带默认值的可选参数 | def query(db, limit=10, offset=0, sort="id", order="asc") |
| 不一致的动词命名 | 同一模块中相同操作类型使用不同动词 | get_user() 对比 fetch_account() 对比 load_profile() |
| 不明确的返回类型 | 没有 TypedDict/NamedTuple 的 -> dict、-> Any、-> tuple | def get_stats() -> dict 而不是 -> StatsResponse |
严重性:
建议:
get_ 用于同步,fetch_ 用于异步等)工作量: 小-中(重构签名 + 调用者)
内容: 触发外部副作用级联链的函数(数据库写入 → 通知 → 指标 → 限制)。
检测: 必读: shared/references/ai_ready_architecture.md 以了解副作用标记、误报排除和不透明接收器规则。
**/services/**/*.{py,ts,js,cs,java} 以查找服务文件严重性:
冲突解决: 如果函数是协调器(导入 3+ 个服务并按顺序委托给它们) → ARCH-AI-SEB 不适用。协调器预期具有多个副作用类别。仅对叶子函数标记 SEB。
建议: 重构为扁平化编排 — 将副作用提取到独立的接收器函数中。参见参考。
工作量: 中-大
输出: 同时按模块生成摘要管道/接收器表:
| 模块 | 接收器 (0-1) | 浅管道 (2) | 深管道 (3+) | 接收器比率 |
|---|
必读: 加载 shared/references/audit_worker_core_contract.md 和 shared/references/audit_scoring.md。
必读: 加载 shared/references/audit_worker_core_contract.md 和 shared/templates/audit_worker_report_template.md。
将报告写入 {output_dir}/624-quality-{domain}.md(或在全局模式下写入 624-quality.md),并设置 category: "Code Quality" 和检查项:cyclomatic_complexity、deep_nesting、long_methods、god_classes、too_many_params、quadratic_algorithms、n_plus_one、magic_numbers、method_signatures、cascade_depth。
向协调器返回摘要:
Report written: docs/project/.audit/ln-620/{YYYY-MM-DD}/624-quality-orders.md
Score: X.X/10 | Issues: N (C:N H:N M:N L:N)
必读: 加载 shared/references/audit_worker_core_contract.md。
domain_mode="domain-aware",则仅扫描 scan_path(而非整个代码库)domain 字段必读: 加载 shared/references/audit_worker_core_contract.md。
{output_dir}/624-quality-{domain}.md(原子性单次 Write 调用)shared/references/audit_output_schema.md版本: 3.0.0 最后更新: 2025-12-23
每周安装次数
209
仓库
GitHub 星标数
245
首次出现
2026年1月24日
安全审计
安装于
opencode191
gemini-cli189
codex189
cursor188
claude-code185
github-copilot180
Paths: File paths (
shared/,references/,../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root. Ifshared/is missing, fetch files via WebFetch fromhttps://raw.githubusercontent.com/levnikolaevich/claude-code-skills/master/{path}.
Specialized worker auditing code complexity, method signatures, algorithms, and constants management.
MANDATORY READ: Load shared/references/audit_worker_core_contract.md.
Receives contextStore with: tech_stack, best_practices, principles, codebase_root, output_dir.
Domain-aware: Supports domain_mode + current_domain (see audit_output_schema.md#domain-aware-worker-output).
MANDATORY READ: Load shared/references/two_layer_detection.md for detection methodology.
scan_path (domain-aware if specified), extract output_dirscan_path (not codebase_root)Grep(pattern="if.*if.*if", path=scan_path) for nesting detectiondomain: domain_name (if domain-aware)What: Too many decision points in single function (> 10)
Detection:
eslint-plugin-complexity, radon (Python), gocyclo (Go)Severity:
Recommendation: Split function, extract helper methods, use early returns
Effort: M-L (depends on complexity)
What: Nested if/for/while blocks too deep
Detection:
Severity:
Recommendation: Extract functions, use guard clauses, invert conditions
Effort: M (refactor structure)
What: Functions too long, doing too much
Detection:
Severity:
Recommendation: Split into smaller functions, apply Single Responsibility
Effort: M (extract logic)
What: Files with too many responsibilities
Detection:
Severity:
Recommendation: Split into multiple files, apply separation of concerns
Effort: L (major refactor)
What: Functions with excessive parameters
Detection:
Severity:
Recommendation: Use parameter object, builder pattern, default parameters
Effort: S-M (refactor signature + calls)
What: Inefficient nested loops over collections
Detection:
for (i) { for (j) { ... } }arr.map(x => arr.filter(...))Severity:
Recommendation: Use hash maps, optimize with single pass, use better data structures
Effort: M (algorithm redesign)
What: ORM lazy loading causing N+1 queries
Detection:
users.forEach(u => u.getPosts())Severity:
Recommendation: Use eager loading, batch queries, JOIN
Effort: M (change ORM query)
What: Magic numbers/strings, decentralized constants, duplicates
Detection:
| Issue | Pattern | Example |
|---|---|---|
| Magic numbers | Hardcoded numbers in conditions/calculations | if (status === 2) |
| Magic strings | Hardcoded strings in comparisons | if (role === 'admin') |
| Decentralized | Constants scattered across files | MAX_SIZE = 100 in 5 files |
| Duplicates | Same value multiple times | STATUS_ACTIVE = 1 in 3 places |
| No central file | Missing constants.ts or |
Severity:
Recommendation:
constants.ts, config.py, constants.go)const STATUS_ACTIVE = 1Effort: M (extract constants, update imports, consolidate)
What: Poor method contracts reducing readability and maintainability
Detection:
| Issue | Pattern | Example |
|---|---|---|
| Boolean flag params | >=2 boolean params in signature | def process(data, is_async: bool, skip_validation: bool) |
| Too many optional params | >=3 optional params with defaults | def query(db, limit=10, offset=0, sort="id", order="asc") |
| Inconsistent verb naming | Different verbs for same operation type in one module | get_user() vs fetch_account() vs load_profile() |
| Unclear return type | , , without TypedDict/NamedTuple |
Severity:
Recommendation:
get_ for sync, fetch_ for async, etc.)Effort: S-M (refactor signatures + callers)
What: Functions triggering cascading chains of external side-effects (DB writes → notifications → metrics → limits).
Detection: MANDATORY READ: shared/references/ai_ready_architecture.md for side-effect markers, false positive exclusions, and opaque sink rules.
**/services/**/*.{py,ts,js,cs,java} to find service filesSeverity:
Conflict Resolution: IF function is an orchestrator/coordinator (imports 3+ services AND delegates to them sequentially) → ARCH-AI-SEB does NOT apply. Orchestrators are EXPECTED to have multiple side-effect categories. Only flag SEB for leaf functions.
Recommendation: Refactor to flat orchestration — extract side-effects into independent sink functions. See reference.
Effort: M-L
Output: Also generate summary Pipe/Sink table per module:
| Module | Sinks (0-1) | Shallow Pipes (2) | Deep Pipes (3+) | Sink Ratio |
|---|
MANDATORY READ: Load shared/references/audit_worker_core_contract.md and shared/references/audit_scoring.md.
MANDATORY READ: Load shared/references/audit_worker_core_contract.md and shared/templates/audit_worker_report_template.md.
Write report to {output_dir}/624-quality-{domain}.md (or 624-quality.md in global mode) with category: "Code Quality" and checks: cyclomatic_complexity, deep_nesting, long_methods, god_classes, too_many_params, quadratic_algorithms, n_plus_one, magic_numbers, method_signatures, cascade_depth.
Return summary to coordinator:
Report written: docs/project/.audit/ln-620/{YYYY-MM-DD}/624-quality-orders.md
Score: X.X/10 | Issues: N (C:N H:N M:N L:N)
MANDATORY READ: Load shared/references/audit_worker_core_contract.md.
domain_mode="domain-aware", scan ONLY scan_path (not entire codebase)domain field in each finding when domain-awareMANDATORY READ: Load shared/references/audit_worker_core_contract.md.
{output_dir}/624-quality-{domain}.md (atomic single Write call)shared/references/audit_output_schema.mdVersion: 3.0.0 Last Updated: 2025-12-23
Weekly Installs
209
Repository
GitHub Stars
245
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode191
gemini-cli189
codex189
cursor188
claude-code185
github-copilot180
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
31,600 周安装
shared/templates/audit_worker_report_template.md, write to {output_dir}/624-quality-{domain}.md (or 624-quality.md in global mode) in single Write callconfig.py| No single source of truth |
-> dict-> Any-> tupledef get_stats() -> dict instead of -> StatsResponse |