visual-dom-comparison
Skill10 starsChanged 2 months agoApache-2.0View on GitHub
Compare page states before/after any command — live snapshot pairs, historical session diffs, JS-execution change capture, and extension ON/OFF DOM comparison to isolate injected artifacts.
In this repository16 other files it gives its agents.
- browser-forensicsSkill
- browser-interactionSkill
- browser-state-recoverySkill
- dom-inspectionSkill
- dom-mutationSkill
- dom-targetingSkill
- extension-troubleshootingSkill
- human-like-interactionSkill
- mcp-troubleshootingSkill
- page-annotationSkill
- project-captureSkill
- project-reconstructionSkill
- regression-testingSkill
- selector-recoverySkill
- tab-managementSkill
- viewport-testingSkill
The file
Files
Skill: Visual-DOM Comparison
PURPOSE
Answer "what changed?" with evidence instead of impressions. Four comparison surfaces: page-state snapshot pairs (live), structural DOM diffs (historical sessions), JS execution with automatic change capture, and extension ON/OFF comparison that isolates what the extension itself injects into a page.
WHEN TO USE
- Verifying that a click, mutation or script actually changed the DOM (and by how much).
- Detecting drift after navigation, reconnects or background app behavior.
- Proving an extension is (or is not) polluting the page — e.g. debugging "the injected UI breaks my page" reports.
- Building before/after evidence for bug reports or project diffs.
- Gathering evidence for bug reports: a snapshot pair plus a diff summary beats a screenshot alone.
PREREQUISITES
- MCP server running; live page in the extension or Node simulation.
- Historical
diff_domrequires a recorded forensic session (sessionId from a recording run). compare_extension_statesrequires a real browser + extension (it disables/re-enables the extension and reloads the tab).
WORKFLOW
capture_page_state {}— anchor snapshot:snapshotId, timestamp, url, title, viewport,domLength,domHash(stable hash of the DOM),interactiveCount,extensionEnabled,pendingMutations,annotationCount. Snapshots are capped at 100 per session (oldest pruned).- Perform the action under test (click, mutate, script, wait…).
capture_page_state {}again, thencompare_page_states {}— with no arguments it compares the two most recent snapshots; passsnapshotIdA/snapshotIdBfor explicit pairs. Output:identical, field-levelchanges(url, title, domLength, domHash, interactiveCount, viewport, extensionEnabled, annotationCount),domDeltaand a summary line.- For scripted changes use
execute_js_and_capture_changes {code, timeoutMs, world}— one call returns theJSExecutionResult(outcome state, console output, duration) plus before/afterPageStateSnapshots and the comparison. Prefer this over execute-then-compare when the script is the experiment. - For time-travel questions over a recorded session:
diff_dom {sessionId, t1, t2}— structural tree diff between two timestamps; find the timestamps viaget_timeline/get_events_around, and root-cause disappearances withfind_disappearing_elements/why_did_element_disappear. - For extension-impact questions:
compare_extension_states {extensionId, tabId, waitDurationMs, cleanDomPath, injectedDomPath, cleanScreenshotPath, injectedScreenshotPath, diffOutputPath}— it disables the extension, hard-reloads the tab, captures clean DOM (+optional screenshot), re-enables, reloads again, captures the injected state, then reportsdomSizeDifferenceCharsandinjectedMarkersDetected(known markers: annota, workspace, shadow-root, history-tree, knowledge-hub, codex). list_page_states {}to audit captured snapshot ids, timestamps, urls and sizes.
TOOLS
capture_page_state, compare_page_states, list_page_states, execute_js_and_capture_changes, execute_javascript, diff_dom, compare_extension_states, get_action_timeline, get_operation_trace
EXAMPLES
tools/call capture_page_state {}
tools/call compare_page_states {}
tools/call execute_js_and_capture_changes { "code": "document.querySelector('.banner').remove(); return 'removed';" }
tools/call diff_dom { "sessionId": "sess_abc123", "t1": 1717000000000, "t2": 1717000099000 }
tools/call compare_extension_states { "extensionId": "forensic-recorder@mcpdom", "tabId": 42, "cleanDomPath": "./clean.html", "injectedDomPath": "./injected.html", "diffOutputPath": "./ext-diff.json" }FAILURE MODES
- Snapshot not found — explicit snapshotId typo or the pair was pruned by the 100-cap; use
list_page_statesand re-capture. - SESSION_NOT_FOUND for
diff_dom— no recorded session with that id; start a recording first. - compare_extension_states without a real browser — needs actual extension enable/disable and tab reloads; in Node-only contexts it cannot produce meaningful clean/injected pairs.
- identical: true after an expected change — the change was in an iframe/shadow root not covered by the digest, or the DOM re-rendered back to an equivalent state; fall back to
diff_domor targetedinspect_live_element. - domHash equal but domLength differs — impossible for the same hash function; if you see inconsistency, suspect you compared snapshots from different tabs.
VALIDATION
compare_page_stateslists every changed field with before/after values — read the field list, not justidentical.execute_js_and_capture_changesmust show the JS outcome state AND the comparison; EXECUTED_WITH_ERROR means your script failed — the "change" evidence is then meaningless.- Extension comparison:
domSizeDifferenceCharsshould be ≥ 0 with markers listed; zero delta + no markers = extension injects nothing into that page.
RECOVERY
- Missing before-state: re-capture, re-run the action, re-compare (actions with side effects may not be safely repeatable — prefer recordings for those).
- Noisy diffs from background churn: run
wait_for_dom_stablebefore each capture to reduce race noise. - Extension comparison interrupted: re-enable the extension (
set_extension_enabled {extensionId, enabled: true}) and reload the tab — never leave the extension disabled after a failed run.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

