Skip to content

Commit 46cb361

Browse files
committed
feat(v3.6.0): Claude Code Skill + documentation fixes
Added claude-skills/slop-detector/ with SKILL.md implementing four slash commands (/slop, /slop-file, /slop-gate, /slop-spar) for the scan -> patch -> re-scan -> gate quality loop. Session-persistent review criteria live in the skill layer, not the prompt. Added docs/CLAUDE_CODE_SKILL.md with full command reference, metric explanation table, patch reference, and calibration guide. Fixed README documentation gaps: Purity added as 4th metric axis, weight normalization note, [go] extra in Quick Start, positioning line. Removed stale test artifacts: tests/manual_test/{audit_report, audit_report_full,report}.md. Bumped version 3.5.0 -> 3.6.0. Tests: 311 passed.
1 parent 43b0539 commit 46cb361

7 files changed

Lines changed: 521 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
---
99

10+
## [3.6.0] — Claude Code Skill + Documentation Fixes
11+
12+
### Added
13+
14+
**Claude Code Skill — `claude-skills/slop-detector/`**
15+
- `SKILL.md` with YAML frontmatter (`name: slop-detector`, description 456 chars)
16+
- Four slash commands: `/slop` (full project scan + interpretation), `/slop-file [path]`
17+
(single file + per-pattern fix guidance), `/slop-gate` (CI hard gate PASS/FAIL),
18+
`/slop-spar` (adversarial validation via `fhval spar`)
19+
- Implements full `scan -> patch -> re-scan -> gate` quality loop with delta reporting
20+
- Session-persistent review criteria: quality policy lives in skill layer, not prompt
21+
- `docs/CLAUDE_CODE_SKILL.md` — full skill documentation with command reference,
22+
metric explanation table, patch reference, and calibration guide
23+
- README `Claude Code Skill` section with install instructions and loop diagram
24+
25+
### Fixed
26+
27+
**Documentation accuracy**
28+
- `What It Detects` table: corrected "Three metric axes" to "Four metric axes"; added
29+
Purity row (`exp(-0.5 x n_critical_patterns)`) — consistent with 4D scoring model
30+
stated in introduction and `docs/MATH_MODELS.md`
31+
- Scoring Model: added normalization note — weights sum to 1.10; GQG divides by
32+
`total_w` so exact normalization is not required (matches `docs/MATH_MODELS.md:160`)
33+
- Quick Start: added missing `pip install "ai-slop-detector[go]"` extra (was listed in
34+
Key Features and `pyproject.toml` but absent from Quick Start)
35+
- Positioning: added `Not a style linter. A structural-risk scanner for AI-assisted code.`
36+
under the tagline
37+
38+
### Removed
39+
40+
- `tests/manual_test/audit_report.md`, `audit_report_full.md`, `report.md` — stale
41+
artifacts from previous manual runs; no automated test dependency
42+
43+
---
44+
1045
## [3.5.0] — Phase 3: Domain-Aware Init + JS/TS + Go Analysis
1146

1247
### Added

README.md

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT License"/></a>
1212
<br/>
1313
<a href="https://github.com/flamehaven01/AI-SLOP-Detector/actions"><img src="https://github.com/flamehaven01/AI-SLOP-Detector/actions/workflows/ci.yml/badge.svg" alt="CI"/></a>
14-
<a href="https://github.com/flamehaven01/AI-SLOP-Detector/actions"><img src="https://img.shields.io/badge/tests-308%20passed-brightgreen.svg?v=3.5.0" alt="Tests"/></a>
14+
<a href="https://github.com/flamehaven01/AI-SLOP-Detector/actions"><img src="https://img.shields.io/badge/tests-311%20passed-brightgreen.svg?v=3.6.0" alt="Tests"/></a>
1515
<a href="htmlcov/"><img src="https://img.shields.io/badge/coverage-71%25-brightgreen.svg" alt="Coverage"/></a>
1616
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black"/></a>
1717
<a href="https://github.com/flamehaven01/AI-SLOP-Detector/issues"><img src="https://img.shields.io/github/issues/flamehaven01/AI-SLOP-Detector.svg" alt="Issues"/></a>
1818
</p>
1919

2020
<p align="center"><b>Catches the slop that AI produces — before it reaches production.</b></p>
2121

