Communitygithub.com

Plankton コード品質スキル

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

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

Plankton コード品質スキルは、@alxfazio による Claude Code 向けの書き込み時コード品質強制システムです。ファイル編集のたびに PostToolUse フックを介してフォーマッターとリンターを実行し、エージェントが見逃した違反を Claude サブプロセスで修正します。多言語(Python、TypeScript、Shell、YAML、JSON、TOML、Markdown、Dockerfile)をサポートし、ルール変更による不正回避を防ぐ設定保護機構を備えています。違反の複雑さに応じて Haiku(簡単なスタイル)、Sonnet(リファクタリング)、Opus(型システム)のモデル階層に自動ルーティングし、120~600秒のタイムアウトで効率的な修正を実現します。ECC と組み合わせて使用することで、包括的なコード品質管理が可能になります。

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

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

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

ドキュメント

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

@alxfazio による Claude Code 向け書き込み時コード品質強制システム、Plankton の統合リファレンスです。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 を再実行して修正を検証
└─ 正常なら Exit 0、違反が残っていれば Exit 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

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

プロジェクトごとの統合

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. PR 前の最終ゲートとして ECC の検証ループを使用

フック競合の回避

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/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.

関連スキル