开源项目

modern-web-guidance-src

给 coding agent 用的 Web 平台知识技能包:npx CLI 通过离线 embedding + BM25 检索现代浏览器 API、CSS 布局、性能与无障碍指南,直接注入模型上下文,让 agent 少生成 training data 里的旧式写法。亮点是自带 Playwright grader 的 eval 闭环,量化有/无技能时的通过率差值;检索全本地、无网络调用。注意 CLI 默认上报匿名使用数据,可用 DISABLETELEMETRY 关闭。

README

Modern Web Guidance Modern Web Guidance(源码仓库)

本仓库是 GoogleChrome/modern-web-guidance 的源码仓库,包含用于编写、校准和评估其内容的代码与文档。

Modern Web Guidance 是一组技能(skills),将 Web 平台专业知识、最佳实践和浏览器兼容性数据直接嵌入到你的编码 agent 中。它帮助引导你的编码 agent 远离遗留模式,转而采用能够发挥现代 Web 平台能力与优势的解决方案。

关于我们如何开展该项目以及代码库的组织方式,请参阅 CONTRIBUTING.md 和 GOVERNANCE.md。


由 Google Chrome、Microsoft Edge、Mozilla Firefox 和 MDN 团队以及 Web 开发社区共同维护。

文档 · Eval Dashboard · 源代码 · 报告问题

快速开始

npx modern-web-guidance@latest install

该命令会运行一个交互式向导来安装 Modern Web Guidance。参见下方的其他安装方式。

试一试(无需安装)
# Search for relevant guides
npx modern-web-guidance@latest search "animate a dialog modal backdrop"

# Retrieve a guide by ID
npx modern-web-guidance@latest retrieve "animate-to-from-top-layer"

# Scan a codebase for legacy patterns to modernize
npx modern-web-guidance@latest legacy-scan .

为什么需要它?

编码 agent 常常默认采用较旧的模式,因为 LLM 训练数据中包含大量遗留代码。这导致它们经常为那些如今已有原生、高性能 Web 平台解决方案的任务生成臃肿的 JavaScript。

即使模型知道某个 API 存在,它也往往缺乏生产级代码所需的密集、真实世界的现代实现模式。

Modern Web Guidance 弥合了这一差距。 我们的技能 CLI 会将针对性的、专家精心策划的指南直接返回到你的 agent 上下文中,重点包括:

  • 现代浏览器 API:帮助模型正确构建它们经常误用的 API。
  • 性能与可访问性:优先使用平台级 API,这些 API 可由浏览器优化,并内置可访问性支持。
  • 负责任的降级方案:引导模型使用合理、轻量的降级方案,而不是沉重的 polyfill 或遗留库。

包含哪些内容?

我们覆盖了过去几年 Web 平台的新特性,直至最前沿。这些指南设计为 token 高效;我们运行 evals,以便裁剪掉模型已经掌握的最低共同标准内容。

核心领域

🎨 用户体验

平滑的视觉状态(View Transitions、入场/退场动画、视差滚动、CSS scrollbar-color)。

📐 CSS 布局

现代布局系统(container queries、subgrid、如 oklch 的现代色彩空间、text-wrap 调优,以及 line-height 修剪)。

⚡ 性能

速度优化(即时预加载、Interaction to Next Paint (INP) 诊断,以及通过 scheduler.yield 调度任务)。

📝 表单与 UI

原生组件(用于 tooltip 的 Anchor Positioning、Popover API、dialogs、:user-invalid 校验,以及自动调整大小的字段)。

♿ 可访问性

重要考量(屏幕阅读器与键盘可操作性、内容导航与可发现性)。

🤖 内置 AI

本地客户端模型(原生翻译、摘要,以及语言检测 API)。

查看示例:navigation-drawer 指南。

完整列表
250 个现代 Web 特性

CSS 与布局(140 个特性)

::backdrop content-visibility progress()
::details-content contrast-color() reading-flow
::file-selector-button Cross-document view transitions Relative colors
::placeholder currentColor rem
::selection Custom highlights resize (CSS property)
:dir() Custom properties revert
:focus-visible display animation revert-rule
:focus-within Element-scoped view transitions Safe area inset environment variables
:has() em unit Scroll marker target pseudo-classes
:host-context() field-sizing Scroll method promises
:is() filter Scroll snap
:modal flex-wrap: balance Scroll snap events
:not() Flexbox scroll-axis-lock
:nth-child() of <selector> font-size scroll-behavior
:placeholder-shown font-size-adjust Scroll-driven animations
:user-valid and :user-invalid Forced colors scroll-initial-target
:where() Gradient interpolation scroll-target-group
@function Gradients scrollbar-color
@scope Grid scrollbar-gutter
@starting-style Grid lanes scrollbar-width
@supports Hyphenation scrollend
abs() and sign() image-set() scrollIntoView()
accent-color Individual transform properties Shadow parts
Active view transition inherit sibling-count() and sibling-index()
Alt text for generated content initial Sticky positioning
Anchor position container queries Interaction media queries Subgrid
Anchor positioning interpolate-size System colors
Animations (CSS) isolation Text overflow
appearance Lab and LCH Text stroke and fill (compatibility prefixes)
aspect-ratio light-dark() text-box
at-rule() line-clamp text-decoration
attr() line-height text-decoration-skip-ink
background-blend-mode linear() easing text-decoration-skip-ink: all
background-clip: border-area Logical properties text-decoration-skip-spaces
border-radius Masks text-wrap
box-shadow min(), max(), and clamp() text-wrap: balance
calc-size() mix-blend-mode text-wrap: pretty
Cascade layers Nesting transition-behavior
ch unit Oklab and OkLCh Transitions (CSS)
clip-path overflow-clip-margin Trigonometric functions (CSS)
color-mix() overflow-wrap unset
color-scheme overflow: clip user-select
Conic gradients overlay View transitions
Container queries (size) overscroll-behavior view-transition-class
Container scroll-state queries prefers-color-scheme media query Viewport units
Container style queries prefers-contrast media query Web animations
Content prefers-reduced-motion media query

HTML 与 DOM(36 个特性)

:autofill <slot> HTML streaming setters
:indeterminate <video> HTML-in-canvas
<audio> Autonomous custom elements inert
<details> blocking="render" Interest invokers
<dialog closedby> Customizable <select> Invoker commands
<dialog> Declarative shadow DOM Lazy-loading media
<input type="checkbox" switch> Email, telephone, and URL <input> types moveBefore()
<input type="range"> Fetch priority MutationObserver
<input> focusgroup Mutually exclusive <details> elements
<link rel="expect"> Form-associated custom elements Popover
<link rel="preload"> hidden="until-found" popover="hint"
<progress> HTML setter methods Shadow DOM

JavaScript 与 API(74 个特性)

<install> integrity() for url() Sanitizer API
<meta name="text-scale"> Interaction contentful paint performance entries Scheduler API
<template for> Intersection observer Small, large, and dynamic viewport units
AbortController and AbortSignal Intl.DurationFormat Soft navigation performance entries
ARIA attribute reflection Keyboard events Speculation rules
ariaNotify() Language detector Subresource integrity
Async clipboard LanguageModel Summarizer
autocorrect Lazy-loading images and iframes SVG
beforeinstallprompt light-dark() image values Temporal
border-shape Local network access text-decoration-inset
Connection allowlists Long animation frames performance entries text-fit
corner-shape long-animation-frames-style-layout Top-level await
Credential management Navigation API touch-action
cross-origin() for url() [n

[原 README 过长已截断]

开源项目GoogleChrome2026-11-11原文

相关内容