litclaude-ai 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,52 +1,347 @@
1
1
  ---
2
2
  name: remove-ai-slops
3
- description: Cleanup workflow for AI-generated bloat, vague wording, fake certainty, overbroad abstractions, and unsupported claims in LitClaude code and docs.
3
+ description: Cleanup workflow for AI-generated bloat, vague wording, fake certainty, overbroad abstractions, and unsupported claims across a bounded set of LitClaude files. Locks behavior with regression/characterization tests FIRST, then runs a categorized, risk-ordered cleanup, then verifies with quality gates and a critical review. Covers 10 slop categories including performance equivalences, needless abstraction, and oversized modules. Use when the user asks to "remove slop", "clean AI code", "deslop", or clean up AI-generated patterns from recent changes.
4
4
  ---
5
5
 
6
6
  # Remove AI Slops
7
7
 
8
8
  Use this skill when output feels padded, generic, or less precise than the
9
- system it describes. The cleanup must be behavior-preserving unless paired with
10
- a test for a behavior change.
9
+ system it describes, OR when a branch's changed files carry AI-generated code
10
+ smells. This is the FULL multi-file cleanup workflow. For a single isolated
11
+ file, use the `ai-slop-remover` alias instead.
11
12
 
12
- ## Slop Signals
13
+ The cleanup must be behavior-preserving unless a behavior change is explicitly
14
+ requested and paired with a test for the new behavior.
13
15
 
14
- - Grand claims without an observable command.
15
- - "Seamless", "robust", or "powerful" without concrete behavior.
16
- - Repeated caveats in every section.
17
- - Large abstractions with only one caller.
18
- - Tests that assert exact prose but not policy.
19
- - Docs that say a feature exists when the runtime only has guidance.
20
- - Placeholder-like skills that omit the actual workflow.
16
+ ## Central safety invariant: test-first behavior lock
21
17
 
22
- ## Cleanup Rules
18
+ **Behavior is locked by green tests BEFORE a single line is removed.** A
19
+ checklist is not safety; a passing regression test is. If you cannot establish a
20
+ green baseline first, you have no safe ground to clean on — STOP and report.
23
21
 
24
- - Replace hype with commands, paths, and expectations.
25
- - Replace vague "verify it works" with exact test and QA scenario.
26
- - Delete duplicate warnings once the actionable warning remains.
27
- - Keep constraints that protect users from publish, destructive commands, and
28
- secret exposure.
29
- - Do not remove useful nuance about Claude Code vs source runtime surfaces.
22
+ This is the one rule that cannot be skipped. Cleaning on uncovered ground is a
23
+ behavior-change time bomb no matter how careful the pass looks.
30
24
 
31
- ## LitClaude Hotspots
25
+ ## Inputs
32
26
 
