web_script — Claude Code prompt: what it does, how to install
The web_script Claude Code prompt runs JavaScript to handle several tasks on the current web page. It can read list entries, move through results, or fill multiple fields in one call.
Apache-2.0 ★ 9,488 updated 2026-11-16
.claude/commands/web_script.mdWhat web_script does
The prompt runs an async JavaScript function that reads page data and acts through mika. It can collect visible text and element details, click and type, scroll, navigate, or wait for a text match or a time interval. The return includes the result, logs, and outcomes for each action.
Browser globals such as document, window, and fetch are unavailable; the script has plain JavaScript and mika. Clicks and typing require ref values from the latest mika.snapshot(), and each mika call must be awaited. A navigation that loads another page ends the script. Actions use the same execution and recording path as regular calls, including sending, ordering, deleting, and paying.
What it helps with
- collect text from many list entries
- page through results and read items
- fill several form fields in one call
Example prompts for the agent
- Collect the names and links of every item in the current list.
- Page through the results and gather the text from each entry.
- Fill several form fields with the values from this data.
How to install web_script
Manually: put the files in place
.claude/commands/web_script.mdHow to use
Paste the text at the start of a chat or into project instructions
Questions about web_script
How do I install web_script in Claude Code?
Add the command file at .claude/commands/web_script.md. Then use the prompt for multi-step work on the current web page.
What does web_script do?
It runs JavaScript that reads page data and performs several actions through mika, such as filling fields or moving through result lists.
What are web_script’s limitations?
The script cannot access the DOM or browser globals such as document and fetch. Loading a new page ends execution, and action, read, and time limits use {{max_actions}}, {{max_reads}}, and {{max_seconds}}.
Source text
web_script.md · Apache-2.0
Run a JavaScript program against the current web page to do repetitive multi-step work in one call: read many list items, page through results, fill several fields. Not for a single action: use web_tap/web_type_text for that. code is the body of an async function; return a JSON-serialisable value. The script has no DOM: document, window, location, fetch and every other browser global are undefined; only plain JavaScript (Math, JSON, Array, …) and `mika` are there, and everything mika returns is plain data (always await): mika.snapshot() → {snapshotId, elements:[{ref, role, name, center}]}; mika.read({maxChars, offset}) → page text chunk {text, nextOffset}; mika.queryAll(cssSelector, {fields: ['text','attrs','value','box'], limit, maxChars}) → {items:[{tag, text, attrs, value, box}], total}; mika.query(cssSelector, opts) → first item or null (fields ['count'] → number); mika.text(cssSelector) → visible text (password-like values read as ***); mika.tap(ref); mika.type(ref, text, {enter}); mika.scroll('down'|'up'|'left'|'right', {amount}); mika.navigate(url); mika.wait(ms) or mika.wait({text, timeoutMs}) → true/false; mika.log(...). tap/type use refs from the latest mika.snapshot() in the script. Every action runs through the same execution and recording path as a normal call, including send, post, order, delete and pay. A failed mika call throws an Error whose message starts with the error code. Limits: {{max_actions}} actions, {{max_reads}} reads, {{max_seconds}} s. A navigation that loads a new page ends the script (endedBy=navigation). Returns result (JSON), logs, and actions with each outcome. Call web_observe before acting after it: the page may have changed.
© wangzan101 · Apache-2.0 · wangzan101/Mika