If you use AI coding agents like Claude Code, Codex, Cursor, or Gemini CLI to build or refactor web applications, you've probably noticed a frustrating pattern: AI often writes more JavaScript than necessary, relies on outdated workarounds, and overlooks features already built into modern browsers.
Ask an agent to build a modal, tooltip, or auto-growing textarea, and it might reach for manual focus management, JavaScript resize listeners, custom scroll-locking logic, or another third-party dependency.
The problem isn't necessarily that these approaches don't work. It's that browsers have evolved, and AI-generated code doesn't always reflect those changes.
To address this, the Google Chrome team introduced Modern Web Guidance (MWG), an open-source collection of agent skills, CLI tools, and static analysis capabilities designed to bring current web platform knowledge directly into AI-assisted development.
Here's how it works, how it analyzes existing code, and how to integrate it into your development workflow.
Large language models learn from years of publicly available code, documentation, and technical discussions. That includes a substantial amount of legacy code.
As a result, AI coding agents can fall back on older implementation patterns even when simpler native alternatives exist.
Three common problems stand out:
JavaScript over-engineering: Building custom solutions for behaviors that modern HTML and CSS can already handle, including native dialogs, popovers, CSS Anchor Positioning, and auto-sizing form controls.
Outdated browser knowledge: Missing recently standardized features or relying on assumptions about browser support.
Poor fallback decisions: Either avoiding newer APIs entirely or using them without considering older browsers and project-specific compatibility requirements.
Modern Web Guidance addresses these problems by connecting AI agents to curated web platform guidance and Web Platform Baseline compatibility information.
Baseline helps developers distinguish between features that are widely available, newly available, or still have limited browser support.
Importantly, not every modern API is supported equally. MWG helps agents consider browser targets and choose appropriate fallbacks rather than assuming that newer always means better.
MWG supports two main workflows: helping agents choose better implementations when generating new code and identifying opportunities to modernize existing codebases.
When you ask an agent to review an existing project, MWG can use its legacy-scan CLI to identify recognizable legacy patterns.
Instead of sending an entire repository to an LLM for inspection, the scanner uses local static analysis to examine supported source files and identify candidate modernization opportunities.
The initial scan runs locally without requiring LLM calls, making it faster and more predictable than asking an agent to inspect every file manually.
However, zero LLM calls during scanning does not mean the entire modernization workflow is free of token usage. The agent still consumes tokens when reviewing findings, retrieving guidance, proposing changes, and verifying the results.
One of the biggest problems with automated code analysis is false positives.
A scanner that flags every unfamiliar pattern creates unnecessary work, especially in large applications where older implementations may exist for valid compatibility reasons.
The MWG modernization workflow uses precision-focused static rules that have been evaluated against large collections of open-source repositories.
The project's published methodology describes testing across approximately 45,000 repositories, with rule acceptance criteria targeting at least 80% static matching precision and 90% precision after contextual verification.
The goal is to identify meaningful modernization opportunities rather than generate warnings for every stylistic difference.
Finding a potentially outdated pattern is only the first step.
For example, a JavaScript-based textarea resizing implementation might be unnecessary in a modern browser environment. But it could also be an intentional fallback for browsers that don't support the newer CSS alternative.
MWG's guidance includes contextual criteria that help an agent determine when a pattern should be replaced and when it should remain.
This distinction matters because modernization should improve the codebase, not simply replace old syntax with new syntax.
There's also an important limitation: the automated legacy scanner covers only a subset of MWG's broader guidance catalog. The remaining guidance can still be discovered and applied through the agent's search and retrieval workflow.
A clean scan therefore doesn't guarantee that an application follows every modern web recommendation.
After identifying and reviewing a candidate, the agent can retrieve the relevant MWG guide and use it to plan a safer refactor.
A typical workflow looks like this:
Scan a selected directory for legacy patterns.
Review each finding against the surrounding code and supported browser targets.
Retrieve the relevant modernization guidance.
Refactor the affected component while preserving its behavior and accessibility.
Run the scanner again, followed by the project's existing tests.
For changes involving layout, focus behavior, or user interactions, browser-based verification is also important. Static analysis alone cannot prove that a refactored component behaves correctly.
The practical value of MWG becomes clearer when looking at common frontend patterns.
A traditional implementation might resize a textarea after every input event:
Before: JavaScript-driven resizing
textarea.addEventListener('input', () => {
textarea.style.height = 'auto';
textarea.style.height = `${textarea.scrollHeight}px`;
});This works, but it requires JavaScript to measure and update layout.
For supported browsers, CSS now offers a simpler alternative.
After: Native CSS sizing
textarea.auto-grow {
field-sizing: content;
min-block-size: 3lh;
max-block-size: 12lh;
}The field-sizing: content property allows the browser to size the textarea based on its content.
This removes the need for custom resize listeners in environments where the feature is supported.
For applications supporting older browsers, the implementation should retain an appropriate fallback or progressive enhancement strategy.
The key benefit isn't just fewer lines of code. It's allowing the browser to handle a behavior that previously required application-level logic.
Another common example is modal implementation.
Older React applications often use custom components with:
Manually managed focus traps
Escape-key listeners
Custom backdrop elements
Body scroll-locking logic
ARIA attributes that must be maintained manually
Modern HTML provides the native <dialog> element.
<dialog id="settings-dialog">
<h2>Settings</h2>
<p>Update your preferences.</p>
<button id="close-dialog">Close</button>
</dialog>const dialog = document.querySelector('#settings-dialog');
dialog.showModal();
document.querySelector('#close-dialog')
.addEventListener('click', () => {
dialog.close();
});Calling showModal() places the dialog in the browser's top layer and provides built-in modal behavior, including focus handling and Escape-key dismissal.
Additional features, such as the closedby attribute, can control dismissal behavior where supported.
Native dialogs can significantly reduce custom implementation code, but they don't eliminate the need to test focus behavior, scrolling, accessibility, and browser compatibility.
For React applications, the same principles apply, although opening and closing the dialog should be coordinated with component lifecycle and state.
Modern Web Guidance can be installed through its CLI or integrated with supported AI coding agents.
From your project root, run:
npx modern-web-guidance@latest installThe interactive installer helps configure MWG for your development environment.
You can also use the CLI directly without a permanent installation.
For example, search the guidance catalog:
npx modern-web-guidance@latest search "animate a dialog modal backdrop"Retrieve a specific guide:
npx modern-web-guidance@latest retrieve "animate-to-from-top-layer"Or scan a repository:
npx modern-web-guidance@latest legacy-scan .Claude Code
claude plugin marketplace add GoogleChrome/modern-web-guidance
claude plugin install modern-web-guidance@googlechromeVercel Agent Skills
npx skills add GoogleChrome/modern-web-guidanceGemini CLI
gemini extensions install https://github.com/GoogleChrome/modern-web-guidance --auto-updateOpenAI Codex
MWG also provides a Codex-compatible plugin. Check the project's current installation documentation for the supported setup method in your Codex environment.
The universal CLI remains a straightforward option when you want to avoid depending on an agent-specific installation process.
If you're introducing MWG into an existing React, TypeScript, or other frontend application, start with a limited scope.
Avoid asking an agent to modernize the entire repository in one pass.
First, run a scan against a selected directory:
npx modern-web-guidance@latest legacy-scan src/componentsThen give your coding agent a prompt like this:
Scan
src/componentsusing Modern Web Guidance for legacy web patterns. Verify each finding against our existing browser targets, accessibility requirements, and intentional fallbacks. Produce a prioritized refactoring plan with expected benefits, compatibility risks, and affected files. Do not modify any code until I review the plan.
This approach gives you more control over the changes and makes the findings easier to evaluate.
It's especially useful in established applications where older code may be intentional, widely reused, or dependent on framework-specific behavior.
After approving a change, verify it using the project's existing linting, TypeScript checks, automated tests, and relevant browser tests.
Modern Web Guidance is useful, but it isn't a replacement for engineering judgment.
First, newer isn't automatically better. A native API may simplify an implementation, but only if it meets the application's browser compatibility, accessibility, and functional requirements.
Second, the scanner doesn't cover everything. Its deterministic rules identify specific recognizable patterns, while broader modernization opportunities may still require agent-assisted review.
Third, fewer lines of JavaScript don't automatically mean better performance. Performance improvements should be measured using relevant metrics and browser tooling.
Finally, review the tool's configuration and telemetry behavior before adopting it in sensitive or enterprise environments. As with any development dependency, teams should understand what gets installed, what runs locally, and whether usage data is collected.
AI coding agents can generate working applications quickly, but working code isn't necessarily modern, efficient, or maintainable code.
Modern Web Guidance helps close that gap by giving agents access to current browser capabilities, compatibility information, and expert-reviewed implementation guidance.
Its combination of deterministic scanning, contextual verification, and targeted refactoring makes it particularly useful for teams maintaining existing frontend applications.
The goal isn't to replace every older implementation with the newest API.
It's to stop writing unnecessary complexity when the web platform already provides a better solution.
Masoud
November 20th, 2026