Ui eng vision logic consolidator

From ChromeDevTools/devtools-frontend · View interactive version

Ui eng vision logic consolidator is an AI agent skill from the GitHub repository ChromeDevTools/devtools-frontend. Consolidates manual DOM creation, updates, and constructors into private helper methods and structured state interfaces.

How to use this skill

Skill file

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:

element.createChild('div'), document.createElement,

element.appendChild).

  1. Isolate Update and Draw Operations:

methods (e.g., #updateSummaryBar(...) or #createEditorToolbar(...)).

modified during buttons clicks) into centralized functions like

onPageSizeChanged.

  1. Define the State Interface:

variables, e.g.

```typescript

#entries: Entry[];

#canGoBack: boolean;

#canGoForward: boolean;

#staleWarningVisible: boolean;

```

variables, then trigger a single consolidated update path:

imperative helper (e.g., this.#updateUI()) that updates existing

element references in place (inlining if there are only one or two

update helpers). Do not call this.performUpdate() synchronously

on state updates.

asynchronous updates via this.requestUpdate().

  1. Extract/Consolidate Rendering Operations:

mutations through private #update*() helpers. Never define

override performUpdate() calling render(..., this.contentElement)

while imperative constructor DOM on this.contentElement still exists,

because instantiateWidget() calls requestUpdate() automatically and

prepends duplicate DOM nodes and IDs alongside the constructor children.

master call to Lit render inside performUpdate. The master template

might include calls to the helper functions e.g.

```typescript

render(html`

<div class="specific-view">

<span>View Title</span>

${this.renderOverviewSection()}

</div>

`, this.contentElement);

```

  1. Minimize Diffs (Safety Rule):

function signature around the existing code to minimize the diff.

code.

that first extracts the code that needs to be reordered into named

helper functions and pause the migration, waiting for user confirmation.

  1. No Write-Only State Fields in Prefactor CLs:

written to in that CL and only read in the next CL's DEFAULT_VIEW.

#render... helper) or introduce them in the CL that actually adds

DEFAULT_VIEW.

  1. Extract Imperative #renderSubtreeContent() Helpers:

helper in Pass 1 (while keeping the outer container imperative) minimizes

the Pass 2/3 diff when converting #renderFooContent() to

renderFooContent(input: ViewInput): LitTemplate.

  1. Preserve Imperative Cleanup Calls:

#tabbedLocationHeader with #debuggerSidebarTabbedLocation), preserve

imperative cleanup calls like splitWidget.uninstallResizer(...) until the

imperative container itself is removed.

  1. Wait for confirmation:

🔍 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?
  5. ❓ No Premature performUpdate(): Did I avoid synchronous performUpdate() calls on state updates and avoid render(..., this.contentElement) while imperative constructor DOM remains?
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.