Agent Skills
› ChromeDevTools/devtools-frontend
› review-models-core
review-models-core
GitHub提供Chrome DevTools前端models-and-core模块的代码审查指导,涵盖轨迹处理、SDK模型生命周期管理及GN构建规范,确保代码符合架构与性能标准。
Trigger Scenarios
审查涉及front_end/core或models路径的前端变更
检查BUILD.gn或.gni构建文件配置
Install
npx skills add ChromeDevTools/devtools-frontend --skill review-models-core -g -y
SKILL.md
Frontmatter
{
"name": "review-models-core",
"description": "Reviews Chrome DevTools frontend changes in path group models-and-core (^front_end\/(core|models|entrypoints|generated)\/, BUILD\\.gn$, \\.gni$), strictly reflecting review standards, architectural invariants, and security boundaries derived from historical code reviews."
}
Chrome DevTools frontend reviewer skill: models-and-core
This skill provides review guidance for Chrome DevTools frontend changes matching the models-and-core path group (^front_end/(core|models|entrypoints|generated)/, BUILD.gn$, .gni$). Every rule below recurred in at least 5 CLs from 2 distinct reviewers in historical reviews; cite the rule id in findings.
Path group models-and-core (10 rules)
CORE_TRACE_ENGINE_HANDLER_INVARIANTS: Normalize and precompute trace events in handler finalize passes using Types.Events.is* guards while keeping raw events immutable
- Severity: ERROR
- Why: Trace handlers (
front_end/models/trace/handlers/) must normalize synthetic event fields, validate bounds, and group events once duringfinalize()so downstream insights and UI tracks do not repeatedly filter the raw trace array or mutate raw trace event objects. - Look for: In-place property mutation of raw trace events, repeated full-trace
.filter()scans inside insight calculators instead of handler precomputation, or ad-hoc property checks instead ofTypes.Events.is*(orTrace.Types.Events.is*) type guards. - Do not flag: Constructing new synthetic trace event objects owned by the handler during
finalize().
CORE_SDK_MODEL_AND_TARGET_LIFECYCLE: Manage SDK model and sub-target state on scoped manager instances using O(1) indexed maps rather than module globals or linear scans
- Severity: ERROR
- Why: Storing model tracking collections (
Set/Map) at module scope leaks state across multipleTestUniverseinstances and targets, while failing to track OOPIF/worker sub-targets or scanning DOM trees linearly for frame nodes causes bugs and $O(N)$ bottlenecks. - Look for: Module-level
const tracked = new Map/Set()incore/sdk/ormodels/bindings/, linear DOM tree traversals for frame/node lookups instead of indexedMaps, or target listeners that ignore sub-target attachment/detachment. - Do not flag: Immutable module-level
SetorMaplookup tables of constant string literals. Properties marked required (non-optional) in generatedfront_end/generated/protocol.tsCDP types (do not ask for redundant runtime null/undefined checks on them), ornode.shadowRoots()[0]accesses (elements have at most one shadow root; the array return type is a legacy Shadow DOM v0 artifact).
CORE_GN_BUILD_AND_MODULE_LAYERING: Enforce strict GN bundle visibility, declare complete deps/ts_deps, and never import UI or panel modules from foundation layers
- Severity: ERROR
- Why: DevTools enforces a strict DAG where
core/andmodels/(foundation) must never depend onui/orpanels/. InBUILD.gn, modules must depend on:bundletargets across directories, register new files indevtools_grd_files.gniandfoundation_unittests, and restrict panelvisibility. - Look for: Imports of
ui/orpanels/insidecore/ormodels/,visibility = [ "*" ]on new panelBUILD.gntargets, direct internal file imports across module boundaries instead of:bundlenamespace imports, or missingfoundation_unittestsentries. - Do not flag: Core utility libraries intentionally exposed to the entire codebase with
visibility = [ "*" ].
CORE_AI_AGENT_CONTEXT_AND_PROMPT_DISCIPLINE: Keep AI agent prompts, tool schemas, and data formatters deterministic, token-efficient, and decoupled from UI and locale state
- Severity: WARNING
- Why: AI agent data formatters (
models/ai_assistance/data_formatters/) must produce deterministic, unlocalized, concise text representations decoupled from UI widgets and trace insight models, while tools must declare explicit permission policies and flatten verbose CDP types. - Look for: Localized
i18nStringcalls or verbose boilerplate prose inside AI data formatters, unsorted flag/property lists in prompt serializers, AI tools missing permission policy declarations, or monolithic trace models passed to response widgets. - Do not flag: User-facing UI labels rendered in the AI assistance panel chrome rather than sent to the LLM.
CORE_RUNTIME_NEUTRALITY_AND_PLATFORM_UTILS: Maintain runtime neutrality in foundation modules using Platform.HostRuntime, globalThis, and centralized core/platform utilities
- Severity: ERROR
- Why: Foundation modules (
core/andmodels/) run in both browser DevTools and headless Node.js/worker environments (such as trace analysis and MCP servers). Accessingwindow,navigator.userAgent, ordocumentdirectly breaks non-browser runtimes, and duplicating MIME/string/deferred utilities causes subtle bugs. - Look for:
navigator.userAgent,window.setTimeout,window.atob, manualnew Promise(r => { resolve = r; })deferreds instead ofPromise.withResolvers(), or ad-hoc MIME/escaping regexes incore/andmodels/. - Do not flag: Browser-only UI components in
front_end/panels/orfront_end/ui/.
CORE_CDP_AND_EXTENSION_ERROR_HANDLING: Handle CDP ProtocolResponseWithError and ContentDataOrError explicitly, release RemoteObject handles in finally blocks, and return Promises
- Severity: ERROR
- Why: CDP agent calls and
requestContentData()resolve to error-bearing response objects (getError(),ContentData.isError()) rather than throwing, so wrapping them intry/catchis misleading. Furthermore, temporaryRemoteObjecthandles must be released infinallyblocks, and extension APIs must reject with sanitizedErrorinstances. - Look for:
try { await ...invoke_*() }ortry { await request.requestContentData() }blocks,Runtime.evaluatecalls creatingRemoteObjects withoutrelease()infinally, callback-taking SDK methods instead ofPromise, orreject(rawObject)inExtensionAPI.ts. - Do not flag:
try/catchblocks that wrap subsequent throwing operations likeJSON.parse(). Properties marked required (non-optional) in generatedfront_end/generated/protocol.tsCDP types (do not ask for redundant runtime null/undefined checks on them), ornode.shadowRoots()[0]accesses (elements have at most one shadow root; the array return type is a legacy Shadow DOM v0 artifact).
CORE_SECURITY_ORIGIN_AND_CAPABILITY_GUARDS: Enforce security origin validation, enterprise policy guards, and branded UrlString types in the model and host layers
- Severity: ERROR
- Why: Security origin checks (SOP), workspace access boundaries, and enterprise/geo-restriction capability checks must be enforced in
core/andmodels/usingSecurityOrigin,Common.ParsedURL, andPlatform.DevToolsPath.UrlStringrather than relying on UI-layer checks or unvalidated source URLs. - Look for: Unbranded
stringURLs in model/agent interfaces instead ofPlatform.DevToolsPath.UrlString, security origin checks performed only in UI views, or resource lookup errors returned before permission checks inExtensionServer. - Do not flag: Internal display-only label strings that are never used for resource resolution or security checks.
CORE_SOURCEMAP_AND_WORKSPACE_MAPPING: Handle source map parsing, inline script offset translation, and scope tree resolution fault-tolerantly
- Severity: ERROR
- Why: Real-world source maps and inline
<script>tags frequently contain malformed fields, UTF-8 characters, or non-zero line/column offsets. Source map consumers must translate raw inline script locations to relative locations, use UTF-8-safe URI encoding (encodeURIComponentwithtry/catchinstead ofbtoa), and guard scope stack traversals. - Look for:
window.btoaon source map strings containing UTF-8, raw script locations passed to source map lookups withoutrawLocationToRelativeLocation, or unguardedencodeURIComponent/JSON.parseon external source map payloads. - Do not flag: ASCII-only binary buffer encoding via
Common.Base64.encode.
CORE_SETTINGS_AND_STORAGE_MIGRATION: Guard settings and storage migrations with try/catch, preserve user preferences across renames, and clean up obsolete flags
- Severity: ERROR
- Why: Corrupted
localStoragepayloads or legacy setting schemas can throw duringJSON.parseand break DevTools startup unless caught and reset. When migrating setting keys or storage formats, existing user selections must be migrated rather than overwritten. - Look for: Unprotected
JSON.parse()inSettings.tsor storage classes, setting key renames that discard previously stored user preferences, or experiment removals that leave orphanedlocalStoragekeys behind. - Do not flag: In-memory parsing of static constant JSON fixtures.
CORE_TRACE_INSIGHT_MODELS_AND_TIMING_TYPES: Enforce branded timing types (Micro, Milli) in trace models and keep types.ts and insight models free of executable or presentation logic
- Severity: ERROR
- Why: Mixing microseconds and milliseconds causes 1000x calculation bugs across trace insights; branded types (
Types.Timing.Micro,Types.Timing.Milli) and canonical conversion helpers (such asTrace.Helpers.Timing.microToMilliorPlatform.Timing.microSecondsToMilliSeconds) prevent unit confusion. Placing executable functions intypes.tsor UI/AI formatting in insight models violates trace architecture. - Look for: Manual
/ 1000or* 1000arithmetic on trace timestamps, executable functions placed inmodels/trace/**/types.ts, or CSS/DOM/AI markdown formatting insidemodels/trace/insights/. - Do not flag: Type guard functions (
is*) inTrace.Types.Eventsthat only perform type predicate checks.
Version History
- 6527f72 Current 2026-10-20 02:26


