Plankton Code Quality Skill
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.
When to Use
- You want automatic formatting and linting on every file edit (not just at commit time)
- You need defense against agents modifying linter configs to pass instead of fixing code
- You want tiered model routing for fixes (Haiku for simple style, Sonnet for logic, Opus for types)
- You work with multiple languages (Python, TypeScript, Shell, YAML, JSON, TOML, Markdown, Dockerfile)
How It Works
Three-Phase Architecture
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)
What the Main Agent Sees
| 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.
Config Protection (Defense Against Rule-Gaming)
LLMs will modify .ruff.toml or biome.json to disable rules rather than fix code. Plankton blocks this with three layers:
- PreToolUse hook —
protect_linter_configs.sh blocks edits to all linter configs before they happen
- Stop hook —
stop_config_guardian.sh detects config changes via git diff at session end
- Protected files list —
.ruff.toml, biome.json, .shellcheckrc, .yamllint, .hadolint.yaml, and more
Package Manager Enforcement
A PreToolUse hook on Bash blocks legacy package managers:
pip, pip3, poetry, pipenv → Blocked (use uv)
npm, yarn, pnpm → Blocked (use bun)
- Allowed exceptions:
npm audit, npm view, npm publish
Setup
Quick Start
# 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.
Per-Project Integration
To use Plankton hooks in your own project:
- Copy
.claude/hooks/ directory to your project
- Copy
.claude/settings.json hook configuration
- Copy linter config files (
.ruff.toml, biome.json, etc.)
- Install the linters for your languages
Language-Specific Dependencies
| Language |
Required |
Optional |
| Python |
ruff, uv |
ty (types), vulture (dead code), bandit (security) |
| TypeScript/JS |
biome |
oxlint, semgrep, knip (dead exports) |
| Shell |
shellcheck, shfmt |
— |
| YAML |
yamllint |
— |
| Markdown |
markdownlint-cli2 |
— |
| Dockerfile |
hadolint (>= 2.12.0) |
— |
| TOML |
taplo |
— |
| JSON |
jaq |
— |
Pairing with ECC
Complementary, Not Overlapping
| 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) |
Recommended Combination
- Install ECC as your plugin (agents, skills, commands, rules)
- Add Plankton hooks for write-time quality enforcement
- Use AgentShield for security audits
- Use ECC's verification-loop as a final gate before PRs
Avoiding Hook Conflicts
If running both ECC and Plankton hooks:
- ECC's Prettier hook and Plankton's biome formatter may conflict on JS/TS files
- Resolution: disable ECC's Prettier PostToolUse hook when using Plankton (Plankton's biome is more comprehensive)
- Both can coexist on different file types (ECC handles what Plankton doesn't cover)
Configuration Reference
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:
- Disable languages you don't use to speed up hooks
volume_threshold — violations > this count auto-escalate to a higher model tier
subprocess_delegation: false — skip Phase 3 entirely (just report violations)
Environment Overrides
| 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 |
References
- Plankton (credit: @alxfazio)
- Plankton REFERENCE.md — Full architecture documentation (credit: @alxfazio)
- Plankton SETUP.md — Detailed installation guide (credit: @alxfazio)
1---2name: plankton-code-quality3description: Write-time code quality enforcement using Plankton — auto-formatting, linting, and Claude-powered fixes on every file edit via hooks.4---56# Plankton Code Quality Skill78Integration 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.910## When to Use1112- You want automatic formatting and linting on every file edit (not just at commit time)13- You need defense against agents modifying linter configs to pass instead of fixing code14- You want tiered model routing for fixes (Haiku for simple style, Sonnet for logic, Opus for types)15- You work with multiple languages (Python, TypeScript, Shell, YAML, JSON, TOML, Markdown, Dockerfile)1617## How It Works1819### Three-Phase Architecture2021Every time Claude Code edits or writes a file, Plankton's `multi_linter.sh` PostToolUse hook runs:2223```24Phase 1: Auto-Format (Silent)25├─ Runs formatters (ruff format, biome, shfmt, taplo, markdownlint)26├─ Fixes 40-50% of issues silently27└─ No output to main agent2829Phase 2: Collect Violations (JSON)30├─ Runs linters and collects unfixable violations31├─ Returns structured JSON: {line, column, code, message, linter}32└─ Still no output to main agent3334Phase 3: Delegate + Verify35├─ Spawns claude -p subprocess with violations JSON36├─ Routes to model tier based on violation complexity:37│ ├─ Haiku: formatting, imports, style (E/W/F codes) — 120s timeout38│ ├─ Sonnet: complexity, refactoring (C901, PLR codes) — 300s timeout39│ └─ Opus: type system, deep reasoning (unresolved-attribute) — 600s timeout40├─ Re-runs Phase 1+2 to verify fixes41└─ Exit 0 if clean, Exit 2 if violations remain (reported to main agent)42```4344### What the Main Agent Sees4546| Scenario | Agent sees | Hook exit |47|----------|-----------|-----------|48| No violations | Nothing | 0 |49| All fixed by subprocess | Nothing | 0 |50| Violations remain after subprocess | `[hook] N violation(s) remain` | 2 |51| Advisory (duplicates, old tooling) | `[hook:advisory] ...` | 0 |5253The main agent only sees issues the subprocess couldn't fix. Most quality problems are resolved transparently.5455### Config Protection (Defense Against Rule-Gaming)5657LLMs will modify `.ruff.toml` or `biome.json` to disable rules rather than fix code. Plankton blocks this with three layers:58591. **PreToolUse hook** — `protect_linter_configs.sh` blocks edits to all linter configs before they happen602. **Stop hook** — `stop_config_guardian.sh` detects config changes via `git diff` at session end613. **Protected files list** — `.ruff.toml`, `biome.json`, `.shellcheckrc`, `.yamllint`, `.hadolint.yaml`, and more6263### Package Manager Enforcement6465A PreToolUse hook on Bash blocks legacy package managers:66- `pip`, `pip3`, `poetry`, `pipenv` → Blocked (use `uv`)67- `npm`, `yarn`, `pnpm` → Blocked (use `bun`)68- Allowed exceptions: `npm audit`, `npm view`, `npm publish`6970## Setup7172### Quick Start7374```bash75# Clone Plankton into your project (or a shared location)76# Note: Plankton is by @alxfazio77git clone https://github.com/alexfazio/plankton.git78cd plankton7980# Install core dependencies81brew install jaq ruff uv8283# Install Python linters84uv sync --all-extras8586# Start Claude Code — hooks activate automatically87claude88```8990No install command, no plugin config. The hooks in `.claude/settings.json` are picked up automatically when you run Claude Code in the Plankton directory.9192### Per-Project Integration9394To use Plankton hooks in your own project:95961. Copy `.claude/hooks/` directory to your project972. Copy `.claude/settings.json` hook configuration983. Copy linter config files (`.ruff.toml`, `biome.json`, etc.)994. Install the linters for your languages100101### Language-Specific Dependencies102103| Language | Required | Optional |104|----------|----------|----------|105| Python | `ruff`, `uv` | `ty` (types), `vulture` (dead code), `bandit` (security) |106| TypeScript/JS | `biome` | `oxlint`, `semgrep`, `knip` (dead exports) |107| Shell | `shellcheck`, `shfmt` | — |108| YAML | `yamllint` | — |109| Markdown | `markdownlint-cli2` | — |110| Dockerfile | `hadolint` (>= 2.12.0) | — |111| TOML | `taplo` | — |112| JSON | `jaq` | — |113114## Pairing with ECC115116### Complementary, Not Overlapping117118| Concern | ECC | Plankton |119|---------|-----|----------|120| Code quality enforcement | PostToolUse hooks (Prettier, tsc) | PostToolUse hooks (20+ linters + subprocess fixes) |121| Security scanning | AgentShield, security-reviewer agent | Bandit (Python), Semgrep (TypeScript) |122| Config protection | — | PreToolUse blocks + Stop hook detection |123| Package manager | Detection + setup | Enforcement (blocks legacy PMs) |124| CI integration | — | Pre-commit hooks for git |125| Model routing | Manual (`/model opus`) | Automatic (violation complexity → tier) |126127### Recommended Combination1281291. Install ECC as your plugin (agents, skills, commands, rules)1302. Add Plankton hooks for write-time quality enforcement1313. Use AgentShield for security audits1324. Use ECC's verification-loop as a final gate before PRs133134### Avoiding Hook Conflicts135136If running both ECC and Plankton hooks:137- ECC's Prettier hook and Plankton's biome formatter may conflict on JS/TS files138- Resolution: disable ECC's Prettier PostToolUse hook when using Plankton (Plankton's biome is more comprehensive)139- Both can coexist on different file types (ECC handles what Plankton doesn't cover)140141## Configuration Reference142143Plankton's `.claude/hooks/config.json` controls all behavior:144145```json146{147 "languages": {148 "python": true,149 "shell": true,150 "yaml": true,151 "json": true,152 "toml": true,153 "dockerfile": true,154 "markdown": true,155 "typescript": {156 "enabled": true,157 "js_runtime": "auto",158 "biome_nursery": "warn",159 "semgrep": true160 }161 },162 "phases": {163 "auto_format": true,164 "subprocess_delegation": true165 },166 "subprocess": {167 "tiers": {168 "haiku": { "timeout": 120, "max_turns": 10 },169 "sonnet": { "timeout": 300, "max_turns": 10 },170 "opus": { "timeout": 600, "max_turns": 15 }171 },172 "volume_threshold": 5173 }174}175```176177**Key settings:**178- Disable languages you don't use to speed up hooks179- `volume_threshold` — violations > this count auto-escalate to a higher model tier180- `subprocess_delegation: false` — skip Phase 3 entirely (just report violations)181182## Environment Overrides183184| Variable | Purpose |185|----------|---------|186| `HOOK_SKIP_SUBPROCESS=1` | Skip Phase 3, report violations directly |187| `HOOK_SUBPROCESS_TIMEOUT=N` | Override tier timeout |188| `HOOK_DEBUG_MODEL=1` | Log model selection decisions |189| `HOOK_SKIP_PM=1` | Bypass package manager enforcement |190191## References192193- Plankton (credit: @alxfazio)194- Plankton REFERENCE.md — Full architecture documentation (credit: @alxfazio)195- Plankton SETUP.md — Detailed installation guide (credit: @alxfazio)