Communitygithub.com

Planktonコード品質スキル

Planktonを使用した書き込み時のコード品質強制 — ファイル編集ごとに自動フォーマット、リンター、Claudeによる修正をフック経由で実行。書き込み時のフォーマット、リンター、自動修正フックの設定時に使用します。

Planktonコード品質スキル とは?

Planktonコード品質スキルは、Claude Codeエージェントがファイルを編集・書き込むたびに、自動フォーマット、リンター実行、そしてClaudeサブプロセスによる修正をPostToolUseフックとして実行するシステムです。Python、TypeScript、Shell、YAML、JSON、TOML、Markdown、Dockerfileなど複数の言語をサポートし、ruff、biome、shellcheck、hadolintなどの20以上のツールを統合しています。違反の複雑さに応じてHaiku、Sonnet、Opusのモデルを自動ルーティングする階層型修正アーキテクチャを採用し、ほとんどの問題を透明に解決します。また、エージェントがリンター設定を改変してルールを回避するのを防ぐ設定ファイル保護機能(PreToolUseブロック+Stopフック検出)や、レガシーパッケージマネージャー(pip、npmなど)の使用をブロックする機能も備えています。ECC(Enhanced Claude Code)と組み合わせて使用でき、互いの機能を補完しながらコード品質を強化します。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/plankton-code-quality

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

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

ドキュメント

Planktonコード品質スキル は何をしますか?

Plankton(クレジット: @alxfazio)の統合リファレンス。Claude Code向けの書き込み時コード品質強制システム。PlanktonはPostToolUseフックを介してファイル編集ごとにフォーマッターとリンターを実行し、エージェントが見逃した違反を修正するためにClaudeサブプロセスを起動します。

使用タイミング

  • ファイル編集ごとに自動フォーマットとリンターを実行したい場合(コミット時だけでなく)
  • エージェントがリンター設定を改変してルールを回避するのを防ぐ必要がある場合
  • 修正に階層型モデルルーティングを使用したい場合(スタイルはHaiku、ロジックはSonnet、型はOpus)
  • 複数の言語(Python、TypeScript、Shell、YAML、JSON、TOML、Markdown、Dockerfile)で作業する場合

仕組み

3フェーズアーキテクチャ

Claude Codeがファイルを編集または書き込むたびに、Planktonのmulti_linter.sh PostToolUseフックが実行されます:

フェーズ1: 自動フォーマット(サイレント)
├─ フォーマッターを実行(ruff format、biome、shfmt、taplo、markdownlint)
├─ 問題の40~50%をサイレントに修正
└─ メインエージェントへの出力なし

フェーズ2: 違反収集(JSON)
├─ リンターを実行し、修正不能な違反を収集
├─ 構造化JSONを返却: {line, column, code, message, linter}
└─ メインエージェントへの出力なし

フェーズ3: 委任+検証
├─ 違反JSONを含む claude -p サブプロセスを起動
├─ 違反の複雑さに基づいてモデル階層にルーティング:
│   ├─ Haiku: フォーマット、インポート、スタイル(E/W/Fコード) — タイムアウト120秒
│   ├─ Sonnet: 複雑さ、リファクタリング(C901、PLRコード) — タイムアウト300秒
│   └─ Opus: 型システム、深い推論(unresolved-attribute) — タイムアウト600秒
├─ フェーズ1+2を再実行して修正を検証
└─ クリーンなら終了コード0、違反残存なら終了コード2(メインエージェントに報告)

メインエージェントが見るもの

シナリオエージェントが見るフック終了コード
違反なしなし0
サブプロセスで全て修正なし0
サブプロセス後も違反残存[hook] N violation(s) remain2
アドバイザリ(重複、古いツール)[hook:advisory] ...0

メインエージェントはサブプロセスが修正できなかった問題のみを見ます。ほとんどの品質問題は透過的に解決されます。

設定保護(ルールゲーミング対策)

LLMはコードを修正する代わりに.ruff.tomlやbiome.jsonを変更してルールを無効化しようとします。Planktonは3つのレイヤーでこれをブロックします:

  1. PreToolUseフック — protect_linter_configs.shがリンター設定への編集をブロック
  2. Stopフック — stop_config_guardian.shがセッション終了時にgit diffで設定変更を検出
  3. 保護ファイルリスト — .ruff.toml、biome.json、.shellcheckrc、.yamllint、.hadolint.yamlなど

パッケージマネージャー強制

Bash用のPreToolUseフックがレガシーパッケージマネージャーをブロック:

  • pip、pip3、poetry、pipenv → ブロック(代わりにuvを使用)
  • npm、yarn、pnpm → ブロック(代わりにbunを使用)
  • 許可される例外: npm audit、npm view、npm publish

セットアップ

クイックスタート

注意: Planktonはリポジトリから手動でインストールする必要があります。インストール前にコードを確認してください。

# コア依存関係のインストール
brew install jaq ruff uv

# Pythonリンターのインストール
uv sync --all-extras

# Claude Codeの起動 — フックが自動的に有効化されます
claude

