Atlas / Skills / lkdx0220 / ai-code-quality-skill

ai-code-quality-skillSAFE

skills/lkdx0220/ai-code-quality-skill

AI Agent Skill + 本地 CLI(cq):把 ruff/mypy/radon/vulture/pytest/import-linter/DeepSec 聚合成一套代码质量工作流——扫描/归因/基线/分批修复/质量门,可装进 DSH/Claude Code/Codex/Cursor

Verdict
SAFE
Grade
B
Trust score
89 /100
Version
—
Hosts
3 documented
License
NOASSERTION
Stars
0
01

Overview

From the repository's own README, as read at the audited commit. Badges and raw HTML are left out.

[](https://github.com/lkdx0220/ai-code-quality-skill/actions/workflows/ci.yml) [](LICENSE)

这是一个 AI Agent Skill:一份可安装到 DSH / Claude Code / Codex / Cursor 等任何 AI Agent 的 说明文件(agent-adapters/),外加一个由它驱动的本地 CLI cq—— 把 AI 写的代码按可复现的流程,从"能跑但 AI 味重"带到质量门 A 级。

30 秒上手

# 一行安装(任选其一)
pipx install git+https://github.com/lkdx0220/ai-code-quality-skill
uv tool install git+https://github.com/lkdx0220/ai-code-quality-skill
pip install -e .   # 开发态

cq doctor                     # 1 环境体检:缺什么工具,按提示装(系统已有会自动发现)
cq scan --project    # 2 扫描 → audits//report.md
cq gate --run  --target A   # 3 质量门:blocker/high/复杂度/覆盖率/新增,exit 0=达标

怎么接进你的 AI Agent(适配器矩阵)

装好后对 Agent 说"帮我审一下这个项目的代码质量"即可;各 harness 安装点与同步命令见 agent-adapters/README.md。

  • 当 CLI 用:cq scan --project → audits// 下的统一 findings 报告

(聚合 ruff / mypy / radon / vulture / pytest-cov / import-linter / DeepSec L1+L2, 全程本地离线、只读、密钥自动脱敏)

完整工作流:扫描 → 环境体检 → 四维归因 → 固化基线 → 分批修复 → 复扫对比 → 质量门验收。

设计原则

  • 核心 CLI + 薄适配层:cq 不依赖任何 Agent 框架(DSH/Codex/ZCode 各自只需一份说明文件,见 agent-adapters/)。
  • 零运行时依赖:核心包只用 Python 标准库;外部工具全部 subprocess 调用。
  • 不许静默 pass:工具缺失/超时/
Read from source at commit 4d22f60b71edOBSERVED · 2026-10-12
02

Install

Commands as the repository documents them. They are shown, not run.

uv tool install git+https://github.com/lkdx0220/ai-code-quality-skill
pip install -e .   # 开发态
pip install ruff mypy radon vulture pytest pytest-cov import-linter
pip install git+https://github.com/Unclecheng-li/DeepSec        # 形态一:pip 安装
git clone https://github.com/Unclecheng-li/DeepSec <任意路径>    # 形态二:源码 + 环境变量
uv tool install --editable .
03

Host compatibility

What the documentation claims. We have not run a compatibility test.

HostStatusNotes
claude-codementioned
codexmentioned
cursormentioned
04

What it tells the agent

The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.

---
name: ai-code-quality
description: "INVOKE THIS SKILL when the user asks to 审查代码, 代码质量, 可维护性, AI 味, slop, 重构风险, 安全扫描, Sonar E 到 A, quality gate, ruff/mypy/radon/vulture/coverage, or before committing/refactoring a large change. Runs a unified local quality workflow: DeepSec L1/L2 + 可维护性工具链 + 基线对比 + 分批修复计划 + 复扫验收 + 质量门."
---

# ai-code-quality(cq)

统一本地代码质量工作流。核心入口是 `cq` CLI(独立安装,不属于 DSH),
本 skill 只定义"何时调、怎么调、如何汇报"——实现细节一律以 `cq --help` 和产物为准。

<when-to-use>
- 用户说"帮我看看这段代码能不能维护""AI 写的代码太乱了""审一下这个项目"
- 用户要代码质量评级、安全扫描、复杂度/死代码/覆盖率/类型检查
- 用户要修一轮大改动、做重构、提交前检查
- 用户要"从 E 修到 A"式的质量提升工作流
</when-to-use>

<when-not-to-use>
- 只讨论单一语法错误:直接修,不用跑全流程
- 用户只要 DeepSec 安全扫描:直接 `python -m deepsec shield scan`
- 用户只要某一个小工具的原始输出(如只跑 ruff):直接跑那个工具
</when-not-to-use>

<workflow>
1. 陌生环境先 `cq doctor --format json`;缺工具时把 install 命令原样转告用户,
   征得同意再安装(绝不静默 pip install)。deepsec 缺失可降级(安全维度无结论)。
2. `cq scan --project <路径>` 全量扫描,读 audits/<run_id>/summary.json 的 tools[]:
   任何 skipped/timeout/error 都不许当"通过"汇报。
3. `cq triage --run <run_id>` 看四维分布与修复批次,选最有效的 1-3 批。
4. 修之前 `cq baseline --run <run_id> --name baseline` 固化基线。
5. 修复:自动修复类用 `cq fix --run <id> --batch N --apply`(需用户显式批准);
   其余批次按 triage 指引人工修。一次只修一类,每批跑测试。
6. `cq scan` 复扫 → `cq diff --run <新run> --baseline baseline`(exit 1 = 有新增 blocker/high,
   必须处理)→ `cq gate --run <新run> --baseline baseline --target A` 验收。
7. 确认误报/用户说暂不修的 finding 用 `cq suppress`(必须带理由);
   大改/全量格式化后 id 失配时用 `cq suppress --reapply --run <新run>` 按签名对齐。
8. 汇报:diff 的数字(新增 X / 修复 Y / 仍存在 Z / 豁免 W)+ gate 各检查项状态 + 产物路径。

起步期覆盖率提示:默认阈值 80% 对测试刚起步的仓库必然红。让用户在仓库根放 `cq.toml`
设一个当前可达成的 `coverage_threshold`(如 40),配提升计划逐级上调——gate 红着才有意义。
</workflow>

<hard-rules>
- cq 默认只读;`cq fix --apply` 必须用户明确批准,apply 后必须跑测试,绝不自动 commit。
- 一次只修一类规则,每批必须跑测试。
- 工具缺失/超时 → skipped,不允许静默 pass。
- 不把密钥、token、.env 内容写进报告(cq 已统一脱敏)。
- DeepSec L3 / Spear / 外部 AI review 必须显式授权,本 skill 永不默认调用。
- suppression 必须写理由;不许为了让 gate 变绿而豁免真问题。
- 报告只回摘要和产物路径,不要把工具原始输出全贴回来。
- 汇报注明检测能力来自底层开源工具(ruff/mypy/radon/vulture/pytest/import-linter/DeepSec),cq 只做聚合编排。
</hard-rules>

## 环境引导(第一次使用必读)

cq 的能力来自 8 个外部工具,不一定已安装。`cq doctor` 会告诉你缺什么、装到哪。
安装知识只在 doctor 一处维护:不要凭记忆拼安装命令,一律以 doctor 输出为准。

**解释器陷阱(新机器必踩,先看这段再决定装不装)**:cq 装在 uv tool/pipx 隔离 venv 时,
`cq doctor` 默认只探 cq 自带解释器——系统 Python 里已装好的工具链它一开始看不见。
doctor/scan 已内置兜底:默认解释器缺核心工具时自动改用 PATH 上工具链全齐的系统 Python,
并在输出里给出固化命令。若要显式指定:

```bash
cq doctor --python <系统python.exe> --deepsec-home <DeepSec仓库路径>   # 显式探测
# 固化(任选其一):设 CQ_PYTHON / CQ_DEEPSEC_HOME 环境变量;仓库根 cq.toml;每次传 --python
```

**不要一看到"缺 5 个工具"就 pip install 重装一遍**——先确认是不是解释器指错了。
另外:工具报 error/timeout 时先查环境(临时目录/缓存不可写),cq 会把崩溃如实报 error
而非静默当 ok,受限环境配方见 README「受限环境怎么跑」。

详细说明见仓库 `agent-adapters/generic/PROMPT.md`(与本文件同步维护,以仓库版本为准)。
05

Trust audit

SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.

LayerWhat it checksResult
L0Provenance & inventoryPASS
L1Static analysis of the codeWARN
L2Instruction surface (what it tells the agent)PASS
L3Class-specific surfacePASS
L4Behavioural (sandbox)SKIPPED

What the source does

Filesystem
none-observed
Network
none-observed
Shell
none-observed
Dependencies
pinned
Secrets in source
found

Findings (3)

MEDIUMHard-coded secrets · secret.private_key · CWE-798, CWE-321
tests/test_redact.py:43
text = "-----BEGIN RSA PRIVATE KEY-----\nMIIEow...\n-----END RSA PRIVATE KEY-----"
LOWCode injection · code.eval_exec · CWE-78, CWE-94, CWE-95
tests/test_parsers.py:21
assert _safe_evidence("insecure_config_eval", "insecure_config", "eval(") == "eval("
Why it matters. evaluates text as code
Fix. remove; use a parser or a dispatch table
LOWInsecure crypto · crypto.weak_hash · CWE-327, CWE-338
src/ai_code_quality/schema.py:44
return hashlib.sha1(raw.encode("utf-8")).hexdigest()

Gates applied: no_behavioural_pass.

Audited 2026-10-12 · audit v0.4.1 · source sha 4d22f60b71edfull audit observations/trust-audit/skill/lkdx0220__ai-code-quality-skill.json · Report an issue / request a re-scan
06

Audit history

Every audit this skill has had.

DateSourceVerdictGradeScoreChange
2026-10-124d22f60b71edSAFEB89first audit
07

Questions

What does the ai-code-quality-skill skill do?

AI Agent Skill + 本地 CLI(cq):把 ruff/mypy/radon/vulture/pytest/import-linter/DeepSec 聚合成一套代码质量工作流——扫描/归因/基线/分批修复/质量门,可装进 DSH/Claude Code/Codex/Cursor

Is ai-code-quality-skill safe to install?

The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.

What can ai-code-quality-skill access on my machine?

The audit observed no filesystem, network or shell use at all in its source.

Which assistants does ai-code-quality-skill work with?

Its documentation mentions claude-code, codex and cursor. That is what the text claims, not a compatibility test we ran.

How current is this page?

The grade is for one exact copy of the source (4d22f60b71ed), read on 2026-10-12. The repository is watched, and a new audit runs when it changes — this is the first audit.

Advertisement