Communitygithub.com

codehealth-mcp

透過 CodeScene MCP 進行即時結構性程式碼健康檢查——在編輯前審查,在變更後驗證分數差異,並在提交和 PR 時設置關卡。用於審查程式碼品質、重構、檢查 AI 更改是否導致檔案品質下降,或在提交/PR 前使用。

codehealth-mcp 是什麼?

此技能為 AI 輔助編碼提供結構性可維護性回饋,專注於設計層級的程式碼健康評分與回歸關卡,以補充風格與 lint 檢查技能。它基於 CodeScene 的 MCP 伺服器,支援 Claude Code、Cursor 等 MCP 相容平台,透過 npx 執行獨立工具(無需付費 CodeScene 平台帳戶)。技能提供四個核心工具:`code_health_review`(修改前完整分析)、`code_health_score`(變更後快速評分)、`pre_commit_code_health_safeguard`(提交前阻止健康度回歸)及 `analyze_change_set`(PR 前分支級檢查)。它要求使用者手動設定 `CS_ACCESS_TOKEN`,並強調安全性與選擇性啟用。使用流程包括:修改前記錄基線分數,每次編輯後檢查分數是否下降,提交前執行保護檢查,PR 前對比基礎分支。適用於重構、處理熱點或遺留模組、大型 AI 產出差異審查等場景,可與驗證循環、TDD 工作流程或品質關卡搭配使用,但不是測試或 lint 的替代品。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/codehealth-mcp

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Code Health MCP (CodeScene)

針對 AI 輔助編碼的結構性可維護性回饋。此技能可補充風格/lint 技能(coding-standards、plankton-code-quality),提供設計層級的健康評分與回歸關卡。

上游: codescene-oss/codescene-mcp-server 套件: @codescene/codehealth-mcp(透過 npx 的 stdio)

安全性與邊界

選擇啟用 (ECC): mcp-configs/mcp-servers.json 中的 codescene 區塊僅為範本。ECC 外掛安裝不會自動啟用隨附的 MCP 伺服器。只有當您想要使用時,才將該項目複製到您的設定中。您也可以在 ECC 安裝/同步時使用 ECC_DISABLED_MCPS=codescene,... 將其排除。

憑證: 不包含隨附的 Token。請自行設定 CS_ACCESS_TOKEN(請參閱上游儲存庫中的 getting-a-personal-access-token.md)。切勿將 Token 提交至儲存庫。

工具讀取的內容: 呼叫時,工具會分析本地儲存庫中您指定的檔案和 git 狀態(您傳入的路徑,以及 analyze_change_set 的分支上下文)。它們不會自行執行。對於獨立模式,請遵循上游隱私文件:codescene-mcp-server README 和 CodeScene 政策。請勿將此技能用於您不希望被分析的機密、憑證或路徑。

如果 MCP 無法使用(離線、Token 錯誤、伺服器崩潰): 請勿自行編造 Code Health 分數。告知使用者該檢查已被跳過。僅在獲得使用者明確同意後才繼續。當 MCP 無法使用時,建議使用 lint/測試/驗證循環作為關卡。一旦伺服器重新連線,再重新啟用檢查。

使用時機

  • 使用者要求審查程式碼品質、重構檔案,或檢查 AI 更改是否降低了可維護性
  • 在編輯熱點、遺留模組或不熟悉的檔案之前
  • 在需要可維護性保護的提交或拉取請求之前
  • 在大型代理產出差異之後——驗證 Code Health 沒有回歸
  • 與 verification-loop、tdd-workflow 或 /quality-gate 搭配使用,作為結構性檢查(非測試/lint 的替代品)

啟用時機

與上述使用時機相同——此標題是 ECC 用於技能自動啟動的依據。

運作方式

1. 連接 MCP 伺服器

將 mcp-configs/mcp-servers.json 中的 codescene 項目複製到您的 harness MCP 設定中。

Claude Code(~/.claude.json → mcpServers):

"codescene": {
  "command": "npx",
  "args": ["-y", "@codescene/codehealth-mcp"],
  "env": {
    "CS_ACCESS_TOKEN": "YOUR_CS_ACCESS_TOKEN_HERE"
  }
}

專案範圍: 將相同的區塊合併到儲存庫根目錄的 .mcp.json 中。

