Agent Skill · Evidence-driven · MIT

Prove it, then delete it.

Code Janitor is a single Agent Skill with two independent objectives: ordinary simplification, and cleanup of AI-generated anti-regression layers. It doesn't chase "more lines removed" — it asks whether a change reduces the concepts and obligations the team must keep coherent from now on.

01

Pick one objective — ordinary simplification or AI defensive-layer cleanup. Never mixed.

02

Read-only audit first; build a proof record for every candidate.

03

Act only when authorized; validate in layers and hand over a rollback path.

A complex software structure converges, through evidence, into a smaller and clearer system

A complex structure, passed through evidence, converges into a smaller, clearer system.

Two objectives

One objective per cut.

Both share consumer analysis, boundary proof and layered validation — but you must choose first, and never blur the deletion boundary in one batch.

objective 1

Ordinary simplification

Identify and safely remove accidental complexity while preserving live behavior, boundaries and compatibility.

Handles
Dead code, duplicate state, ownerless abstractions
Redundant APIs and unnecessary layers
Obsolete compatibility paths, over-engineering
Out of scope
Formatting-only changes, general code review
Performance tuning
objective 2

AI defensive-layer cleanup

Clean up the anti-regression layers AI changes leave behind: pick a category first, then prove and remove the maintenance burden.

Handles
Tests added to shield an AI change
Build / deploy / CI guardrails
Static source scans and inventories
Out of scope
Code still protecting real business or APIs
Security, data-integrity and deployment boundaries
Why static analysis isn't enough

Lint gives leads, not proof.

"Nobody calls it" is not "safe to delete". Code Janitor keeps tracing these surfaces before deciding to delete, merge, keep, or mark as unresolved.

runtime

Runtime consumers

From entrypoints through configuration, registration and dispatch to the real execution path.

dynamic

Dynamic registration

Reflection, plugin tables, string references — reachability the compiler can't see.

persisted

Stored formats

Persistence, migrations, replay: delete a field and old data may never read back.

public

Public interfaces

Package boundaries, wire formats, external consumers you can't grep for in-repo.

history

Historical decisions

A design still owned by a live ADR or RFC is not redundant debt.

verify

Validation boundaries

What is the smallest check that would expose a wrong cut? No answer, no action.

Proof records

Every candidate gets a proof.

Nine fields turn "I think we can delete this" into reviewable evidence. Incomplete proof means the candidate stays.

proof-record.mdsurvey · broad
Candidate     the exact contract, representation, or layer to remove or merge
Burden        the concepts, synchronization, publication, or testing cost it creates
Reachability  production, non-production, dynamic, external, and persisted consumers
Rationale     why it exists and whether that reason remains current
Cut           declarations, implementations, branches, artifacts, docs, dependencies
Consequence   observable capability or compatibility behavior surrendered
Confidence    evidence strength, uncertainty, blast radius, reversibility
Proof         the smallest check that would expose an incorrect cut
Net effect    maintenance concepts removed − replacement or migration machinery added

Deleting lines is only the outcome. The real win is retiring a fact, state, contract or concept the team must keep coherent. A high-value guess never outranks a smaller proved cut.

What it treats with care

Boundaries it routes around.

Public APIs & plugin registration

Dynamic loading, registry entries, published interfaces.

Data formats & migrations

Stored representations, replay, backward compatibility.

Authorization & input validation

Isolation, credentials, data-loss prevention — security code is not a defensive layer.

Concurrency & lifecycle

Cancellation, cleanup, ownership: the code that establishes quiescence.

Generated files & external consumers

Shared resources, vendored code, references outside the repo.

Still-valid ADRs

A design still governed by a live decision record is not debt to delete.

When a real consumer exists, a boundary is unresolved, or a simplification merely relocates complexity, it recommends keeping — instead of deleting to produce a result.

Validation

Not a slogan — exercised scenarios.

973
-file production repo (Python + TypeScript) audited broad, partitioned, with a clean worktree
143/143
frontend tests green after defensive-layer cleanup, plus six API smoke checks
29
guardrail cases safely removed; backend failures matched the known baseline
14
candidate-exclusive CSS classes proved below file granularity in a shared stylesheet

Full records for Change, Broad, Integration, Decision-record, shared-artifact and AI defensive-layer scenarios live in docs/validation.md. A narrow green check is never packaged as full runtime or user acceptance.

Usage

Invoke it like a colleague.

If the objective is unclear, the Skill asks first — it never deletes without one.

Audit · read-only

Use $code-janitor to audit this repo and list the safest, highest-value simplification candidates. Do not modify files.

Investigate · one question

Use $code-janitor to decide whether these readiness flags express different lifecycle guarantees or duplicate state.

Change · a proved cut

Use $code-janitor to remove one high-confidence source of accidental complexity. Preserve live contracts, validate, and hand over an operation receipt and rollback path.

Integrate · another branch

Use $code-janitor to revalidate and integrate the simplification findings in this PR. Preserve evidence, not finding counts.

Install

One package, seven harnesses.

The directory must be named code-janitor. Pick your platform and copy one command.

Codex$ git clone https://github.com/zhouyuanxinand/code-janitor.git ~/.codex/skills/code-janitor
Claude Code$ git clone https://github.com/zhouyuanxinand/code-janitor.git ~/.claude/skills/code-janitor
Cursor$ git clone https://github.com/zhouyuanxinand/code-janitor.git .agents/skills/code-janitor
GitHub Copilot$ git clone https://github.com/zhouyuanxinand/code-janitor.git .github/skills/code-janitor
Cline$ git clone https://github.com/zhouyuanxinand/code-janitor.git .cline/skills/code-janitor
Gemini CLI$ git clone https://github.com/zhouyuanxinand/code-janitor.git .gemini/skills/code-janitor
OpenCode$ git clone https://github.com/zhouyuanxinand/code-janitor.git .opencode/skills/code-janitor

Refresh the skill directory per platform after install. Scope, discovery rules and migration from the old $simplify-codebase entry live in docs/harness-compatibility.md.