This repo uses deterministic lint rules as tripwires for deeper clean-code review. The static layer stays fast and reproducible; the semantic layer decides whether a finding is a real maintainability issue and what refactor would be safe.
ESLint / Pylint / Ruff
-> clean-code review candidates
-> clean-code-tools skill
-> clean-code MCP pattern lookup
-> advisory finding or refactor plan
-> normal tests and lint verification
The scanner output uses schema clean-code-review-candidates/v1. Each
candidate contains:
languagefilesymbolanchorskill- deterministic
triggers semantic_questions- suggested
mcp_queries
Rule-to-query mappings come from the shared clean-code review trigger catalog. The candidate scanner and the agent-feedback hook both read that catalog so the same deterministic triggers lead to the same semantic review questions.
From lint JSON files:
bun run clean-code:candidates -- \
--eslint-json eslint-report.json \
--pylint-json pylint-report.json \
--ruff-json ruff-report.jsonFrom lint commands:
bun run clean-code:candidates -- \
--pylint-command "uv run --group lint pylint src/python/mcp_server --output-format=json" \
--ruff-command "uv run --group lint ruff check src/python/mcp_server --output-format=json"Markdown is useful for agent prompts:
bun run clean-code:candidates -- \
--pylint-command "uv run --group lint pylint src/python/mcp_server --output-format=json" \
--ruff-command "uv run --group lint ruff check src/python/mcp_server --output-format=json" \
--format markdownThe clean-code-tools installer can also add an advisory pre-push hook.
The hook runs the same candidate generation before Git pushes and prints
semantic review prompts for the agent without blocking the push unless a project
chooses a stricter mode.
Only rules with a strong relationship to maintainability are promoted into semantic candidates. Formatting and ordinary style rules are intentionally ignored.
Good triggers include:
- large files, functions, or classes
- high complexity or nesting
- too many arguments, locals, statements, branches, or public methods
- duplicated branches or functions
- boolean flag arguments
- output argument mutation
- TODO/comment hygiene, commented-out code, and traceable technical debt
- policy literals, magic values, duplicate strings, and repeated domain values
- train-wreck object navigation, broad imports, and dependency cycles
- dead stores, unused symbols, and incomplete cleanup
The trigger is not the recommendation. For example, max-lines means "inspect
this file for mixed responsibilities"; it does not mean "split the file."
skill is always clean-code-tools. The candidate does not name
language-specific skills because consuming systems may only install this repo's
MCP reviewer skill. Agents should use clean-code-tools when it is
available; if it is not installed, they should follow the same contract manually.
Agents should:
- Read the candidate's file plus its
symboloranchorfirst. - Confirm or reject the semantic questions using local code evidence.
- Query the MCP narrowly with the suggested query or a refined one.
- Suppress weak matches.
- Produce a scoped refactor plan only when it preserves behavior and follows local conventions.
This keeps the deterministic check useful without turning clean-code guidance into noisy doctrine.