33
- Check:
27
+ - **Default scope**: the branch diff versus `merge-base main` (no arguments).
28
+ - **Optional scope**: an explicit file list passed by the caller (e.g. a
29
+ loop workflow's changed-files set).
34
30
 
35
- - `README.md` and `README_ko-KR.md` for version drift.
36
- - `docs/hooks.md` for noisy fallback wording.
37
- - `plugins/litclaude/skills/*/SKILL.md` for shallow placeholders.
38
- - `plugins/litclaude/commands/*.md` for broken `$ARGUMENTS`.
39
- - `bin/litclaude-ai.js` for one-off helper bloat.
40
- - `test/*.test.mjs` for brittle prose pins.
31
+ ## Slop categories (what counts as slop)
41
32
 
42
- ## Verification
33
+ Ten categories. The first three are stylistic, the next three structural, the
34
+ next two are hidden cost, then behavior coverage, then module size. Each lists
35
+ explicit KEEP versus REFACTOR/REMOVE rules — the KEEP rules are as binding as
36
+ the removals.
43
37
 
44
- Run tests after cleanup. For docs-only cleanup, docs tests are enough for
45
- automated evidence, but a package dry-run is useful when the README command or
46
- published package surface changed.
38
+ ### Stylistic
47
39
 
48
- ## Output Style
40
+ 1. **Redundant comments** — comments restating the code, trivial docstrings,
41
+ section-divider banners, commented-out code, vague `TODO`/`Note` markers.
42
+ - KEEP: comments explaining WHY (business logic, edge cases, workarounds),
43
+ ticket/issue links, regex and algorithm explanations.
44
+ - KEEP: behavior markers used by tests (`# given`, `# when`, `# then`).
45
+ - REMOVE: comments that only restate WHAT the next line does.
49
46
 
50
- Summarize removed slop by category, not by every sentence. If a section was
51
- intentionally left verbose because it encodes a workflow, say so.
47
+ 2. **Over-defensive guards** null checks for guaranteed values, try/catch
48
+ around code that cannot throw, type checks on statically typed params,
49
+ defaults for required params, backward-compat shims, validation duplicated at
50
+ multiple layers, broad catch-alls (`except Exception` in Python, empty
51
+ `catch {}` or `catch (e) { console.error(e) }` without narrowing in
52
+ TypeScript/JavaScript).
53
+ - KEEP: validation at system boundaries (user input, external APIs), I/O
54
+ error handling, nullable persisted fields. A top-level boundary catch-all
55
+ (CLI `main()`, HTTP handler) with explicit logging plus re-raise is fine.
56
+ - REFACTOR: broad catch → catch the specific error you expect; empty
57
+ `catch {}` → narrow with `instanceof` or re-throw.
52
58
 
59
+ 3. **Excessive complexity** — deep nesting (>3 levels), nested ternaries,
60
+ boolean expressions combining 4+ predicates, parameter lists over 5 args
61
+ without a struct/record/object, god functions (>50 lines doing many things),
62
+ clever one-liners that sacrifice readability, `if/elif` chains discriminating
63
+ on a type/enum/literal (prefer an exhaustive switch with a never-fallthrough
64
+ guard).
65
+ - KEEP: complexity idioms already established in this codebase, intentionally
66
+ complex hot paths. `if/else` for genuine boolean and range conditions.
67
+ - REFACTOR: nested if-chains → guard clauses / early returns; complex
68
+ ternaries → explicit if/else.
69
+
70
+ ### Structural
71
+
72
+ 4. **Needless abstraction / configurability** — pass-through wrappers,
73
+ single-use helpers, speculative indirection ("we might need this later"),
74
+ interfaces with one implementer that add no test seam, factory functions that
75
+ only call a constructor, options/flags nobody requested.
76
+ - KEEP: abstractions that provide a real seam (testability, multiple
77
+ implementers, framework-required boundaries).
78
+
79
+ 5. **Boundary violations** — wrong-layer imports (UI reaching into a DB
80
+ driver), leaky responsibilities (a handler doing service-layer logic), hidden
81
+ coupling (one module reading another's private state), side effects in
82
+ pure-named functions.
83
+ - KEEP: pragmatic short-circuits already established as a pattern here. When
84
+ unsure, flag for human judgment rather than rewrite.
85
+
86
+ 6. **Dead code** — unused imports, unused private functions/methods, unreachable
87
+ branches, stale feature flags, debug leftovers (`console.log`, `print(...)`),
88
+ code referenced nowhere after a removal.
89
+ - KEEP: code reached via reflection, dynamic dispatch, or string lookup; code
90
+ intentionally retained as a rollback path (confirm with the user).
91
+
92
+ ### Hidden cost
93
+
94
+ 7. **Duplication** — copy-pasted branches with trivial differences, redundant
95
+ helpers doing the same thing in two places, repeated magic-number sequences.
96
+ - KEEP: incidental duplication — two blocks that look alike but serve intents
97
+ that could diverge. Prefer leaving them separate over forcing a premature
98
+ shared abstraction.
99
+
100
+ 8. **Performance-equivalent rewrites** — changes provably equivalent in
101
+ semantics but cheaper in time or space:
102
+ - O(n²) → O(n) when correctness is preserved (set lookup vs list scan)
103
+ - repeated computation inside a loop → hoist it out
104
+ - eager intermediate collections used once → lazy iteration
105
+ - string concatenation in a loop → join
106
+ - redundant calls in a loop → batch
107
+ - `.length`/`len()` recomputed inside a loop → cache it
108
+ - **Hard rule**: apply only when equivalence is obvious. Do NOT change
109
+ algorithms with subtle correctness implications and do NOT micro-optimize
110
+ hot paths without a benchmark. When in doubt, SKIP.
111
+
112
+ ### Behavior coverage
113
+
114
+ 9. **Missing tests** — observable behavior in a changed file that no test pins.
115
+ The fix is NOT to remove code; it is to ADD the narrowest characterization
116
+ test that locks current behavior.
117
+
118
+ ### Module size
119
+
120
+ 10. **Oversized modules** — a source file exceeding **250 pure LOC** (non-blank,
121
+ non-comment lines). This is an architectural defect, not a style preference.
122
+ Measure pure LOC, then split by responsibility:
123
+ - identify the distinct responsibilities the file currently owns;
124
+ - name each new file after the concept it owns — never `utils`, `helpers`,
125
+ `common`, or numbered shards like `part1`;
126
+ - present the split plan to the user before executing;
127
+ - keep any index/re-export file to re-exports only, no logic.
128
+ - KEEP: a genuinely self-contained single-responsibility script (e.g. a
129
+ standalone checker). Opt out by saying so and explaining why.
130
+ - Forbidden escapes: counting blanks/comments toward budget; splitting by
131
+ token count; catch-all dump files; "it's generated" (only valid for build
132
+ output); "230 LOC, close enough" — a file about to grow is already over.
133
+
134
+ ## Quality gates
135
+
136
+ A pass is complete only when every applicable gate is green. Gates genuinely
137
+ N/A for the project are reported as `N/A` with a reason — never silently
138
+ skipped.
139
+
140
+ | Gate | Tool | Pass condition |
141
+ |---|---|---|
142
+ | Regression/characterization tests | `node --test` or the project's runner via Bash | all green, including any tests added in the behavior-lock phase |
143
+ | Lint | the project's linter via Bash | zero errors (pre-existing warnings OK) |
144
+ | Typecheck | LSP diagnostics on changed files plus the project type-checker | zero new errors on changed files |
145
+ | Unit/integration tests | the project's runner via Bash | all green (pre-existing failures noted, not introduced) |
146
+ | Static/security scan | the project's scanner via Bash | zero new findings, or `N/A` if none configured |
147
+
148
+ ## Process
149
+
150
+ ### Phase 0: Plan
151
+
152
+ List the phases below as tracked todos and work one at a time.
153
+
154
+ ### Phase 1: Determine scope
155
+
156
+ If the caller passed file paths, that is the scope. Otherwise compute the branch
157
+ diff with Bash:
158
+
159
+ ```bash
160
+ git diff "$(git merge-base main HEAD)..HEAD" --name-only
161
+ ```
162
+
163
+ Filter out deleted, binary, and generated/vendored files (`node_modules/`,
164
+ `dist/`, `target/`, lockfiles). List the final scope.
165
+
166
+ For LitClaude specifically, watch these hotspots: `README.md` and
167
+ `README_ko-KR.md` for version drift, `docs/hooks.md` for noisy fallback wording,
168
+ `plugins/litclaude/skills/*/SKILL.md` for shallow placeholders,
169
+ `plugins/litclaude/commands/*.md` for broken `$ARGUMENTS`, `bin/litclaude-ai.js`
170
+ for one-off helper bloat, and `test/*.test.mjs` for brittle prose pins.
171
+
172
+ ### Phase 2: Lock behavior FIRST (non-negotiable)
173
+
174
+ For each in-scope source file:
175
+
176
+ 1. Identify the observable behavior it exposes (exported functions, HTTP
177
+ handlers, CLI commands, classes used elsewhere).
178
+ 2. Check whether existing tests cover that behavior (`git grep`, project test
179
+ conventions).
180
+ 3. If behavior is uncovered or weakly covered, write the narrowest
181
+ regression/characterization test that pins CURRENT behavior **before**
182
+ editing the file. Pin observable outputs, not implementation details.
183
+ 4. Run the suite via Bash. It must be **green** before any cleanup begins.
184
+
185
+ If you cannot establish a green baseline (e.g. the runner is broken), STOP and
186
+ report. Do not clean on unverified ground.
187
+
188
+ ### Phase 3: Cleanup plan
189
+
190
+ Produce an explicit plan before removing anything:
191
+
192
+ ```
193
+ File: plugins/litclaude/lib/foo.js
194
+ Categories: dead code, excessive complexity, performance
195
+ Order: dead code → complexity → performance
196
+ Risk: medium (touches a caching path)
197
+
198
+ File: docs/bar.md
199
+ Categories: redundant comments, over-defensive wording
200
+ Order: comments → defensive
201
+ Risk: low
202
+ ```
203
+
204
+ Apply categories in this risk order (safest → riskiest) to minimize the blast
205
+ radius of any single change:
206
+
207
+ `comments → dead code → defensive bloat → duplication → complexity → abstraction/boundary → performance → missing tests → oversized modules`
208
+
209
+ ### Phase 4: Execute the cleanup
210
+
211
+ For a small scope, clean the files directly with Edit, one category at a time in
212
+ the risk order above. For a large scope, fan out: dispatch one subagent per file
213
+ with the `Task` tool, each running this same discipline on exactly one file.
214
+ Keep batches bounded (about 5 in flight) so results stay reviewable, and never
215
+ let a subagent touch a file outside its assignment.
216
+
217
+ Each subagent assignment must be executable: start with `TASK:`, name the exact
218
+ file, the categories to evaluate, the risk order, and the hard constraints
219
+ below; require a `DELIVERABLE` (per-category report with before/after, why-slop,
220
+ why-safe, and reasons for every skip).
221
+
222
+ Hard constraints for every cleanup, direct or delegated:
223
+ - Behavior MUST be preserved. When equivalence is not obvious, SKIP.
224
+ - Do NOT change public API signatures.
225
+ - Do NOT remove type hints.
226
+ - Do NOT introduce new abstractions or dependencies.
227
+ - Keep the diff minimal and scoped strictly to slop removal.
228
+ - Do NOT touch files outside scope, even if you notice slop in passing — report
229
+ those under "Remaining risks".
230
+
231
+ ### Phase 5: Verify with quality gates plus critical review
232
+
233
+ Run all applicable gates, then walk the review checklists.
234
+
235
+ **Safety**:
236
+ - [ ] No functional logic accidentally removed
237
+ - [ ] All error handling preserved (especially I/O, network, external APIs)
238
+ - [ ] Type hints intact and correct
239
+ - [ ] Imports still valid
240
+ - [ ] No breaking changes to public APIs
241
+
242
+ **Behavior**:
243
+ - [ ] Return values unchanged (verified by the Phase 2 tests)
244
+ - [ ] Side effects unchanged
245
+ - [ ] Error/exception behavior unchanged
246
+ - [ ] Edge-case handling preserved
247
+
248
+ **Quality**:
249
+ - [ ] Removed items are genuinely slop, not intentional patterns
250
+ - [ ] Remaining code follows project conventions
251
+ - [ ] No orphaned code or dangling references
252
+ - [ ] Performance rewrites are obviously equivalent (no subtle algorithm shift)
253
+ - [ ] No new abstractions introduced
254
+
255
+ For a broad, risky, or release-facing scope, run a reviewer pass with a separate
256
+ `Task` subagent in a reviewer role — not a generic worker — to re-walk these
257
+ checklists independently.
258
+
259
+ ### Phase 6: Fix issues
260
+
261
+ If any gate fails or any checklist item flips:
262
+
263
+ 1. Identify the specific change that caused it and why it broke.
264
+ 2. Revert just that hunk (`git checkout` the file or a targeted Edit).
265
+ 3. Re-apply only the changes you can prove are safe.
266
+ 4. Re-run the failing gate and re-walk the checklist for that file.
267
+ 5. Repeat until all gates are green AND the checklists are clean.
268
+
269
+ If the same file fails three times, STOP and escalate with the file, what you
270
+ tried, what failed, and your hypothesis. Do not keep editing blindly.
271
+
272
+ ## Output report
273
+
274
+ ```text
275
+ AI SLOP REMOVAL REPORT
276
+ ======================
277
+
278
+ Scope: [branch diff vs merge-base main / explicit file list]
279
+ Files: [N files]
280
+ - path/to/file1.js
281
+ - path/to/file2.md
282
+
283
+ Behavior Lock:
284
+ - Existing coverage: [N files already covered]
285
+ - Tests added: [M new tests at path/to/test.mjs]
286
+ - Baseline status: GREEN
287
+
288
+ Cleanup Plan:
289
+ - path/to/file1.js: [dead code → complexity → performance]
290
+ - path/to/file2.md: [comments → defensive]
291
+
292
+ Per-File Results:
293
+ path/to/file1.js
294
+ - Dead code: 3 removed (lines X-Y, A-B, C)
295
+ - Excessive complexity: 1 simplified (nested ternary → if/else)
296
+ - Performance: 1 (list scan → set lookup, O(n²)→O(n), behavior identical)
297
+ - Skipped (preserved): 2 (boundary null check; WHY comment at L88)
298
+
299
+ Quality Gates:
300
+ - Regression tests: PASS (N tests, 0 failed)
301
+ - Lint: PASS
302
+ - Typecheck (LSP + project): PASS (0 new errors on changed files)
303
+ - Unit/integration tests: PASS
304
+ - Static/security scan: N/A (not configured)
305
+
306
+ Critical Review:
307
+ - Safety: PASS
308
+ - Behavior: PASS
309
+ - Quality: PASS
310
+
311
+ Issues Found & Fixed:
312
+ - [None] OR [issue → fix applied]
313
+
314
+ Remaining Risks / Deferred:
315
+ - [None] OR [e.g. boundary violation flagged, needs human judgment]
316
+
317
+ Final Status: CLEAN | ISSUES FIXED | REQUIRES ATTENTION
318
+ ```
319
+
320
+ Summarize removed slop by category, not by every sentence. If a section was left
321
+ intentionally verbose because it encodes a workflow, say so.
322
+
323
+ ## Anti-patterns (do not do these)
324
+
325
+ - **Skipping Phase 2.** Removing code on uncovered ground is a behavior-change
326
+ time bomb. The regression test IS the safety mechanism; the checklist
327
+ complements it, never replaces it.
328
+ - **Bundling unrelated refactors.** Dead-code deletion plus abstraction removal
329
+ plus a performance change in one commit is impossible to review or bisect.
330
+ - **Algorithm changes disguised as performance.** If equivalence needs a proof,
331
+ it is a refactor, not a slop fix — put it in a separate change.
332
+ - **Silent skips.** If a gate is N/A, say `N/A` and why. If a check failed and
333
+ you could not fix it, say so. Never claim PASS without evidence.
334
+ - **Removing WHY comments.** "It's obvious from the code" is rarely true for the
335
+ next reader. Only remove comments that restate WHAT.
336
+ - **Touching files outside scope.** Report drive-by slop under "Remaining
337
+ risks" instead of editing it.
338
+ - **Deleting pre-existing dead code you were not asked about.** Flag it; do not
339
+ remove it as part of an unrelated cleanup.
340
+
341
+ ## When in doubt, SKIP
342
+
343
+ The default action under any uncertainty is SKIP, not GUESS. A false negative
344
+ (leaving real slop) is recoverable; a false positive (removing load-bearing
345
+ code) breaks the system. Never remove code that serves a functional purpose,
346
+ always verify changes parse and typecheck, and always preserve test coverage by
347
+ adding tests rather than removing them.