PUBLIC WORK / CODE JANITOR

Code without the clutter.

Code Janitor is an independently maintained family of extensions for Visual Studio and VS Code. It removes repetitive C# clutter, modernizes syntax and keeps cleanup rules consistent without making developers hunt for every small issue by hand.

PLATFORMS
Visual Studio · VS Code
LANGUAGE
C#
LICENSE
LGPL-3.0

Why does it exist?

Large C# repositories do not become messy only because of large mistakes. Over time they accumulate small inconsistencies: whitespace, incorrectly ordered usings, older syntax, missing explicit modifiers, regions, untidy namespaces and missing documentation. Each item is trivial, but fixing thousands of them manually is expensive and rarely consistent.

Code Janitor automates that repetitive part of development. Instead of treating cleanup as a one-off activity before review, you can define rules, choose a scope and get a predictable set of changes to inspect.

The project is an independently maintained continuation derived from CodeMaid. It keeps proven capabilities while evolving them for current Visual Studio, .NET, Razor and team workflows.

Two editors, two feature sets.

IMPLEMENTATION

Visual Studio

GitHub ↗

A full set of tools for cleaning, organizing and navigating code inside Visual Studio.

  • whitespace normalization, Visual Studio formatting, and using organization and sorting
  • explicit access modifiers, namespace cleanup, and removal of unnecessary regions
  • member reorganization, code sorting and joining, plus hierarchy visualization
  • navigation helpers: active file in Solution Explorer, related files, and recursive tree collapse
  • safe Razor/Blazor formatting for control blocks including if/else, loops, switch and try/catch/finally
  • deterministic C# change preview as a native diff, with per-file and per-rule selection
  • optional AI-assisted XML documentation with explicit scope, filters, budgets and controls
  • repository policy through .codejanitor / .code-janitor.json with settings import/export

Development includes Visual Studio 2022 and 2026 installation compatibility; exact requirements depend on the release.

IMPLEMENTATION

VS Code

GitHub ↗

A lightweight local C# cleanup engine that needs no .NET runtime, with optional AI actions on demand.

  • cleanup of a single file, selection, multiple files, open files, Git-changed files or the whole workspace
  • cleanup-on-save for automatically keeping supported files tidy while you work
  • C# syntax modernization including var, pattern matching and collection expressions
  • generate/remove XML documentation, fix namespaces, format comments and remove regions
  • Split Top-Level Types for classes, interfaces, records, enums and delegates
  • repository policy through .codejanitor, with explicit VS Code settings taking precedence
  • coverage report analysis and test generation focused on uncovered code
  • optional Explain, Review, Refactor and Generate Tests through GitHub Copilot or a configured OpenAI/Claude-compatible endpoint

Runs on Windows, macOS and Linux; deterministic cleanup needs no AI account, .NET runtime or network access.

One shared philosophy.

The core cleanup operations are deterministic and local. They do not require an AI model, an account or sending source code to an external provider. That matters for repositories where source code must stay inside the development environment.

Scope is explicit: a single file, selected files, a project, a workspace, Git-changed files or an on-save rule, depending on the editor. Rules can be configured individually or stored as repository policy.

AI is an optional layer, not a requirement. Where available, it is opt-in and reserved for work that benefits from generation or analysis, such as XML documentation, review, refactoring or test generation.

Control over changes.

Cleanup is not a replacement for code review. In Visual Studio, deterministic C# changes can be inspected in a native diff before application. In VS Code, changes should also be reviewed, especially syntax modernization, because the engine does not perform Roslyn semantic analysis.

The .codejanitor file lets a team share cleanup policy. A local developer can still deliberately override it with user settings where the environment requires that.

This is a tool for keeping code under control, not a mechanism for blindly rewriting an entire solution.

Origin and project boundaries.

Code Janitor for Visual Studio is a fork and independently maintained continuation of CodeMaid. The VS Code extension is a separate implementation that shares the cleanup concept and repository policy, but has its own engine and feature set.

This page therefore describes Code Janitor as one project with two editor implementations without pretending that both extensions expose exactly the same capabilities.