dotnet-slopwatch
Slopwatch: LLM Anti-Cheat Quality Gate for .NET
Run the Slopwatch.Cmd dotnet tool as an automated quality gate after code modifications to detect "slop" -- shortcuts
that make builds/tests pass without fixing real problems.
Scope
- Slopwatch CLI installation and configuration
- Running quality gate checks (disabled tests, suppressed warnings, empty catches)
- Hook integration and CI/CD pipeline usage
- Detection rule reference
Out of scope
- Pattern recognition and manual code review for slop -- see [skill:dotnet-agent-gotchas] for Slopwatch anti-patterns
Prerequisites
- .NET 8.0+ SDK
Slopwatch.Cmd NuGet package (v0.4.0+)
Cross-references: [skill:dotnet-tool-management] for general dotnet tool installation mechanics.
Installation
Local Tool (Recommended)
Add to .config/dotnet-tools.json:
{
"version": 1,
"isRoot": true,
"tools": {
"slopwatch.cmd": {
"version": "0.4.0",
"commands": ["slopwatch"],
"rollForward": false
}
}
}
```text
Then restore:
```bash
dotnet tool restore
```bash
### Global Tool
```bash
dotnet tool install --global Slopwatch.Cmd
```bash
See [skill:dotnet-tool-management] for tool manifest conventions and restore patterns.
### Harness Bootstrap (Recommended for Multi-Agent Repos)
If this repository already uses `dotnet-agent-harness`, prefer the runtime bootstrap path:
```bash
dotnet agent-harness bootstrap \
--profile platform-native \
--enable-pack dotnet-intelligence \
--run-rulesync
```
This installs `Slopwatch.Cmd` into the local tool manifest, writes `.slopwatch/config.json`, and enables advisory
post-edit hook reporting through the generated RuleSync hooks. Hard enforcement still happens in runtime validation.
---
## Usage
### Basic Analysis
```bash
# Analyze current directory for slop
slopwatch analyze
# Analyze specific directory
slopwatch analyze -d ./src
# Strict mode -- fail on warnings too
slopwatch analyze --fail-on warning
# JSON output for tooling integration
slopwatch analyze --output json
# Show performance stats
slopwatch analyze --stats
```json
### First-Time Setup: Establish a Baseline
For existing projects with pre-existing issues, create a baseline so slopwatch only catches **new** slop. The `init` command scans all files and records current findings as the accepted baseline:
```bash
slopwatch init
git add .slopwatch/baseline.json
git commit -m "Add slopwatch baseline"
```bash
### Updating the Baseline (Rare)
Only update when slop is **truly justified** and documented:
```bash
slopwatch analyze --update-baseline
```bash
Valid reasons: third-party library forces a pattern, intentional rate-limiting delay (not test flakiness), generated code that cannot be modified. Always add a code comment explaining the justification.
---
## Configuration
Create `.slopwatch/config.json` to manage suppressions intentionally:
```json
{
"globalSuppressions": [],
"suppressions": []
}
```text
Use `slopwatch analyze -d . --fail-on warning` in CI and runtime validation when you want warnings to fail the quality
gate.
---
## Detection Rules
| Rule | Severity | What It Catches |
|------|----------|-----------------|
| SW001 | Error | Disabled tests (`Skip=`, `Ignore`, `#if false`) |
| SW002 | Warning | Warning suppression (`#pragma warning disable`, `SuppressMessage`) |
| SW003 | Error | Empty catch blocks that swallow exceptions |
| SW004 | Warning | Arbitrary delays in tests (`Task.Delay`, `Thread.Sleep`) |
| SW005 | Warning | Project file slop (`NoWarn`, `TreatWarningsAsErrors=false`) |
| SW006 | Warning | CPM bypass (`VersionOverride`, inline `Version` attributes) |
### When Slopwatch Flags an Issue
1. **Understand why** the shortcut was taken
2. **Request a proper fix** -- be specific about what's wrong
3. **Verify the fix** doesn't introduce different slop
```text
# Example output
❌ SW001 [Error]: Disabled test detected
File: tests/MyApp.Tests/OrderTests.cs:45
Pattern: [Fact(Skip="Test is flaky")]
```csharp
**Never disable tests to achieve a green build.** Fix the underlying issue.
---
## Claude Code Hook Integration
Add slopwatch as a `PostToolUse` hook to automatically validate every edit. Create or update `.claude/settings.json`:
```json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "slopwatch analyze -d . --hook",
"timeout": 60000
}
]
}
]
}
}
```text
The `--hook` flag:
- Only analyzes **git dirty files** (fast, even on large repos)
- Outputs errors to stderr in readable format
- Blocks the edit on warnings/errors (exit code 2)
- Claude sees the error and can fix it immediately
When using the toolkit's shared RuleSync hooks, the generated harness keeps this advisory-only by design. Findings are
surfaced back to the agent as context, while `dotnet agent-harness validate --mode repo --run` remains the blocking
quality gate.
This is the pattern used by projects like BrighterCommand/Brighter.
---
## CI/CD Integration
### GitHub Actions
```yaml
jobs:
slopwatch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x' # any .NET 8+ SDK works
- name: Install Slopwatch
run: dotnet tool install --global Slopwatch.Cmd
- name: Run Slopwatch
run: slopwatch analyze -d . --fail-on warning
```text
### Azure Pipelines
```yaml
- task: DotNetCoreCLI@2
displayName: 'Install Slopwatch'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --global Slopwatch.Cmd'
- script: slopwatch analyze -d . --fail-on warning
displayName: 'Slopwatch Analysis'
```text
---
## Agent Gotchas
- **Do not suppress slopwatch findings.** If slopwatch flags an issue, fix the code -- do not update the baseline or disable the rule without explicit user approval.
- **Run after every code change**, not just at the end. Catching slop early prevents cascading shortcuts.
- **Use `--hook` flag in Claude Code hooks**, not bare `analyze`. The hook flag restricts analysis to dirty files for performance.
- **Baseline is not a wastebasket.** Adding items to the baseline requires documented justification. Never bulk-update baseline to silence warnings.
- **Local tool preferred over global.** Use `.config/dotnet-tools.json` so the version is pinned and reproducible across team members.
---
## Quick Reference
```bash
# First time setup
slopwatch init
git add .slopwatch/baseline.json
# After every code change
slopwatch analyze
# Strict mode (recommended)
slopwatch analyze --fail-on warning
# Hook mode (for Claude Code integration)
slopwatch analyze -d . --hook
# JSON output for tooling
slopwatch analyze --output json
# Update baseline (rare, document why)
slopwatch analyze --update-baseline
```json
---
## References
- [Slopwatch NuGet Package](https://www.nuget.org/packages/Slopwatch.Cmd)
- [skill:dotnet-tool-management] -- dotnet tool installation and manifest conventions
- [skill:dotnet-agent-gotchas] -- manual slop pattern recognition (visual detection counterpart)
- [skill:dotnet-test-quality] -- test coverage and quality measurement
Code Navigation (Serena MCP)
Primary approach: Use Serena symbol operations for efficient code navigation:
- Find definitions:
serena_find_symbol instead of text search
- Understand structure:
serena_get_symbols_overview for file organization
- Track references:
serena_find_referencing_symbols for impact analysis
- Precise edits:
serena_replace_symbol_body for clean modifications
When to use Serena vs traditional tools:
- Use Serena: Navigation, refactoring, dependency analysis, precise edits
- Use Read/Grep: Reading full files, pattern matching, simple text operations
- Fallback: If Serena unavailable, traditional tools work fine
Example workflow:
# Instead of:
Read: src/Services/OrderService.cs
Grep: "public void ProcessOrder"
# Use:
serena_find_symbol: "OrderService/ProcessOrder"
serena_get_symbols_overview: "src/Services/OrderService.cs"
1---2name: dotnet-slopwatch-83category: developer-experience4subcategory: analyzers5description: Runs Slopwatch CLI to detect LLM reward hacking -- disabled tests, suppressed warnings.6license: MIT7targets: ['*']8tags: [foundation, dotnet, skill]9version: '0.0.1'10author: 'dotnet-agent-harness'11invocable: true12claudecode:13 allowed-tools: ['Read', 'Grep', 'Glob', 'Bash', 'Write', 'Edit']14codexcli:15 short-description: '.NET skill guidance for foundation tasks'16opencode:17 allowed-tools: ['Read', 'Grep', 'Glob', 'Bash', 'Write', 'Edit']18copilot: {}19geminicli: {}20antigravity: {}21metadata:22 source: https://skillmd.com/skills/rudironsoni/dotnet-slopwatch-823---2425# dotnet-slopwatch2627Slopwatch: LLM Anti-Cheat Quality Gate for .NET2829Run the `Slopwatch.Cmd` dotnet tool as an automated quality gate after code modifications to detect "slop" -- shortcuts30that make builds/tests pass without fixing real problems.3132## Scope3334- Slopwatch CLI installation and configuration35- Running quality gate checks (disabled tests, suppressed warnings, empty catches)36- Hook integration and CI/CD pipeline usage37- Detection rule reference3839## Out of scope4041- Pattern recognition and manual code review for slop -- see [skill:dotnet-agent-gotchas] for Slopwatch anti-patterns4243## Prerequisites4445- .NET 8.0+ SDK46- `Slopwatch.Cmd` NuGet package (v0.4.0+)4748Cross-references: [skill:dotnet-tool-management] for general dotnet tool installation mechanics.4950---5152## Installation5354### Local Tool (Recommended)5556Add to `.config/dotnet-tools.json`:5758````json5960{61 "version": 1,62 "isRoot": true,63 "tools": {64 "slopwatch.cmd": {65 "version": "0.4.0",66 "commands": ["slopwatch"],67 "rollForward": false68 }69 }70}7172```text7374Then restore:7576```bash7778dotnet tool restore7980```bash8182### Global Tool8384```bash8586dotnet tool install --global Slopwatch.Cmd8788```bash8990See [skill:dotnet-tool-management] for tool manifest conventions and restore patterns.9192### Harness Bootstrap (Recommended for Multi-Agent Repos)9394If this repository already uses `dotnet-agent-harness`, prefer the runtime bootstrap path:9596```bash97dotnet agent-harness bootstrap \98 --profile platform-native \99 --enable-pack dotnet-intelligence \100 --run-rulesync101```102103This installs `Slopwatch.Cmd` into the local tool manifest, writes `.slopwatch/config.json`, and enables advisory104post-edit hook reporting through the generated RuleSync hooks. Hard enforcement still happens in runtime validation.105106---107108## Usage109110### Basic Analysis111112```bash113114# Analyze current directory for slop115slopwatch analyze116117# Analyze specific directory118slopwatch analyze -d ./src119120# Strict mode -- fail on warnings too121slopwatch analyze --fail-on warning122123# JSON output for tooling integration124slopwatch analyze --output json125126# Show performance stats127slopwatch analyze --stats128129```json130131### First-Time Setup: Establish a Baseline132133For existing projects with pre-existing issues, create a baseline so slopwatch only catches **new** slop. The `init` command scans all files and records current findings as the accepted baseline:134135```bash136137slopwatch init138git add .slopwatch/baseline.json139git commit -m "Add slopwatch baseline"140141```bash142143### Updating the Baseline (Rare)144145Only update when slop is **truly justified** and documented:146147```bash148149slopwatch analyze --update-baseline150151```bash152153Valid reasons: third-party library forces a pattern, intentional rate-limiting delay (not test flakiness), generated code that cannot be modified. Always add a code comment explaining the justification.154155---156157## Configuration158159Create `.slopwatch/config.json` to manage suppressions intentionally:160161```json162163{164 "globalSuppressions": [],165 "suppressions": []166}167168```text169170Use `slopwatch analyze -d . --fail-on warning` in CI and runtime validation when you want warnings to fail the quality171gate.172173---174175## Detection Rules176177| Rule | Severity | What It Catches |178|------|----------|-----------------|179| SW001 | Error | Disabled tests (`Skip=`, `Ignore`, `#if false`) |180| SW002 | Warning | Warning suppression (`#pragma warning disable`, `SuppressMessage`) |181| SW003 | Error | Empty catch blocks that swallow exceptions |182| SW004 | Warning | Arbitrary delays in tests (`Task.Delay`, `Thread.Sleep`) |183| SW005 | Warning | Project file slop (`NoWarn`, `TreatWarningsAsErrors=false`) |184| SW006 | Warning | CPM bypass (`VersionOverride`, inline `Version` attributes) |185186### When Slopwatch Flags an Issue1871881. **Understand why** the shortcut was taken1892. **Request a proper fix** -- be specific about what's wrong1903. **Verify the fix** doesn't introduce different slop191192```text193194# Example output195❌ SW001 [Error]: Disabled test detected196 File: tests/MyApp.Tests/OrderTests.cs:45197 Pattern: [Fact(Skip="Test is flaky")]198199```csharp200201**Never disable tests to achieve a green build.** Fix the underlying issue.202203---204205## Claude Code Hook Integration206207Add slopwatch as a `PostToolUse` hook to automatically validate every edit. Create or update `.claude/settings.json`:208209```json210211{212 "hooks": {213 "PostToolUse": [214 {215 "matcher": "Write|Edit|MultiEdit",216 "hooks": [217 {218 "type": "command",219 "command": "slopwatch analyze -d . --hook",220 "timeout": 60000221 }222 ]223 }224 ]225 }226}227228```text229230The `--hook` flag:231- Only analyzes **git dirty files** (fast, even on large repos)232- Outputs errors to stderr in readable format233- Blocks the edit on warnings/errors (exit code 2)234- Claude sees the error and can fix it immediately235236When using the toolkit's shared RuleSync hooks, the generated harness keeps this advisory-only by design. Findings are237surfaced back to the agent as context, while `dotnet agent-harness validate --mode repo --run` remains the blocking238quality gate.239240This is the pattern used by projects like BrighterCommand/Brighter.241242---243244## CI/CD Integration245246### GitHub Actions247248```yaml249250jobs:251 slopwatch:252 runs-on: ubuntu-latest253 steps:254 - uses: actions/checkout@v4255256 - name: Setup .NET257 uses: actions/setup-dotnet@v4258 with:259 dotnet-version: '8.0.x' # any .NET 8+ SDK works260261 - name: Install Slopwatch262 run: dotnet tool install --global Slopwatch.Cmd263264 - name: Run Slopwatch265 run: slopwatch analyze -d . --fail-on warning266267```text268269### Azure Pipelines270271```yaml272273- task: DotNetCoreCLI@2274 displayName: 'Install Slopwatch'275 inputs:276 command: 'custom'277 custom: 'tool'278 arguments: 'install --global Slopwatch.Cmd'279280- script: slopwatch analyze -d . --fail-on warning281 displayName: 'Slopwatch Analysis'282283```text284285---286287## Agent Gotchas288289- **Do not suppress slopwatch findings.** If slopwatch flags an issue, fix the code -- do not update the baseline or disable the rule without explicit user approval.290- **Run after every code change**, not just at the end. Catching slop early prevents cascading shortcuts.291- **Use `--hook` flag in Claude Code hooks**, not bare `analyze`. The hook flag restricts analysis to dirty files for performance.292- **Baseline is not a wastebasket.** Adding items to the baseline requires documented justification. Never bulk-update baseline to silence warnings.293- **Local tool preferred over global.** Use `.config/dotnet-tools.json` so the version is pinned and reproducible across team members.294295---296297## Quick Reference298299```bash300301# First time setup302slopwatch init303git add .slopwatch/baseline.json304305# After every code change306slopwatch analyze307308# Strict mode (recommended)309slopwatch analyze --fail-on warning310311# Hook mode (for Claude Code integration)312slopwatch analyze -d . --hook313314# JSON output for tooling315slopwatch analyze --output json316317# Update baseline (rare, document why)318slopwatch analyze --update-baseline319320```json321322---323324## References325326- [Slopwatch NuGet Package](https://www.nuget.org/packages/Slopwatch.Cmd)327- [skill:dotnet-tool-management] -- dotnet tool installation and manifest conventions328- [skill:dotnet-agent-gotchas] -- manual slop pattern recognition (visual detection counterpart)329- [skill:dotnet-test-quality] -- test coverage and quality measurement330````331332## Code Navigation (Serena MCP)333334**Primary approach:** Use Serena symbol operations for efficient code navigation:3353361. **Find definitions**: `serena_find_symbol` instead of text search3372. **Understand structure**: `serena_get_symbols_overview` for file organization3383. **Track references**: `serena_find_referencing_symbols` for impact analysis3394. **Precise edits**: `serena_replace_symbol_body` for clean modifications340341**When to use Serena vs traditional tools:**342343- **Use Serena**: Navigation, refactoring, dependency analysis, precise edits344- **Use Read/Grep**: Reading full files, pattern matching, simple text operations345- **Fallback**: If Serena unavailable, traditional tools work fine346347**Example workflow:**348349```text350# Instead of:351Read: src/Services/OrderService.cs352Grep: "public void ProcessOrder"353354# Use:355serena_find_symbol: "OrderService/ProcessOrder"356serena_get_symbols_overview: "src/Services/OrderService.cs"357```