Slopwatch.Cmd
0.1.0
See the version list below for details.
dotnet tool install --global Slopwatch.Cmd --version 0.1.0
dotnet new tool-manifest
dotnet tool install --local Slopwatch.Cmd --version 0.1.0
#tool dotnet:?package=Slopwatch.Cmd&version=0.1.0
nuke :add-package Slopwatch.Cmd --version 0.1.0
<p align="center"> <img src="https://raw.githubusercontent.com/Aaronontheweb/dotnet-slopwatch/dev/images/logo.png" alt="Slopwatch Logo" width="256" height="256"> </p>
<h1 align="center">Slopwatch</h1>
<p align="center"> <strong>// LLM anti-cheat</strong><br> A .NET tool that detects LLM "reward hacking" behaviors in code changes. </p>
<p align="center"> <a href="https://www.nuget.org/packages/Slopwatch.Cmd"><img src="https://img.shields.io/nuget/v/Slopwatch.Cmd.svg" alt="NuGet"></a> <a href="https://github.com/Aaronontheweb/dotnet-slopwatch/blob/dev/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License"></a> </p>
Runs as a Claude Code hook or in CI/CD pipelines to catch when AI coding assistants take shortcuts instead of properly fixing issues.
What is "Slop"?
When LLMs generate code, they sometimes take shortcuts that make tests pass or builds succeed without actually solving the underlying problem. These patterns include:
- Disabling tests instead of fixing them (
[Fact(Skip="flaky")]) - Suppressing warnings instead of addressing them (
#pragma warning disable) - Swallowing exceptions with empty catch blocks
- Adding arbitrary delays to mask timing issues (
Task.Delay(1000)) - Project-level warning suppression (
<NoWarn>,<TreatWarningsAsErrors>false</TreatWarningsAsErrors>) - And more...
Slopwatch catches these patterns before they make it into your codebase.
Installation
# Install as a global tool
dotnet tool install --global Slopwatch.Cmd
# Or install locally
dotnet tool install Slopwatch.Cmd
Quick Start
# 1. Install slopwatch
dotnet tool install --global Slopwatch.Cmd
# 2. Initialize in your project (creates baseline from existing code)
cd your-project
slopwatch init
# 3. Commit the baseline to your repository
git add .slopwatch/baseline.json
git commit -m "Add slopwatch baseline"
# 4. From now on, only NEW slop is detected
slopwatch analyze
The baseline approach ensures slopwatch catches new slop being introduced without flagging legacy code. Your CI/CD pipeline will fail if someone introduces new slop patterns.
Usage
Initialize a Project
# Create baseline from existing code
slopwatch init
# Force overwrite existing baseline
slopwatch init --force
This creates .slopwatch/baseline.json containing all existing detections. Commit this file to your repository.
Analyze for New Issues
# Analyze current directory (requires baseline by default)
slopwatch analyze
# Analyze specific directory
slopwatch analyze -d src/
# Skip baseline and report ALL issues (not recommended for CI)
slopwatch analyze --no-baseline
Update Baseline
When you intentionally add code that triggers slopwatch (with proper justification):
# Add new detections to existing baseline
slopwatch analyze --update-baseline
Output Formats
# Human-readable console output (default)
slopwatch analyze
# JSON for programmatic use
slopwatch analyze --output json
Exit Codes
# Fail if errors found (default)
slopwatch analyze --fail-on error
# Fail on warnings too
slopwatch analyze --fail-on warning
Detection Rules
| Rule | Severity | Description |
|---|---|---|
| SW001 | Error | Disabled tests via Skip, Ignore, or #if false |
| SW002 | Warning | Warning suppression via pragma or SuppressMessage |
| SW003 | Error | Empty catch blocks that swallow exceptions |
| SW004 | Warning | Arbitrary delays in test code (Task.Delay, Thread.Sleep) |
| SW005 | Warning | Project file slop (NoWarn, TreatWarningsAsErrors=false) |
Claude Code Integration
Add slopwatch as a hook to catch slop patterns during AI-assisted coding. Create a file at .claude/hooks/slopwatch-hook.json:
{
"hooks": {
"Stop": [
{
"type": "command",
"command": "dotnet slopwatch analyze -d . --output json --fail-on error",
"timeout": 60
}
]
}
}
The hook will run when you stop a coding session, analyzing all C# files in the current directory for slop patterns.
CI/CD Integration
GitHub Actions
- name: Install Slopwatch
run: dotnet tool install --global Slopwatch.Cmd
- name: Run Slopwatch
run: slopwatch analyze -d . --output json --fail-on error
Note: The baseline file (.slopwatch/baseline.json) should be committed to your repository. Run slopwatch init locally first.
Azure DevOps
- task: DotNetCoreCLI@2
displayName: 'Install Slopwatch'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --global Slopwatch.Cmd'
- script: slopwatch analyze -d . --fail-on error
displayName: 'Run Slopwatch'
Configuration
Create a .slopwatch/slopwatch.json configuration file to customize behavior:
{
"minSeverity": "warning",
"rules": {
"SW001": { "enabled": true, "severity": "error" },
"SW002": { "enabled": true, "severity": "warning" },
"SW003": { "enabled": true, "severity": "error" },
"SW004": { "enabled": true, "severity": "warning" }
},
"exclude": ["**/Generated/**", "**/obj/**", "**/bin/**"]
}
Use the -c or --config option to specify a custom configuration file location:
slopwatch analyze -d . --config path/to/config.json
Building from Source
dotnet build
dotnet test
dotnet pack
Contributing
- Fork and create a feature branch
- Make changes and add tests
- Submit a pull request
Note: This project uses slopwatch on itself - your PR will be analyzed for slop patterns!
License
Apache 2.0 - see LICENSE for details.
Inspiration
- Slopometry - Python equivalent for Claude Code
- Incrementalist - Git diff analysis patterns
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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. |
This package has no dependencies.
Initial release of Slopwatch - LLM anti-cheat for .NET.
**Features:**
* Detection rules: SW001-SW005 for common LLM reward-hacking patterns
* Baseline mode to detect only NEW slop in existing codebases
* `slopwatch init` command for easy project onboarding
* JSON output format for CI/CD integration
* Configurable severity levels and rule customization
* Multi-level suppression system (attributes, comments, config)
**Detection Rules:**
* SW001: Disabled tests (Skip, Ignore, #if false)
* SW002: Warning suppression (pragma, SuppressMessage)
* SW003: Empty catch blocks
* SW004: Timeout jiggling (Task.Delay, Thread.Sleep in tests)
* SW005: Project file slop (NoWarn, TreatWarningsAsErrors)