Muggle test feature local

From multiplex-ai/muggle-ai-works · View interactive version

Muggle test feature local is an AI agent skill from the GitHub repository multiplex-ai/muggle-ai-works. Run a real-browser end-to-end (E2E) acceptance test against localhost to verify a feature works correctly — signup flows, checkout, form validation, UI interactions, or any user-facing behavior. Launches a browser that executes test steps and captures screenshots. The browser runs under a real ident

How to use this skill

Skill file

Muggle Test Feature Local

Telemetry first step: see CODE0. Use skillName: "muggle-test-feature-local".

Running outside Claude Code (in Codex, for one)? Read CODE0 first — it maps the tools and paths this skill names to your host's.

Goal: Run or generate an end-to-end test against a local URL using Muggle Test's Electron browser.

| Scope | MCP tools |

| :---- | :-------- |

| Cloud (projects, cases, scripts, auth) | muggle-remote-* |

| Local (Electron run, results — the studio publishes during the run) | muggle-local-* |

| Create new entities (preview / create) | muggle-remote-project-create, muggle-remote-use-case-prompt-preview, muggle-remote-use-case-create-from-prompts, muggle-remote-test-case-generate-from-prompt, muggle-remote-test-case-create |

The local URL only changes where the browser opens; it does not change the remote project or test definitions.

Branch hygiene

Three gates apply, each per the standard procedure in CODE0:

Local environment prerequisites

Before the first run, once every question that run needs is answered (Step 3), invoke CODE0 from the checkout under test. Halt on what it surfaces — a checkout it cannot bring onto the latest base included.

Then read ~/.muggle-ai/e2e-instructions/<key>.md when it exists — this stack's recorded startup order, manual steps, and local gotchas. A gotcha listed there explains a symptom that would otherwise read as a failure. Absent is normal.

UX Guidelines — Minimize Typing

