dom-targeting
Skill10 starsChanged 2 months agoApache-2.0View on GitHub
Build resilient multi-strategy TARGET objects (ranked selector candidates, fingerprints, confidence) for elements you intend to store, share, or act on.
In this repository16 other files it gives its agents.
- browser-forensicsSkill
- browser-interactionSkill
- browser-state-recoverySkill
- dom-inspectionSkill
- dom-mutationSkill
- extension-troubleshootingSkill
- human-like-interactionSkill
- mcp-troubleshootingSkill
- page-annotationSkill
- project-captureSkill
- project-reconstructionSkill
- regression-testingSkill
- selector-recoverySkill
- tab-managementSkill
- viewport-testingSkill
- visual-dom-comparisonSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Before storing an element reference anywhere (project region, spec, recording, handoff to another agent).
- Distinctive: line 14
When a raw CSS selector keeps breaking across page states.
- Very specific: line 15
After search_dom / element-picker selection, to convert a one-off hit into a durable identity.
- Distinctive: line 16
Before destructive actions, to know the confidence and volatility you are standing on.
- Very specific: line 28
Read overall confidence: 60% best-selector confidence + up to 0.3 for low fingerprint volatility (+0.15 medium) + 0.1 if a unique ≥0.9 …
- Very specific: line 58
If generate_element_target fails, re-find the element with search_dom and retry with the found selector.
- Very specific: line 59
If a previously built TARGET stops resolving, switch to the selector-recovery skill (recover_selector + snapshot).
- Distinctive: line 60
Never invent a selector you have not resolved — re-target, don't guess.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: DOM Targeting
PURPOSE
Produce the canonical TARGET object for an element so that later lookups survive re-renders, framework churn and navigation. Targeting is the contract between inspection and action: every interaction, mutation, region annotation and reconstruction spec consumes TARGETs.
WHEN TO USE
- Before storing an element reference anywhere (project region, spec, recording, handoff to another agent).
- When a raw CSS selector keeps breaking across page states.
- After
search_dom/ element-picker selection, to convert a one-off hit into a durable identity. - Before destructive actions, to know the confidence and volatility you are standing on.
- Building multi-step automation where one broken reference mid-flow would waste the whole run — target first, then act.
- Handing an element to another agent or session: a raw selector is a guess, a TARGET is evidence.
PREREQUISITES
- MCP server running; live page reachable via the extension or the Node simulation context (JSDOM fixture, results marked
simulated: true). - A way to reference the element: selector, xpath, nodeId,
selectedElementRef(from the picker) or coordinates.
WORKFLOW
generate_element_target {target|selector}— resolve the element and build the TARGET:targetId,tag,role,selector,selectorCandidates[],xpath,domPath,textFingerprint,attributeFingerprint,structuralFingerprint,attributes,confidencein [0,1],bounds,resolvedFrom.- Inspect
selectorCandidates— ranked by confidence, each withstrategy,unique,reasons:id(1.0) →semantic-attributee.g. data-testid/aria/name (0.92) →classfrom stable classes (0.72) →attribute-fingerprintcombos (0.68) →text-derived-xpath(0.6) →structural-pathnth-of-type (0.55).
- Read overall
confidence: 60% best-selector confidence + up to 0.3 for low fingerprint volatility (+0.15 medium) + 0.1 if a unique ≥0.9 candidate exists. - Cross-check volatility with
get_element_fingerprint—volatilityRisklow/medium/high withvolatilityReasons(hashed utility classes, dynamic text, custom elements, no stable identity attribute are the usual suspects). - Persist the TARGET snapshot (region annotation or your own store); keep
structuralFingerprint,stableAttributes, text and parentSelector — they are the raw material forrecover_selector. - Resolution is deterministic:
selector→xpath→nodeId(registry) →coordinates; a multi-match selector is disambiguated to the first visible match and reported asresolvedFrom: "selector+disambiguated".
TOOLS
generate_element_target, get_element_fingerprint, search_dom, inspect_live_element, get_element_ancestry, recover_selector
EXAMPLES
tools/call generate_element_target { "selector": "button[data-testid='submit']" }
tools/call generate_element_target { "target": { "xpath": "//button[contains(text(), 'Sign in')]" } }
tools/call get_element_fingerprint { "selector": "#checkout-cta" }FAILURE MODES
- TARGET_NOT_FOUND — no strategy resolved: element removed, re-rendered mid-flight, inside a closed shadow root, or in a cross-origin frame. Check with
inspect_live_pagethat the page you think is loaded is loaded. - TARGET_INVALID — selector throws at parse time (typo, unescaped characters).
- TARGET_INVALID_XPATH — xpath engine rejected the expression.
- Low confidence (<0.5) — element is volatility-heavy (CSS-module hashes, generated ids); do not treat a structural-path candidate as durable.
- Multi-match selector auto-disambiguation — several matches resolved to the first visible one; fine for a one-off click, dangerous for stored references — tighten the selector instead.
VALIDATION
confidence≥ 0.7 with aunique: truecandidate is a durable TARGET; below 0.6 expect churn and plan for recovery.selectorCandidatesshould contain ≥ 3 distinct strategies for anything you intend to reuse.resolvedFromtells you which strategy actually resolved — if it fell through tocoordinates, the selector/xpath are already stale.- Volatility
highwith reasons like "all classes are framework-generated" is a predictor: plan the recovery workflow now, before the next re-render. boundsin the TARGET should matchinspect_live_elementbounds — a mismatch means the page re-rendered between the two calls.
RECOVERY
- If
generate_element_targetfails, re-find the element withsearch_domand retry with the found selector. - If a previously built TARGET stops resolving, switch to the selector-recovery skill (
recover_selector+ snapshot). - Never invent a selector you have not resolved — re-target, don't guess.
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.