22+
<p align="center"><i>Not a style linter. A structural-risk scanner for AI-assisted code.</i></p>
23+
2224
<p align="center">
2325
The problem isn't that AI writes code.<br/>
2426
The problem is the specific class of defects AI reliably introduces:<br/>
@@ -36,6 +38,7 @@ unimplemented stubs, disconnected pipelines, phantom imports, and buzzword-heavy
3638
[What It Detects](#what-it-detects)
3739
[Scoring](#scoring-model)
3840
[Key Features](#key-features)
41+
[Claude Code Skill](#claude-code-skill)
3942
[Security](#security-considerations)
4043
[CI/CD](#cicd-integration)
4144
[Config](#configuration)
@@ -76,6 +79,7 @@ slop-detector --project . --ci-mode hard --ci-report # CI gate
7679

7780
# Optional extras
7881
pip install "ai-slop-detector[js]" # JS/TS tree-sitter analysis
82+
pip install "ai-slop-detector[go]" # Go tree-sitter analysis
7983
pip install "ai-slop-detector[ml]" # ML secondary signal
8084

8185
# No install required
@@ -129,13 +133,14 @@ Full specification: [docs/HOW_IT_WORKS.md](docs/HOW_IT_WORKS.md) · [docs/MATH_M
129133
| **Python Advanced** | `god_function`, `dead_code`, `deep_nesting`, `lint_escape`, `function_clone_cluster`, `placeholder_variable_naming` | Structural complexity + evasion |
130134
| **Phantom** | `phantom_import` | Hallucinated packages |
131135

132-
**Three metric axes per file:**
136+
**Four metric axes per file:**
133137

134138
| Metric | What it measures |
135139
|---|---|
136140
| **LDR** (Logic Density Ratio) | `logic_lines / total_lines` — code vs. whitespace/comments |
137141
| **ICR** (Inflation Check) | `jargon_density × complexity_modifier` — buzzword weight |
138142
| **DDC** (Dependency Check) | `used_imports / total_imports` — import utilization |
143+
| **Purity** | `exp(-0.5 × n_critical_patterns)` — AND-gate on critical pattern severity |
139144

140145
---
141146

@@ -154,7 +159,7 @@ deficit_score = 100 × (1 − quality) + pattern_penalty
154159
| ≥ 30 | `SUSPICIOUS` |
155160
| < 30 | `CLEAN` |
156161

157-
Default weights: `ldr=0.40 · inflation=0.30 · ddc=0.30 · purity=0.10` (all four calibrated via `--self-calibrate` in v3.2.0+)
162+
Default weights: `ldr=0.40 · inflation=0.30 · ddc=0.30 · purity=0.10` — sum is 1.10; GQG divides by `total_w` so exact normalization is not required (all four calibrated via `--self-calibrate` in v3.2.0+)
158163
Project aggregation uses SR9 conservative weighting: `0.6 × min + 0.4 × mean`
159164

160165
Full specification: [docs/MATH_MODELS.md](docs/MATH_MODELS.md)
@@ -225,6 +230,39 @@ the training signal for ML self-calibration.
225230

226231
---
227232

233+
## Claude Code Skill
234+
235+
Turn AI-SLOP Detector into a persistent quality loop inside Claude Code — same scan criteria, same output shape, same gate logic, every session.
236+
237+
```bash
238+
# Install
239+
cp -r claude-skills/slop-detector ~/.claude/skills/
240+
# then restart Claude Code
241+
```
242+
243+
**Four commands:**
244+
245+
| Command | What it does |
246+
|---|---|
247+
| `/slop` | Full project scan — interprets findings, prioritizes fixes |
248+
| `/slop-file [path]` | Single-file analysis with per-pattern fix guidance |
249+
| `/slop-gate` | CI hard gate — PASS/FAIL with blocking file list |
250+
| `/slop-spar` | Adversarial validation — catches calibration drift |
251+
252+
**The loop:**
253+
254+
```
255+
/slop -> review findings -> patch -> /slop-file <path> -> /slop-gate
256+
```
257+
258+
> "It felt like the missing piece in my workflow — code quality tightened up almost immediately."
259+
>
260+
> A real user built this loop around the skill and reported: context burn dropped, review criteria held across sessions, and code quality improved immediately. The win was not that the agent became smarter — it was that the review loop stopped drifting.
261+
262+
Skill source: [`claude-skills/slop-detector/SKILL.md`](claude-skills/slop-detector/SKILL.md) · [Full documentation →](docs/CLAUDE_CODE_SKILL.md)
263+
264+
---
265+
228266
## Security Considerations
229267

230268
### `.slopconfig.yaml` sensitivity
@@ -343,6 +381,7 @@ cd vscode-extension && npm install && npx vsce package
343381

344382
| Version | Highlights |
345383
|---|---|
384+
| **v3.6.0** | Claude Code Skill (`/slop`, `/slop-file`, `/slop-gate`, `/slop-spar`); docs: Purity row added to metric axes, weight normalization note, `[go]` extra in Quick Start; stale test artifacts removed; 311 tests GREEN |
346385
| **v3.5.0** | Domain-aware `--init` (8 profiles, `--domain` flag); JS/TS analysis via JSAnalyzer v2.8.0 + `[js]`; Go analysis via GoAnalyzer v1.0.0 + `[go]`; self-calibration patches: project-scoped history (`project_id`), re-scan milestone trigger, domain-anchored grid search (±0.15), `CalibrationResult.warnings` (drift > 0.25); 308 tests GREEN |
347386
| **v3.4.1** | `FileRole.STUB` (Protocol/ABC stubs skip ldr+patterns); auto-discover `.slopconfig.yaml`; Python 3.8 CI compat; mypy `attr-defined` fix |
348387
| **v3.4.0** | Per-rule FP rate tracking (LEDA Phase 2A); purity weight ceiling `MAX_PURITY_WEIGHT=0.25` (Phase 2B) |
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
name: slop-detector
3+
description: Structural risk scanner for AI-assisted code using AI-SLOP Detector CLI. Triggers on /slop (full project scan), /slop-file [path] (single file), /slop-gate (CI hard gate), /slop-spar (adversarial validation). Interprets findings, prioritizes fixes, and drives the scan -> patch -> re-scan -> gate quality loop. Use when asked to check code quality, detect AI slop, validate imports, review structural integrity, or run a quality gate on Python/JS/Go files.
4+
---
5+
6+
# AI-SLOP Detector Skill
7+
8+
Structural risk scanner for AI-assisted code. Runs `slop-detector` CLI commands, interprets 4D scoring output (LDR + ICR + DDC + Purity), and drives the `scan -> patch -> re-scan -> gate` quality loop.
9+
10+
## Prerequisites
11+
12+
```bash
13+
pip install ai-slop-detector # core
14+
pip install "ai-slop-detector[js]" # optional: JS/TS
15+
pip install "ai-slop-detector[go]" # optional: Go
16+
```
17+
18+
Verify: `slop-detector --version`
19+
20+
---
21+
22+
## Commands
23+
24+
### /slop — Full Project Scan
25+
26+
```bash
27+
slop-detector --project . --json
28+
```
29+
30+
**Workflow:**
31+
1. Run the command above from the project root
32+
2. Parse JSON: iterate `file_results[]`
33+
3. Group by `status`: CRITICAL_DEFICIT first, then INFLATED_SIGNAL, SUSPICIOUS
34+
4. For each flagged file: report path, deficit_score, top pattern issues, metric warnings
35+
5. Show project aggregate: overall status, avg_ldr, avg_ddc, structural_coherence
36+
6. Propose a prioritized patch plan (see Patch Guidance below)
37+
38+
**Output format:**
39+
```
40+
[SCAN RESULTS]
41+
Project: <path> | Status: <OVERALL> | Files: <N> | Flagged: <M>
42+
43+
CRITICAL_DEFICIT (<count>):
44+
<file> | score: <X> | patterns: <list> | ldr: <X> ddc: <X>
45+
46+
INFLATED_SIGNAL (<count>):
47+
...
48+
49+
Recommended fixes: [ordered list]
50+
```
51+
52+
---
53+
54+
### /slop-file [path] — Single File Analysis
55+
56+
```bash
57+
slop-detector <path> --json
58+
```
59+
60+
**Workflow:**
61+
1. Run on the specified file
62+
2. Report: status, deficit_score, ldr_score, inflation_score, ddc usage_ratio
63+
3. List each pattern issue with severity and line reference if available
64+
4. Explain WHY each metric is flagged (not just the score)
65+
5. Provide concrete fix for each HIGH/CRITICAL pattern
66+
67+
**Explain metrics:**
68+
- `ldr_score < 0.30` -> "Less than 30% of lines are executable logic. Heavy padding or empty stubs."
69+
- `inflation_score > 1.0` -> "Jargon density exceeds threshold. Unjustified quality claims detected."
70+
- `ddc usage_ratio < 0.50` -> "More than half of imported modules are unused. Possible phantom imports."
71+
- `purity < 0.60` -> "Multiple critical patterns detected. AND-gate score pulled down."
72+
73+
---
74+
75+
### /slop-gate — CI Gate Decision
76+
77+
```bash
78+
slop-detector --project . --ci-mode hard --ci-report
79+
```
80+
81+
**Workflow:**
82+
1. Run the command; capture exit code
83+
2. Exit 0 = PASS. Exit non-zero = FAIL.
84+
3. Report: PASS/FAIL, files exceeding threshold, critical pattern counts
85+
4. On FAIL: list blocking files with deficit_score >= 70 or critical_patterns >= 3
86+
5. Suggest minimum fixes required to unblock the gate
87+
88+
**Gate thresholds (hard mode):**
89+
- deficit_score >= 70 -> blocks
90+
- critical_pattern_count >= 3 -> blocks
91+
92+
---
93+
94+
### /slop-spar — Adversarial Validation
95+
96+
```bash
97+
fhval spar
98+
```
99+
100+
Options:
101+
```bash
102+
fhval spar --layer a # known-pattern anchors
103+
fhval spar --layer b # metric boundary probes
104+
fhval spar --layer c # existence probes
105+
```
106+
107+
**Workflow:**
108+
1. Run full 3-layer check
109+
2. Report any calibration drift detected
110+
3. Flag dimensions where metric claims diverge from measured behavior
111+
4. If drift found: recommend `slop-detector . --self-calibrate --apply-calibration`
112+
113+
---
114+
115+
## Status Interpretation
116+
117+
| Status | Score | Action |
118+
|---|---|---|
119+
| `CLEAN` | < 30 | No action needed |
120+
| `SUSPICIOUS` | 30-50 | Review flagged patterns; low urgency |
121+
| `INFLATED_SIGNAL` | 50-70 | Fix before merge; likely AI padding |
122+
| `CRITICAL_DEFICIT` | >= 70 | Block merge; structural issue confirmed |
123+
124+
---
125+
126+
## Patch Guidance — Per Pattern
127+
128+
| Pattern | Fix |
129+
|---|---|
130+
| `not_implemented` / `pass_placeholder` | Implement the function body or remove the stub |
131+
| `phantom_import` | Remove import; if needed, install the actual package |
132+
| `empty_except` | Add specific exception type and handling logic |
133+
| `god_function` | Decompose into focused units (<= 50 lines each) |
134+
| `function_clone_cluster` | Extract shared logic into a single helper |
135+
| `dead_code` | Delete unreachable branches |
136+
| `todo_comment` / `fixme_comment` | Resolve or file a tracked issue; remove inline comment |
137+
| `star_import` | Replace with explicit named imports |
138+
| `placeholder_variable_naming` | Rename single-letter params to descriptive names |
139+
| `return_constant_stub` | Return computed value or raise NotImplementedError |
140+
141+
---
142+
143+
## Scan -> Patch -> Re-scan Loop
144+
145+
```
146+
1. /slop -- baseline scan; identify top offenders
147+
2. Review findings -- prioritize CRITICAL_DEFICIT files
148+
3. Apply patches -- use Patch Guidance above
149+
4. /slop-file <path> -- verify each patched file
150+
5. /slop -- confirm project aggregate improved
151+
6. /slop-gate -- gate decision before merge
152+
```
153+
154+
**Delta reporting:** After re-scan, compare `deficit_score` before vs. after for each patched file. Report improvement or regression.
155+
156+
---
157+
158+
## Self-Calibration (when scores seem off)
159+
160+
```bash
161+
slop-detector . --self-calibrate # preview recommended weights
162+
slop-detector . --self-calibrate --apply-calibration # write to .slopconfig.yaml
163+
```
164+
165+
Triggers automatically after 10 re-scanned files per project. Domain-anchored (+-0.15 from profile baseline). Use when false-positive rate feels high for your project type.
166+
167+
---
168+
169+
## Domain Profiles
170+
171+
```bash
172+
slop-detector --init # auto-detect domain
173+
slop-detector --init --domain data_science # explicit override
174+
```
175+
176+
Profiles: `general`, `web_frontend`, `data_science`, `cli_tool`, `library`, `ml_research`, `backend_api`, `scientific`
177+
178+
---
179+
180+
## Scoring Model Reference
181+
182+
```
183+
purity = exp(-0.5 x n_critical_patterns)
184+
GQG = exp( sum(w_i * ln(dim_i)) / total_w ) -- weighted geometric mean
185+
deficit_score = 100 * (1 - GQG) + pattern_penalty
186+
total_w = w_ldr + w_inflation + w_ddc + w_purity -- self-normalizing
187+
```
188+
189+
Default weights: `ldr=0.40, inflation=0.30, ddc=0.30, purity=0.10` (sum=1.10; normalized by total_w)
190+
Project aggregation: `0.6 * min + 0.4 * mean` (SR9 conservative)

0 commit comments

Comments
 (0)