Universal Janitor
Cleans up any codebase by deleting unused code, flattening unnecessary complexity and auditing dependencies, on the premise that removing code is the most effective refactor available.
Overview
Universal Janitor works from a single premise stated right in its instructions: less code is less debt, and deletion is the most powerful refactor available. It's built for the cleanup pass after a feature ships, not for building new functionality.
How it works
- It measures what's actually used before removing anything: unused functions, variables, imports and dependencies, dead code paths, and commented-out debug leftovers.
- It simplifies what's left by inlining single-use functions, flattening nested conditionals, and swapping custom implementations for built-in language features where one already exists.
- It audits dependency hygiene: removing packages that are declared but unused, flagging outdated packages with known vulnerabilities, and consolidating similar dependencies that do overlapping jobs.
- It applies the same lens to tests (deleting obsolete or duplicate ones, removing flaky tests) and to documentation (removing stale comments and boilerplate) as it does to application code.
- It validates continuously rather than batching every deletion into one change: measure first, delete safely, test after each removal, and repeat.
Examples
"Clean up the utils/ folder, it's grown a lot of dead code over the last
year."
The agent finds functions with zero call sites, removes them along with their now-unused imports, runs the test suite after each deletion, and reports what it removed.
Installation
You need VS Code with the GitHub Copilot extension.
- Create the agents folder and download the file into your repo:
mkdir -p .github/agents curl -o .github/agents/janitor.agent.md \ https://raw.githubusercontent.com/github/awesome-copilot/main/agents/janitor.agent.md - Reload VS Code, or open a new Copilot Chat; custom agents under
.github/agents/are picked up automatically. - Pick this agent from the mode picker in Copilot Chat and point it at a folder to confirm it measures usage before deleting anything.
Related assets
Accessibility Expert
Reviews code and designs against WCAG 2.1/2.2, covering semantics, keyboard and focus behavior, forms, media and dynamic SPA updates, and ships framework-specific examples plus a CI setup for automated checks.
Address Comments Agent
Works through pull request review comments one at a time: applies the minimal fix for each, pushes back on comments that don't make sense, adds test coverage, and commits with a descriptive message before moving to the next comment.
ADR Generator
Turns a decision discussion into a numbered Architecture Decision Record: gathers the missing context, assigns the next sequential ADR number, and writes a structured markdown file with consequences, alternatives and rejection reasons.