Communitygithub.com

codehealth-mcp

CodeScene MCPによるリアルタイムな構造的コード健全性フィードバック—編集前のレビュー、変更後のスコア差分検証、コミット/PRのゲートに使用。コード品質レビュー、リファクタリング、AI変更によるファイル劣化確認、コミット/PR前などに活用。

codehealth-mcp とは?

Code Health MCP(CodeScene)は、AI支援コーディング向けの構造的メンテナンス性フィードバックを提供するスキルです。スタイル・リンター系スキル(`coding-standards`、`plankton-code-quality`)とは異なり、**設計レベル**の健全性スコアと回帰ゲートを備えています。このスキルは、ファイル編集前の完全な構造分析(`code_health_review`)、変更後のスコア差分チェック(`code_health_score`)、コミット前の回帰防止(`pre_commit_code_health_safeguard`)、PR前のブランチレベルのチェック(`analyze_change_set`)という4つのツールを提供します。CodeSceneのスタンドアロンモードで動作し、有料のCodeSceneプラットフォームアカウントは不要です。Claude CodeやECC(Enhanced Code Companion)などのAIエージェントプラットフォームと連携し、コードのメンテナンス性を維持しながらリファクタリングや機能追加を行いたい場合に最適です。スコアは1〜10段階で評価され、緑(9.0〜10.0)が健全、黄色(4.0〜8.9)が負債あり、赤(1.0〜3.9)が深刻な負債を示します。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/codehealth-mcp

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Code Health MCP (CodeScene)

AI支援コーディングのための構造的メンテナンス性フィードバック。スタイル/リンター系スキル (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,... を使用して除外することもできます。

認証情報: トークンはバンドルされていません。CS_ACCESS_TOKEN は自身で設定してください(上流リポジトリの getting-a-personal-access-token.md を参照)。トークンをリポジトリにコミットしないでください。

ツールの読み取り対象: ツールを呼び出すと、指定されたローカルリポジトリ内のファイルとgit状態を分析します(渡したパスと、analyze_change_set のブランチコンテキスト)。ツールは自動的には実行されません。スタンドアロンモードの場合は、上流のプライバシードキュメント(codescene-mcp-server README および CodeSceneポリシー)に従ってください。このスキルを、分析されたくないシークレット、認証情報、パスに使用しないでください。

MCPが利用できない場合(オフライン、不正なトークン、サーバークラッシュ): Code Healthスコアをでっち上げないでください。チェックがスキップされたことをユーザーに伝えてください。明示的なユーザーの承認がある場合のみ続行してください。MCPがダウンしている場合は、ゲートにはリンター/テスト/検証ループを優先してください。サーバーが接続されたらチェックを再有効にしてください。

使用時

  • ユーザーが コード品質のレビュー、ファイルの リファクタリング、または AI変更によるメンテナンス性の低下 の確認を依頼した場合
  • ホットスポット、レガシーモジュール、または不慣れなファイルを編集する前
  • メンテナンス性の安全策が必要な コミット または プルリクエスト の前
  • 大規模なエージェント作成差分の後 — Code Healthが低下していないことを確認
  • 構造チェックとして verification-loop、tdd-workflow、または /quality-gate と組み合わせる(テスト/リンターの代わりにはなりません)

アクティブ化時

上記の使用時と同じトリガーです — この見出しはECCがスキルの自動アクティブ化に使用するものです。

仕組み

1. MCPサーバーに接続

mcp-configs/mcp-servers.json から codescene エントリをハーネスの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 にマージします。

トークン設定は上流リポジトリ(上記リンク)に文書化されています。スタンドアロンモードでは、以下の4つのツールに対して有料のCodeSceneプラットフォームアカウントは不要です。セッションを再起動し、codescene サーバーが接続されていることを確認してからスコアに依存してください。

2. スタンドアロンツールのみを呼び出す

ツール使用時
code_health_reviewファイルを変更する前の完全な構造分析
code_health_score各変更後の素早い数値スコア(差分チェック)
pre_commit_code_health_safeguardCode Healthの回帰をもたらすコミットをブロック
analyze_change_setPRを開く前のブランチレベルチェック

プラットフォーム専用ツール(例: リポジトリ全体の技術的負債ホットスポットリスト)は呼び出さないでください。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(無料スタンドアロントークンのみ)。

例: 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記述時リンター/フォーマット;Code Health = 編集前後の構造ゲート
verification-loop / /quality-gate「完了」前に構造回帰チェックを追加
security-reviewセキュリティ vs メンテナンス性 — 両方該当する場合は両方使用
tdd-workflowテスト合格 ≠ 健全な設計 — リファクタリング後にスコアを確認

コンテキストのヒント: ECCはMCPの数を少なく保つことを推奨しています。実質的な編集を行う場合に codescene を有効にし、不要な場合は無効にしてください。

関連スキル

  • coding-standards — 基本規約
  • plankton-code-quality — 記述時リンター/フォーマットフック
  • verification-loop — ビルド/テスト/リンターゲート
  • 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/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

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.

関連スキル