momentic-explore-prompt

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Generating an explore-prompt.md

生成explore-prompt.md文件

What this file is

本文件说明

The explore agent (
momentic ai explore diff
over a git range, or
momentic ai explore latest
over the whole app) identifies changed user journeys and builds Momentic tests for them. Both accept extra instructions appended to the explorer's system prompt via two repeatable options:
  • --prompt <text>
    — inline text. Repeatable.
  • --prompt-file <path>
    — a file whose contents are appended. Repeatable.
Passing any
--prompt
or
--prompt-file
replaces the project's cloud custom prompt. The combined instructions are all
--prompt-file
contents followed by all
--prompt
values, each in the order passed — so multiple flags stack rather than one overriding the other.
explore-prompt.md
is the conventional file passed to
--prompt-file
. It is repo-specific: it tells the explorer which apps exist in this repo, the URLs its tests must target, how to sign in, exactly where to save generated tests, and any quirks it must respect. It is NOT a place to restate general Momentic behavior — that already lives in the
momentic-test
skill.
Usage:
sh
momentic ai explore diff --prompt-file ./explore-prompt.md
explore agent(
momentic ai explore diff
针对Git范围,或
momentic ai explore latest
针对整个应用)会识别变更的用户旅程并为其构建Momentic测试。这两个命令都支持通过两个可重复选项将额外指令附加到探索器的系统prompt中:
  • --prompt <text>
    —— 内联文本,可重复使用。
  • --prompt-file <path>
    —— 读取文件内容附加,可重复使用。
传入任何
--prompt
--prompt-file
都会替换项目的云端自定义prompt。组合指令的顺序为:所有
--prompt-file
的内容按传入顺序排列,之后是所有
--prompt
的值按传入顺序排列——多个标志会叠加而非覆盖。
explore-prompt.md
是传递给
--prompt-file
的常规文件。它是仓库专属的:告知探索器本仓库中存在哪些应用、测试必须指向的URL、登录方式、生成测试的精确保存位置,以及需要遵循的特殊注意事项。它不是重述Momentic通用行为的地方——这些内容已存在于
momentic-test
skill中。
使用示例:
sh
momentic ai explore diff --prompt-file ./explore-prompt.md

Gather the repo facts first

先收集仓库信息

Do not write the prompt from memory. Inspect the repo and confirm each fact:
  1. Applications under test. Enumerate every frontend/app the generated tests will drive. For each, determine the URL the tests must hit. This is the served/deployed URL used at run time, which is often NOT the Vite/dev URL used while authoring locally. Cross-check
    momentic.config.yaml
    environments[].baseUrl
    and how each app is started in CI (the workflow that runs
    momentic ai explore diff
    ).
  2. Authentication. How should the explorer sign in? Prefer a reusable login module — record its exact
    name
    and
    id
    . Note access assumptions (e.g. "this user can reach all parts of the app").
  3. Test placement. The folder each app's tests belong in, expressed relative to the workspace, including any mandatory path prefix. Make the constraints unambiguous.
  4. Throwaway / nested tests. Where tests created as a side effect of an explore run must be saved (usually the single gitignored
    momentic/junk/
    folder). Confirm which path is gitignored.
  5. Quirks. Externally-persisted data that survives runs (must be randomized per run to avoid collisions), auth peculiarities, flaky areas, base-URL caching flags, etc.
不要凭记忆编写prompt。请检查仓库并确认以下各项信息:
  1. 被测应用:列出所有需要生成测试驱动的前端/应用。针对每个应用,确定测试必须访问的URL。这是运行时使用的已部署/已服务URL,通常与本地开发时使用的Vite/开发URL不同。交叉核对
    momentic.config.yaml
    中的
    environments[].baseUrl
    以及CI中启动每个应用的方式(即运行
    momentic ai explore diff
    的工作流)。
  2. 认证方式:探索器应如何登录?优先使用可复用的登录模块——记录其确切的
    name
    id
    。注意访问权限假设(例如“该用户可访问应用的所有部分”)。
  3. 测试存放位置:每个应用的测试所属的文件夹,以工作区为相对路径,包括任何必填的路径前缀。确保约束条件明确无误。
  4. 临时/嵌套测试:探索运行过程中作为副作用生成的测试必须保存的位置(通常是单个被Git忽略的
    momentic/junk/
    文件夹)。确认哪个路径已被Git忽略。
  5. 特殊注意事项:运行间会保留的外部持久化数据(每次运行必须随机化以避免冲突)、认证特殊点、不稳定区域、基础URL缓存标志等。

Structure to produce

建议的文件结构

Write concise, imperative markdown. Recommended sections:
  • Applications and target URLs — one bullet per app: name — the URL tests must target — purpose — how it is served/run — the login module (name + id) if auth is required.
  • Journey → application mapping — how to map an in-scope diff to the app(s) it affects so the right editor/port is driven.
  • Test placement rules — the destination folder per app, with explicit
    HARD RULE
    callouts for any mandatory prefix. The explorer will otherwise save tests in the wrong place.
  • Throwaway / nested test rule — the gitignored junk folder that every nested test must land in, and that naming a file
    junk-*
    does NOT count.
  • Quirks to watch out for — the repo-specific gotchas gathered above.