インストールコマンドやプラグイン設定は不要です。PlanktonディレクトリでClaude Codeを実行すると、.claude/settings.jsonのフックが自動的に認識されます。

プロジェクトごとの統合

自分のプロジェクトでPlanktonフックを使用するには:

  1. .claude/hooks/ディレクトリをプロジェクトにコピー
  2. .claude/settings.jsonのフック設定をコピー
  3. リンター設定ファイル(.ruff.toml、biome.jsonなど)をコピー
  4. 使用する言語のリンターをインストール

言語別依存関係

言語必須オプション
Pythonruff、uvty(型)、vulture(デッドコード)、bandit(セキュリティ)
TypeScript/JSbiomeoxlint、semgrep、knip(デッドエクスポート)
Shellshellcheck、shfmt—
YAMLyamllint—
Markdownmarkdownlint-cli2—
Dockerfilehadolint(>= 2.12.0)—
TOMLtaplo—
JSONjaq—

ECCとの組み合わせ

補完的、重複なし

関心事ECCPlankton
コード品質強制PostToolUseフック(Prettier、tsc)PostToolUseフック(20+リンター+サブプロセス修正)
セキュリティスキャンAgentShield、security-reviewerエージェントBandit(Python)、Semgrep(TypeScript)
設定保護—PreToolUseブロック+Stopフック検出
パッケージマネージャー検出+セットアップ強制(レガシーPMをブロック)
CI統合—git用Pre-commitフック
モデルルーティング手動(/model opus)自動(違反の複雑さ→階層)

推奨される組み合わせ

  1. ECCをプラグインとしてインストール(エージェント、スキル、コマンド、ルール)
  2. Planktonフックを書き込み時品質強制として追加
  3. AgentShieldをセキュリティ監査に使用
  4. ECCの検証ループをPR前の最終ゲートとして使用

フックの競合回避

ECCとPlanktonフックの両方を実行する場合:

  • ECCのPrettierフックとPlanktonのbiomeフォーマッターがJS/TSファイルで競合する可能性あり
  • 解決策: Planktonを使用する場合はECCのPrettier PostToolUseフックを無効にする(Planktonのbiomeの方が包括的)
  • 両方を異なるファイルタイプで共存可能(ECCはPlanktonがカバーしない部分を処理)

設定リファレンス

Planktonの.claude/hooks/config.jsonがすべての動作を制御:

{
  "languages": {
    "python": true,
    "shell": true,
    "yaml": true,
    "json": true,
    "toml": true,
    "dockerfile": true,
    "markdown": true,
    "typescript": {
      "enabled": true,
      "js_runtime": "auto",
      "biome_nursery": "warn",
      "semgrep": true
    }
  },
  "phases": {
    "auto_format": true,
    "subprocess_delegation": true
  },
  "subprocess": {
    "tiers": {
      "haiku":  { "timeout": 120, "max_turns": 10 },
      "sonnet": { "timeout": 300, "max_turns": 10 },
      "opus":   { "timeout": 600, "max_turns": 15 }
    },
    "volume_threshold": 5
  }
}

主要設定:

  • 使用しない言語を無効にしてフックを高速化
  • volume_threshold — 違反数がこの値を超えると自動的に上位モデル階層にエスカレーション
  • subprocess_delegation: false — フェーズ3を完全にスキップ(違反を報告するのみ)

環境変数オーバーライド

変数目的
HOOK_SKIP_SUBPROCESS=1フェーズ3をスキップ、違反を直接報告
HOOK_SUBPROCESS_TIMEOUT=N階層タイムアウトをオーバーライド
HOOK_DEBUG_MODEL=1モデル選択の決定をログに記録
HOOK_SKIP_PM=1パッケージマネージャー強制をバイパス

参考資料

  • Plankton(クレジット: @alxfazio)
  • Plankton REFERENCE.md — 完全なアーキテクチャドキュメント(クレジット: @alxfazio)
  • Plankton SETUP.md — 詳細なインストールガイド(クレジット: @alxfazio)

ECC v1.8 追加事項

コピー可能なフックプロファイル

厳格な品質動作を設定:

export ECC_HOOK_PROFILE=strict
export ECC_QUALITY_GATE_FIX=true
export ECC_QUALITY_GATE_STRICT=true

言語ゲートテーブル

  • TypeScript/JavaScript: Biome推奨、Prettierフォールバック
  • Python: Ruff format/check
  • Go: gofmt

設定改ざんガード

品質強制中、同じイテレーション内での設定ファイル変更にフラグを立てます:

  • biome.json、.eslintrc*、prettier.config*、tsconfig.json、pyproject.toml

違反を抑制するために設定が変更された場合、マージ前に明示的なレビューが必要です。

CI統合パターン

ローカルフックと同じコマンドをCIで使用:

  1. フォーマッターチェックを実行
  2. リンター/型チェックを実行
  3. 厳格モードで早期失敗
  4. 是正サマリーを公開

健全性メトリクス

追跡:

  • ゲートでフラグされた編集
  • 平均是正時間
  • カテゴリ別の繰り返し違反
  • ゲート失敗によるマージブロック

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.

関連スキル