Communitygithub.com

Plankton 程式碼品質技能

使用 Plankton 在每次檔案編輯時自動進行格式化、 linting,並透過 Claude 子程序修復問題。適合在設定寫入時格式化、linting 或自動修復鉤子時使用。

Plankton 程式碼品質技能 是什麼?

Plankton 程式碼品質技能是一個強大的寫入時間程式碼品質強制系統,專為 Claude Code 設計。它透過 PostToolUse 鉤子在每次檔案編輯時自動執行格式化工具和 linter,並生成 Claude 子程序來修復代理程式未捕捉到的違規。該技能支援多層次模型路由(Haiku 用於簡單風格、Sonnet 用於邏輯重構、Opus 用於型別系統),並提供配置保護機制以防止 LLM 修改 linter 設定檔來繞過規則。Plankton 支援 Python、TypeScript、Shell、YAML、JSON、TOML、Markdown 和 Dockerfile 等多種語言,並可與 ECC(增強 Claude Code)互補使用,提供完整的程式碼品質和安全性保障。該系統設計為開發者透明運行,只會在主代理無法修復時回報問題。

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

在你喜歡的 AI 中提問

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

說明文件

Plankton 程式碼品質技能 是做什麼的?

Plankton(致謝:@alxfazio)的整合參考文件,這是一個針對 Claude Code 的寫入時間程式碼品質強制系統。Plankton 在每次檔案編輯時透過 PostToolUse 鉤子執行格式化工具和 linter,然後生成 Claude 子程序來修復代理程式未捕捉到的違規。

使用時機

  • 你想要在每次檔案編輯時自動進行格式化和 linting(不僅限於提交時)
  • 你需要防禦代理程式修改 linter 設定檔以通過檢查,而非修復程式碼
  • 你想要分層模型路由來修復問題(Haiku 用於簡單風格,Sonnet 用於邏輯,Opus 用於型別)
  • 你使用多種語言(Python、TypeScript、Shell、YAML、JSON、TOML、Markdown、Dockerfile)

運作方式

三階段架構

每當 Claude Code 編輯或寫入檔案時,Plankton 的 multi_linter.sh PostToolUse 鉤子會執行:

階段 1:自動格式化(靜默)
├─ 執行格式化工具(ruff format、biome、shfmt、taplo、markdownlint)
├─ 靜默修復 40-50% 的問題
└─ 不對主代理輸出

階段 2:收集違規(JSON)
├─ 執行 linter 並收集無法修復的違規
├─ 回傳結構化 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 透過三層機制阻止此行為:

  1. PreToolUse 鉤子 — protect_linter_configs.sh 在編輯發生前就阻擋所有對 linter 設定檔的修改
  2. 停止鉤子 — 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 linter
uv sync --all-extras

# 啟動 Claude Code — 鉤子會自動啟用
claude

無需安裝指令,也無需外掛設定。當你在 Plankton 目錄下執行 Claude Code 時,.claude/settings.json 中的鉤子會自動被載入。

每個專案的整合方式

若要將 Plankton 鉤子用於自己的專案:

  1. 將 .claude/hooks/ 目錄複製到你的專案中
  2. 複製 .claude/settings.json 鉤子設定
  3. 複製 linter 設定檔(.ruff.toml、biome.json 等)
  4. 為你的語言安裝對應的 linter

語言特定依賴

語言必要選擇性
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+ linter + 子程序修復)
安全性掃描AgentShield、security-reviewer agentBandit(Python)、Semgrep(TypeScript)
設定檔保護—PreToolUse 阻擋 + 停止鉤子偵測
套件管理器偵測 + 設定強制執行(阻擋舊版套件管理器)
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. 執行 lint/型別檢查
  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.

相關技能