/muggle:muggle-test-importfrom muggle
Migrates existing test artifacts (Playwright, Cypress, Gherkin, PRDs, Notion/Confluence exports) into Muggle Test by reading source files, structuring them into use/test cases, and creating them via the API.
Ships in muggle. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Telemetry first step: see
_shared/telemetry-emit.md. UseskillName: "muggle-test-import".
Running outside Claude Code (in Codex, for one)? Read
../_shared/host-tool-equivalents.mdfirst — it maps the tools and paths this skill names to your host's.
This skill migrates existing test artifacts into Muggle Test. It reads your source files, structures them into use cases and test cases, gets your approval, then creates everything in a Muggle Test project via the API.
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 frontloadQuestions.md) |
autoLogin | 4 | Reuse saved credentials when auth is required |
autoSelectProject | 5 | Reuse last-used Muggle Test project for this repo |
suggestRelatedUseCases | 8a | Suggest related use cases after import |
suggestRelatedTestCases | 8b | Suggest related test cases after import |
Ask the user which files to analyse. Accept glob patterns, directory paths, or individual files. Common sources:
| Source type | Typical patterns |
|---|---|
| Playwright | **/*.spec.ts, **/*.test.ts, e2e/** |
| Cypress | **/*.cy.js, **/*.cy.ts, cypress/integration/** |
| PRD / design doc | *.md, *.txt, docs/** |
| Other | Any file the user points to |
If the user is vague, scan the current directory for test file patterns and show what you found.
Also ask for the base URL of the app under test if it is not embedded in the source files — you will need it for every test case.
Confirm the final file list before reading.
The extraction strategy depends on the file type. Choose the right path before reading.
Muggle Test has a native PRD processing workflow that extracts use cases more accurately than
manual parsing. Use this path for .md, .txt, .pdf, or any prose document.
After authentication and project selection (Steps 4–5), come back and:
muggle-remote-prd-file-upload with the encoded content and filenamemuggle-remote-workflow-start-prd-file-process using the fields returned by the upload
(prdFilePath, contentChecksum, fileSize) plus the project URLmuggle-remote-wf-get-prd-process-latest-run until the status is completemuggle-remote-use-case-list to retrieve the created use cases and
their IDs — then skip Step 6 Pass 1 (use cases are already created) and go straight to
creating any additional test cases if neededNote: base64-encode in-memory using a Bash one-liner or Python — do not modify the file.
If the native workflow fails or the document is in a format it cannot parse, fall back to Path B (manual extraction).
Read each file and extract a use case → test case hierarchy manually.
describe() / test.describe() block → use case nameit() / test() block → test casepage.goto('...') calls for the URLgoal and expectedResult from assertion text and commentsdescribe() groupinggoal or expectedResult blank — infer them from contextHIGH for critical paths and error handling, MEDIUM for secondary flows, LOW for edge casesBuild an internal model before presenting anything to the user (Path B only):
Use Case: <Name>
- TC1: <title> | goal | expectedResult | precondition | priority | url
- TC2: ...
Present the extracted structure clearly. Example format:
Found 3 use cases with 8 test cases:
1. User Authentication (3 test cases)
✦ [HIGH] Login with valid credentials
✦ [HIGH] Login with wrong password shows error
✦ [MEDIUM] Forgot password flow sends reset email
2. Shopping Cart (3 test cases)
✦ [HIGH] Add item to cart
✦ [MEDIUM] Remove item from cart
✦ [LOW] Cart persists after page reload
3. Checkout (2 test cases)
✦ [HIGH] Complete checkout with credit card
✦ [HIGH] Checkout fails with invalid payment info
Use AskUserQuestion to confirm:
If the user wants changes, incorporate feedback, then ask again. Only proceed after explicit approval.
For Path A (native PRD upload): present the use case/test case list that Muggle Test extracted after the processing workflow completes, and ask the user to confirm before adding any extra test cases manually.
autoLogin)Call muggle-remote-auth-status first.
If already authenticated → gate autoLogin (per preference-gates/README.md):
always → skip to Step 5.never → muggle-remote-auth-login with forceNewSession: true, then muggle-remote-auth-poll.ask → run Picker 1 from preference-gates/autoLogin.md via AskUserQuestion; map the answer back to one of the actions above.If not authenticated:
muggle-remote-auth-login (opens browser automatically).muggle-remote-auth-poll to wait for completion.autoSelectProject)A project is where all your imported use cases, test cases, and future test results are grouped on the Muggle AI dashboard.
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.
always + cache → use cached projectId, skip to Step 6. No cache → fall through to ask.never → full project list; skip Picker 2.ask → project list picker (see gate file for spec + Picker 2 override). Skip Picker 2 if "Create new project".Call muggle-remote-project-list (only when not satisfied by the always cache).
Use AskUserQuestion to present all projects as clickable options. Include the project URL in each label. Always include a "Create new project" option at the end.
Prompt: "Pick the project to import into:"
If creating a new project, propose values based on what you learned from the source files:
Show the proposal and confirm before calling muggle-remote-project-create.
Import in two passes using bulk-preview. Show progress to the user as you go.
Both passes use Muggle Test's async bulk-preview MCP tools, which route prompts through OpenAI's Batch API for roughly ~50% of normal LLM cost. The flow is always: submit → poll → persist.
If the source is a PRD or design document, use Muggle Test's built-in processing pipeline:
base64 -i /path/to/doc.md
muggle-remote-prd-file-upload:
projectId: <chosen project ID>
fileName: "checkout-prd.md"
contentBase64: "<base64 string>"
contentType: "text/markdown"
muggle-remote-workflow-start-prd-file-process using all fields returned by the upload:
projectId: <project ID>
name: "Import from checkout-prd.md"
description: "Auto-extract use cases from PRD"
prdFilePath: <from upload response>
originalFileName: "checkout-prd.md"
url: <app base URL>
contentChecksum: <from upload response>
fileSize: <from upload response>
muggle-remote-wf-get-prd-process-latest-run every 5 seconds until status is complete.muggle-remote-use-case-list to retrieve the created use cases and their IDs.If the upload or processing fails, fall back to Path B manual extraction.
Run both passes below for Playwright, Cypress, or other test scripts.
instruction.The bulk-preview submit and get/cancel MCP tools surface structured error codes — look for these on any tool result and act accordingly:
| Error code / symptom | What happened | What to do |
|---|---|---|
TOO_MANY_IN_FLIGHT_JOBS (HTTP 429) | Already 3 in-flight jobs for this project | Tell the user: "There are already 3 bulk-preview jobs in progress for this project. Wait for them to finish, then retry." Stop. |
NOT_FOUND on submit (HTTP 404) | Project or parent use case does not exist, or this server version doesn't expose bulk-preview yet | Tell the user which — double-check the IDs you passed. If you're confident the IDs are right, ask the user to make sure the prompt-service is up to date. Stop. |
VALIDATION_ERROR (HTTP 400) | A prompt exceeds limits (e.g. >4000 chars) or the prompt list is empty | Fix the offending prompts and retry. |
| Payload > 1 MB (HTTP 413) | Body too large | Split into smaller batches. |
After a successful submit, poll with muggle-remote-bulk-preview-job-get (inputs: projectId,
jobId) every 15 seconds. Show progress like:
Generating previews for "User Authentication"... (status: running, elapsed: 30s)
status values and what to do:
| Status | Terminal? | Action |
|---|---|---|
queued | No | Keep polling |
submitted | No | Keep polling |
running | No | Keep polling |
succeeded | Yes | All prompts processed — proceed to persist results |
partial | Yes | Some prompts succeeded — show summary, ask user whether to proceed |
failed | Yes | Job failed entirely — show error.message and stop |
cancelled | Yes | Job was cancelled — stop |
expired | Yes | Job expired before completing — tell user to retry |
If status is partial, show:
Preview completed with partial results: <N> of <promptCount> generated successfully.
Failed items:
- [<clientRef>] "<source text>": <error message>
Proceed with the <N> successful items, or cancel to review?
Use AskUserQuestion with options "Proceed with successful items" / "Cancel import". Only continue
if the user chooses to proceed.
If you need to abort an in-flight job, call muggle-remote-bulk-preview-job-cancel — the
server picks up the request cooperatively within one harvester tick.
Call muggle-remote-use-case-bulk-preview-submit with one prompt per use case:
projectId: <chosen project ID>
prompts: [
{ clientRef: "uc-0", instruction: "<Use case name> — <one-sentence description>" },
...
]
The call returns { jobId, status, kind, promptCount }.
Run the Shared polling loop above until the job reaches a terminal status.
For each successful result (shape: { clientRef, index, status: "success", useCase: IUseCaseCreationRequest }),
call muggle-remote-use-case-create to persist it — no LLM is invoked, so this is fast and free:
projectId: <project ID>
title: <from useCase.title>
description: <from useCase.description>
userStory: <from useCase.userStory>
url: <from useCase.url> # optional
useCaseBreakdown: <from useCase.useCaseBreakdown>
status: <from useCase.status> # e.g. DRAFT
priority: <from useCase.priority> # e.g. MEDIUM
source: <from useCase.source> # e.g. PROMPT
category: <from useCase.category> # optional
Collect the returned useCaseId of each created use case — you'll need it for Pass 2.
It is safe to persist use cases in parallel once the job is terminal.
For each use case, run a bulk-preview job to generate its test cases.
Call muggle-remote-test-case-bulk-preview-submit:
projectId: <project ID>
useCaseId: <use case ID>
prompts: [
{
clientRef: "tc-0",
instruction: "<title> | goal: <goal> | expectedResult: <expectedResult> | precondition: <precondition> | priority: <HIGH|MEDIUM|LOW> | url: <url>"
},
...
]
Run the Shared polling loop above until the job reaches a terminal status.
Each successful result has this shape (note the fan-out):
{ "clientRef": "tc-0", "index": 0, "status": "success", "testCases": [ /* ITestCaseCreationRequest[] — fan-out 1–5 */ ] }
One input prompt may produce 1–5 test case items. For each item in result.testCases, call
muggle-remote-test-case-create:
projectId: <project ID>
useCaseId: <use case ID>
title: <from testCase.title>
description: <from testCase.description>
goal: <from testCase.goal>
expectedResult: <from testCase.expectedResult>
precondition: <from testCase.precondition>
priority: <from testCase.priority>
url: <from testCase.url>
Anything the source says a test must or must not touch stays in description; add it if the preview dropped it (limits).
Print progress: Creating test cases for "User Authentication"... (1/3)
It is safe to create test cases for different use cases in parallel once their bulk-preview jobs have reached a terminal status. However, submit bulk-preview jobs sequentially to avoid exceeding the 3 in-flight job cap per project.
When all imports are done, print a clean summary. Include:
The link is the dashboardUrl field the create calls return (muggle-remote-use-case-create / muggle-remote-test-case-create), already resolved against the dashboard of the lane the MCP runs on. Never write a dashboard host yourself — a production URL is a dead link for a staging user.
Example:
✅ Import complete!
Project: Acme App
→ {dashboardUrl}
Source: e2e/auth.spec.ts, e2e/cart.spec.ts
Imported: 3 use cases · 8 test cases
1. User Authentication (3 test cases)
2. Shopping Cart (3 test cases)
3. Checkout (2 test cases)
Next step: run /muggle:do to generate executable browser test scripts for these test cases.
Two preferences gate optional follow-ups: suggestRelatedUseCases and suggestRelatedTestCases. Both are independent — handle each in turn.
suggestRelatedUseCases)The query is: "from the use cases already in this project, which ones are not in the import set but look related to it?" — surface them so the user can decide whether their import missed something the project already tracks.
Gate suggestRelatedUseCases (per preference-gates/README.md):
always → run the query below.never → skip.ask → run Picker 1 from preference-gates/suggestRelatedUseCases.md via AskUserQuestion; map the answer back to one of the actions above.When running the query:
muggle-remote-use-case-list for the project.useCaseId is in the set you just imported in Step 6 (Pass 1).AskUserQuestion with allow_multiple: true. Label each with <title> — <one-line description>.muggle-remote-test-case-bulk-preview-submit → poll → persist via muggle-remote-test-case-create).suggestRelatedTestCases)For each use case the user just created, surface other test cases already attached that the import didn't add — same idea, scoped to a single use case.
Gate suggestRelatedTestCases (per preference-gates/README.md):
always → run the query below.never → skip.ask → run Picker 1 from preference-gates/suggestRelatedTestCases.md via AskUserQuestion; map the answer back to one of the actions above.When running the query, for each use case in the import:
muggle-remote-test-case-list-by-use-case with that useCaseId.AskUserQuestion with allow_multiple: true, labeled [<priority>] <title> — <goal>.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
48 skills in this plugin
/mExplicit short alias for the `muggle` skill (router/menu). ONLY invoke when the user explicitly types `m` or `/m` — never auto-trigger from any other phrasing./mbtExplicit short alias for the `muggle-browser-task` skill. ONLY invoke when the user explicitly types `mbt` or `/mbt` — never auto-trigger from any other phrasing./mbugreportExplicit short alias for the `muggle-bug-report` skill. ONLY invoke when the user explicitly types `mbugreport` or `/mbugreport` — never auto-trigger from any other phrasing./mciExplicit short alias for the `muggle-ci-install` skill. ONLY invoke when the user explicitly types `mci` or `/mci` — never auto-trigger from any other phrasing.npx claudepluginhub multiplex-ai/muggle-ai-works --plugin muggleaiOther plugins' skills for the same job