一键导入
analyze-code-quality
Run all available tests and linters, check for anti-patterns, and generate a comprehensive code quality report
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Run all available tests and linters, check for anti-patterns, and generate a comprehensive code quality report
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create a new bug ticket in Hot Sheet
Create a new feature ticket in Hot Sheet
Create a new investigation ticket in Hot Sheet
Create a new issue ticket in Hot Sheet
Create a new req change ticket in Hot Sheet
Create a new task ticket in Hot Sheet
| name | analyze-code-quality |
| description | Run all available tests and linters, check for anti-patterns, and generate a comprehensive code quality report |
| allowed-tools | Read, Grep, Glob, Bash, Agent |
Analyze the overall quality of the source code in this project. Generate a comprehensive report.
The goal is not just "does it compile and are the lines covered" — it is "is the code correct in the sequences it actually runs." A green test suite at 100% line coverage routinely ships behavioral bugs (see step 6). Weight the report accordingly.
Run unit tests with coverage
npm test
Report: total tests, pass/fail count, coverage percentage by directory.
Note: npm test (vitest) does NOT run the Rust tests. If src-tauri/ exists, also run npm run test:rust (cargo test — needs the Rust toolchain) and report those separately. Plugin tests (plugins/*/src/*.test.ts) run only when targeted — run npm run test:all-including-plugins if you want plugin coverage folded in.
Run E2E tests
npm run test:e2e
Report: total E2E tests, pass/fail count. (Use npm run test:e2e:fast to skip GitHub-credentialed specs if credentials aren't configured.)
Run linter
npm run lint
Report: total errors/warnings, categorized by rule.
Check TypeScript strictness
npx tsc --noEmit
Report any type errors.
Check for anti-patterns documented in CLAUDE.md
Read CLAUDE.md and the docs/ requirements files first — the authoritative anti-pattern list lives there and evolves, so treat CLAUDE.md as the source of truth over this list. Prefer ast-grep for structural checks (ast-grep run --lang <ts|tsx|rust> -p '<pattern>' <path>) over text grep — it matches the AST, skipping comments/strings and catching multi-line shapes; pick --lang per file extension (tsx ≠ ts ≠ rust). Look for violations of documented conventions, including:
document.createElement() instead of toElement() from dom.ts (note the documented intentional exceptions in CLAUDE.md).xxx.innerHTML = yyy in client code instead of morph() / replaceChildren(toElement(...)) (the no-restricted-syntax ESLint rule flags this outside an allowlist).SafeHtml (use raw() for pre-rendered HTML).as type assertions where a runtime check belongs — JSON.parse(x) as Y, res.json() as Y (flagged by no-restricted-syntax), and DB JSON-column reads that skip a zod schema. Prefer instanceof / type predicates / zod / the api() schema param.src/client/**, plugins/*/src/**): window.confirm/alert/prompt/open — must use the in-app equivalents (confirmDialog, invoke('open_external_url'), etc.). These silently no-op in Tauri's WKWebView but pass in Chromium E2E, so they won't show up as test failures.exec() instead of execFile()/execFileSync() for shell commands..js extension on relative import paths (TS ESM convention).api<{…}>() literals or raw api()/apiWithSecret()/apiUpload() calls in client code instead of a typed caller from src/api/.CHANNEL_VERSION / EXPECTED_CHANNEL_VERSION out of sync (must be equal integers).Behavioral / state-transition audit — the anti-false-confidence step.
Coverage percentage (step 1) is structurally blind to a missing state transition: a bug living in an untested interaction between operations sails through a green 100% report, because each individual line still gets hit by isolated, single-operation-from-clean-state tests. Real bugs have shipped this way in stateful modules under 100% line/branch/function/statement coverage. This step exists to catch that class.
Identify the stateful modules. Heuristic — flag any source module that has any of:
In this codebase, likely candidates include (verify against current source, names drift): the snapshot/backup lifecycle (src/db/), the background scheduler (§75), the WebSocket sync event bus + ring/seq (§93), telemetry ingest rollups / dedup sets (§67, §82, §85), the worker-pool claim/lease/drain state machine (§89–92), terminal lifecycle / active-device lease (§109), reactive stores (defineStore, §61), and debounced markdown sync. Don't treat this list as exhaustive — derive it from the actual code.
For each stateful module, enumerate its states and the transitions between them, then check whether the test suite exercises the transitions — multi-step sequences that cross state boundaries — not just each operation starting from a clean initial state. A test file that only calls each function once from a fresh fixture does NOT cover transitions, even at 100% line coverage.
Flag any stateful module whose tests are single-operation-from-clean-state only, and recommend an adversarial transition-matrix test for it. Give concrete sequences to try:
If docs/manual-test-plan.md exists, cross-check it: features listed there as manual-only that have since become automatable, and stateful features missing from both the automated suite and the manual plan.
Generate a structured report with: