Agent Skills › ChromeDevTools/devtools-frontend › ui-eng-vision-logic-consolidator

ui-eng-vision-logic-consolidator

GitHub

将手动DOM创建和渲染逻辑从构造函数提取至私有辅助方法,定义状态接口并通过performUpdate统一更新UI。旨在简化代码结构,优化前端组件的可维护性与逻辑清晰度。

.agents/skills/ui-eng-vision-logic-consolidator/SKILL.md ChromeDevTools/devtools-frontend

Trigger Scenarios

重构前端类中的手动DOM操作 整理分散的事件处理与渲染逻辑 将命令式UI更新转换为声明式状态驱动

Install

npx skills add ChromeDevTools/devtools-frontend --skill ui-eng-vision-logic-consolidator -g -y
More Options

Non-standard path

npx skills add https://github.com/ChromeDevTools/devtools-frontend/tree/main/.agents/skills/ui-eng-vision-logic-consolidator -g -y

Use without installing

npx skills use ChromeDevTools/devtools-frontend@ui-eng-vision-logic-consolidator

指定 Agent (Claude Code)

npx skills add ChromeDevTools/devtools-frontend --skill ui-eng-vision-logic-consolidator -a claude-code -g -y

安装 repo 全部 skill

npx skills add ChromeDevTools/devtools-frontend --all -g -y

预览 repo 内 skill

npx skills add ChromeDevTools/devtools-frontend --list

SKILL.md

Frontmatter
{
    "name": "ui-eng-vision-logic-consolidator",
    "description": "Consolidates manual DOM creation, updates, and constructors into private helper methods and structured state interfaces.",
    "allowed-tools": "code_search open_urls"
}

Subskill: Logic Consolidator (Pass 1)

This subskill extracts manual layout building, attribute modifications, and rendering loops out of the constructor and scattered event handlers, consolidating them into private helper methods with explicit data contracts.


1. Logic Consolidation Rules

  1. Identify UI updates Creation:

    • Scan the class constructor and search for manual DOM operations (e.g., element.createChild('div'), document.createElement, element.appendChild).
    • Also look for any UI updates which call lit-html render.
  2. Isolate Update and Draw Operations:

    • Group the imperative creation/update lines into dedicated private helper methods (e.g., #updateSummaryBar(...) or #createEditorToolbar(...)).
    • Group event-handling updates (e.g., state variables like pageSize, modified during buttons clicks) into centralized functions like onPageSizeChanged.
  3. Define the State Interface:

    • Identify the class state and ensure it is captured in the private member variables, e.g.

      #entries: Entry[];
      #canGoBack: boolean;
      #canGoForward: boolean;
      #staleWarningVisible: boolean;
      
    • Replace direct mutations of UI with updates to these member variables, followed by a call to the public performUpdate() method that is calling previously extracted update helpers. Use this specific identifier.

    • If there's only one or two update helpers, consider inlining them into the performUpdate.

  4. Extract/Consolidate Rendering Operations:

    • If Logic First (imperative DOM remains), make sure all updates to the UI go through the performUpdate method

    • If Lit First (Lit template already exists), make sure there's a single master call to Lit render inside performUpdate. The master template might include calls to the helper functions e.g.

      render(html`
        <div class="specific-view">
          <span>View Title</span>
          ${this.renderOverviewSection()}
        </div>
      `, this.contentElement);
      
  5. Minimize Diffs (Safety Rule):

    • Avoid moving existing code to a different location in the file. Put the function signature around the existing code to minimize the diff.
    • The Gerrit Code Review UI cannot identify moved blocks of unchanged code.
    • If blocks of code need to be reordered, create a "prefactoring" change that first extracts the code that needs to be reordered into named helper functions and pause the migration, waiting for user confirmation.
  6. No Write-Only State Fields in Prefactor CLs:

    • Do not introduce #state fields in a logic-consolidation CL that are only written to in that CL and only read in the next CL's DEFAULT_VIEW.
    • Either read them in the prefactor CL (e.g., inside an extracted imperative #render... helper) or introduce them in the CL that actually adds DEFAULT_VIEW.
  7. Extract Imperative #renderSubtreeContent() Helpers:

    • For complex layouts, extracting an imperative #renderFooContent() helper in Pass 1 (while keeping the outer container imperative) minimizes the Pass 2/3 diff when converting #renderFooContent() to renderFooContent(input: ViewInput): LitTemplate.
  8. Preserve Imperative Cleanup Calls:

    • When consolidating DOM/widget references (e.g., replacing #tabbedLocationHeader with #debuggerSidebarTabbedLocation), preserve imperative cleanup calls like splitWidget.uninstallResizer(...) until the imperative container itself is removed.
  9. Wait for confirmation:

    • Wait for an explicit confirmation from the user (or Parent Orchestrator Agent) before proceeding to the next step.

🔍 Mental Audit (Internal Self-Correction)

Before reporting back or committing, re-read the instructions and verify:

  1. ❓ Minimal Diffs: Did I move code blocks around unnecessarily?
  2. ❓ State Completeness & Utility: Are all state variables actually read in this CL, with no write-only placeholders?
  3. ❓ Cleanup Preserved: Are resizer/listener uninstallation calls preserved during reference consolidation?
  4. ❓ Build: Does the code still compile?

Version History

  • 6527f72 Current 2026-10-20 02:26

    新增避免在合并前引入仅写状态字段的规则,增加对交叉仓库耦合检查及测试钩子清理的学习总结。

  • 678d19c 2026-08-20 15:20

Same Skill Collection

.agents/skills/code-review/SKILL.md
.agents/skills/devtools-ci/SKILL.md
.agents/skills/devtools-imports/SKILL.md
.agents/skills/devtools-model-management/SKILL.md
.agents/skills/devtools-setting-migration/SKILL.md
.agents/skills/devtools-source-maps/SKILL.md
.agents/skills/devtools-testing-guidance/SKILL.md
.agents/skills/devtools-unicode-escaping/SKILL.md
.agents/skills/devtools-ux-writing-refactor/SKILL.md
.agents/skills/devtools-verification/SKILL.md
.agents/skills/evaluate-ai-css-completion/SKILL.md
.agents/skills/fix-tests/SKILL.md
.agents/skills/fixing-skipped-tests/SKILL.md
.agents/skills/foundation-test-migration/SKILL.md
.agents/skills/gerrit-cli/SKILL.md
.agents/skills/merging-devtools-module/SKILL.md
.agents/skills/migrate-chromium-test/SKILL.md
.agents/skills/review-models-core/SKILL.md
.agents/skills/review-tests/SKILL.md
.agents/skills/review-ui-widgets/SKILL.md
.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md
.agents/skills/ui-eng-vision-orchestrator/SKILL.md
.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md
.agents/skills/ui-eng-vision-widget-promoter/SKILL.md
.agents/skills/ui-widgets/SKILL.md
.agents/skills/version-control/SKILL.md
.agents/skills/repro-flaky-tests/SKILL.md

Metadata

Files
0
Version
6527f72
Hash
e4d1c24c
Indexed
2026-08-20 15:20

홈 - 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-22 03:43
浙ICP备14020137号-1