Catalog
fauziyasin-s2m4qw/ui-eng-vision-logic-consolidator

fauziyasin-s2m4qw

ui-eng-vision-logic-consolidator

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

v1.0LATEST
NewUpdated Oct 20, 2026

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?

Overall Score

82/100

Grade

B

Good

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

85

Quality

82

Clarity

85

Completeness

75

Summary

This skill guides consolidation of imperative DOM operations, event handlers, and rendering logic in a class-based UI component into structured helper methods and state interfaces. It provides rule-based refactoring patterns with emphasis on minimal diffs, safety during code migrations, and proper state management.

Detected Capabilities

code search and analysisdocumentation of refactoring patternsdiff minimization guidancestate interface definition

Trigger Keywords

Phrases that agents use to match this skill to user intent.

consolidate dom logicextract helper methodsrefactor ui stateminimize refactoring difflit-html migration

Use Cases

  • Consolidate scattered DOM creation and manipulation into dedicated private helper methods during UI refactoring
  • Extract state variables from component constructors and event handlers into a centralized interface
  • Minimize code review diffs when migrating from imperative to declarative rendering (e.g., moving toward Lit-html templates)
  • Define clear data contracts between state management and UI update methods during incremental refactoring passes
  • Preserve cleanup logic (resizers, listeners) while consolidating widget references during component evolution

Quality Notes

  • Clear, well-structured refactoring guidance with numbered rules and examples (TypeScript code blocks)
  • Includes a mental audit section for self-verification, promoting careful incremental changes
  • Explicitly addresses code review tooling constraints (Gerrit's inability to track moved code blocks), showing domain expertise
  • Provides specific method naming conventions and patterns (e.g., performUpdate, renderFooContent helpers)
  • Safety-focused: emphasizes minimal diffs, write-only state avoidance, and cleanup preservation to reduce refactoring risk
  • Strong emphasis on waiting for confirmation before proceeding to next steps, reducing automation risks
  • Guidance is scoped to class-based UI components with both imperative and Lit-html rendering patterns
Model: claude-haiku-4-5-20251001Analyzed: Oct 20, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Use fauziyasin-s2m4qw/ui-eng-vision-logic-consolidator in your dev environment

Command Palette

Search for a command to run...