Communitygithub.com

codehealth-mcp

CodeScene MCP を使用したリアルタイム構造的コードヘルス——編集前にレビュー、変更後のスコア差分確認、コミットとPRをゲート。コード品質確認、リファクタリング、AI変更による劣化チェック、コミット/PR前に使用。

codehealth-mcp とは?

このスキルは、AIエージェントによるコード変更の品質を構造的な保守性の観点から評価・ゲートするためのMCP(Model Context Protocol)サーバーです。CodeScene のスタンドアロンツール(`code_health_review`、`code_health_score`、`pre_commit_code_health_safeguard`、`analyze_change_set`)を利用し、ファイル編集前のベースラインスコア取得、編集後のスコア差分確認、コミット前の品質ゲート、PR前のブランチレベルチェックをワークフローに組み込みます。スタイルやリントをチェックするスキル(`coding-standards`、`plankton-code-quality`)を補完し、設計レベルの健全性を担保します。Claude Code や ECC(Enhanced Coding Convention)との連携を想定しており、`CS_ACCESS_TOKEN` を環境変数に設定することで無料のスタンドアロンモードで利用可能です(有料プラットフォームアカウント不要)。スコアは1〜10の範囲で評価され、9.0以上は健全、4.0〜8.9は技術的負債あり、3.9以下は深刻な負債と見なします。AIエージェントはこのスキルを用いて、変更前にコードヘルスをレビューし、変更後はスコアが低下していないことを確認しながらタスクを進めることが推奨されます。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/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_DISABLED_MCPS=codescene,... を使用して ECC インストール/同期時に除外することもできます。

認証情報: トークンはバンドルされていません。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/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.

関連スキル