Give Claude these 20 UX laws before it builds a UI: one A/B test, page 27% shorter, order buttons 13 → 3
20 UX laws, one plain rule each, pasted after your request. Two Claude Code runs on a fictional coffee shop page: 27% shorter, order buttons 13 → 3.
Ask Claude for an interface and you often get a long page with a lot of buttons. We tried a simple fix: paste 20 UX laws after the request, each with one plain rule. To find out whether it actually helps, we gave the same prompt to two fresh Claude Code agents, one with the laws and one without, and had each build a mobile landing page once for 巷尾焙豆, a fictional coffee roaster in Tainan. Then we measured both in headless Chrome.
You get: the 20 laws (each with one line), a prompt you can copy, how we ran the test, the real numbers, and how to test it yourself. Every page screenshot below is a real page the two agents built.
01The result first: same prompt, with and without the laws

Both pages were measured at a 390 px phone width with exactly the same rules:
- Page height: 5,287 px → 3,858 px, 27% shorter.
- Buttons that open the order form: 13 → 3.
- Tap targets smaller than 44×44 px: 1 → 0.
- Invented reviews or customer counts: 0 → 0. Neither page made any up, so this one is a tie.
Each side ran once, so this is a strong hint, not proof. Below: how to use the laws, how we tested, and how to test your own pages.
02The 20 UX laws, one plain line each

Claude knows the law names, but a bare name doesn't tell it what you want on the screen. So each law gets one line on what it means for an interface:
- Aesthetic-Usability Effect (美即好用效應): A good-looking interface feels easier to use; keep visuals polished and consistent.
- Hick's Law (希克定律): More choices mean slower decisions; give each screen one main action.
- Fitts's Law (費茨定律): Bigger, closer targets are easier to hit; anything tappable on a phone is at least 44×44 px.
- Jakob's Law (雅各布定律): Users expect your site to work like the sites they already use; put navigation and buttons where people expect them.
- Miller's Law (米勒定律): Short-term memory holds about 7±2 items; group information and keep each group small.
- Doherty Threshold (多爾蒂門檻): Respond within 400 ms; every tap gets an immediate reaction.
- Law of Proximity (鄰近原則): Put related things close together and unrelated things apart.
- Law of Similarity (相似原則): Things that look alike are read as one kind; same function, same style.
- Law of Common Region (共同區域): Things inside the same box are seen as one group.
- Visual Hierarchy (視覺層級): Use size, weight and colour to set what people see first and next.
- Progressive Disclosure (漸進揭露): Show what is needed first; reveal details when the user asks for them.
- Recognition over Recall (辨識優於回憶): Show the options on screen; don't make people remember them.
- Von Restorff Effect (馮雷斯托夫效應): The most important item should look different from the rest.
- Peak-End Rule (峰終定律): People remember the peak and the end of an experience; make the ending good.
- Goal-Gradient Effect (目標梯度效應): People push harder as they near a goal; show them their progress.
- Serial Position Effect (序列位置效應): The first and last items are remembered best; put key points at the start and end.
- Tesler's Law (泰斯勒定律): Complexity never disappears; let the system carry it, not the user.
- Postel's Law (波斯特爾定律): Be forgiving with what users type in, strict with what you show back.
- Occam's Razor (奧坎剃刀): Remove whatever you can; the simplest solution is usually best.
- Feedback Loops (回饋迴圈): Every action gets visible feedback.
03Copy this prompt: paste it after your request
- Write your request the way you normally would: what to build, for whom, what it sells, what the goal is.
- Leave a blank line after the request and paste the whole 20-laws block.
- Give it to Claude Code (or Claude), then open the result at phone width.
Build me a [mobile landing page / homepage / app screen] ([technical limits, e.g. one HTML file]). Shop / product: "[name]", [one line: where it is and what it is]. What it sells: [products, prices, plans] [opening hours, location or other facts] Goal: [the one thing you want users to do] (paste the whole "20 UX laws" block right after this)
While you build it, follow these 20 UX laws: 1. Aesthetic-Usability Effect: A good-looking interface feels easier to use; keep visuals polished and consistent. 2. Hick's Law: More choices mean slower decisions; give each screen one main action. 3. Fitts's Law: Bigger, closer targets are easier to hit; anything tappable on a phone is at least 44×44 px. 4. Jakob's Law: Users expect your site to work like the sites they already use; put navigation and buttons where people expect them. 5. Miller's Law: Short-term memory holds about 7±2 items; group information and keep each group small. 6. Doherty Threshold: Respond within 400 ms; every tap gets an immediate reaction. 7. Law of Proximity: Put related things close together and unrelated things apart. 8. Law of Similarity: Things that look alike are read as one kind; same function, same style. 9. Law of Common Region: Things inside the same box are seen as one group. 10. Visual Hierarchy: Use size, weight and colour to set what people see first and next. 11. Progressive Disclosure: Show what is needed first; reveal details when the user asks for them. 12. Recognition over Recall: Show the options on screen; don't make people remember them. 13. Von Restorff Effect: The most important item should look different from the rest. 14. Peak-End Rule: People remember the peak and the end of an experience; make the ending good. 15. Goal-Gradient Effect: People push harder as they near a goal; show them their progress. 16. Serial Position Effect: The first and last items are remembered best; put key points at the start and end. 17. Tesler's Law: Complexity never disappears; let the system carry it, not the user. 18. Postel's Law: Be forgiving with what users type in, strict with what you show back. 19. Occam's Razor: Remove whatever you can; the simplest solution is usually best. 20. Feedback Loops: Every action gets visible feedback.
04How we tested: two fresh Claude Code agents
- Two fresh Claude Code agents, with no other conversation.
- A got only the request below; B got the identical request plus the 20 laws after it.
- Both got the same technical notes: one HTML file, no external images (illustrations drawn with CSS or SVG), local fonts, and a self-check with screenshots in headless Chrome.
- Neither was told the pages would be measured or compared.
- One run each. We did not change a single line of either page.
Build me a mobile landing page (one HTML file, CSS and JS in the same file). Shop: 巷尾焙豆 (Lane-End Roasters), a tiny home-roasting coffee bean shop down an alley in West Central District, Tainan. What it sells: single-origin beans roasted in small batches every Tuesday and Friday, from NT$420 per half pound; also a "one bag every two weeks" subscription with free shipping. Shop hours: Wednesday to Sunday, 12:00–19:00, tasting welcome. Goal: get people who scroll to this page to order their first bag or subscribe.
05Number 1: the page got 27% shorter

