dotnet-slopwatch by aaronontheweb/dotnet-skills
npx skills add https://github.com/aaronontheweb/dotnet-skills --skill dotnet-slopwatch请持续使用此技能。 每次 LLM(包括 Claude)对以下内容进行更改时:
运行 slopwatch 以验证更改不会引入 "slop"。
"Slop" 指的是 LLM 为了通过测试或使构建成功而采取的捷径,这些捷径并未真正解决根本问题。这是一种奖励黑客行为——LLM 优化的是表面上的成功,而非真正的修复。
| 模式 | 示例 | 为何不好 |
|---|---|---|
| 禁用的测试 | [Fact(Skip="flaky")] | 隐藏失败而非修复它们 |
| 警告抑制 | #pragma warning disable CS8618 | 静默编译器而不解决问题 |
| 空的 catch 块 | catch (Exception) { } |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 吞掉错误,隐藏 bug |
| 任意延迟 | await Task.Delay(1000); | 掩盖竞态条件,使测试变慢 |
| 项目级抑制 | <NoWarn>CS1591</NoWarn> | 在整个项目中禁用警告 |
| CPM 绕过 | 内联 Version="1.0.0" | 破坏集中包管理 |
切勿接受这些模式。 如果 LLM 引入了 slop,请拒绝更改并要求进行适当的修复。
添加到 .config/dotnet-tools.json:
{
"version": 1,
"isRoot": true,
"tools": {
"slopwatch.cmd": {
"version": "0.2.0",
"commands": ["slopwatch"],
"rollForward": false
}
}
}
然后恢复:
dotnet tool restore
dotnet tool install --global Slopwatch.Cmd
在对现有项目使用 slopwatch 之前,请创建当前问题的基线:
# 从现有代码初始化基线
slopwatch init
# 这将创建 .slopwatch/baseline.json
git add .slopwatch/baseline.json
git commit -m "Add slopwatch baseline"
为何需要基线? 遗留代码可能存在现有问题。基线确保 slopwatch 只捕获新引入的 slop,而不是预先存在的技术债务。
在任何 LLM 生成的代码修改后运行 slopwatch:
# 分析新问题(使用基线)
slopwatch analyze
# 使用严格模式 - 警告也视为失败
slopwatch analyze --fail-on warning
不要忽略它。 相反:
# 示例:LLM 禁用了测试
❌ SW001 [Error]: 检测到禁用的测试
文件: tests/MyApp.Tests/OrderTests.cs:45
模式: [Fact(Skip="Test is flaky")]
# 正确回应:要求实际修复
"此测试被禁用而非修复。请调查其不稳定的原因,并修复底层的时序/竞态条件问题。"
仅在 slop 确实合理且有文档记录时更新基线:
# 将当前检测添加到基线(谨慎使用!)
slopwatch analyze --update-baseline
合理理由示例:
更新基线时,请在代码注释中记录原因。
将 slopwatch 添加为钩子,以自动验证每次编辑。创建或更新 .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "slopwatch analyze -d . --hook",
"timeout": 60000
}
]
}
]
}
}
--hook 标志的作用:
将 slopwatch 添加到你的 CI 流水线作为质量门:
jobs:
slopwatch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install Slopwatch
run: dotnet tool install --global Slopwatch.Cmd
- name: Run Slopwatch
run: slopwatch analyze -d . --fail-on warning
- 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'
| 规则 | 严重性 | 捕获内容 |
|---|---|---|
| SW001 | 错误 | 禁用的测试 (Skip=, Ignore, #if false) |
| SW002 | 警告 | 警告抑制 (#pragma warning disable, SuppressMessage) |
| SW003 | 错误 | 吞掉异常的空的 catch 块 |
| SW004 | 警告 | 测试中的任意延迟 (Task.Delay, Thread.Sleep) |
| SW005 | 警告 | 项目文件 slop (NoWarn, TreatWarningsAsErrors=false) |
| SW006 | 警告 | CPM 绕过 (VersionOverride, 内联 Version 属性) |
创建 .slopwatch/slopwatch.json 以进行自定义:
{
"minSeverity": "warning",
"rules": {
"SW001": { "enabled": true, "severity": "error" },
"SW002": { "enabled": true, "severity": "warning" },
"SW003": { "enabled": true, "severity": "error" },
"SW004": { "enabled": true, "severity": "warning" },
"SW005": { "enabled": true, "severity": "warning" },
"SW006": { "enabled": true, "severity": "warning" }
},
"exclude": [
"**/Generated/**",
"**/obj/**",
"**/bin/**"
]
}
为了在 LLM 编码会话期间提供最大保护,将所有规则提升为错误:
{
"minSeverity": "warning",
"rules": {
"SW001": { "enabled": true, "severity": "error" },
"SW002": { "enabled": true, "severity": "error" },
"SW003": { "enabled": true, "severity": "error" },
"SW004": { "enabled": true, "severity": "error" },
"SW005": { "enabled": true, "severity": "error" },
"SW006": { "enabled": true, "severity": "error" }
}
}
目标是防止技术债务的逐渐累积,这种累积发生在 LLM 优化"让测试通过"而非"解决实际问题"时。
# 首次设置
slopwatch init
git add .slopwatch/baseline.json
# 每次 LLM 代码更改后
slopwatch analyze
# 严格模式(推荐)
slopwatch analyze --fail-on warning
# 带统计信息(性能调试)
slopwatch analyze --stats
# 更新基线(罕见,记录原因)
slopwatch analyze --update-baseline
# JSON 输出供工具使用
slopwatch analyze --output json
更新基线或禁用规则的唯一有效理由:
| 场景 | 操作 | 要求 |
|---|---|---|
| 第三方强制模式 | 更新基线 | 代码注释解释原因 |
| 生成代码(不可编辑) | 添加到排除列表 | 在配置中记录 |
| 故意的速率限制延迟 | 更新基线 | 代码注释,不在测试中 |
| 遗留代码清理 | 一次性基线更新 | PR 描述 |
无效理由:
每周安装次数
96
代码仓库
GitHub Stars
500
首次出现
Jan 29, 2026
安全审计
安装于
claude-code78
codex59
github-copilot55
opencode55
gemini-cli54
kimi-cli52
Use this skill constantly. Every time an LLM (including Claude) makes changes to:
Run slopwatch to validate the changes don't introduce "slop."
"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.
| Pattern | Example | Why It's Bad |
|---|---|---|
| Disabled tests | [Fact(Skip="flaky")] | Hides failures instead of fixing them |
| Warning suppression | #pragma warning disable CS8618 | Silences compiler without fixing issue |
| Empty catch blocks | catch (Exception) { } | Swallows errors, hides bugs |
| Arbitrary delays | await Task.Delay(1000); | Masks race conditions, makes tests slow |
| Project-level suppression | <NoWarn>CS1591</NoWarn> | Disables warnings project-wide |
| CPM bypass | Version="1.0.0" inline | Undermines central package management |
Never accept these patterns. If an LLM introduces slop, reject the change and require a proper fix.
Add to .config/dotnet-tools.json:
{
"version": 1,
"isRoot": true,
"tools": {
"slopwatch.cmd": {
"version": "0.2.0",
"commands": ["slopwatch"],
"rollForward": false
}
}
}
Then restore:
dotnet tool restore
dotnet tool install --global Slopwatch.Cmd
Before using slopwatch on an existing project, create a baseline of current issues:
# Initialize baseline from existing code
slopwatch init
# This creates .slopwatch/baseline.json
git add .slopwatch/baseline.json
git commit -m "Add slopwatch baseline"
Why baseline? Legacy code may have existing issues. The baseline ensures slopwatch only catches new slop being introduced, not pre-existing technical debt.
Run slopwatch after any LLM-generated code modification:
# Analyze for new issues (uses baseline)
slopwatch analyze
# Use strict mode - fail on warnings too
slopwatch analyze --fail-on warning
Do not ignore it. Instead:
# Example: LLM disabled a test
❌ SW001 [Error]: Disabled test detected
File: tests/MyApp.Tests/OrderTests.cs:45
Pattern: [Fact(Skip="Test is flaky")]
# Correct response: Ask for actual fix
"This test was disabled instead of fixed. Please investigate why
it's flaky and fix the underlying timing/race condition issue."
Only update the baseline when slop is truly justified and documented:
# Add current detections to baseline (use sparingly!)
slopwatch analyze --update-baseline
Justification examples:
Document why in a code comment when updating baseline.
Add slopwatch as a hook to automatically validate every edit. Create or update .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "slopwatch analyze -d . --hook",
"timeout": 60000
}
]
}
]
}
}
The --hook flag:
Add slopwatch to your CI pipeline as a quality gate:
jobs:
slopwatch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Install Slopwatch
run: dotnet tool install --global Slopwatch.Cmd
- name: Run Slopwatch
run: slopwatch analyze -d . --fail-on warning
- 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'
| 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, ) |
Create .slopwatch/slopwatch.json to customize:
{
"minSeverity": "warning",
"rules": {
"SW001": { "enabled": true, "severity": "error" },
"SW002": { "enabled": true, "severity": "warning" },
"SW003": { "enabled": true, "severity": "error" },
"SW004": { "enabled": true, "severity": "warning" },
"SW005": { "enabled": true, "severity": "warning" },
"SW006": { "enabled": true, "severity": "warning" }
},
"exclude": [
"**/Generated/**",
"**/obj/**",
"**/bin/**"
]
}
For maximum protection during LLM coding sessions, elevate all rules to errors:
{
"minSeverity": "warning",
"rules": {
"SW001": { "enabled": true, "severity": "error" },
"SW002": { "enabled": true, "severity": "error" },
"SW003": { "enabled": true, "severity": "error" },
"SW004": { "enabled": true, "severity": "error" },
"SW005": { "enabled": true, "severity": "error" },
"SW006": { "enabled": true, "severity": "error" }
}
}
The goal is to prevent the gradual accumulation of technical debt that occurs when LLMs optimize for "make the test pass" rather than "fix the actual problem."
# First time setup
slopwatch init
git add .slopwatch/baseline.json
# After every LLM code change
slopwatch analyze
# Strict mode (recommended)
slopwatch analyze --fail-on warning
# With stats (performance debugging)
slopwatch analyze --stats
# Update baseline (rare, document why)
slopwatch analyze --update-baseline
# JSON output for tooling
slopwatch analyze --output json
The only valid reasons to update baseline or disable a rule:
| Scenario | Action | Required |
|---|---|---|
| Third-party forces pattern | Update baseline | Code comment explaining why |
| Generated code (not editable) | Add to exclude list | Document in config |
| Intentional rate limiting delay | Update baseline | Code comment, not in test |
| Legacy code cleanup | One-time baseline update | PR description |
Invalid reasons:
Weekly Installs
96
Repository
GitHub Stars
500
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykPass
Installed on
claude-code78
codex59
github-copilot55
opencode55
gemini-cli54
kimi-cli52
Flutter/Dart代码审查最佳实践:提升应用性能与质量的完整检查清单
945 周安装
资深架构师AI助手 - Claude高级架构设计技能,提升系统架构与代码质量
235 周安装
Polymarket交易员分析工具:追踪链上交易活动与持仓数据
237 周安装
Next.js开发技能:构建现代全栈Web应用指南(App Router/服务器组件/SEO优化)
70 周安装
aixyz 智能体开发框架:基于 Bun 和 Vercel AI SDK 构建可盈利 AI 代理
237 周安装
Telegram Bot 开发指南:Node.js/Python 构建机器人教程(含Webhook、支付、部署)
240 周安装
病毒式钩子生成器:基于心理学模式的社交媒体内容创作工具 | 提升参与度
248 周安装
Thread.Sleep| SW005 | Warning | Project file slop (NoWarn, TreatWarningsAsErrors=false) |
| SW006 | Warning | CPM bypass (VersionOverride, inline Version attributes) |