Janitor.Cli 1.0.5

dotnet tool install --global Janitor.Cli --version 1.0.5
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local Janitor.Cli --version 1.0.5
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Janitor.Cli&version=1.0.5
                    
nuke :add-package Janitor.Cli --version 1.0.5
                    

Janitor

Clean up and standardize your C# repository structure automatically.

Janitor is a powerful CLI tool that analyzes .NET repositories, intelligently categorizes projects, and reorganizes them into clean, standardized folder structures following industry best practices like Clean Architecture, Vertical Slice, or Microservices patterns.

NuGet NuGet Downloads .NET 8.0 License: MIT Build Status


Why Janitor?

Over time, repositories become messy:

  • Projects scattered across inconsistent folders
  • Namespaces that don't match folder structure
  • Mixed naming conventions (PascalCase, lowercase, kebab-case)
  • IDE clutter and build artifacts everywhere
  • Missing or outdated .gitignore, .editorconfig files

Janitor cleans it all up automatically while you focus on building great software.


Installation

# Install globally from NuGet
dotnet tool install -g Janitor.Cli

# Or update if already installed
dotnet tool update -g Janitor.Cli

Once installed, use janitor from any directory:

janitor init              # Create configuration
janitor plan /path/repo   # Preview changes
janitor apply /path/repo  # Apply transformations

Alternative installations: See INSTALL.md for building from source or local installation.


Quick Start

# 1. Initialize configuration (interactive wizard)
janitor init

# 2. Preview what will change
janitor plan /path/to/repo

# 3. Apply the transformations
janitor apply /path/to/repo

Key Features

๐ŸŽฏ Intelligent Project Classification

Automatically categorizes projects using weighted multi-factor analysis:

  • Naming conventions (*.Api, *.Worker, *.Core, etc.)
  • NuGet packages (ASP.NET Core, Hangfire, EF Core, etc.)
  • Output type (executable vs library)
  • Current folder location

๐Ÿ—๏ธ Built-in Templates

Choose from 5 folder structure templates:

  • .NET Standard (default) - Category-based organization
  • Clean Architecture - Presentation/Application/Domain/Infrastructure
  • Vertical Slice - Feature-based organization
  • Microservices - Service-oriented structure
  • Minimal - Lowercase minimal structure

๐ŸŽจ Flexible Folder Casing

7 casing styles: PascalCase, lowercase, UPPERCASE, camelCase, kebab-case, snake_case, or Preserve

๐Ÿ“ Namespace Alignment

Automatically updates namespaces to match your configured pattern:

  • {Company}.{Product}.{Category}.{Module}
  • {Company}.{Product}.{Category}
  • Custom patterns supported

โš™๏ธ DevOps Integration

Automatically updates paths in:

  • Helm charts - values.yaml, Chart.yaml, templates
  • CI/CD pipelines - GitHub Actions, Azure Pipelines, GitLab CI
  • Docker - Dockerfile, docker-compose.yml

๐Ÿ›ก๏ธ Safety First

  • Automatic backups before every change
  • Plan mode to preview without applying
  • Validation checks for circular dependencies and namespace collisions
  • Interactive review with confidence scores

๐Ÿงน Cleanup Features

  • Removes build artifacts (bin/, obj/)
  • Cleans empty directories
  • Optional IDE/OS clutter removal
  • Creates/updates .gitignore, .gitattributes, .editorconfig

Commands

# Core commands
janitor init [path]                    # Create configuration file
  --template, -t <name>                # Use template
  --yes, -y                            # Skip interactive prompts

janitor plan [repo]                    # Preview changes
  --config, -c <path>                  # Custom config file
  --format, -f <format>                # Output: console, json, markdown

janitor apply [repo]                   # Apply transformations
  --yes, -y                            # Auto-approve all changes
  --config, -c <path>                  # Custom config file

janitor templates                      # List available templates
janitor template show <name>           # Show template details
janitor validate <config>              # Validate configuration
janitor backup list [repo]             # List backups
janitor backup restore <backup>        # Restore from backup
janitor version                        # Show version

Project Categories

Category Description Detected By
Api REST APIs, GraphQL, gRPC *.Api, AspNetCore, Swashbuckle
Worker Background services *.Worker, Hosting packages
Job Scheduled tasks *.Job, Quartz, Hangfire
Consumer Message consumers *.Consumer, MassTransit, RabbitMQ
Service Business logic *.Service naming
Core Domain models *.Core, *.Domain
Infrastructure Data access *.Infrastructure, EF Core
Test Tests *.Tests, xUnit, NUnit

Configuration

Janitor auto-discovers config files: .janitorrc.json, janitor.json, etc.

Example configuration:

{
  "company": "MyCompany",
  "productName": "MyProduct",
  "namespacePattern": "{Company}.{Product}.{Category}",
  "targetStructure": {
    "srcFolder": "src",
    "testFolder": "tests",
    "folderNameCasing": "Pascal",
    "categoryFolders": {
      "Api": "Apis",
      "Worker": "Workers",
      "Core": "Core",
      "Infrastructure": "Infrastructure"
    }
  },
  "transformations": {
    "moveProjects": true,
    "updateNamespaces": true,
    "cleanupUnusedFiles": false
  },
  "validation": {
    "blockOnCircularDependencies": true,
    "blockOnNamespaceCollisions": true
  }
}

How It Works

Classification Algorithm uses weighted scoring:

Score = (Naming ร— 0.4) + (Packages ร— 0.3) + (OutputType ร— 0.15) + (Location ร— 0.15)

Workflow Phases:

  1. Scan - Discover all .csproj and .sln files
  2. Classify - Categorize projects with confidence scores
  3. Propose - Generate transformation plan
  4. Review - Interactive approval (or auto-approve with --yes)
  5. Backup - Create timestamped snapshot
  6. Apply - Execute transformations and update DevOps files

Confidence Levels:

  • ๐ŸŸข High (โ‰ฅ80%) - Safe to apply
  • ๐ŸŸก Medium (50-79%) - Review recommended
  • ๐Ÿ”ด Low (<50%) - Manual review required

Documentation


Architecture

src/
โ”œโ”€โ”€ Janitor.Core/          # Domain models, interfaces
โ”œโ”€โ”€ Janitor.Analysis/      # Repository scanning
โ”œโ”€โ”€ Janitor.Rules/         # Classification engine
โ”œโ”€โ”€ Janitor.Transformation/# Proposal & application
โ”œโ”€โ”€ Janitor.Validation/    # Validation checks
โ”œโ”€โ”€ Janitor.Infrastructure/# Backup, git files
โ””โ”€โ”€ Janitor.Cli/           # CLI (Spectre.Console)

Requirements

  • .NET 8.0 SDK or higher
  • C# 12
  • Tested on macOS, Linux, Windows

Contributing

Contributions welcome! Areas of interest:

  • New classification rules
  • Additional templates
  • Improved namespace refactoring
  • More comprehensive tests

Roadmap

  • Publish as NuGet global tool
  • Build verification (dotnet build before/after)
  • Roslyn-based namespace improvements
  • Visual dependency graphs
  • Plugin system for custom rules
  • VS Code extension

License

MIT License - See LICENSE file for details


Built to clean up messy repositories so you can focus on building great software. ๐Ÿงนโœจ

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.0.5 86 2/9/2026
1.0.4 88 2/7/2026
1.0.3 83 2/7/2026
1.0.2 93 2/7/2026
1.0.1 97 2/7/2026