We scrolled each page top to bottom once so every scroll animation finished, then measured the full height. Scrolled at the same speed, the page with the laws reaches its bottom first.

06Number 2: order buttons went from 13 to 3

How we counted: every tappable element was clicked once, each on a fresh load, and we checked whether the order form opened.
- Without the laws: 13. Two at the top, four 「選這支」 (pick this one), 「訂第一包」 (order your first bag), 「加入訂閱」 (subscribe), 「先訂好,來店自取」 (order ahead, pick up in store), two at the end and two in the fixed bottom bar.
- With the laws: 3. 「挑我的第一包豆子 →」 (pick my first bag) at the top, the same button at the end, and 「訂這包」 (order this bag) in the fixed bottom bar.
On the page with the laws, tapping a bean card selects the bean instead of opening the form, and the order form is split into 3 steps with 「已完成 1/3」 (1 of 3 done) at the top. That looks like Hick's Law and the Goal-Gradient Effect at work.

07Numbers 3 and 4: small tap targets 1 → 0, invented reviews 0 → 0

Small tap targets: anything visible and tappable with a width or height under 44 px. The page without the laws had 1; the page with them had 0. Its top links (beans, subscription, shop) are exactly 44 px tall.

Invented reviews: the request gave no customer counts, ratings or reviews, so any on the page would have to be made up. We matched the text for suspicious lines, then checked each one by eye. Neither page made any up. What the match flagged on the page with the laws was 「第一次推薦」 (a "recommended for first-timers" badge on one bean) and 「30 分」 (the order cut-off countdown), not reviews.
08Test it yourself: 4 measurements
Don't take our single run for it: measure your own pages. The easiest way is to have Claude Code write the measuring script:
- Build the same request twice: once without the laws, once with them. Save them in two folders.
- Paste the prompt below into Claude Code and let it write and run the script.
- If a page shows "open now" or roast dates based on today's date, freeze the clock at the same moment for both pages so the test is fair.
- If you have time, run each side a few more times and see whether the result holds.
Write me a Node.js script that uses puppeteer-core to open headless Chrome (path: [your Chrome path]) at a 390×844 phone viewport, loads [path to page A] and [path to page B], measures these 4 things and saves the result as JSON: 1. Page height: scroll top to bottom once (so scroll animations finish), then read document.documentElement.scrollHeight. 2. Small tap targets: every visible a, button, input, select, textarea, summary, label and [role=button] whose width or height is under 44 px. 3. Buttons that open [your main form, e.g. the order form]: click every tappable element once, each on a fresh load, check whether [the form's selector, e.g. [role=dialog]] appears, and count them. 4. Invented social proof: list any text that looks like customer counts, star ratings, reviews or testimonials so I can check each one by eye. Use exactly the same rules for both pages.
09Good to know
- One run per side. Claude builds something a little different every time, so this is a strong hint, not proof.
- Not every number moved: invented reviews were 0 on both pages; there was only 1 small tap target to begin with; and the total number of tappable elements went up from 19 to 23 (selectable bean cards, expandable FAQ items).
- Shorter is not automatically better. We measured length, button counts and tap sizes, not sales; for that you need real users.
- 4 of the 20 (Visual Hierarchy, Progressive Disclosure, Recognition over Recall, Feedback Loops) are not on lawsofux.com; they are standard UX principles. The one-line rules are our own wording.
- 巷尾焙豆 is a fictional shop. The products, price details, address and delivery fee on its pages were made up by the AI for this demo.