agentleFS
bestdeejay-designbestdeejay-design/agent-skills/skills/frontend-perfection/SKILL.md

frontend-perfection

Skill6 starsChanged 3 months agoMITView on GitHub

Audit and polish frontend (static HTML/CSS/JS or built SPA) to measurable perfection: real-Chrome Lighthouse >=13 runs (mobile+desktop, no Playwright internals), SEO meta layer, WCAG contrast by computed luminance, heading order, a11y checks (axe-core subset), back-to-top navigation, design tokens (zero raw hex), adaptive checks, OG-image generation, plus Security/Privacy/i18n static coverage (HTTPS/mixed content, CSP, SRI, security headers, noopener, secrets-in-URL, cookie consent, i18n lang/dir/Intl). Front-End Checklist-inspired. Triggers: 'frontend audit', 'perfect the layout', 'lighthouse check', 'make it 100/100/100/100', 'audit the page', 'fix performance', 'contrast check', 'design tokens', 'og image', 'security headers', 'privacy', 'https', 'mixed content', 'CSP', 'SRI', 'i18n', 'internationalization', 'social share meta'.

  • Reads credentials
  • Installs packages

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 0 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Serve it locally: if needed: python3 -m http.server 8377 (or the project's dev server).

    line 38
  2. Very specific:

    Default threshold is 100; exit 0 only when every measured category is at or above it.

    line 45
  3. Very specific:

    Do NOT re-implement those domains here — this skill owns layout/perf-SEO/tokens + the Security/Privacy/i18n static subset above.

    line 203
  4. Very specific:

    Every hex color must be declared once in the token block (a :root { --color-*: ....

    line 212
  5. Very specific:

    If position: fixed header exists, anchor jumps hide content underneath.

    line 242
  6. Very specific:

    Do NOT fix with !important spray or target 100 by hiding audits: raise the underlying metrics (real fix at the root).

    line 252
  7. Very specific:

    Do NOT delete or modify user tests/screenshots.

    line 254
  8. Very specific:

    Do not use for a narrow a11y or performance audit.

    line 280

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

frontend-perfection

Audit and polish a frontend — static HTML/CSS/JS or a built SPA — towards verifiable perfection. The skill exists because production web perf tooling commonly breaks when it pokes at private APIs (Playwright internals, old Lighthouse signatures, unisolated global deps). This skill runs on STABLE apis only, computes exactly (luminance, not eyeballs), and demands a before/after report bound to audit ids.

When to use

  • User asks to "make the layout perfect", "fix performance", "reach 100/100/100/100", "check the frontend", "audit the page".
  • User wants an OG image or social share meta for a homepage.
  • User reports contrast problems, missing SEO tags, broken anchors under a fixed header, colors duplicated as raw hex.

Composition

  • For Core Web Vitals / schema.org / SEO deep-dives — load seo-toolkit (this skill measures layout, contrast, tokens and a11y; the SEO-layer breadth lives there).
  • For a distinctive visual DIRECTION before building — load frontend-design-taste (palette/type/signature), then run this skill to verify the result.

Workflow

  1. Locate the project — static files (index.html + css/) or built SPA.
  2. Serve it locally if needed: python3 -m http.server 8377 (or the project's dev server). Static files are fine over http://localhost.
  3. Run audit.js (Lighthouse, real Chrome):
    node scripts/audit.js --url http://localhost:8377/ --mobile --out lh-mobile.json
    node scripts/audit.js --url http://localhost:8377/ --desktop --out lh-desktop.json
    Default threshold is 100; exit 0 only when every measured category is at or above it. Add --only <category> to iterate on one category.
  4. Run meta_audit.py (SEO/contrast/headings/tokens, offline):
    python3 scripts/meta_audit.py --html index.html --css main.css css/demo.css --out meta.json
    Exit 0 = no violations; exit 1 = violations found.
  • Run security_privacy_audit.py (Security/Privacy/i18n, offline) — see the section below. Exit 0 = no violations; exit 1 = violations found.
  1. Fix by audit id — every fix must reference the audit it closes (e.g. audit.js color-contrast, meta_audit.py meta:description).
  2. Re-audit until green on both form factors. Only then call it done.
  3. Write the before/after report in the showcase format: input paths, exact commands, real output, interpretation. Explicitly list what was deliberately NOT done.

audit.js — Lighthouse runner (stable API)

  • Real Chrome via chrome-launcher (default channel = installed Chrome; --no-headless to watch). No Playwright dependency, no private fields, no _ws_url transport hacks. CDP port comes from chrome.port (public).
  • Lighthouse >= 13 support: module may export a namespace; the script falls back to require("lighthouse").default automatically.
  • Dependency isolation: modules resolve local node_modules → NODE_PATH → npm root -g. The script explains how to install instead of dying with Cannot find module:
    npm i lighthouse chrome-launcher     # in the script's dir
    # or globally:
    npm i -g lighthouse chrome-launcher && export NODE_PATH=$(npm root -g)
  • Output: compact JSON (--out) with per-category scores and only the failed weighted audits (id, title, score, weight) — no 4000-line dump.
  • Exit codes: 0 all categories ≥ threshold, 1 below threshold, 2 runner error.

meta_audit.py — static audit (Python stdlib, offline)

Checks and their ids:

idwhat it verifies
meta:title / meta:title-lengthtitle present, ≤ 60 chars
meta:description / meta:description-lengthdescription present, ≤ 160 chars
meta:canonicalcanonical link
meta:og:*, meta:og:sizeOG tags; image must declare 1200×630 (crop-safe)
meta:twitter:cardtwitter card tag
meta:json-ldany application/ld+json script
meta:robotsnot blocked with noindex/nofollow
meta:sitemap-linksitemap referenced
headings:single-h1exactly one h1
headings:orderh1→h6 sequence, no level skips (h1→h3 is a violation)
tokens:raw-hexzero raw hex outside the token block (:root/tokens)
contrast:wcag-aacomputed WCAG relative luminance, fg/bg pairs ≥ 4.5:1
adaptive:scroll-paddingfixed header ⇒ scroll-padding-top present
adaptive:media-queriesresponsive breakpoints exist for tablet widths
a11y:img-altevery <img> has an alt attribute (decorative may be empty) — WCAG 1.1.1 / axe image-alt
a11y:button-name / a11y:link-namebuttons and links have an accessible name (text or aria-label) — WCAG 4.1.2 / axe button-name, link-name
a11y:form-labelinputs/selects/textareas have a label (<label for>, wrapper, aria-label) — WCAG 4.1.2 / axe label
a11y:aria-validevery aria-* attribute name is in the WAI-ARIA 1.2 set — axe aria-valid-attr
a11y:landmark-uniqueat most one <main>; multiple <nav> need distinct labels — WCAG 1.3.1 / axe landmark-unique
html:doctypeHTML5 doctype on the first line
html:charsetcharset declared as utf-8
html:viewportresponsive viewport meta present
html:lang<html lang> with a BCP 47 code (a11y + SEO)
html:dir-rtlRTL languages (ar/he/fa/ur/yi) require dir="rtl"
html:unique-idno duplicate id attributes
html:semanticsemantic elements used: header, main, footer
html:faviconsfavicon link present
html:web-app-manifestmanifest.json referenced (PWA)
html:sriCDN-hosted scripts carry integrity (SRI); local scripts exempt
html:defer-asyncexternal scripts load with defer/async/type=module (no render-blocking)
html:input-typesinputs declare a type (not defaulting to text)
images:dimensionsimg has width/height (CLS prevention)
images:lazy-loading3+ images lazy-load offscreen content
images:srcsetresponsive srcset used for fixed-size images
images:modern-formatraster jpg/png converted to webp/avif
js:no-inlineno inline handlers (onclick=…) or inline <script> blocks
js:no-consoleno console.log/debug/warn in HTML
css:focus-visiblevisible :focus-visible indicator for keyboard users
css:print@media print stylesheet exists
css:dark-modeprefers-color-scheme dark mode supported
css:font-displaywebfonts use font-display: swap (no FOIT)
perf:resource-hintspreload/preconnect/dns-prefetch hints for critical origins (LCP)
security:httpsno http:// URLs in src/href
security:noopenertarget="_blank" links carry rel="noopener"
privacy:consentcookie/consent mention present (GDPR / 152-ФЗ)
nav:back-to-toplong pages have a way back to top — logo links to top and/or a floating scroll-to-top button (bottom-right, aria-label, appears after scroll) — WCAG 2.4.1 / UX pattern

Security, Privacy & i18n (static, offline)

scripts/security_privacy_audit.py extends the skill with the Front-End-Checklist Security (22), Privacy (5) and Internationalization (5) categories — the statically verifiable subset. It is pure Python 3 stdlib (no requests/bs4/ PyYAML), mirrors meta_audit.py's JSON/exit-code conventions, and emits audit ids prefixed sec: / priv: / i18n:. It does NOT duplicate the dedicated sibling skills' a11y/perf/testing checks — only Security/Privacy/i18n.

python3 scripts/security_privacy_audit.py --html index.html --css main.css --js app.js --out sec.json
python3 scripts/security_privacy_audit.py --html a.html b.html --json   # stdout JSON

Exit 0 = no violations; 1 = ≥1 violation; 2 = runner error. The report is machine-readable JSON only on stdout (no human summary) — evidence gate.

idseveritywhat it verifies
sec:httpshighno http:// URLs in href/src (HTTPS everywhere)
sec:mixed-contenthighno http:// in CSS url()/@import/srcset (mixed content)
sec:cspmediumContent-Security-Policy present (meta or server header) — OWASP A05
sec:srihighexternal <script>/<link> carry integrity (SRI)
sec:security-headerslowHSTS/XCTO/XFO/Referrer-Policy/Permissions-Policy (meta; server-side canonical)
sec:noopenerhightarget="_blank" carries rel="noopener noreferrer"
sec:secrets-in-urlcriticalno tokens/keys in query strings (token=/api_key=/secret=)
sec:localstorage-secretsmediumno secret keys in localStorage/sessionStorage
sec:csrfmediumstate-changing (POST) forms carry a CSRF token
sec:evalhighno eval()/new Function() in JS
sec:deprecated-cryptomediumno md5/sha1 in security context
sec:external-originslowexternal script origins enumerated (info)
sec:internal-leakmediumno internal IPs / .env references leaked
sec:cookie-flagslowdocument.cookie assignments use Secure
priv:cookie-consentmediumcookie/consent banner before non-essential tracking (GDPR / 152-ФЗ)
priv:tracking-before-consentmediumno tracking scripts (GA/GTM/fbq/Metrika) before consent
priv:privacy-policylowprivacy policy link present
priv:dntlowDo Not Track / Global Privacy Control respected (info/manual)
priv:third-party-datalowno PII sent to third parties without consent (info)
i18n:langmedium<html lang> present, valid BCP 47
i18n:dirmediumRTL languages (ar/he/fa/ur/yi) set dir="rtl"
i18n:intl-apilowIntl.NumberFormat/DateTimeFormat used for formatting (info)
i18n:charset-earlymedium<meta charset> within first 1024 bytes
i18n:hardcoded-localelowno hardcoded locale-specific strings (info)

Static subset only — runtime/header checks are manual

security_privacy_audit.py covers the static surface. The following require a live server or manual review and are NOT asserted by the script:

  • Real HTTP response headers (Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy, CSP as a header) — verify with frontend-performance's perf_headers.py (perf:sec:* / perf:hsts) or curl -I.
  • Live cookie flags (Secure/HttpOnly/SameSite on Set-Cookie) — inspect response headers.
  • CSP violation reporting, real mixed-content in dev proxies, screen-reader/locale correctness.

Routing to dedicated skills

For depth beyond this skill's baseline, delegate to the dedicated sibling skills (same skills/ dir):

  • Deep accessibility (95 rules: tables, landmarks, ARIA values, focus traps, runtime contrast, screen-reader) → frontend-a11y static + a11y_axe.mjs runtime).
  • Deep performance (network/headers, Core Web Vitals, bundle size, HTTP/2, caching, service worker) → frontend-performance (perf_headers.py offline + audit.js Lighthouse).
  • E2E / visual / contract / a11y-in-CI testing (Playwright, jest-axe, Pact, perf-budget CI) → frontend-testing (scaffolds configs; does not re-audit).

Do NOT re-implement those domains here — this skill owns layout/perf-SEO/tokens + the Security/Privacy/i18n static subset above; the siblings own their full categories.

Design tokens — "colors as constants"

For static projects WITHOUT a build system (plain HTML/CSS/JS), a minimal design system still applies:

  • Every hex color must be declared once in the token block (a :root { --color-*: ...; } layer or a dedicated tokens.css).
  • Zero raw hex anywhere else — components reference var(--color-*).
  • meta_audit.py flags any raw hex outside the token block; this is the enforceable version of "no hardcoded colors".
  • The same idea extends to type scale and spacing (custom properties), but the audit enforces colors only.

OG image generation — crop-safe social share

Social networks crop images differently (WhatsApp square-ish, Facebook center-crop). The skill's rules, learned the hard way:

  1. Change the file name, never overwrite — social caches keyed by URL will keep showing the old preview forever. New content ⇒ new URL (e.g. og-2026-08-09.png).
  2. Content must fit the central safe zone — standard 1200×630 canvas is not enough: keep the hero/graphic content within ~600–640px centered width so a square/center crop (≈630×630) never clips text or logos.
  3. Force a reflow before the screenshot — after setting width via inline style, the first screenshot() may capture the stale layout. Read void element.offsetHeight (or getBoundingClientRect()) to force layout sync, then shoot.
  4. Declare exact dimensions — og:image:width/og:image:height = 1200/630 so scrapers don't guess and mis-trim.
  5. Re-test in 2+ networks after changing the URL (WhatsApp + Telegram at minimum; they cache most aggressively).

Fixed-header anchoring

If position: fixed header exists, anchor jumps hide content underneath. Fix: html { scroll-padding-top: <header-height> } (+ scroll-margin-top on the anchors if needed). meta_audit.py reports adaptive:scroll-padding when this is missing.

Constraints / non-goals

  • audit.js opens a real Chrome; do not substitute CLI lighthouse headless-shell in the default call.
  • Meta audit is offline and stdlib-only — no PyYAML, no requests.
  • Do NOT fix with !important spray or target 100 by hiding audits: raise the underlying metrics (real fix at the root).
  • Do NOT delete or modify user tests/screenshots; artifacts go to --out files you name.
  • Lighthouse scores on localhost vs production differ (no CDN, no real TLS); state this in the report when it matters.

Examples

Full loop on a static site:

cd ~/projects/lovii_demo
python3 -m http.server 8377 &
node .../audit.js --url http://localhost:8377/ --mobile --out lh-mobile.json
node .../audit.js --url http://localhost:8377/ --desktop --out lh-desktop.json
python3 .../meta_audit.py --html index.html --css main.css css/demo.css --out meta.json

Iterate on one category until green:

node .../audit.js --url http://localhost:8377/ --mobile --only accessibility

See references/canonical-patterns.md for the canonical sources this skill is aligned with, and the showcase in docs/showcase/showcase-frontend-perfection-lovii.md.

Boundaries

  • Do not use for a narrow a11y or performance audit; use frontend-a11y or frontend-performance.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.