$npx -y skills add Aaronontheweb/dotnet-skills --skill slopwatchUse Slopwatch to detect LLM reward hacking in .NET code changes. Run after every code modification to catch disabled tests, suppressed warnings, empty catch blocks, and other shortcuts that mask real problems.
| 1 | # Slopwatch: LLM Anti-Cheat for .NET |
| 2 | |
| 3 | ## When to Use This Skill |
| 4 | |
| 5 | **Use this skill constantly.** Every time an LLM (including Claude) makes changes to: |
| 6 | - C# source files (.cs) |
| 7 | - Project files (.csproj) |
| 8 | - Props files (Directory.Build.props, Directory.Packages.props) |
| 9 | - Test files |
| 10 | |
| 11 | Run slopwatch to validate the changes don't introduce "slop." |
| 12 | |
| 13 | ## What is Slop? |
| 14 | |
| 15 | "Slop" refers to shortcuts LLMs take that make tests pass or builds succeed without actually solving the underlying problem. These are reward hacking behaviors - the LLM optimizes for apparent success rather than real fixes. |
| 16 | |
| 17 | ### Common Slop Patterns |
| 18 | |
| 19 | | Pattern | Example | Why It's Bad | |
| 20 | |---------|---------|--------------| |
| 21 | | Disabled tests | `[Fact(Skip="flaky")]` | Hides failures instead of fixing them | |
| 22 | | Warning suppression | `#pragma warning disable CS8618` | Silences compiler without fixing issue | |
| 23 | | Empty catch blocks | `catch (Exception) { }` | Swallows errors, hides bugs | |
| 24 | | Arbitrary delays | `await Task.Delay(1000);` | Masks race conditions, makes tests slow | |
| 25 | | Project-level suppression | `<NoWarn>CS1591</NoWarn>` | Disables warnings project-wide | |
| 26 | | CPM bypass | `Version="1.0.0"` inline | Undermines central package management | |
| 27 | |
| 28 | **Never accept these patterns.** If an LLM introduces slop, reject the change and require a proper fix. |
| 29 | |
| 30 | --- |
| 31 | |
| 32 | ## Installation |
| 33 | |
| 34 | ### As a Local Tool (Recommended) |
| 35 | |
| 36 | Add to `.config/dotnet-tools.json`: |
| 37 | |
| 38 | ```json |
| 39 | { |
| 40 | "version": 1, |
| 41 | "isRoot": true, |
| 42 | "tools": { |
| 43 | "slopwatch.cmd": { |
| 44 | "version": "0.2.0", |
| 45 | "commands": ["slopwatch"], |
| 46 | "rollForward": false |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | ``` |
| 51 | |
| 52 | Then restore: |
| 53 | ```bash |
| 54 | dotnet tool restore |
| 55 | ``` |
| 56 | |
| 57 | ### As a Global Tool |
| 58 | |
| 59 | ```bash |
| 60 | dotnet tool install --global Slopwatch.Cmd |
| 61 | ``` |
| 62 | |
| 63 | --- |
| 64 | |
| 65 | ## First-Time Setup: Establish a Baseline |
| 66 | |
| 67 | Before using slopwatch on an existing project, create a baseline of current issues: |
| 68 | |
| 69 | ```bash |
| 70 | # Initialize baseline from existing code |
| 71 | slopwatch init |
| 72 | |
| 73 | # This creates .slopwatch/baseline.json |
| 74 | git add .slopwatch/baseline.json |
| 75 | git commit -m "Add slopwatch baseline" |
| 76 | ``` |
| 77 | |
| 78 | **Why baseline?** Legacy code may have existing issues. The baseline ensures slopwatch only catches **new** slop being introduced, not pre-existing technical debt. |
| 79 | |
| 80 | --- |
| 81 | |
| 82 | ## Usage During LLM Sessions |
| 83 | |
| 84 | ### After Every Code Change |
| 85 | |
| 86 | Run slopwatch after any LLM-generated code modification: |
| 87 | |
| 88 | ```bash |
| 89 | # Analyze for new issues (uses baseline) |
| 90 | slopwatch analyze |
| 91 | |
| 92 | # Use strict mode - fail on warnings too |
| 93 | slopwatch analyze --fail-on warning |
| 94 | ``` |
| 95 | |
| 96 | ### When Slopwatch Flags an Issue |
| 97 | |
| 98 | **Do not ignore it.** Instead: |
| 99 | |
| 100 | 1. **Understand why** the LLM took the shortcut |
| 101 | 2. **Request a proper fix** - be specific about what's wrong |
| 102 | 3. **Verify the fix** doesn't introduce different slop |
| 103 | |
| 104 | ``` |
| 105 | # Example: LLM disabled a test |
| 106 | ❌ SW001 [Error]: Disabled test detected |
| 107 | File: tests/MyApp.Tests/OrderTests.cs:45 |
| 108 | Pattern: [Fact(Skip="Test is flaky")] |
| 109 | |
| 110 | # Correct response: Ask for actual fix |
| 111 | "This test was disabled instead of fixed. Please investigate why |
| 112 | it's flaky and fix the underlying timing/race condition issue." |
| 113 | ``` |
| 114 | |
| 115 | ### Updating the Baseline (Rare) |
| 116 | |
| 117 | Only update the baseline when slop is **truly justified** and documented: |
| 118 | |
| 119 | ```bash |
| 120 | # Add current detections to baseline (use sparingly!) |
| 121 | slopwatch analyze --update-baseline |
| 122 | ``` |
| 123 | |
| 124 | **Justification examples:** |
| 125 | - Third-party library forces a pattern (e.g., must suppress specific warning) |
| 126 | - Intentional delay for rate limiting (not test flakiness) |
| 127 | - Generated code that can't be modified |
| 128 | |
| 129 | Document why in a code comment when updating baseline. |
| 130 | |
| 131 | --- |
| 132 | |
| 133 | ## Claude Code Hook Integration |
| 134 | |
| 135 | Add slopwatch as a hook to automatically validate every edit. Create or update `.claude/settings.json`: |
| 136 | |
| 137 | ```json |
| 138 | { |
| 139 | "hooks": { |
| 140 | "PostToolUse": [ |
| 141 | { |
| 142 | "matcher": "Write|Edit|MultiEdit", |
| 143 | "hooks": [ |
| 144 | { |
| 145 | "type": "command", |
| 146 | "command": "slopwatch analyze -d . --hook", |
| 147 | "timeout": 60000 |
| 148 | } |
| 149 | ] |
| 150 | } |
| 151 | ] |
| 152 | } |
| 153 | } |
| 154 | ``` |
| 155 | |
| 156 | The `--hook` flag: |
| 157 | - Only analyzes **git dirty files** (fast, even on large repos) |
| 158 | - Outputs errors to stderr in readable format |
| 159 | - Blocks the edit on warnings/errors (exit code 2) |
| 160 | - Claude sees the error and can fix it immediately |
| 161 | |
| 162 | --- |
| 163 | |
| 164 | ## CI/CD Integration |
| 165 | |
| 166 | Add slopwatch to your CI pipeline as a quality gate: |
| 167 | |
| 168 | ### GitHub Actions |
| 169 | |
| 170 | ```yaml |
| 171 | jobs: |
| 172 | slopwatch: |
| 173 | runs-on: ubuntu-latest |
| 174 | steps: |
| 175 | - uses: actions/checkout@v4 |
| 176 | |
| 177 | - name: Setup .NET |
| 178 | uses: actions/setup-dotnet@v4 |
| 179 | with: |
| 180 | dotnet-version: '9.0.x' |
| 181 | |
| 182 | - name: Install Slopwatch |
| 183 | run: dotnet tool install --global Slopwatch.Cmd |
| 184 | |
| 185 | - name: Run Slopwatch |
| 186 | run: slopwatch analyze -d . --fail-on warning |
| 187 | ``` |
| 188 | |
| 189 | ### Azure Pipelines |
| 190 | |
| 191 | ```yaml |
| 192 | - task: DotNetCoreCLI@2 |
| 193 | displayN |