Token 設定在 upstream 儲存庫中已有文件說明(連結如上)。對於下面列出的四個工具,獨立模式不需要付費的 CodeScene 平台帳戶。在依賴分數之前,請重新啟動會話並確認 codescene 伺服器已連線。

2. 僅呼叫獨立工具

工具使用時機
code_health_review在修改檔案之前進行完整的結構性分析
code_health_score每次變更後快速取得數值分數(差異檢查)
pre_commit_code_health_safeguard阻止引入 Code Health 回歸的提交
analyze_change_set在開啟 PR 之前進行分支級別的檢查

請勿呼叫僅限平台的工具(例如倉庫範圍的技術債務熱點清單)。請勿引用 delta_analysis——此功能在獨立模式下不可用。

3. 解讀分數 (1–10)

範圍意義代理行為
9.0–10.0綠色——健康擴展較安全;但仍偏好垂直切片
4.0–8.9黃色——有債務謹慎處理;無順便重構
1.0–3.9紅色——嚴重債務僅限縮小範圍

4. 執行回饋循環

在接觸檔案之前

  1. 對目標路徑執行 code_health_review。
  2. 記錄基線分數和列出的程式碼異味。
  3. 規劃能解決任務的最小變更。

根據分數界定範圍:低於 5——僅做最小差異;5–7——不做廣泛重構;高於 7——重構較安全,但每次編輯後仍需驗證。

每次變更後

  1. 對同一個檔案執行 code_health_score。
  2. 與 code_health_review 的基線進行比較。
  3. 如果分數回歸,請在繼續之前修復。切勿在分數低於起始值時將任務標記為完成。

每次提交前——對儲存庫路徑執行 pre_commit_code_health_safeguard。

PR 前——對基礎分支(例如 main)執行 analyze_change_set。

範例

範例:Flask 可維護性改善

在 pallets/flask 上,僅使用獨立工具的代理循環:

  1. code_health_review 對目標模組(基線 4.82)
  2. 針對列出的異味進行目標重構
  3. 每次編輯後執行 code_health_score
  4. 提交前執行 pre_commit_code_health_safeguard
  5. PR 前執行 analyze_change_set

結果:Code Health 4.82 → 9.1(僅使用免費獨立 Token)。

範例:AGENTS.md 強制區塊

貼入專案 AGENTS.md 或 CLAUDE.md:

## Code Health (CodeScene MCP)

修改任何檔案前:執行 `code_health_review`,記錄分數和問題。

- 分數低於 5:有問題的範圍——嚴格限定變更範圍。
- 分數 5–7:警告範圍——不做廣泛重構。

每次變更後:執行 `code_health_score` 以驗證差異。

- 如果分數回歸:在繼續前修復;如果分數下降,切勿宣稱完成。

每次提交前:執行 `pre_commit_code_health_safeguard`。

PR 前:執行 `analyze_change_set`。

範例:反模式 vs 正確循環

# 錯誤:先編輯,後檢查
[未使用 code_health_review 的大型重構]

# 錯誤:忽略分數下降
"測試通過" → 在 Code Health 降低的情況下將任務標記為完成

# 錯誤:對紅色分數檔案(低於 5)進行廣泛重構
在模組中進行順便清理

# 正確:審查 → 小變更 → 分數 → 提交保護 → analyze_change_set

與 ECC 搭配使用

ECC 技能/流程Code Health MCP 角色
coding-standards風格/命名;Code Health = 結構/複雜度
plankton-code-quality編寫時 lint/格式化;Code Health = 編輯前/後結構性關卡
verification-loop / /quality-gate在標記「完成」前加入結構性回歸檢查
security-review安全性 vs 可維護性——在相關時兩者都使用
tdd-workflow測試通過 ≠ 設計健康——重構後檢查分數

上下文提示: ECC 建議保持較少的 MCP 數量。在進行實質性編輯時啟用 codescene;不需要時將其停用。

相關技能

  • coding-standards——基本慣例
  • plankton-code-quality——編寫時 lint/格式化鉤子
  • verification-loop——建置/測試/lint 關卡
  • tdd-workflow——測試優先開發
  • security-review——安全性檢查清單
  • documentation-lookup——透過 Context7 查詢函式庫文件(正交功能)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相關技能