vitexec
Use vitexec when the truth lives in the running browser: client state, imported app modules, DOM, canvas/WebGL, screenshots, recordings, or browser-only errors.
Do not use it for questions static files, unit tests, or TypeScript can answer directly.
References
- For mouse, keyboard, or pointer lock, read references/inputs.md.
- For CPU, network, performance timeline, or heap analysis, read references/performance.md.
- For WebXR, read references/webxr.md.
Workflow
- Identify the page path if it is not
/.
- Write the smallest snippet that performs the user-like action or reads the browser-only state.
- Run
vitexec '<snippet>' or vitexec check.ts for ./vitexec/check.ts, adding --path, --gpu, --screenshot, --record, --cpu-profile, --network-trace, --performance-trace, --heap-snapshot, --timeout, or --config only when needed.
- Treat stdout as browser logs. It starts with
logs:.
If vitexec itself is missing, install vitexec with the package manager already used by the project.
vitexec 'console.log("ready")'
vitexec check-scene.ts
For one argument, the CLI checks the path as written, then checks it below
./vitexec, then treats it as inline code.
For structured state, log JSON:
vitexec --path /cart '
import { mouse } from "vitexec";
import { useCartStore } from "/src/store/cart.ts";
const button = document.querySelector("[data-testid=add-to-cart]");
if (!(button instanceof HTMLElement)) throw new Error("Add button not found");
const box = button.getBoundingClientRect();
await mouse.moveTo(box.x + box.width / 2, box.y + box.height / 2);
await mouse.click();
await new Promise((resolve) => requestAnimationFrame(resolve));
console.log("cart", JSON.stringify(useCartStore.getState()));
'
Guidance
- Prefer importing exported app state over scraping DOM when state is available.
- Use direct state reads for observation and assertions, not to bypass user interaction.
- Use
mouse and keyboard from vitexec for physical input; do not substitute synthetic DOM events.
--timeout covers boot, physical input, and script time; budget wall time, not only application time.
- Use live progress logs and focused assertions to early-exit on failures and see current progress.
- Keep logs concise; overly verbose logs become unreadable and unnecessarily fill the context.
- Prefer browser-root imports such as
/src/store.ts, not local filesystem paths.
- Use
--gpu for WebGL, canvas, Three.js, and WebXR behavior.
- If the local machine has no usable GPU, use
--gpu --browser-ws-endpoint <ws-url> to connect to a remote Playwright server that was started with the right host-specific GPU settings.
- If repeated runs need the same endpoint or artifact settings, prefer
VITEXEC_* environment variables over repeating long flags.
- Use screenshots or recordings only when visual evidence matters.
- Do not leave temporary code in the app when
vitexec can inspect it from outside.
Project integration
A Vite app can add vitexec() from the vitexec package. The plugin maps each
top-level module in ./vitexec to a page with the same name:
import { vitexec } from "vitexec";
export default {
plugins: [vitexec()]
};
vitexec/smoke.ts → /smoke.html
The mapping works in the Vite dev server and in vite build. Each generated page
loads the normal index.html and then its vitexec script. Multiple vitexec()
declarations are safe and deduplicated; conflicting page mappings fail clearly.
Reading a screenshot as proof
A screenshot is only proof if you read it critically — "something rendered" is not "it works and looks right". When the evidence is a screenshot or clip, look at it for tells of unfinished work and treat any you find as a defect to fix, not as proof of done:
- A character standing in a T-pose (or not animating) — its rig/animation isn't driving the model.
- Flat solid-color boxes/planes standing in for real objects — placeholder geometry that needs a real asset or material.
- Untextured surfaces (a flat-color ground, gray "clay") — missing materials.
- Objects that float with no contact shadow — missing shadows or grounding.
- A flat, raw render with no finishing pass.
Pair the picture with state assertions: confirm the player-visible outcome from real app state (the count changed, the entity was removed, the animation state advanced), not just that the frame drew.
1---2name: vitexec3description: Use this skill when an AI agent needs to inspect, verify, debug, profile, or play through a live Vite app by running temporary scripts against the browser page and reading browser logs or captured artifacts. Use for client state after interactions, imported app modules, DOM state, human-like input, canvas/WebGL/Three.js state, screenshots, videos, CPU/network/performance/heap analysis, WebXR/Three.js XR with IWER, and runtime-only behavior without editing app files.4---56# vitexec78Use `vitexec` when the truth lives in the running browser: client state, imported app modules, DOM, canvas/WebGL, screenshots, recordings, or browser-only errors.910Do not use it for questions static files, unit tests, or TypeScript can answer directly.1112## References1314- For mouse, keyboard, or pointer lock, read [references/inputs.md](references/inputs.md).15- For CPU, network, performance timeline, or heap analysis, read [references/performance.md](references/performance.md).16- For WebXR, read [references/webxr.md](references/webxr.md).1718## Workflow19201. Identify the page path if it is not `/`.212. Write the smallest snippet that performs the user-like action or reads the browser-only state.223. Run `vitexec '<snippet>'` or `vitexec check.ts` for `./vitexec/check.ts`, adding `--path`, `--gpu`, `--screenshot`, `--record`, `--cpu-profile`, `--network-trace`, `--performance-trace`, `--heap-snapshot`, `--timeout`, or `--config` only when needed.234. Treat stdout as browser logs. It starts with `logs:`.2425If `vitexec` itself is missing, install `vitexec` with the package manager already used by the project.2627```sh28vitexec 'console.log("ready")'29vitexec check-scene.ts30```3132For one argument, the CLI checks the path as written, then checks it below33`./vitexec`, then treats it as inline code.3435For structured state, log JSON:3637```sh38vitexec --path /cart '39 import { mouse } from "vitexec";40 import { useCartStore } from "/src/store/cart.ts";4142 const button = document.querySelector("[data-testid=add-to-cart]");43 if (!(button instanceof HTMLElement)) throw new Error("Add button not found");44 const box = button.getBoundingClientRect();45 await mouse.moveTo(box.x + box.width / 2, box.y + box.height / 2);46 await mouse.click();47 await new Promise((resolve) => requestAnimationFrame(resolve));48 console.log("cart", JSON.stringify(useCartStore.getState()));49'50```5152## Guidance5354- Prefer importing exported app state over scraping DOM when state is available.55- Use direct state reads for observation and assertions, not to bypass user interaction.56- Use `mouse` and `keyboard` from `vitexec` for physical input; do not substitute synthetic DOM events.57- `--timeout` covers boot, physical input, and script time; budget wall time, not only application time.58- Use live progress logs and focused assertions to early-exit on failures and see current progress.59- Keep logs concise; overly verbose logs become unreadable and unnecessarily fill the context.60- Prefer browser-root imports such as `/src/store.ts`, not local filesystem paths.61- Use `--gpu` for WebGL, canvas, Three.js, and WebXR behavior.62- If the local machine has no usable GPU, use `--gpu --browser-ws-endpoint <ws-url>` to connect to a remote Playwright server that was started with the right host-specific GPU settings.63- If repeated runs need the same endpoint or artifact settings, prefer `VITEXEC_*` environment variables over repeating long flags.64- Use screenshots or recordings only when visual evidence matters.65- Do not leave temporary code in the app when `vitexec` can inspect it from outside.6667## Project integration6869A Vite app can add `vitexec()` from the `vitexec` package. The plugin maps each70top-level module in `./vitexec` to a page with the same name:7172```ts73import { vitexec } from "vitexec";7475export default {76 plugins: [vitexec()]77};78```7980```txt81vitexec/smoke.ts → /smoke.html82```8384The mapping works in the Vite dev server and in `vite build`. Each generated page85loads the normal `index.html` and then its vitexec script. Multiple `vitexec()`86declarations are safe and deduplicated; conflicting page mappings fail clearly.8788## Reading a screenshot as proof8990A screenshot is only proof if you read it critically — "something rendered" is not "it works and looks right". When the evidence is a screenshot or clip, look at it for tells of unfinished work and treat any you find as a defect to fix, not as proof of done:9192- A character standing in a **T-pose** (or not animating) — its rig/animation isn't driving the model.93- **Flat solid-color boxes/planes** standing in for real objects — placeholder geometry that needs a real asset or material.94- **Untextured surfaces** (a flat-color ground, gray "clay") — missing materials.95- Objects that **float** with no contact shadow — missing shadows or grounding.96- A **flat, raw render** with no finishing pass.9798Pair the picture with state assertions: confirm the player-visible *outcome* from real app state (the count changed, the entity was removed, the animation state advanced), not just that the frame drew.