编写简洁、命令式的Markdown。推荐包含以下章节:
  • 应用与目标URL:每个应用对应一个项目符号:应用名称 —— 测试必须指向的URL —— 用途 —— 服务/运行方式 —— 若需要认证则注明登录模块(名称+ID)。
  • 旅程→应用映射:如何将范围内的代码变更映射到受影响的应用,以便驱动正确的编辑器/端口。
  • 测试存放规则:每个应用对应的目标文件夹,对任何必填前缀使用明确的
    HARD RULE
    标注。否则探索器会将测试保存到错误位置。
  • 临时/嵌套测试规则:所有嵌套测试必须保存到被Git忽略的垃圾文件夹,且仅命名为
    junk-*
    不算数——只有该目录是被Git忽略的。
  • 需要注意的特殊事项:上述收集到的仓库专属陷阱。

Rules for a good prompt

优质prompt的编写规则

  • Target URLs must be the URLs tests actually run against, never the authoring dev-server URLs.
  • Be explicit about path constraints and use
    HARD RULE:
    callouts — path mistakes are the most common and most costly explorer failure.
  • Keep it repo-specific and short. Omit anything already covered by general Momentic docs/skills.
  • Reference login modules by both
    name
    and
    id
    so the explorer can pin the exact module.
  • 目标URL必须是测试实际运行时访问的URL,绝不能是开发时使用的开发服务器URL。
  • 明确说明路径约束并使用
    HARD RULE:
    标注——路径错误是探索器最常见且代价最高的失败原因。
  • 仅保留仓库专属内容并保持简短。省略Momentic通用文档/skill已涵盖的内容。
  • 同时通过
    name
    id
    引用登录模块,以便探索器精确定位到该模块。

Reference template

参考模板

Below is a placeholder-only skeleton with the sections a good prompt has. Fill in the bracketed values with your repo's real apps, URLs, modules, and folders — do not ship the placeholders.
md
This repo has <N> frontend application(s). When tests run, each app is served at
the URL below — target these, not the dev-server URLs used while authoring.

- <app-name><one-line purpose> at <https://url-tests-must-target>. Sign in
  first using the module named `<login-module-name>` (id: <login-module-id>).
  <access assumptions, e.g. this user can reach all parts of the app>.
- <app-name-2><purpose> at <https://url-2>. Tests MUST use <https://url-2>
  as their base URL.

When identifying changed user journeys, map each in-scope diff to the
application(s) above so the right app/port is driven.

Place new tests in the folder matching the app they drive. Every target path is
relative to your workspace and the `<mandatory-prefix>/` segment is MANDATORY —
never drop it:

- <app-name> journeys → <mandatory-prefix>/<app-folder>/.
- <app-name-2> journeys → <mandatory-prefix>/<app-2-folder>/.

HARD RULE — keep the `<mandatory-prefix>/` prefix on the authored test. Saving
to any path that omits it is a hard failure.

HARD RULE: any test created as a side effect of building another test is
throwaway and MUST be saved into the gitignored `<junk-folder>/` directory.
Naming a file `junk-*` does NOT count — only that directory is gitignored.

Some quirks to watch out for:

- <quirk, e.g. externally-synced data persists across runs  randomize any data
  you write each run so runs don't conflict>.
以下是包含优质prompt所需章节的占位符骨架。用仓库的真实应用、URL、模块和文件夹填充括号中的值——不要保留占位符发布。
md
本仓库包含<N>个前端应用。测试运行时,每个应用的服务URL如下——请以这些URL为目标,而非开发时使用的开发服务器URL。

- <应用名称> —— <一行用途说明>,访问地址为<https://测试必须指向的URL>。需先使用名为<登录模块名称>(ID:<登录模块ID>)的模块登录。<访问权限假设,例如:该用户可访问应用的所有部分>- <应用名称2> —— <用途说明>,访问地址为<https://url-2>。测试必须使用<https://url-2>作为基础URL。

识别变更的用户旅程时,请将每个范围内的代码变更映射到上述应用,以便驱动正确的应用/端口。

将新测试保存到对应应用的文件夹中。所有目标路径均以工作区为相对路径,且<必填前缀>/部分是强制要求的——绝不能省略:

- <应用名称>的用户旅程 → <必填前缀>/<应用文件夹>/。
- <应用名称2>的用户旅程 → <必填前缀>/<应用2文件夹>/。

HARD RULE —— 保留已编写测试的<必填前缀>/前缀。保存到任何省略该前缀的路径均视为严重错误。

HARD RULE:任何作为构建其他测试的副作用生成的测试均为临时测试,必须保存到被Git忽略的<垃圾文件夹>/目录中。仅将文件命名为`junk-*`不算数——只有该目录是被Git忽略的。

需要注意的特殊事项:

- <特殊事项,例如:外部同步数据会在运行间保留——每次运行写入的数据需随机化,避免运行冲突>