Every selection-based question MUST use the AskUserQuestion tool (or the platform's equivalent structured selection tool). Never ask the user to "reply with a number" in a plain text message — always present clickable options.

Preferences

Gates run per preference-gates/README.md.

| Preference | Step | Decision it gates |

|------------|------|-------------------|

| frontloadQuestions | every step | When the run asks: one up-front batch before the first long-running step, nothing after it (see CODE1) |

| autoLogin | 1 | Reuse saved credentials when auth is required |

| autoSelectProject | 2 | Reuse last-used Muggle Test project for this repo |

| autoSelectLocalHost | 4 | Reuse last-used local dev server URL for this repo |

| autoUseWorktree | 0 (pre-flight) | Isolate dev work in a worktree (see CODE1) |

| autoRebase | 0 (pre-flight) | Rebase onto origin/<default> before Step 7 (Execute) (see CODE2) |

| showElectronBrowser | 7 | Show Electron browser window during local E2E tests |

| openTestResultsAfterRun | 8 | Open results page on Muggle Test dashboard after run |

| postPRVisualWalkthrough | 10 | Post visual walkthrough to PR after results |

| autoCreatePR | 10 (if no PR) | Auto-create the PR when posting the walkthrough has no PR to target |

| autoWatchPR | 10.5 (if a PR exists) | Start a muggle-pr-followup watcher on the PR after the run |

| autoCleanup | post-merge | Run cleanup after the PR for this work is merged (see CODE1) |

Workflow

1. Auth (gated by `autoLogin`)

2. Targets (user must confirm)

The per-repo project cache lives in ~/.muggle-ai/last-project.json, in the entry keyed on <cwd> (via the muggle-local-last-project-get / muggle-local-last-project-set MCP tools). Look for Muggle Test Last Project: id=… url=… name="…" in session context.

Gate autoSelectProject (per preference-gates/README.md). Cache: Muggle Test Last Project session line.

Ask the user to pick project, use case, and test case (do not infer).

Selection UI (mandatory): Every selection MUST use AskUserQuestion with clickable options. Never ask the user to "reply with the number" in plain text.

Project selection context: A project groups all your test results, use cases, and test scripts on the Muggle AI dashboard. Include the project URL in each option label so the user can identify the right one.

Prompt for projects: "Pick the project to group this test into:"

Relevance-first filtering (mandatory for project, use case, and test case lists):

Create new — tools and flow (use these MCP tools; preview before persist):

1. muggle-remote-use-case-prompt-preview with projectId, instruction — show preview; get confirmation via AskUserQuestion.

2. muggle-remote-use-case-create-from-prompts with projectId and instructions: ["<the user's natural-language instruction>"] — persist. Use the created use case id and continue to test-case selection.

1. muggle-remote-test-case-generate-from-prompt with projectId, useCaseId, instruction — preview only (server test-case prompt preview); show the returned draft(s); get confirmation via AskUserQuestion.

2. Persist the accepted draft with muggle-remote-test-case-create, mapping preview fields into the required properties (title, description, goal, expectedResult, url, etc.). Then continue from section 5 with that testCaseId.

3. Ensure Local Services Are Ready

Ask first. Prepare's grant holds ports other sessions wait for, and its lease ends four minutes after the services come up with no run. So before invoking it, resolve every question asked on the way to the first run: Step 4's URL gate, Step 5's script choice (applied after Step 4a), and Step 7's showElectronBrowser gate. From prepare to the first execute call, ask nothing. Under frontloadQuestions=always — the default, so also when the key is absent — add to this batch every later gate that resolves to ask: Step 8's openTestResultsAfterRun, Step 10's postPRVisualWalkthrough and autoCreatePR, Step 10.5's autoWatchPR. Ask each one's Picker 1 here, never default it; nothing is asked after the first execute call.

Then invoke the muggle:muggle-test-prepare skill via the Skill tool from the checkout under test — every run, even when services look up. Live PIDs prove nothing about which code they serve: prepare syncs this checkout onto the latest base, starts sibling services from base checkouts on the latest default branch, and keeps a running service only when it still serves the right commit. It fast-exits when everything is proven. Once it reports ready, check its readiness table: this checkout's services must show this checkout as their Source at its current HEAD. Then proceed to Step 4.

This step is especially important when the user's app depends on sibling services (a backend API, an auth service, etc.) that may not be running yet. The prepare skill handles discovery, startup, and cleanup so this skill doesn't have to.

Compile-gate (do not skip) — after muggle-test-prepare reports ready, run the two-stage readiness probe per CODE1 before dispatching any test. Halt on any failure it surfaces; do not dispatch against a broken bundle.

4. Local URL (gated by `autoSelectLocalHost`)

Skill responsibilities (the rest is in preference-gates/autoSelectLocalHost.md):

Gate autoSelectLocalHost per preference-gates/README.md + preference-gates/autoSelectLocalHost.md.

Remind them: local URL is only the execution target, not tied to cloud project config.

4a. Satisfy the test case chain (prerequisite parents)

Before deciding the target's script, resolve its prerequisite chain from the backend test-plan graph and ensure every ancestor already has a ready script — generating any that don't, test-generation only, root-first. Follow CODE0.

muggle-remote-test-case-ancestors-get returns the chain; an orphan test case has no prerequisites — skip straight to Step 5. Do not infer parents from precondition text; the graph is authoritative.

5. Existing scripts vs new generation

muggle-remote-test-script-list with testCaseId and runEnvironmentType: "local" — this skill always replays against localhost, so resolve the local-lane script (the remote-lane script carries the deployed URL).

A test case whose local lane has records runs once per record (CODE0), so the pick sets only the mode: a script means replay, which replays each record's own script, and "Generate new script" means regen.

6. Load data for the chosen path

Run the shared loop in CODE0: one run per record, CODE1, replay vs regen, CODE2 as-is, CODE3, and failure interpretation.

Caller glue: mode is the path chosen in §5; localUrl from §4; cwd = the repo root, or the prepared worktree when one is in use.

7. Execute (`showUi` gated by `showElectronBrowser`)

Resolve the showElectronBrowser gate first, then call muggle-local-execute-test-generation or muggle-local-execute-replay. Do not ask the user to re-approve the Electron launch itself — choosing this skill is the approval. That run-approval suppression does not extend to the gate below: when showElectronBrowser=ask you must still fire its picker.

Gate showElectronBrowser (per preference-gates/README.md). Reuse the choice within a session. The runner shows the browser by default, so treat showUi as a hide switch — include it only to turn the browser off:

So the execute call carries no showUi key for always, or showUi: false for never — never showUi: true.

8. Open the run on the dashboard (`viewUrl` gated by `openTestResultsAfterRun`)

The studio publishes every completed run — pass or fail — to the cloud during execution, so the run result already carries the cloud refs. Failed runs are published too, so reviewers get the per-step screenshots, not just a generic "failed" link.

9. Report

Read the run record per CODE0 and failure interpretation — never diagnose from execute's stdout tail.

9a. Route a failed run through the debug path

If the run's status is failed or any non-passing terminal state, route through CODE1 — mandatory; a failure is never reported without it. It gathers evidence (attempted steps + reasoning + screenshot), diagnoses via CODE2 (§B replay / §C regen), shows the debug card, and presents the guaranteed selection in which "give feedback & rerun" is always offered and "skip" is never the default.

Pass it: the runId, the mode that failed (replay if the user picked an existing script in Step 5, else regen), testCaseId, projectId, and the local execution handle so a rerun re-enters the same path.

Skip only when the run passed cleanly — the debug path is by definition about failures.

This step is not an exit. Whatever the user picks — feedback, rerun, or skip — control returns to the reporting and walkthrough steps. A failed run is the highest-value walkthrough: a reviewer needs the screenshots of what broke far more than confirmation that a passing flow passed. Ending the turn inside this step with results unposted is what the walkthrough Stop gate blocks.

9b. Remind the user to guide the agent (every Electron invocation)

Fires after every Electron run, pass or fail. A run can technically pass while still containing steps the user would correct — a misclick, wrong element, or a summary that doesn't match intent. This is the user's chance to flag it before regeneration picks up elsewhere.

Skip if 9a already routed the user into muggle-feedback for this run. Under frontloadQuestions=always, print the question below as a report line with its path — /muggle-feedback <runId> — instead of asking. Otherwise ask via AskUserQuestion:

"Did the agent miss or do anything wrong on this run? Your feedback regenerates the affected scripts."

Non-blocking — one click to dismiss. Do not re-ask for the same runId within a session.

10. Offer to post a visual walkthrough to the PR

After reporting results:

  1. Fire CODE0. On skip → 10.5.
  2. gh pr view --json number,title,url 2>/dev/null — find the PR.
  3. If no PR: fire CODE0. On skip → 10.5.
  4. Assemble the E2eReport — see CODE1.
  5. Invoke CODE0 Mode A with the E2eReport.

10.5. Offer to watch the PR for review follow-ups

Once a PR exists for this work, offer to keep watching its review thread.

  1. Identify the PR — reuse the gh pr view --json number,title,url result from section 10 if available, else run it now. No PR (none exists, none created) → end.
  2. Fire CODE0 with {pr} = <owner>/<repo>#<number>. On skip → end.
  3. On proceed: start the watcher reusing this run's context so it never re-prompts —

The /mprfollowup shortcut starts the same watcher manually at any time.

Non-negotiables

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.