Skip to main content

sprezzature-ux-laws

License Python

🇫🇷 LISEZMOI.md · 🇬🇧 README.md

logo

A static Laws-of-UX auditor for HTML.

The "Laws of UX" are named heuristics from psychology and human-computer-interaction research: for instance, Hick's Law says that the more choices a screen offers at once, the longer a person takes to pick one, so a navigation menu with forty links is measurably harder to use than one with seven. This tool cannot see a rendered page or watch a real person use it; instead it reads the raw HTML text and flags the mistakes that are decidable from that text alone, such as counting the links in a <nav>. That trade keeps it fast and deterministic enough to run in a pre-commit hook or a CI step, at the cost of catching only the fraction of each law's violations that a text scan can see (the full, sourced definition of each law lives in references/laws-of-ux.md).

Laws covered

Law What it catches
Hick's Law Too many choices presented at once (over-long menus / nav).
Choice overload Long option lists with no grouping or default.
Miller's Law Unchunked digit runs (phone numbers, codes) beyond ~7 items.
Jakob's Law Non-conventional patterns where a familiar one is expected.
Fitts's Law Interactive controls with no 44 px (min-h-11) hit area.
Aesthetic-Usability Interactive elements missing a visible focus ring.
Selective attention Elements styled like ads that carry real content.
Tesler's Law Irreducible complexity pushed onto the user.

Install

pip install sprezzature-ux-laws               # the auditor: no dependencies
pip install "sprezzature-ux-laws[click]"      # + the click front door
pip install "sprezzature-ux-laws[api,mcp]"    # + the HTTP and agent surfaces

That the auditor has no dependencies at all is the point of it, and the reason it is cheap enough to put in a pre-commit hook: standard library, milliseconds, no browser. Everything heavier is an extra, named after what needs it.

Use

# Audit a file or a whole directory tree
sprezzature-ux-laws-audit public/index.html
sprezzature-ux-laws-audit site/ --json

# Restrict to specific laws, or auto-fix the mechanical ones
sprezzature-ux-laws-audit page.html --only fitts,jakob
sprezzature-ux-laws-audit page.html --fix

sprezzature-ux-laws is the same thing through click, with the same flags and the same handler — use whichever matches the rest of your tooling. From a clone, without installing, it reads python scripts/audit_laws_of_ux.py page.html.

Findings are error or warning; the process exits non-zero when an error is present, so it drops cleanly into CI.

From Python

from pathlib import Path

import sprezzature_ux_laws as ux

for finding in ux.audit_html("<nav>" + '<a href="/">x</a>' * 12 + "</nav>"):
    print(finding.law, finding.message)

ux.audit_file(Path("public/index.html"), laws={"fitts", "jakob"})
ux.fix_file(Path("page.html"), laws=set(ux.LAWS), dry_run=True)

ux.LAWS is the tuple of every law it knows, in the order the checks run — the same list the command line validates --only against and the HTTP API publishes, read from one place so the four surfaces cannot disagree.

Honest scope

The auditor catches mechanical, source-decidable violations. It does not judge whether a screen answers the right question or whether a flow makes sense. That stays a human call. It is a fast gate, not a substitute for design review.

License

BSD-3-Clause © Warith HARCHAOUI. Part of the sprezzature toolkit.

Metadata

Release files for sprezzature-ux-laws 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sprezzature-ux-laws 1.2.0
File Size Uploaded Provenance Actions
sprezzature_ux_laws-1.2.0.tar.gz 47.5 kB Without provenance Details for sprezzature_ux_laws-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sprezzature-ux-laws 1.2.0
File Interpreter ABI Platform Actions
sprezzature_ux_laws-1.2.0-py3-none-any.whl Python 3 none any Details for sprezzature_ux_laws-1.2.0-py3-none-any.whl

Total release size: 81.9 kB

Release files / sprezzature_ux_laws-1.2.0.tar.gz

Download URL sprezzature_ux_laws-1.2.0.tar.gz
Size 47.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2b00fdc25a15ba54da374ee36e4aefcc7bb9ad9d60bf8bba9e402f6ebeff336a
BLAKE2b-256 checksum
How to use checksums
86bddf26e5bc52da1baa2d18cfa6ec24648ab15d153a1169068bb7155684383c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / sprezzature_ux_laws-1.2.0-py3-none-any.whl

Download URL sprezzature_ux_laws-1.2.0-py3-none-any.whl
Size 34.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd1ec1fd817219586806c884a06c8fa009a95321deb93d3315a0bf15c393ebe4
BLAKE2b-256 checksum
How to use checksums
ddb41c8b06dcafc606239d5dfb7afca550f24313a4fa33b633b11c391b45acd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for sprezzature-ux-laws 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page