@sloppy-ai/skill-code 0.0.0-stage → 1.4.0
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.
- package/SKILL.md +101 -0
- package/package.json +13 -4
- package/README.md +0 -3
package/SKILL.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sloppy-code
|
|
3
|
+
description: Specialist anti-slop skill for React/TypeScript component architecture, accessibility semantics, dead placeholder cleanup, and code comment hygiene. Load on-demand when writing component code, refactoring logic, or auditing comments.
|
|
4
|
+
metadata:
|
|
5
|
+
version: 1.4.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Sloppy Code: Component Semantics, Accessibility & Comment Hygiene
|
|
9
|
+
|
|
10
|
+
This specialist skill enforces professional senior-developer standards across React, TypeScript, and JSX implementations. It strips synthetic AI noise and guarantees accessible interactive controls.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 1. Comment Hygiene Pass (`COD-01`)
|
|
15
|
+
|
|
16
|
+
AI code generators litter files with low-signal narration comments and decorative box-drawing banners.
|
|
17
|
+
|
|
18
|
+
### Narration Comments Blocked & Stripped:
|
|
19
|
+
- Comments stating the obvious next line:
|
|
20
|
+
- `// Render the header button`
|
|
21
|
+
- `// Return the component JSX`
|
|
22
|
+
- `// Main container wrapper`
|
|
23
|
+
- `// State management variables`
|
|
24
|
+
- `// Handle click event`
|
|
25
|
+
- Decorative ascii box-drawing section banners:
|
|
26
|
+
- `/* ========================================================================== */`
|
|
27
|
+
- `// ---------------------------------------------------------------------------`
|
|
28
|
+
- `///////////////////////////////////////////////////////////////////////////////`
|
|
29
|
+
|
|
30
|
+
### Comments Strictly Preserved:
|
|
31
|
+
- **Invariants**: `// Invariant: User token must be validated before render`
|
|
32
|
+
- **Workaround Rationales**: `// Workaround: Safari 15 flex child requires explicit min-height`
|
|
33
|
+
- **Performance Rationale**: `// Note: Debounce threshold must remain >= 300ms to avoid rate-limiting`
|
|
34
|
+
- **Pragmas**: `// eslint-disable...`, `// @ts-expect-error...`, `// sloppy-override: ...`
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 2. Accessible Controls & Semantics (`AX-01` - Floor Blocker)
|
|
39
|
+
|
|
40
|
+
AI agents routinely render `<div onClick={handleClick}>` without accessibility affordances.
|
|
41
|
+
|
|
42
|
+
### Required Accessibility Semantics:
|
|
43
|
+
1. Prefer native `<button>` elements for all interactive actions.
|
|
44
|
+
2. If a `<div>` or `<span>` must be interactive:
|
|
45
|
+
- Provide `role="button"`
|
|
46
|
+
- Provide `tabIndex={0}` for keyboard navigation
|
|
47
|
+
- Provide an `onKeyDown` handler that triggers on Enter and Space:
|
|
48
|
+
```tsx
|
|
49
|
+
<div
|
|
50
|
+
role="button"
|
|
51
|
+
tabIndex={0}
|
|
52
|
+
onClick={handleClick}
|
|
53
|
+
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') handleClick(); }}
|
|
54
|
+
className="cursor-pointer focus:outline-none focus:ring-2 focus:ring-neutral-400"
|
|
55
|
+
>
|
|
56
|
+
Action
|
|
57
|
+
</div>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 3. Zero Dead Placeholder Callbacks (`UX-02` - Floor Blocker)
|
|
63
|
+
|
|
64
|
+
- **Dead Anchor Targets**: Never use `href="#"` or `href="javascript:void(0)"`. Link to authentic routes (`href="/dashboard"`, `href="/api/docs"`) or use a semantic `<button>`.
|
|
65
|
+
- **Empty Handlers**: Replace empty stubs like `onClick={() => {}}` with functional dispatch, state mutation, or an explicit logged callback (`onClick={() => console.log('Action triggered')}`).
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 4. Stacking Context Discipline (`TOK-01` - Floor Blocker)
|
|
70
|
+
|
|
71
|
+
- Arbitrary z-index escalation (`z-[9999]`, `z-[99999]`, `style={{ zIndex: 10000 }}`) is blocked.
|
|
72
|
+
- Use structured, predictable stacking scale:
|
|
73
|
+
- `z-0`: Base canvas ground
|
|
74
|
+
- `z-10`: Sticky headers and navbars
|
|
75
|
+
- `z-20`: Dropdowns, popovers, tooltips
|
|
76
|
+
- `z-50`: Modals, dialog overlays, command bars
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 5. Low-Evidence TypeScript Code Rules (`COD-02`..`COD-06`)
|
|
81
|
+
|
|
82
|
+
AI agents often fabricate type safety that compiles without runtime guarantees:
|
|
83
|
+
- **`COD-02` (`CHAINED_TYPE_ASSERTION`, Reflex)**: Avoid `as unknown as T` or `as any as T`; validate shapes with type guards or Zod schemas.
|
|
84
|
+
- **`COD-03` (`UNVALIDATED_DYNAMIC_RETURN`, Reflex)**: Specify concrete return interfaces instead of `(): any` or `(): Promise<unknown>`.
|
|
85
|
+
- **`COD-04` (`BROAD_RECORD_SLOP`, Reflex)**: Replace broad `Record<string, any>` / `Record<string, unknown>` maps with explicit property keys or union dictionaries.
|
|
86
|
+
- **`COD-05` (`EMPTY_OBJECT_SPREAD`, Finish)**: Avoid `...(cond ? { key } : {})`; declare optional properties explicitly.
|
|
87
|
+
- **`COD-06` (`NON_NULL_ASSERTION_SLOP`, Floor)**: Never chain `foo!.bar!.baz`; use optional chaining (`?.`) or defensive guards.
|
|
88
|
+
- **Strict Invariant Ignores (`--strict`)**: Suppressing any rule with `// sloppy-ignore-next-line <RULE>` in strict mode requires a written invariant reason (`-- <reason>` of at least 5 characters), e.g. `// sloppy-ignore-next-line COD-02 -- Checked invariant: validated via Zod upstream`.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 6. Ponytail Native Platform Primitives (Zero Over-Engineering)
|
|
93
|
+
|
|
94
|
+
- **Native HTML Elements Over Hand-Rolled Divs**:
|
|
95
|
+
- Always reach for `<button type="button">` over `<div onClick=... role="button">`.
|
|
96
|
+
- Always reach for native `<dialog>` or native form controls (`<input type="date">`, `<select>`, `<input type="checkbox">`) before hand-rolling 300 lines of custom dropdown or modal state.
|
|
97
|
+
- **CSS Transitions Over Heavy Runtime Engines**:
|
|
98
|
+
- Use simple CSS transitions (`transition-all duration-150 ease-out`) for hover, focus, and state reveals.
|
|
99
|
+
- Never import external physics libraries when 2 lines of CSS transitions accomplish the same user orientation.
|
|
100
|
+
- **Minimal State Complexity**:
|
|
101
|
+
- Compute values in-render where possible; avoid redundant `useState` + `useEffect` chains that lead to synchronization bugs and layout thrashing.
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sloppy-ai/skill-code",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Specialist anti-slop skill for React/TypeScript component architecture, accessibility semantics, and comment hygiene.",
|
|
5
|
+
"main": "SKILL.md",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"SKILL.md"
|
|
11
|
+
],
|
|
12
|
+
"keywords": ["skill", "code-craft", "anti-slop", "accessibility", "comment-hygiene"],
|
|
13
|
+
"author": "Pavanspoojary",
|
|
14
|
+
"license": "MIT"
|
|
15
|
+
}
|
package/README.md
DELETED