howtocode 0.0.0-stage → 0.7.56

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.
Files changed (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +248 -2
  3. package/dist/chunk-27TRKD65.js +2 -0
  4. package/dist/chunk-2SHU7WQ5.js +10 -0
  5. package/dist/chunk-3FYCFLNK.js +1 -0
  6. package/dist/chunk-4BWBQ4HV.js +1 -0
  7. package/dist/chunk-7IUWRCVT.js +197 -0
  8. package/dist/chunk-7LA2AMZB.js +1 -0
  9. package/dist/chunk-A3LZMZ3C.js +2 -0
  10. package/dist/chunk-ADJLVYL3.js +1 -0
  11. package/dist/chunk-AEDSISJB.js +1 -0
  12. package/dist/chunk-AEWC7NIN.js +5 -0
  13. package/dist/chunk-AYBGCIQH.js +8 -0
  14. package/dist/chunk-DML5JQIR.js +1 -0
  15. package/dist/chunk-DT7VRY24.js +1 -0
  16. package/dist/chunk-EZNNALD3.js +1 -0
  17. package/dist/chunk-FGKA3GGW.js +6 -0
  18. package/dist/chunk-FJBHQI6Q.js +6 -0
  19. package/dist/chunk-JWPDIJUV.js +1 -0
  20. package/dist/chunk-KA2CULSQ.js +2 -0
  21. package/dist/chunk-KTS2F755.js +2 -0
  22. package/dist/chunk-LYLJZVZ7.js +1 -0
  23. package/dist/chunk-MCAAX33K.js +2 -0
  24. package/dist/chunk-MCDEIIEN.js +1 -0
  25. package/dist/chunk-MVVEYKN6.js +6 -0
  26. package/dist/chunk-MWSWXDNN.js +5 -0
  27. package/dist/chunk-ORJ2QZBG.js +3 -0
  28. package/dist/chunk-PH72JBBL.js +4 -0
  29. package/dist/chunk-PVFHAKN6.js +1 -0
  30. package/dist/chunk-QOYTPACU.js +3 -0
  31. package/dist/chunk-RGYXELNI.js +140 -0
  32. package/dist/chunk-SDO33XPR.js +4 -0
  33. package/dist/chunk-SZPFD4XF.js +47 -0
  34. package/dist/chunk-TOV557ET.js +12 -0
  35. package/dist/chunk-TSEKPGK4.js +1 -0
  36. package/dist/chunk-TUXY64DT.js +2 -0
  37. package/dist/chunk-U3GZBLTM.js +2 -0
  38. package/dist/chunk-UTYFLLSM.js +1 -0
  39. package/dist/chunk-V3R4FYTJ.js +1 -0
  40. package/dist/chunk-VWAUPT4A.js +1 -0
  41. package/dist/chunk-WKUJ7CFO.js +1 -0
  42. package/dist/chunk-WOT6VMZA.js +1 -0
  43. package/dist/chunk-XBVWQC7P.js +1 -0
  44. package/dist/chunk-XHHNV7A5.js +2 -0
  45. package/dist/chunk-YNMLRZJK.js +2 -0
  46. package/dist/chunk-YX2QDCVK.js +1 -0
  47. package/dist/main.js +102 -0
  48. package/dist/presets/backend/api/preset.json +17 -0
  49. package/dist/presets/backend/api/prompt.md +9 -0
  50. package/dist/presets/backend/api/skills/api-contract/SKILL.md +35 -0
  51. package/dist/presets/data/sql/preset.json +17 -0
  52. package/dist/presets/data/sql/prompt.md +9 -0
  53. package/dist/presets/data/sql/skills/query-hygiene/SKILL.md +48 -0
  54. package/dist/presets/devops/containers/preset.json +17 -0
  55. package/dist/presets/devops/containers/prompt.md +9 -0
  56. package/dist/presets/devops/containers/skills/image-discipline/SKILL.md +59 -0
  57. package/dist/presets/frontend/web-ui/preset.json +17 -0
  58. package/dist/presets/frontend/web-ui/prompt.md +11 -0
  59. package/dist/presets/frontend/web-ui/skills/responsive-check/SKILL.md +46 -0
  60. package/dist/presets/gamedev/rotoolbox/preset.json +31 -0
  61. package/dist/presets/gamedev/rotoolbox/prompt.md +34 -0
  62. package/dist/presets/gamedev/rotoolbox/skills/rotoolbox/SKILL.md +129 -0
  63. package/dist/presets/hub.json +14582 -0
  64. package/dist/presets/lang/typescript/preset.json +16 -0
  65. package/dist/presets/lang/typescript/prompt.md +5 -0
  66. package/dist/presets/lang/typescript/skills/ts-strict/SKILL.md +48 -0
  67. package/dist/presets/mcp/filesystem/preset.json +27 -0
  68. package/dist/presets/mcp/filesystem/prompt.md +8 -0
  69. package/dist/presets/mcp/filesystem/skills/mcp-files/SKILL.md +27 -0
  70. package/dist/presets/mcp/memory/preset.json +25 -0
  71. package/dist/presets/mcp/memory/skills/mcp-memory/SKILL.md +31 -0
  72. package/dist/presets/mcp/rea/preset.json +28 -0
  73. package/dist/presets/mcp/rea/prompt.md +5 -0
  74. package/dist/presets/mcp/rea/skills/mcp-rea/SKILL.md +6 -0
  75. package/dist/presets/mcp/remotion/preset.json +27 -0
  76. package/dist/presets/mcp/remotion/prompt.md +7 -0
  77. package/dist/presets/mcp/remotion/skills/mcp-remotion/SKILL.md +6 -0
  78. package/dist/presets/mcp-hub.json +157 -0
  79. package/dist/presets/mobile/app/preset.json +17 -0
  80. package/dist/presets/mobile/app/prompt.md +7 -0
  81. package/dist/presets/mobile/app/skills/touch-targets/SKILL.md +47 -0
  82. package/dist/presets/quality/antislop/preset.json +25 -0
  83. package/dist/presets/quality/antislop/prompt.md +16 -0
  84. package/dist/presets/quality/antislop/skills/antislop/SKILL.md +595 -0
  85. package/dist/presets/quality/antislop/skills/antislop/references/gate.md +84 -0
  86. package/dist/presets/quality/antislop/skills/antislop-code/SKILL.md +128 -0
  87. package/dist/presets/quality/antislop/skills/antislop-copywriting/SKILL.md +413 -0
  88. package/dist/presets/quality/antislop/skills/antislop-human/SKILL.md +147 -0
  89. package/dist/presets/quality/antislop/skills/antislop-human/contrast-check.py +165 -0
  90. package/dist/presets/quality/antislop/skills/antislop-layoutmobile/SKILL.md +170 -0
  91. package/dist/presets/quality/antislop/skills/antislop-ui/SKILL.md +313 -0
  92. package/dist/presets/quality/antislop/skills/antislop-ui/references/motion.md +34 -0
  93. package/dist/presets/quality/antislop/skills/antislop-ui/references/states.md +49 -0
  94. package/package.json +34 -4
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: antislop-human
3
+ description: "Human and accessibility skill for antislop. Contrast, keyboard, focus, and states for real people. Includes the contrast checker."
4
+ allowed-tools: Bash(python *) Bash(python3 *) Read Write Edit Glob Grep
5
+ ---
6
+ # antislop-human
7
+
8
+ > Anti Slop: Rules for AI Coding Agents. Human skill
9
+
10
+ > Part of the antislop system. Read together with the core skill, `antislop` (`.howtocode/skills/antislop/SKILL.md`). This skill deep-dives the human concern: the UI must stay usable by people with different eyes, hands, and setups. Contrast, keyboard, focus, states, and the mobile details that exclude people.
11
+
12
+ ## How to use this skill
13
+
14
+ - Load together with the core skill (`antislop`, `.howtocode/skills/antislop/SKILL.md`) whenever the task builds or edits UI. The core holds the mechanism (the purpose test, the three tiers, the Delivery Gate); this skill holds the human-side depth: the parts of a UI that exclude people with different eyes, hands, and setups.
15
+ - Every entry has the same shape: **Tell** (the pattern), **Why** (who it excludes, and why it reads as unfinished), **Fix** (what to do instead), with the governing core rule cited as R-XX.
16
+ - Accessibility is not a checklist of extras bolted on at the end. It is part of the core promise that "the UI holds up" (C-4). The Delivery Gate in the core remains the gate; the "Human Skill Checklist" at the end of this file is the supplement to run alongside it.
17
+ - The contrast checker (formula + reference table + script) lives in this skill. Use it for every color pairing you cannot verify by eye.
18
+ - This skill keeps only the mobile details that exclude people: zooming, and the on-screen keyboard.
19
+
20
+ ## Color & Contrast
21
+
22
+ ### Low-Contrast Text
23
+
24
+ - **Tell:** light grey text on a white or near-white background, thin body text, muted labels chosen because they look "elegant" but are hard to read.
25
+ - **Why:** it excludes low-vision users and everyone in bright light. It is a visual choice made without checking the standard, which is exactly the kind of default the filter exists to catch.
26
+ - **Fix:** meet WCAG AA minimums (R-25): 4.5:1 for normal text, 3:1 for large text (18px+). Compute the ratio; do not eyeball it.
27
+
28
+ ### Text Over a Photo or Gradient
29
+
30
+ - **Tell:** white text placed directly over an image or gradient that is light in some areas, checked at one bright spot only.
31
+ - **Why:** contrast is local. Where the image is light, the text drops below 4.5:1 even if the hero still "looks" fine. R-25 requires testing the whole area the text passes over, not a single point.
32
+ - **Fix:** add a scrim or a solid color block behind the text, then verify the worst spot, not the best. If any part of the text area fails, the treatment fails.
33
+
34
+ ### The Grey-on-Grey Hallucination
35
+
36
+ - **Tell:** "dark grey on black" or "light grey on white" claimed to pass AA without a computation.
37
+ - **Why:** this is the most common accessibility hallucination. The eye overestimates contrast on grey pairs, and agents repeat the claim because it sounds plausible. #555555 on black is 2.8:1. It fails.
38
+ - **Fix:** never assert a pairing passes. Run the contrast checker (below) or apply the formula. When neither is possible, use the reference table.
39
+
40
+ ### Non-Text Contrast
41
+
42
+ - **Tell:** interactive components (buttons, icons, input borders, focus indicators, chart segments) distinguished from their background by less than 3:1.
43
+ - **Why:** non-text UI carries information by shape and edge. When the edge is a hair of tint, low-vision users cannot find the control. The same bar applies to states like hover and selected.
44
+ - **Fix:** give every component boundary and every status indicator a 3:1 ratio against adjacent colors (WCAG 1.4.11). Pair icons with a text label that meets 4.5:1.
45
+
46
+ ### The Contrast Checker
47
+
48
+ The home of the contrast checker. Three layers, from most to least convenient:
49
+
50
+ **The script.** When a script runtime is available and the file is present, run it instead of computing by hand. The script ships in this skill's folder (`contrast-check.py`, next to this `SKILL.md`). Run it with `python3` on macOS and Linux, `python` on Windows:
51
+
52
+ ```bash
53
+ python3 "${CLAUDE_SKILL_DIR}/contrast-check.py" "#FFFFFF" "#777777"
54
+ # normal text: FAIL (4.48 < 4.5)
55
+ # large text: PASS (4.48 >= 3.0)
56
+ ```
57
+
58
+ If the `${CLAUDE_SKILL_DIR}` variable is not available in this agent, point the script path at this skill's folder directly. The script exists so agents stop hallucinating AA. It takes two hex colors and prints the ratio and the verdict for both text sizes. If the file is missing, the formula and table below are complete on their own. Never block on the script.
59
+
60
+ **The formula (WCAG 2.x).**
61
+
62
+ 1. Contrast ratio = (L1 + 0.05) / (L2 + 0.05), where L1 is the lighter relative luminance and L2 the darker.
63
+ 2. Relative luminance L of one color: convert each channel to 0-1 (`c = hex / 255`), then linearize: if `c <= 0.03928`, `c_lin = c / 12.92`; otherwise `c_lin = ((c + 0.055) / 1.055)^2.4`.
64
+ 3. `L = 0.2126*R + 0.7152*G + 0.0722*B`.
65
+ 4. Round the ratio to two decimals and compare: 4.5:1 for normal text, 3:1 for large text (18px+, per R-25). The maximum ratio is 21.0 (black on white).
66
+
67
+ **The reference table** (common pairings, computed with the formula):
68
+
69
+ | Pairing (text on background) | Ratio | Normal text (4.5) | Large text (3.0) |
70
+ |------------------------------|-------|-------------------|------------------|
71
+ | Black on white | 21.00 | Pass | Pass |
72
+ | White on black | 21.00 | Pass | Pass |
73
+ | White on #333333 | 12.63 | Pass | Pass |
74
+ | White on #666666 | 5.74 | Pass | Pass |
75
+ | #777777 on white | 4.48 | Fail | Pass |
76
+ | White on #888888 | 3.54 | Fail | Pass |
77
+ | White on #999999 | 2.85 | Fail | Fail |
78
+ | #555555 on black | 2.82 | Fail | Fail |
79
+
80
+ Read the table as a sanity check, not as a substitute. Any pairing not listed, or anything near a threshold, goes through the formula or the script.
81
+
82
+ ## Keyboard
83
+
84
+ ### Removed Focus Outline
85
+
86
+ - **Tell:** `outline: none` or `outline: 0` with no replacement focus style.
87
+ - **Why:** keyboard users cannot see where they are. It is the fastest way to make a UI unusable without a mouse, and R-32 forbids it outright.
88
+ - **Fix:** keep or replace the outline with a visible `:focus-visible` style that meets the same contrast bar (3:1 against its neighbors). Never set `outline: none` without a replacement.
89
+
90
+ ### Mouse-Only Patterns
91
+
92
+ - **Tell:** menus that open on hover only, dropdowns that click-open but do not keyboard-open, drag-and-drop with no keyboard fallback.
93
+ - **Why:** each one excludes keyboard and assistive-technology users (R-32). If a control cannot be reached and operated by Tab, Enter, or Space, it does not exist for a whole group of people.
94
+ - **Fix:** every interactive element is reachable and operable by keyboard (R-32): logical tab order following visual order, activation with Enter or Space, and dialogs closable with Escape (R-26).
95
+
96
+ ### Broken Tab Order
97
+
98
+ - **Tell:** focus jumps around the page, skips content, or lands on hidden elements because the DOM order does not match the visual order.
99
+ - **Why:** tab order that reads the code order instead of the visual order makes navigation unpredictable (R-32). Users lose their place and the page feels broken.
100
+ - **Fix:** keep the source order matching the visual order, add skip links for long pages, and never give real content `tabindex="-1"` unless it is part of a controlled focus trap such as a dialog.
101
+
102
+ ## Focus & States
103
+
104
+ ### Weak or Invisible Focus Indicator
105
+
106
+ - **Tell:** a focus ring the same color as the background, a ring that only appears on hover, or an indicator thinner than a 1px border.
107
+ - **Why:** the focus indicator is how keyboard users know where they are. If it fails the contrast bar or only shows on hover, keyboard-only use breaks (R-32, R-34).
108
+ - **Fix:** a visible focus indicator on every interactive element, 3:1 against adjacent colors, in every theme you ship. Check it in dark and light mode.
109
+
110
+ ### Color-Only Feedback
111
+
112
+ - **Tell:** success, error, and status communicated only by color: red error text, green success border, a tinted chip, with no icon, label, or text.
113
+ - **Why:** it excludes color-blind and low-vision users, and it disappears entirely in forced-colors mode. A status that depends on seeing hue is not a status (C-4).
114
+ - **Fix:** pair every color signal with text, an icon, or a pattern. Error states are text first: "Password must be at least 8 characters", not just a red border.
115
+
116
+ ### Missing UI States
117
+
118
+ - **Tell:** a data view with no empty, loading, or error state, or states that exist but are invisible: a spinner with no text, an empty screen with no explanation.
119
+ - **Why:** R-27 requires the three states; the accessibility angle is that each must be perceivable and informative, not decorative. A loading spinner with no context reads as a frozen page to screen-reader users.
120
+ - **Fix:** every data view has all three states (R-27), each announced or visible: an explicit empty message, a loading state with text, and an error state that says what happened and how to proceed.
121
+
122
+ ## Zoom & Mobile Use
123
+
124
+ The layout mechanics behind mobile (breakpoints, scale, grids, overflow, tap targets) are the concern of `antislop-layoutmobile`. This section keeps only the mobile details that exclude people: zooming, and the on-screen keyboard.
125
+
126
+ ### Text That Cannot Zoom
127
+
128
+ - **Tell:** fixed pixel font sizes, or containers with `overflow: hidden` that clip text at 200% zoom.
129
+ - **Why:** users must be able to resize text (WCAG 1.4.4). If zooming to 200% clips the content or forces horizontal scroll, the text is not resizable in practice.
130
+ - **Fix:** fluid type that reflows with zoom, no clipping containers on text, and verify the layout holds at 200% zoom on a narrow viewport (R-35).
131
+
132
+ ### Mobile Keyboard Covers the Form
133
+
134
+ - **Tell:** inputs at the bottom of the viewport hidden behind the on-screen keyboard, with no scroll-into-view and no room for the input.
135
+ - **Why:** a form the user cannot see or reach is a form they cannot complete. It is a mobile-only exclusion (R-03).
136
+ - **Fix:** when an input is focused, it scrolls into view above the keyboard, with enough bottom padding that the focused field is never covered. Test with a real device or an emulated keyboard.
137
+
138
+ ## Human Skill Checklist
139
+
140
+ Run these alongside the core Delivery Gate when the task involves UI. All answers must be **yes**:
141
+
142
+ - [ ] Is every text and background pairing verified against the contrast checker (formula, table, or script), including text over images and gradients? (R-25)
143
+ - [ ] Does every interactive component boundary and status indicator meet 3:1 against its background? (non-text contrast)
144
+ - [ ] Is the focus indicator visible, high-contrast, and present on every interactive element in every theme? (R-32, R-34)
145
+ - [ ] Is every interactive element reachable and operable by keyboard, with dialogs closable via Escape and no `outline: none` without a replacement? (R-32, R-26)
146
+ - [ ] Are the empty, loading, and error states of every data view present and perceivable, not color-only? (R-27, C-4)
147
+ - [ ] Can text be resized to 200% without being clipped, and does the mobile keyboard never cover a focused input? (R-35)
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env python3
2
+ """WCAG 2.x contrast checker, home of the antislop-human contrast checker.
3
+
4
+ Usage:
5
+ python3 contrast-check.py "#FFFFFF" "#777777"
6
+ python3 contrast-check.py FFFFFF 777777
7
+ python3 contrast-check.py --selftest
8
+
9
+ Prints the contrast ratio and a PASS/FAIL verdict for normal text (4.5:1)
10
+ and large text (3:1, 18px+ per antislop R-25). Exit code 0 only when both
11
+ verdicts pass, so scripts can chain on it.
12
+
13
+ --selftest parses the reference table out of the SKILL.md next to this script
14
+ (the skill doc is the source of truth, not a list copied into this script) and
15
+ recomputes every row with the formula, checking the ratio and both verdicts.
16
+ """
17
+
18
+ import os
19
+ import re
20
+ import sys
21
+
22
+ REFERENCE_HEADER = "| Pairing (text on background) | Ratio | Normal text (4.5) | Large text (3.0) |"
23
+ NAMED_COLORS = {"black": (0, 0, 0), "white": (255, 255, 255)}
24
+
25
+
26
+ def parse_hex(value):
27
+ value = value.strip().lstrip("#")
28
+ if len(value) == 3:
29
+ value = "".join(ch * 2 for ch in value)
30
+ if not re.fullmatch(r"[0-9A-Fa-f]{6}", value):
31
+ raise ValueError(f"expected a hex color like #FFFFFF, got {value!r}")
32
+ return tuple(int(value[i:i + 2], 16) for i in (0, 2, 4))
33
+
34
+
35
+ def parse_pairing(pairing):
36
+ """Turn 'White on #333333' or '#555555 on black' into two RGB tuples."""
37
+ colors = []
38
+ for token in re.split(r"\s+on\s+", pairing):
39
+ token = token.strip()
40
+ match = re.search(r"#[0-9A-Fa-f]{3,6}", token)
41
+ if match:
42
+ colors.append(parse_hex(match.group(0)))
43
+ elif token.lower() in NAMED_COLORS:
44
+ colors.append(NAMED_COLORS[token.lower()])
45
+ else:
46
+ raise ValueError(f"cannot parse {token!r} from pairing {pairing!r}")
47
+ if len(colors) != 2:
48
+ raise ValueError(f"expected two colors in pairing {pairing!r}")
49
+ return tuple(colors)
50
+
51
+
52
+ def linearize(channel):
53
+ c = channel / 255.0
54
+ if c <= 0.03928:
55
+ return c / 12.92
56
+ return ((c + 0.055) / 1.055) ** 2.4
57
+
58
+
59
+ def luminance(rgb):
60
+ r, g, b = (linearize(ch) for ch in rgb)
61
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b
62
+
63
+
64
+ def contrast_ratio(color_a, color_b):
65
+ lum_a, lum_b = luminance(color_a), luminance(color_b)
66
+ lighter, darker = sorted((lum_a, lum_b), reverse=True)
67
+ return (lighter + 0.05) / (darker + 0.05)
68
+
69
+
70
+ def reference_doc_path():
71
+ here = os.path.dirname(os.path.abspath(__file__))
72
+ candidate = os.path.join(here, "SKILL.md")
73
+ return candidate if os.path.isfile(candidate) else None
74
+
75
+
76
+ def parse_reference_rows(path):
77
+ """Reference table rows from SKILL.md, with the ratio already a float.
78
+
79
+ A row that does not split into four cells is dropped silently, not raised.
80
+ """
81
+ rows = []
82
+ with open(path, encoding="utf-8") as handle:
83
+ in_table = False
84
+ for raw in handle:
85
+ line = raw.rstrip("\n")
86
+ if line.startswith(REFERENCE_HEADER):
87
+ in_table = True
88
+ continue
89
+ if not in_table:
90
+ continue
91
+ if not line.startswith("|"):
92
+ break
93
+ if line.startswith("|---"):
94
+ continue
95
+ cells = [cell.strip() for cell in line.strip().strip("|").split("|")]
96
+ if len(cells) != 4:
97
+ continue
98
+ pairing, ratio, normal, large = cells
99
+ rows.append({
100
+ "pairing": pairing,
101
+ "ratio": float(ratio),
102
+ "normal": normal,
103
+ "large": large,
104
+ })
105
+ return rows
106
+
107
+
108
+ def selftest():
109
+ doc = reference_doc_path()
110
+ if doc is None:
111
+ print("selftest: SKILL.md not found next to the script; cannot check the table")
112
+ return 2
113
+ try:
114
+ rows = parse_reference_rows(doc)
115
+ except (OSError, ValueError) as exc:
116
+ print(f"selftest: could not read the table from SKILL.md: {exc}")
117
+ return 1
118
+ if not rows:
119
+ print("selftest: no reference rows found in SKILL.md")
120
+ return 1
121
+
122
+ failures = 0
123
+ for row in rows:
124
+ color_a, color_b = parse_pairing(row["pairing"])
125
+ computed = round(contrast_ratio(color_a, color_b), 2)
126
+ expected_normal = "Pass" if computed >= 4.5 else "Fail"
127
+ expected_large = "Pass" if computed >= 3.0 else "Fail"
128
+ if f"{computed:.2f}" != f"{row['ratio']:.2f}":
129
+ failures += 1
130
+ print(f"selftest: {row['pairing']}: table says {row['ratio']}, the formula says {computed:.2f}")
131
+ if row["normal"] != expected_normal:
132
+ failures += 1
133
+ print(f"selftest: {row['pairing']}: normal text marked {row['normal']}, should be {expected_normal}")
134
+ if row["large"] != expected_large:
135
+ failures += 1
136
+ print(f"selftest: {row['pairing']}: large text marked {row['large']}, should be {expected_large}")
137
+
138
+ if failures:
139
+ return 1
140
+ print(f"selftest: {len(rows)} reference pairs OK")
141
+ return 0
142
+
143
+
144
+ def main(argv):
145
+ if len(argv) == 1 and argv[0] == "--selftest":
146
+ return selftest()
147
+ if len(argv) != 2:
148
+ print("usage: python3 contrast-check.py <hex1> <hex2> | --selftest")
149
+ return 2
150
+ try:
151
+ ratio = contrast_ratio(parse_hex(argv[0]), parse_hex(argv[1]))
152
+ except ValueError as exc:
153
+ print(f"error: {exc}")
154
+ return 2
155
+
156
+ normal = ratio >= 4.5
157
+ large = ratio >= 3.0
158
+ print(f"ratio: {ratio:.2f}:1")
159
+ print(f"normal text (4.5:1): {'PASS' if normal else 'FAIL'}")
160
+ print(f"large text (3.0:1): {'PASS' if large else 'FAIL'}")
161
+ return 0 if normal and large else 1
162
+
163
+
164
+ if __name__ == "__main__":
165
+ sys.exit(main(sys.argv[1:]))
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: antislop-layoutmobile
3
+ description: "Mobile layout skill for antislop. Use for layouts that reflow across screen sizes, phone to desktop: grids, overflow, tap targets. Load with the core."
4
+ allowed-tools: Read Write Edit Glob Grep
5
+ ---
6
+ # antislop-layoutmobile
7
+
8
+ > Anti Slop: Rules for AI Coding Agents. Mobile Layout skill
9
+
10
+ > Part of the antislop system. Read together with the core skill, `antislop` (`.howtocode/skills/antislop/SKILL.md`). This skill deep-dives the responsive layout concern: how a layout must reflow across screen sizes, phone to desktop. Breakpoints, scale, grids, overflow, tap targets, and navigation. It references core rules by number and never duplicates or renumbers them. Load it when the task builds or edits a layout that has to hold up at any screen width.
11
+
12
+ ## How to use this skill
13
+
14
+ - Load together with the core skill (`antislop`, `.howtocode/skills/antislop/SKILL.md`) whenever the task is mobile or responsive layout work. The core holds the mechanism (the purpose test, the three tiers, the Delivery Gate); this skill holds mobile-layout depth.
15
+ - Every entry has the same shape: **Tell** (the pattern), **Why** (why it reads as slop), **Fix** (what to do instead), with the governing core rule cited as R-XX.
16
+ - The principle behind this skill: **mobile layout is a different layout, not the desktop layout at a smaller size.** It must reflow: re-stack, rescale, and re-order with intent. Every pattern below is a way a layout fails to reflow.
17
+ - The Delivery Gate in the core remains the gate. The "Layoutmobile Skill Checklist" at the end of this file is the mobile-specific supplement to run alongside it.
18
+
19
+ ## Breakpoints
20
+
21
+ ### Desktop-Only Layout
22
+
23
+ - **Tell:** one layout state for every screen; the mobile view is the desktop layout squeezed into a phone.
24
+ - **Why:** R-03 requires a mobile layout that is perfect, not an afterthought. A page that only shrinks has no mobile design at all: cards that worked side by side overlap, and text meant for a wide canvas crowds into a narrow one.
25
+ - **Fix:** define a real mobile state at the breakpoint where the content stops working. The mobile layout reflows: columns stack, sizes drop, and order changes where the content needs it. If the mobile view is just the desktop view at a smaller width, the layout is not done.
26
+
27
+ ### Breakpoint Driven by Device List
28
+
29
+ - **Tell:** breakpoints named after phone widths (375px, 414px, 768px) chosen because "that is the iPhone size", not because the content breaks there.
30
+ - **Why:** device widths change every year and every model. A breakpoint is a point where the layout stops holding; forcing it to match a device list makes the layout follow a spec sheet instead of the content (R-03).
31
+ - **Fix:** place breakpoints where the content actually breaks: when a column stops being readable, when a row of cards gets too narrow. Test by narrowing the viewport and watching where it snaps, then set the breakpoint there.
32
+
33
+ ### Mobile Styled Last
34
+
35
+ - **Tell:** mobile rules bolted on as a trailing override: a long desktop stylesheet with a small media query at the end fixing one or two things.
36
+ - **Why:** an override patch is not a mobile design. It fixes the symptom that got reported and leaves the next one, and the base styles stay tuned for a wide screen (R-03).
37
+ - **Fix:** treat mobile as a designed state, not an override. Give the narrow viewport its own deliberate sizes and stacking, and verify the whole layout there, not just the patched spots (R-35).
38
+
39
+ ### Two-State Layout
40
+
41
+ - **Tell:** a layout with exactly two states: a single stacked column below one breakpoint, and a wide multi-column grid above it, with nothing defined in between. A tablet or small laptop width then inherits whichever state is closest: the phone stack stretched absurdly wide, or the desktop grid crammed into a fraction of its intended canvas.
42
+ - **Why:** a page is a continuous range of widths, and R-03 demands it hold up at every one of them, not just two chosen breakpoints. Two states leave the whole middle band of the range (roughly 600 to 1024 px, where tablets and small laptops live) as an accident: content that neither stacks with intent nor sits in a grid that fits. The layout reads as designed only at its two sample points and broken everywhere between.
43
+ - **Fix:** define real states at the widths where the content stops working, and let them be as many as the content needs. A typical reflow is three states, not two: single column, then a two-column grid when cards get too wide as a single stack, then the full multi-column grid only when it genuinely fits. Verify by dragging the viewport through the whole range, not by checking two widths and calling it done (R-35).
44
+
45
+ ## Scale & Sizing
46
+
47
+ ### Desktop-Sized Everything
48
+
49
+ - **Tell:** padding, gaps, hero heights, and card sizes carried unchanged from desktop to mobile, so every section looks blown up on a phone.
50
+ - **Why:** an element sized for a 1440px canvas dominates a 375px one. What reads as confident on desktop becomes oversized on mobile: nothing fits, nothing breathes, and the page feels like it was designed for a screen that is not the one in hand (R-03). Spacing and type should follow the design rhythm (R-05), and that rhythm has a smaller register on mobile.
51
+ - **Fix:** give mobile its own size step: a smaller type scale, tighter section padding, smaller gaps. Keep tap targets at their minimum size (see Tap Targets), but shrink everything else with intent at the breakpoint.
52
+
53
+ ### Fixed Pixel Type
54
+
55
+ - **Tell:** font sizes in fixed px that never change between desktop and mobile, so headings and body text stay oversized on a phone.
56
+ - **Why:** type that does not respond to the viewport is type sized for one screen. R-03 demands the mobile layout hold up, and R-06 requires typography that improves readability. A headline that spans the whole phone width or a body size tuned for a wide line breaks both.
57
+ - **Fix:** use fluid type (`clamp()`) so sizes scale with the viewport, or set a smaller type step at the breakpoint. Verify the result at a narrow width (R-35), not just in the desktop preview.
58
+
59
+ ### 100vh Sections
60
+
61
+ - **Tell:** hero and section heights set to `100vh`, so a section fills the whole phone screen and pushes everything else below the fold.
62
+ - **Why:** a full-viewport section designed for a desktop monitor becomes a giant slab on a phone, and `100vh` includes the browser chrome, so it overflows the visible area on mobile browsers. It dominates the layout instead of introducing it (R-03).
63
+ - **Fix:** let sections size to their content (`auto`), or use the dynamic viewport unit (`dvh`) where a real full-height section is intended. Nothing below the fold should be an accident of viewport units.
64
+
65
+ ### Huge Empty Padding
66
+
67
+ - **Tell:** desktop-scale section padding (96px, 128px) kept on mobile, creating tall empty gaps between sections on a phone.
68
+ - **Why:** padding tuned for a large canvas turns into wasted vertical space on a small one. The page scrolls through emptiness, and the rhythm R-05 calls for becomes a void between every section.
69
+ - **Fix:** reduce section padding at the breakpoint to a mobile register (roughly half or less), and check that the page scrolls at a natural density instead of through deserts of space.
70
+
71
+ ## Grids & Stacking
72
+
73
+ ### Columns That Don't Collapse
74
+
75
+ - **Tell:** a multi-column grid keeps its side-by-side columns on mobile, so the columns shrink, the text wraps awkwardly, and elements collide.
76
+ - **Why:** a grid is a promise about how much width is available. When the viewport narrows and the grid does not re-stack, every column gets a sliver, text becomes unreadable, and cards overlap (R-03). This is the collision failure: desktop's side-by-side becomes mobile's pileup.
77
+ - **Fix:** collapse the grid to a single reflowing column at the breakpoint. Side-by-side becomes stacked, and each item gets the full width again. Re-verify at a narrow width (R-35).
78
+
79
+ ### Fixed-Width Grid
80
+
81
+ - **Tell:** `grid-template-columns` set in fixed px, or grid areas that cannot reflow, so the grid stays rigid when the viewport shrinks.
82
+ - **Why:** a fixed-px track does not care about the viewport; it keeps its width and forces overflow or collision. The layout was built for one canvas and cannot change shape (R-03).
83
+ - **Fix:** size tracks with `minmax()` or `auto-fit` and `auto-fill` so columns shrink and wrap with the content, and define grid areas that collapse at the breakpoint. The grid should be fluid by default, rigid only where a fixed size is deliberate.
84
+
85
+ ### Forced 12-Column
86
+
87
+ - **Tell:** a 12-column grid forced onto mobile content that needs one or two columns, so spans look arbitrary and the math fights the layout.
88
+ - **Why:** a 12-column system is for a wide canvas with many columns of content. Forcing it on a phone makes every element a fraction of an invisible grid the user never sees, and the content gets fitted to the grid instead of the grid to the content (R-03).
89
+ - **Fix:** let columns follow the content. On mobile the content usually wants one column, or two at most; the 12-column span only makes sense where the layout genuinely has that many things side by side.
90
+
91
+ ## Overflow
92
+
93
+ ### Horizontal Scroll Leak
94
+
95
+ - **Tell:** the page scrolls sideways because some element is wider than the viewport: a table, a code block, an image, a long unbroken string.
96
+ - **Why:** horizontal scrolling is a broken promise on mobile. The user cannot see where the page ends, and the layout visibly spills off the screen (R-03). It is the most common overflow slop because the offender is off-screen in the desktop preview and goes unnoticed until a phone opens it.
97
+ - **Fix:** find the element wider than the viewport (a table that needs a reflow layout or a scroll container, a code block that wraps, images with `max-width: 100%`), then contain or reflow it. Verify the whole page has zero horizontal scroll at the narrowest target (R-35).
98
+
99
+ ### Overflow Hidden Clipping
100
+
101
+ - **Tell:** `overflow: hidden` on a container that clips content at narrow widths, hiding text or controls instead of letting them fit.
102
+ - **Why:** clipping is hiding a failure. When a container cuts off its content because the layout cannot fit it, the user loses information and interaction (R-03). The zoom and text-resize angle on this is covered by `antislop-human`.
103
+ - **Fix:** let the content reflow instead of clipping: allow the container to grow, wrap its content, or collapse it at the breakpoint. Clip only where cropping is the design intent (like a thumbnail), never where it hides content.
104
+
105
+ ### Fixed-Width Children
106
+
107
+ - **Tell:** flex or grid children with a fixed px width or `min-width` that burst out of their parent on a narrow screen.
108
+ - **Why:** a child sized in absolute px does not care how much room its parent has. On mobile the parent shrinks and the child stays wide, so it overflows the container and the page (R-03).
109
+ - **Fix:** size children with relative units and let them wrap (`flex-wrap`, fluid widths, `min-width: 0` on grid children). A child should be allowed to shrink with its container, not hold a desktop size.
110
+
111
+ ## Tap Targets
112
+
113
+ ### Under-Sized Targets
114
+
115
+ - **Tell:** buttons, links, and controls smaller than about 44 x 44 px, easy to hit on desktop with a cursor but hard to hit with a thumb.
116
+ - **Why:** a desktop cursor has pixel accuracy; a thumb does not. A target that is fine at 16px becomes an exercise in frustration on a phone, and it fails the promise that the UI is usable on mobile (R-03).
117
+ - **Fix:** give interactive targets a minimum touch area of 44 x 44 px, using padding or a larger hit box even when the visual is smaller. Verify the whole set of controls at a phone width (R-35).
118
+
119
+ ### Targets Too Close
120
+
121
+ - **Tell:** 44px targets packed together with no gap, so a thumb tap hits the wrong one.
122
+ - **Why:** target size matters only with target spacing. Two large controls touching each other behave like one large control: the user cannot reliably pick either (R-03).
123
+ - **Fix:** leave a clear gap between adjacent interactive targets, at least a few px and ideally enough that the finger press area does not overlap. Spacing is the other half of tappability.
124
+
125
+ ### Hover-Only Interactions
126
+
127
+ - **Tell:** menus, reveals, and tooltips that exist only on hover, so a touch user can never open them.
128
+ - **Why:** there is no hover on a touchscreen. An interaction that only responds to hover simply does not exist for mobile users, and any control that relies on it is a dead end (R-03).
129
+ - **Fix:** give every hover-only interaction a tap equivalent: a menu that opens on hover also opens on tap, a reveal also shows on click, and interactive elements show visible `:active` feedback so a tap registers. Test by using the UI with touch alone (R-35).
130
+
131
+ ## Mobile Navigation
132
+
133
+ ### Nav That Stays Desktop
134
+
135
+ - **Tell:** the desktop top bar with its row of links kept side by side on mobile, so the links crowd, wrap into two rows, or spill past the viewport.
136
+ - **Why:** a desktop nav is sized for a wide canvas. Kept as a row on a phone it becomes a mess of cramped links, and it is the first thing a mobile user meets (R-03). Navigation is where reflow matters most: the user has to find where to go before they can go anywhere.
137
+ - **Fix:** collapse the nav into a mobile pattern at the breakpoint: a bottom nav for the handful of primary destinations, or a menu for the rest. The links reflow out of the row, and the primary destinations stay one thumb tap away. Verify it holds at a narrow width (R-35).
138
+
139
+ ### The Bare Hamburger
140
+
141
+ - **Tell:** everything hidden behind a hamburger icon with no label and no hint, so a user never realizes the menu exists or cannot tell what it opens.
142
+ - **Why:** a bare hamburger assumes the user already knows what the icon means and that a menu hides behind it. That is knowledge the mobile user may not have, and on mobile the hidden menu can hold the only way around the app (R-03).
143
+ - **Fix:** keep the menu discoverable: label the hamburger ("Menu"), or keep the primary destinations visible and hide only the secondary ones. If a menu is the only way to reach something important, that reachability has to be obvious.
144
+
145
+ ### Bottom Nav That Eats Content
146
+
147
+ - **Tell:** a fixed bottom nav bar that sits over the content, covering the last list items, the final button, or the form the user was trying to finish.
148
+ - **Why:** a fixed bar takes real space on a small screen. If nothing reserves that space, the content scrolls under it and the user cannot reach what is hidden, especially at the very bottom of the page (R-03).
149
+ - **Fix:** reserve the bar's height for the content: scroll padding on the page and safe-area insets where the device needs them, so nothing important is ever hidden behind it. Verify at a narrow width that the last item is reachable (R-35).
150
+
151
+ ### Sticky Nav Steals the Screen
152
+
153
+ - **Tell:** a sticky header or tall bottom bar that holds a large fixed height, so a big slice of the phone screen is always taken by navigation.
154
+ - **Why:** on a small viewport every fixed pixel of chrome is a pixel of content lost. A tall sticky header turns the visible area into a letterbox and the content into a sliver (R-03).
155
+ - **Fix:** keep fixed nav compact: small enough that the content stays dominant, and collapse or shrink it on scroll where appropriate. Navigation should be present, not the main occupant of the screen.
156
+
157
+ ## Layoutmobile Skill Checklist
158
+
159
+ Run these alongside the core Delivery Gate when the task is mobile or responsive layout work. All answers must be **yes**:
160
+
161
+ - [ ] Does the layout reflow into a distinct mobile state rather than a squeezed desktop? (R-03)
162
+ - [ ] Are there defined states across the width range, not just phone and desktop, so tablet and small-laptop widths are never a stretched stack or a crammed grid? (R-03, R-35)
163
+ - [ ] Do sizes (type, padding, gaps, section heights) use a mobile scale, not desktop sizes unchanged? (R-03, R-05)
164
+ - [ ] Do multi-column grids collapse and stack instead of colliding? (R-03)
165
+ - [ ] Is there no horizontal overflow and nothing clipped? (R-03)
166
+ - [ ] Are interactive targets at least 44 x 44 px with spacing between them? (R-03)
167
+ - [ ] Do hover-only interactions have a tap equivalent with visible feedback? (R-03)
168
+ - [ ] Does the navigation reflow into a mobile pattern (bottom nav or menu) instead of a squeezed desktop row? (R-03)
169
+ - [ ] Do fixed nav bars (bottom nav, sticky headers) never cover content and respect safe areas? (R-03)
170
+ - [ ] Is the layout verified at mobile breakpoints? (R-35)