From momentic-ai-skills-1
Create and maintain Momentic browser E2E tests via MCP tools for new tests, smoke tests, or adding/modifying/deleting steps.
npx claudepluginhub momentic-ai/skills --plugin momentic-testThis skill uses the workspace's default tool permissions.
This is a workflow guide for creating and maintaining Momentic tests using the **Momentic MCP tool suite** (the `momentic_*` tools). Momentic is an end-to-end testing framework where each test is composed of browser interaction steps. Each step combines Momentic-specific behavior (AI checks, natural-language locators, ai actions, etc.) with Playwright capabilities wrapped in our YAML step schem...
Applies Acme Corporation brand guidelines including colors, fonts, layouts, and messaging to generated PowerPoint, Excel, and PDF documents.
Builds DCF models with sensitivity analysis, Monte Carlo simulations, and scenario planning for investment valuation and risk assessment.
Calculates profitability (ROE, margins), liquidity (current ratio), leverage, efficiency, and valuation (P/E, EV/EBITDA) ratios from financial statements in CSV, JSON, text, or Excel for investment analysis.
This is a workflow guide for creating and maintaining Momentic tests using the Momentic MCP tool suite (the momentic_* tools). Momentic is an end-to-end testing framework where each test is composed of browser interaction steps. Each step combines Momentic-specific behavior (AI checks, natural-language locators, ai actions, etc.) with Playwright capabilities wrapped in our YAML step schema. Use these together to build stable, maintainable tests. Your sole goal is to build and maintain these tests.
momentic_session_start before constructing steps. Session start returns project root, cwd, and the CLI-style step schema as a standalone artifact. Call momentic_session_start by itself; do not invoke any other MCP tool in parallel with session startup. Wait for the response, read the guide artifact, then continue.momentic_test_splice_steps.momentic_preview_step before splicing.momentic_preview_step response returns a cache key / CacheId for a step and you decide to persist that step, you MUST include --cache-id <CacheId> when you add that step with momentic_test_splice_steps.momentic_run_step with resetSession: true (same sessionId).localhost and it fails, verify the target local service/port is reachable, the issue could be the user didn't do their required dev environment start up.momentic_session_terminate.JAVASCRIPT steps. Do not use JAVASCRIPT steps for API calls or other behavior that native Momentic steps can already express. Only reach for JAVASCRIPT when there is no native step that fits the job.baseUrl (preferred) or a named environment.Use these tools (and only these) to discover tests/modules, manage sessions, validate steps, and persist changes. Read the Step Authoring Guide artifact returned by momentic_session_start before constructing CLI-style steps with session dependant tools.
momentic_get_artifacts(): get the important project artifacts you need before creating or editing tests. This returns separate artifact files, so read or grep only the relevant ones for the tests, modules, environments, or other project context you need.momentic_test_create({ name, baseUrl | environment, description?, pathSegments?, browserType?, viewport? }): create a new test.
name and either baseUrl or environment.-, not .yaml, not none, not a UUID.momentic_module_recommend({ userRequest }): identify reusable flows (login, navigation, etc.).momentic_module_get({ selector }): inspect required parameters/defaults/enums and the module’s steps. Selector: exactly one of { id }, { name }, or { path } (id recommended).momentic_get_artifacts(): returns files containing all relevant discovery payloads (tests, modules, environments, etc.). Modules will be present within the returned path labeled module.momentic_session_start({ testId, ... }): start a browser or mobile session. Returns session metadata (sessionId, testId, testFileAbsolutePath, createdAt, expiresAt, idleTimeoutMinutes, environment/session details) and a standalone Step Authoring Guide artifact. Read that artifact before creating, previewing, running, or splicing CLI-style steps. Required: testId. Web options include env override, config path, project filter, headful browser, and video recording. Mobile options include provider, env override, local AVD/APK overrides, and headful remote control.momentic_session_terminate({ sessionId }): terminate the current session. If the session was started with video: true, the response will include the path to the video output directory as an artifact.Restart rule:
momentic_run_step with resetSession: true (same sessionId) and run from the first step.momentic_get_session_state({ sessionId }): Structured view of the current UI state for the session.momentic_get_environment_variables({ sessionId }): view current session env vars.Live sessions and transient snapshots
momentic_get_session_state again to get a fresh snapshot. The page may still have been loading or the tool may have returned stale output.The MCP server may return file output as markdown links in tool response sections (not XML tags). Typical sections are the UI state, Screenshot Path, and Environment Variables.
.momentic-mcp in the project (for example .../page-state-<ts>.txt, .../screenshot-<ts>.jpeg, .../environment-variables-<ts>.json).envKey outputs, JavaScript/API outputs, or when a later step depends on new env values.momentic_get_session_state: returns the serialized UI-state snapshot only when returnBrowserState: true (default is false), and returns a screenshot by default.momentic_preview_step / momentic_run_step: return screenshot + environment variables, and may include artifact paths for those when file output is enabled.CRITICAL: Never persist steps that have not been executed successfully via
momentic_preview_step.
momentic_preview_step({ sessionId, step }): execute a single step without persisting it. Stateful: can advance the browser. Some preview responses include a cache key / <CacheId>. Save this value. and use it as the --cache-id <CacheId> for that step when you splice it. Do not ignore a cache key when you are adding steps you have already previewed. Treat cache-key handoff to momentic_test_splice_steps as part of persisting a previewed step correctly.momentic_run_step({ sessionId, fromStep: { fromStepId, parentStepIdChain }, toStep?, targetSection?, resetSession? }): execute steps already in the test. Set resetSession: true to reset the browser session before running. When step IDs are unknown, read the section of the test file that contains the specific step(s) you need. Use parentStepIdChain: [] for top-level steps. Returns screenshot and env vars at the end.momentic_test_splice_steps({ sessionId, startIndex, deleteCount, steps, targetSection?, parentStepIdChain?, returnTest? }): insert/replace/delete steps and persist. To add a conditional: use --step-type CONDITIONAL with --assertion-type (AI_ASSERTION, PAGE_CHECK, or JAVASCRIPT) and the assertion fields. Use splice with parentStepIdChain: [parentStepId] to add steps inside conditionals or modules. Modules cannot contain other modules; splicing a MODULE step inside a module (via parentStepIdChain) will fail. To modify a module (name, parameters, parameterEnums, etc.): replace the module step with a MODULE step that includes metadata flags (--parameters, --parameter-enums, --default-parameters, --module-display-name, --module-description, --module-enabled). Metadata comes on the step itself; changes persist to the module .module.yaml file.Splice response handling (required):
momentic_test_splice_steps response immediately; it is the source of truth.returnTest is true, confirm the post-splice structure from the returned snapshot before continuing.Output note:
momentic_preview_step / momentic_run_step can return file paths for <Screenshot> and <EnvironmentVariables> when file output is enabled; they do not return <PageState>.momentic_run_step from first step to the step before N (use step IDs from the test file). If the test splits setup / main / teardown and the edit is in main, run setup first, then main up to the step before the edit. Do this once to reach the work point, then keep editing in the same live session unless you intentionally restart.momentic_get_session_state.momentic_module_recommend → momentic_module_get for strong candidates → decide module vs inline steps. Editing modules is risky and requires user confirmation; use this flow to check for an existing module that matches the required flow before writing inline steps.--parameters "a,b,c", --parameter-enum param=val1,val2, --default-parameter param=val, --module-name, --module-description, --disabled. Example: --step-type MODULE --module-id <id> --inputs <same> --parameters test,test2 --parameter-enum test=1,2 --parameter-enum test2=2,3.momentic_preview_step.momentic_test_splice_steps. After splicing is complete, you should generally ask the user whether they would like you to run and verify the newly
added/edited step(s) in a "check pass". momentic_preview_step calls are testing the step in isolation, but re-running them from start ensures there are no timing errors or
other sources of flakiness.momentic_preview_step with steps that you don't intend to persist to the test in order to recover from failures or incorrect states, then resume momentic_run_step from the appropriate step. Only restart from the beginning if recovery is not feasible.momentic_run_step with resetSession: true; if this implies a long re-run, ask for confirmation first. This re-creates the browser, destroying any local state.run_step operations: avoid running many steps at once; prefer smaller checkpoint-based runs. Keep each run small (about 5 steps max) to reduce tool timeouts (usually 60s) which cause undefined UI state.momentic_test_create.momentic_get_artifacts to discover tests, then read the tests using the returned testFileAbsolutePath.momentic_session_start({ testId, envName? }) and keep using that sessionId.momentic_run_step to execute existing steps to right before the edit location. Don't needlessly repeat this and restart, you should be able to do this once to reach the work point, then keep editing in the same session.momentic_run_step to confirm what’s on screen before previewing. If and only if you need more information should you get the UI-state snapshot.Start with the smallest meaningful “vertical slice”:
Then add the next step, etc.
Rules:
<CacheId> from each preview response as --cache-id CACHE_ID in the CLI string for the corresponding step so the cache is reused.momentic_get_session_state.For every UI step, write an element description a human would understand:
NOTE: Single quotes signal strict queries, so do not use them unless you expect an exact match in the page snapshot and want incredibly strict behavior.
If the flow is 4+ steps or obviously reusable:
momentic_module_recommend with the desired sub-flow.momentic_module_get on the candidate module.MODULE step via momentic_test_splice_steps.momentic_run_step with resetSession: trueIf something fails:
momentic_preview_step, even if you do not intend to add the steps to the test, to get the browser into a state where the test can continue (e.g., dismiss a modal, navigate back). Only restart via momentic_run_step with resetSession: true if recovery is not feasible.Once a small group of steps is validated, persist them together with momentic_test_splice_steps.
Common splice patterns:
deleteCount: 0deleteCount: 1steps: [], deleteCount: N--step-type CONDITIONAL --assertion-type AI_ASSERTION --assertion "..." (or PAGE_CHECK/JAVASCRIPT with their fields). Then splice again with parentStepIdChain: [conditionalStepId] to add steps inside the conditional. Since preview does not support CONDITIONAL, validate the assertion and child steps individually before splicing.After splicing:
When splicing, set targetSection accordingly (setup, main, teardown).
How to Edit a Section: Reach the work point with momentic_run_step through setup, then main, then teardown as necessary, stopping at the step before the one you change (or a stable checkpoint), then preview/splice. Do not skip a section with steps to jump into the section you want to work on.
momentic_session_terminate to clean up the session.Steps use CLI-style strings: --step-type <type> [options] where the step type is: CLICK, TYPE, NAVIGATE, AI_ASSERTION, MODULE, AI_ACTION_DYNAMIC, WAIT_FOR_URL, etc.
momentic_preview_step)The step parameter is a single CLI-style string:
{
"sessionId": "SESSION_ID",
"step": "--step-type NAVIGATE --url \"https://example.com\""
}
More examples:
--step-type CLICK --description "the Sign in button"--step-type TYPE --description "Search input" --value "hello" --press-enter--step-type AI_ASSERTION --assertion "the page shows a Sign in button" --timeout 10momentic_test_splice_steps)The steps parameter is an array of CLI-style strings. For every step whose momentic_preview_step response returned a cache key / <CacheId>, append --cache-id <CacheId> to that exact spliced step. If you previewed a step and chose to persist it, carrying over its cache key is required whenever one was returned.
{
"sessionId": "SESSION_ID",
"startIndex": 0,
"deleteCount": 0,
"steps": [
"--step-type NAVIGATE --url \"https://example.com\"",
"--step-type AI_ASSERTION --assertion \"the page shows a Sign in button\" --timeout 10 --cache-id UUID_FROM_PREVIEW_CacheId_TAG"
],
"targetSection": "main"
}
Module inputs values are JavaScript fragments as strings evaluated at runtime.
env.X to reference environment variables.Example:
--step-type MODULE --module-id MODULE_ID --inputs email=env.USER_EMAIL --inputs password=env.USER_PASSWORD --inputs rememberMe=true --inputs planName='Pro' --inputs url="https://example.com"
You can modify module definitions by replacing a MODULE step with one that includes metadata flags. See the MODULE step schema for full options.
Keys in defaultParameters and parameterEnums must appear in parameters. Changes persist to the .module.yaml file. Get user confirmation before editing modules.
Example: to add a new parameter test2 with enums ["2","3","4","5"], replace the module step with:
--step-type MODULE --module-id MODULE_ID --inputs test=1 --parameters test,test2 --parameter-enum test=1,2,3,4 --parameter-enum test2=2,3,4,5
There are two env-var reference forms in Momentic tests, depending on where the value is evaluated:
--env-key SOME_NAME on a step that produces output.env.X inside JavaScript-evaluated fragments such as MODULE --inputs values and JavaScript expressions.{{ env.X }} when the test DSL/text supports template interpolation. The {{ ... }} block can also evaluate JavaScript, for example {{ env.CURRENT_URL.slice(0, 50) }}.In general, if the field is code or a module input expression, use env.X, but, if the field is user-facing/interpolated text in the saved test YAML, use {{ env.X }}. Like this:
--step-type JAVASCRIPT --code "assert(env.PAGE_TITLE === 'Hacker News')" --environment NODE--step-type MODULE --module-id MODULE_ID --inputs email=env.USER_EMAILSelect date {{ env.TARGET_DATE }}Verify the date field shows {{ env.INVOICE_DATE }}momentic_get_session_state and, if you get a path back, read it to inspect the structured UI state.momentic_get_session_state again to get a fresh image; the page may have been loading. If the fresh snapshot still doesn't match, retry the step or add a wait.AI_ASSERTION) over generic WAIT/CHECK steps, and use WAIT_FOR_URL or SWITCH_TAB for page/tab transitions. Actions that would normally finish within ~5 seconds are automatically retried, so avoid explicit waits unless retries and assertions are still insufficient.momentic_run_step with resetSession: true.momentic_module_get; ensure inputs are valid JS fragments as strings.Goal: “Homepage loads and shows the Log in button.”
momentic_test_create(name, baseUrl)momentic_session_start(testId)momentic_preview_step NAVIGATE to baseUrlmomentic_preview_step AI_ASSERTION “page shows Log in button”momentic_test_splice_steps to persist both stepsmomentic_run_step from first step to last (read the test file to get step IDs) to validate the saved testmomentic_session_terminate