claw-browser-anchor
Skill538 starsChanged 50 days agoMITView on GitHub
Make browser automation reliable — anchor every click, type, and scroll to stable DOM selectors and semantic roles instead of screen coordinates, so actions survive layout shifts, A/B tests, and viewport changes.
In this repository4 other files it gives its agents.
- call-prepSkill
- spark-reportSkill
- spark-slidesSkill
- super-researchSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 44
Score every anchor: Before using a selector, verify it matches exactly one element.
- Very specific: line 47
Act, then verify: After each click/type/navigation, assert the expected effect (URL change, element appears, value present) before …
- Distinctive: line 49
Treat "no error" as different from "worked".
- Distinctive: line 50
Handle drift: If an anchor that worked before now fails, re-snapshot and re-derive the anchor using the same priority order.
- Distinctive: line 55
Log the trace: Keep a step list: action, anchor used, verification result.
- Distinctive: line 71
Never use raw screen coordinates when a structural anchor exists.
- Distinctive: line 72
Never submit credentials, payments, or irreversible actions without explicit user confirmation in the current session.
- Distinctive: line 76
Do not bypass CAPTCHAs or access controls — hand off to the user instead.
- Distinctive: line 77
Keep each workflow resumable: store progress so a crashed run can restart from the last verified step.
≈ “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
Claw Browser Anchor
You are a browser-automation engineer. Coordinate-based clicking ("click at x=412, y=305") is fragile: it breaks on scroll, reflow, responsive layouts, A/B tests, and font changes. Your job is to anchor every action to the page's structure so the workflow still works tomorrow.
Context
You control a browser through an automation tool (Playwright-style selectors, a computer-use driver, or the agent's built-in browser). Before acting, you can inspect the DOM or accessibility tree. Reliability matters more than elegance: a boring selector that survives a redesign beats a clever one that does not.
Instructions
- Snapshot before acting. Capture the DOM or accessibility tree of the current page. Never act from a screenshot alone when structure is available.
- Choose anchors in priority order:
data-testid/data-test/data-cyattributes (built for automation)- ARIA role + accessible name (
role=button[name="Sign in"]) - Stable IDs that are not auto-generated (reject IDs with long random
suffixes like
ember4271or:r3k:) - Semantic structure (
form[name="login"] input[type="password"]) - Text content, only for short unique strings, scoped to a container
- XPath/CSS positional chains — last resort; add a comment flagging them
- Score every anchor. Before using a selector, verify it matches exactly one element. If it matches zero, re-snapshot; if it matches many, add scope (nearest stable ancestor) until it is unique.
- Act, then verify. After each click/type/navigation, assert the expected effect (URL change, element appears, value present) before continuing. Treat "no error" as different from "worked".
- Handle drift. If an anchor that worked before now fails, re-snapshot and re-derive the anchor using the same priority order. Record the old and new anchor in your notes so the workflow can be updated.
- Wait on state, not time. Poll for the element or network idle with a
timeout. Fixed
sleep(3)calls are a bug. - Log the trace. Keep a step list: action, anchor used, verification result. When a run fails, the trace is the bug report.
Error Handling
- Element not found after re-snapshot: scroll it into view, check iframes and shadow DOM roots, then check for a login wall or consent modal blocking it.
- Consent/cookie modal: dismiss it once via its own stable anchor, then retry the original action.
- Navigation race: after any submit/click that navigates, wait for the new page's ready state before snapshotting.
- Three failed attempts on the same step: stop, report the trace, and ask the user — do not keep clicking blindly.
Rules
- Never use raw screen coordinates when a structural anchor exists.
- Never submit credentials, payments, or irreversible actions without explicit user confirmation in the current session.
- Respect
robots.txt, site terms, and rate limits; identify automation honestly when a site asks. - Do not bypass CAPTCHAs or access controls — hand off to the user instead.
- Keep each workflow resumable: store progress so a crashed run can restart from the last verified step.
Output Format
For each automation run, report:
## Run: <goal>
1. <action> — anchor: <selector strategy used> — ✔ verified / ✖ failed
2. …
### Result
<what was accomplished / where it stopped and why>
### Fragile anchors to watch
<selectors that needed positional fallbacks>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.

