OpenParable
Skip to content
← Back to skills

UI Eng Vision Logic Consolidator

Development
ui-eng-vision-logic-consolidator

UI Eng Vision Logic Consolidator is an Agent Skill for development published in the ChromeDevTools/devtools-frontend repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Consolidates manual DOM creation, updates, and constructors into private helper methods and structured state interfaces.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/ChromeDevTools/devtools-frontend/blob/HEAD/.agents/skills/ui-eng-vision-logic-consolidator/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/ui-eng-vision-logic-consolidator, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

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. Wait for confirmation:

    • Wait for an explicit confirmation from the user before proceeding to the next step.