2001105254-netizen/RacePulsePH / .agents/skills/antislop-human
antislop-human
VerifiedHuman and accessibility skill for antislop. Contrast, keyboard, focus, states, and interaction affordances for real people. Includes the contrast checker.
| File | Kind | Size |
|---|---|---|
| LICENSE-web-quality-skills | other | 1.0 KB |
| SKILL.md | skill md | 15.5 KB |
| contrast-check.py | script | 5.6 KB |
| contrast-mcp.py | script | 4.0 KB |
| references/A11Y-PATTERNS.md | markdown | 7.0 KB |
| references/WCAG.md | markdown | 8.0 KB |
contrast-mcp.py
View on GitHub#!/usr/bin/env python3
"""Minimal MCP stdio server exposing the antislop contrast checker as a tool.
All logging goes to stderr; stdout is reserved for JSON-RPC responses.
"""
import json
import re
import sys
PROTOCOL_VERSION = "2024-11-05"
SERVER_NAME = "antislop-contrast"
SERVER_VERSION = "3.2.27"
TOOLS = [
{
"name": "check_contrast",
"description": "Compute the WCAG contrast ratio between two hex colors and the pass or fail verdict for normal and large text. Use this instead of guessing whether a color pairing meets AA.",
"inputSchema": {
"type": "object",
"properties": {
"foreground": {"type": "string", "description": "Hex color of the text, for example #777777"},
"background": {"type": "string", "description": "Hex color of the background, for example #FFFFFF"},
},
"required": ["foreground", "background"],
},
}
]
def _channel(c):
c = c / 255.0
return c / 12.92 if c <= 0.03928 else ((c + 0.055) / 1.055) ** 2.4
def relative_luminance(hex_color):
h = hex_color.strip().lstrip("#")
if len(h) == 3:
h = "".join(ch * 2 for ch in h)
# Slicing reads any length, so #00000080 would pass as opaque black. Same check as contrast-check.py.
if not re.fullmatch(r"[0-9A-Fa-f]{6}", h):
raise ValueError(f"expected a hex color like #FFFFFF, got {hex_color!r}")
r, g, b = (int(h[i : i + 2], 16) for i in (0, 2, 4))
return 0.2126 * _channel(r) + 0.7152 * _channel(g) + 0.0722 * _channel(b)
def contrast_ratio(fg, bg):
"""The unrounded WCAG ratio. Callers decide what to print, never what to compare."""
l1, l2 = relative_luminance(fg), relative_luminance(bg)
lighter, darker = max(l1, l2), min(l1, l2)
return (lighter + 0.05) / (darker + 0.05)
def check_contrast(fg, bg):
# The threshold is read from the raw ratio: 4.498:1 fails 4.5:1 even though it
# displays as 4.50 once rounded, and a rounded verdict would report the opposite.
ratio = contrast_ratio(fg, bg)
return {
"foreground": fg,
"background": bg,
"ratio": round(ratio, 2),
"normal_text": {"threshold": 4.5, "pass": ratio >= 4.5},
"large_text": {"threshold": 3.0, "pass": ratio >= 3.0},
}
def _send(msg):
sys.stdout.write(json.dumps(msg) + "\n")
sys.stdout.flush()
def _text(content):
return {"content": [{"type": "text", "text": content}], "isError": False}
def _error(message):
return {"content": [{"type": "text", "text": message}], "isError": True}
def _reply(msg_id, result):
_send({"jsonrpc": "2.0", "id": msg_id, "result": result})
def main():
for line in sys.stdin:
line = line.strip()
if not line:
continue
try:
msg = json.loads(line)
except json.JSONDecodeError:
continue
msg_id = msg.get("id")
method = msg.get("method")
if method == "initialize":
_reply(msg_id, {
"protocolVersion": PROTOCOL_VERSION,
"capabilities": {"tools": {}},
"serverInfo": {"name": SERVER_NAME, "version": SERVER_VERSION},
})
elif method == "notifications/initialized":
pass
elif method == "ping":
_reply(msg_id, {})
elif method == "tools/list":
_reply(msg_id, {"tools": TOOLS})
elif method == "tools/call":
params = msg.get("params") or {}
name = params.get("name")
args = params.get("arguments") or {}
if name == "check_contrast":
try:
result = check_contrast(args["foreground"], args["background"])
_reply(msg_id, _text(json.dumps(result)))
except Exception as exc:
_reply(msg_id, _error("check_contrast failed: " + str(exc)))
else:
_reply(msg_id, _error("Unknown tool: " + str(name)))
elif msg_id is not None:
_reply(msg_id, {})
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |