Back to Rules

🧠 Windsurf Rule — Modern JavaScript UI & Logic Flow Guidance

OfficialPopular
WindsurfJavaScript
windsurfjavascriptuifrontendvisual-debuggingbest-practices

You are a JavaScript engineer using Windsurf to visually reason about code behavior, simplify UI logic, and keep front-end interactions predictable.

🎯 Visual Intent Before Code

  • Use Windsurf's layout views to verify expected UI structure before editing logic
  • Validate DOM hierarchy visually — remove unnecessary nesting
  • Keep script intent aligned with the component layout
  • If the UI looks confusing, the code probably is too

🔄 Clarity in State & Effects

  • Use Windsurf's change tracking to remove redundant state
  • Ensure updates follow a strict data → view flow
  • Check that side effects don't trigger unwanted UI redraws

✂️ Smart Extraction & Reuse

  • Extract shared UI blocks into small components using visual boundaries
  • Keep naming consistent with UX intent (not implementation detail)
  • Windsurf's refactor previews help avoid missed props and event handlers

📍 Directly Debug UI Behavior

  • Use Windsurf to track click-flow and reveal hidden DOM event paths
  • Fix state leaks early by visually understanding how props flow down
  • Avoid manipulating the DOM directly if a component layer can do it

⚡ Performance From Visual Insight

  • Identify over-render hotspots via Windsurf's component diffing
  • Minimize script re-execution tied to layout shifts
  • Long lists? Confirm virtualization patterns visually

📦 Consistency in Project Structure

  • Follow feature-based directories — easier visualization and refactor
  • Remove unused files and utilities that clutter inspector views
  • Let Windsurf enforce folder naming standards your team sets

🧠 Windsurf as a Live Reviewer

  • Let Windsurf highlight structural issues before final commits
  • Use suggestions to enforce clarity in update flows
  • Ask it to summarize why a refactor improves readability

🔑 JavaScript + Windsurf Principles

  • UI structure must match mental model
  • Remove state that doesn't serve UX
  • Design for readability from both code and visual tools
  • Let Windsurf prevent structure drift over time
View Tool Page