plankton-code-quality by affaan-m/everything-claude-code
npx skills add https://github.com/affaan-m/everything-claude-code --skill plankton-code-qualityPlankton(作者:@alxfazio)的集成参考,这是一个为 Claude Code 设计的编写时代码质量强制执行系统。Plankton 通过 PostToolUse 钩子在每次文件编辑时运行格式化程序和 linter,然后生成 Claude 子进程来修复代理未捕获的违规问题。
每次 Claude Code 编辑或写入文件时,Plankton 的 multi_linter.sh PostToolUse 钩子都会运行:
Phase 1: 自动格式化(静默)
├─ 运行格式化程序(ruff format, biome, shfmt, taplo, markdownlint)
├─ 静默修复 40-50% 的问题
└─ 不向主代理输出任何内容
Phase 2: 收集违规信息(JSON)
├─ 运行 linter 并收集无法自动修复的违规信息
├─ 返回结构化 JSON:{line, column, code, message, linter}
└─ 仍然不向主代理输出任何内容
Phase 3: 委托 + 验证
├─ 使用违规信息 JSON 生成 claude -p 子进程
├─ 根据违规复杂度路由到模型层级:
│ ├─ Haiku:格式化、导入、样式(E/W/F 代码)— 120 秒超时
│ ├─ Sonnet:复杂度、重构(C901, PLR 代码)— 300 秒超时
│ └─ Opus:类型系统、深度推理(unresolved-attribute)— 600 秒超时
├─ 重新运行阶段 1+2 以验证修复
└─ 如果干净则退出 0,如果仍有违规则退出 2(报告给主代理)
| 场景 |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 代理看到 |
|---|
| 钩子退出 |
|---|
| 无违规 | 无 | 0 |
| 所有问题被子进程修复 | 无 | 0 |
| 子进程处理后仍有违规 | [hook] N violation(s) remain | 2 |
| 建议性信息(重复项、旧工具) | [hook:advisory] ... | 0 |
主代理只会看到子进程无法修复的问题。大多数质量问题都在后台透明地解决了。
LLM 会修改 .ruff.toml 或 biome.json 来禁用规则,而不是修复代码。Plankton 通过三层防护阻止这种行为:
protect_linter_configs.sh 在编辑发生前阻止对所有 linter 配置的修改stop_config_guardian.sh 在会话结束时通过 git diff 检测配置更改.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 克隆到您的项目中(或共享位置)
# 注意:Plankton 由 @alxfazio 创建
git clone https://github.com/alexfazio/plankton.git
cd plankton
# 安装核心依赖项
brew install jaq ruff uv
# 安装 Python linter
uv sync --all-extras
# 启动 Claude Code — 钩子会自动激活
claude
无需安装命令,无需插件配置。当您在 Plankton 目录中运行 Claude Code 时,.claude/settings.json 中的钩子会自动生效。
要在您自己的项目中使用 Plankton 钩子:
.claude/hooks/ 目录复制到您的项目.claude/settings.json 钩子配置.ruff.toml、biome.json 等)| 语言 | 必需 | 可选 |
|---|---|---|
| Python | ruff, uv | ty(类型), vulture(死代码), bandit(安全) |
| TypeScript/JS | biome | oxlint, semgrep, knip(死导出) |
| Shell | shellcheck, shfmt | — |
| YAML | yamllint | — |
| Markdown | markdownlint-cli2 | — |
| Dockerfile | hadolint (>= 2.12.0) | — |
| TOML | taplo | — |
| JSON | jaq | — |
| 关注点 | ECC | Plankton |
|---|---|---|
| 代码质量强制执行 | PostToolUse 钩子(Prettier, tsc) | PostToolUse 钩子(20+ linter + 子进程修复) |
| 安全扫描 | AgentShield, security-reviewer 代理 | Bandit(Python), Semgrep(TypeScript) |
| 配置保护 | — | PreToolUse 阻止 + Stop 钩子检测 |
| 包管理器 | 检测 + 设置 | 强制执行(阻止旧版包管理器) |
| CI 集成 | — | 用于 git 的预提交钩子 |
| 模型路由 | 手动(/model opus) | 自动(违规复杂度 → 层级) |
如果同时运行 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 | 绕过包管理器强制执行 |
设置严格的质量行为:
export ECC_HOOK_PROFILE=strict
export ECC_QUALITY_GATE_FIX=true
export ECC_QUALITY_GATE_STRICT=true
在质量强制执行期间,标记同一迭代中对配置文件的更改:
biome.json、.eslintrc*、prettier.config*、tsconfig.json、pyproject.toml如果配置被更改以抑制违规,则要求在合并前进行明确审查。
在 CI 中使用与本地钩子相同的命令:
跟踪:
每周安装次数
209
代码仓库
GitHub 星标数
70.6K
首次出现
8 天前
安全审计
安装于
codex198
kimi-cli174
gemini-cli174
cursor174
opencode174
amp174
Integration reference for Plankton (credit: @alxfazio), a write-time code quality enforcement system for Claude Code. Plankton runs formatters and linters on every file edit via PostToolUse hooks, then spawns Claude subprocesses to fix violations the agent didn't catch.
Every time Claude Code edits or writes a file, Plankton's multi_linter.sh PostToolUse hook runs:
Phase 1: Auto-Format (Silent)
├─ Runs formatters (ruff format, biome, shfmt, taplo, markdownlint)
├─ Fixes 40-50% of issues silently
└─ No output to main agent
Phase 2: Collect Violations (JSON)
├─ Runs linters and collects unfixable violations
├─ Returns structured JSON: {line, column, code, message, linter}
└─ Still no output to main agent
Phase 3: Delegate + Verify
├─ Spawns claude -p subprocess with violations JSON
├─ Routes to model tier based on violation complexity:
│ ├─ Haiku: formatting, imports, style (E/W/F codes) — 120s timeout
│ ├─ Sonnet: complexity, refactoring (C901, PLR codes) — 300s timeout
│ └─ Opus: type system, deep reasoning (unresolved-attribute) — 600s timeout
├─ Re-runs Phase 1+2 to verify fixes
└─ Exit 0 if clean, Exit 2 if violations remain (reported to main agent)
| Scenario | Agent sees | Hook exit |
|---|---|---|
| No violations | Nothing | 0 |
| All fixed by subprocess | Nothing | 0 |
| Violations remain after subprocess | [hook] N violation(s) remain | 2 |
| Advisory (duplicates, old tooling) | [hook:advisory] ... | 0 |
The main agent only sees issues the subprocess couldn't fix. Most quality problems are resolved transparently.
LLMs will modify .ruff.toml or biome.json to disable rules rather than fix code. Plankton blocks this with three layers:
protect_linter_configs.sh blocks edits to all linter configs before they happenstop_config_guardian.sh detects config changes via git diff at session end.ruff.toml, biome.json, .shellcheckrc, .yamllint, .hadolint.yaml, and moreA PreToolUse hook on Bash blocks legacy package managers:
pip, pip3, poetry, pipenv → Blocked (use uv)npm, yarn, pnpm → Blocked (use bun)npm audit, npm view, npm publish# Clone Plankton into your project (or a shared location)
# Note: Plankton is by @alxfazio
git clone https://github.com/alexfazio/plankton.git
cd plankton
# Install core dependencies
brew install jaq ruff uv
# Install Python linters
uv sync --all-extras
# Start Claude Code — hooks activate automatically
claude
No install command, no plugin config. The hooks in .claude/settings.json are picked up automatically when you run Claude Code in the Plankton directory.
To use Plankton hooks in your own project:
.claude/hooks/ directory to your project.claude/settings.json hook configuration.ruff.toml, biome.json, etc.)| Language | Required | Optional |
|---|---|---|
| Python | ruff, uv | ty (types), vulture (dead code), bandit (security) |
| TypeScript/JS | biome | oxlint, semgrep, knip (dead exports) |
| Concern | ECC | Plankton |
|---|---|---|
| Code quality enforcement | PostToolUse hooks (Prettier, tsc) | PostToolUse hooks (20+ linters + subprocess fixes) |
| Security scanning | AgentShield, security-reviewer agent | Bandit (Python), Semgrep (TypeScript) |
| Config protection | — | PreToolUse blocks + Stop hook detection |
| Package manager | Detection + setup | Enforcement (blocks legacy PMs) |
| CI integration | — | Pre-commit hooks for git |
| Model routing | Manual (/model opus) | Automatic (violation complexity → tier) |
If running both ECC and Plankton hooks:
Plankton's .claude/hooks/config.json controls all behavior:
{
"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
}
}
Key settings:
volume_threshold — violations > this count auto-escalate to a higher model tiersubprocess_delegation: false — skip Phase 3 entirely (just report violations)| Variable | Purpose |
|---|---|
HOOK_SKIP_SUBPROCESS=1 | Skip Phase 3, report violations directly |
HOOK_SUBPROCESS_TIMEOUT=N | Override tier timeout |
HOOK_DEBUG_MODEL=1 | Log model selection decisions |
HOOK_SKIP_PM=1 | Bypass package manager enforcement |
Set strict quality behavior:
export ECC_HOOK_PROFILE=strict
export ECC_QUALITY_GATE_FIX=true
export ECC_QUALITY_GATE_STRICT=true
During quality enforcement, flag changes to config files in same iteration:
biome.json, .eslintrc*, prettier.config*, tsconfig.json, pyproject.tomlIf config is changed to suppress violations, require explicit review before merge.
Use the same commands in CI as local hooks:
Track:
Weekly Installs
209
Repository
GitHub Stars
70.6K
First Seen
8 days ago
Security Audits
Gen Agent Trust HubWarnSocketPassSnykPass
Installed on
codex198
kimi-cli174
gemini-cli174
cursor174
opencode174
amp174
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
136,300 周安装
Dev Browser:JavaScript沙盒化浏览器控制CLI工具 - 自动化测试与爬虫开发利器
689 周安装
CTF Pwn 二进制漏洞利用技术大全 - 栈溢出、ROP、格式化字符串、内核利用实战指南
690 周安装
Supabase技能创建器指南:构建高效AI技能模块,扩展Claude能力
691 周安装
React 测试命令:运行 Facebook React 代码库测试的完整指南
692 周安装
Apollo Server 5.x 指南:开源GraphQL服务器安装、集成与快速入门教程
693 周安装
产品调查问卷设计指南:9位专家框架,NPS替代方案与MaxDiff优先级排序
693 周安装
| Shell | shellcheck, shfmt | — |
| YAML | yamllint | — |
| Markdown | markdownlint-cli2 | — |
| Dockerfile | hadolint (>= 2.12.0) | — |
| TOML | taplo | — |
| JSON | jaq | — |