Microsoft shaved 4.5% off clarity.js with 50+ AI agent experiments
gaganghotra_ · x · 2026-11-03
Microsoft Clarity engineer Manu Nair describes using pi, an AI coding agent with autoresearch, to shrink clarity.js: the agent made a change, built the script, measured compressed output, ran tests, and kept or reverted based on results. After 50+ experiments, the script lost 1,257 gzip bytes (4.5%) with no functionality or compatibility sacrificed.
Key insights:
- Gzip rewards repetition; every new function name or novel pattern costs real bytes — so "clean code" refactors often backfire
- Extracting a coordinates() helper from four duplicated blocks cut 264 source bytes but grew gzip output by 23 bytes
- Changes that look more efficient in source frequently don't compress smaller, and automated experimentation systematically catches this
The workflow — agent-driven experiments with compressed size as the metric — is directly reusable.
More from coding & agent
- Job seeker runs a 6-bot AI team with Grok; one bot burns 30% of tokens — TopInteraction6753 · 2026-11-03
- Claude-coded WhatsApp bot breaks when users go off-script: state management ask — Ok-Zombie-9595 · 2026-11-03
- Anthropic publishes AI-native SDLC playbook rebuilding dev lifecycle stage by stage — seanwbren · 2026-11-03
- Routant (YC F26) launches secure access infrastructure for AI agents — ycombinator · 2026-11-03
- OpenCode V2 regresses badly for mid-size models, reports long-time user — GodComplecs · 2026-11-03
- Self-hosted backlink outreach stack: OpenSEO + OpenCRM + OpenMail via one MCP gateway — ycombinator · 2026-11-03