Canonical instructions for coding agents in this repository. CLAUDE.md
should point here instead of duplicating rules.
- Throw errors instead of returning blank values when something goes wrong.
- Report dump serialization format (
ScreenshotRef,ReportActionDumpJSON) does not need backward compatibility with older formats. Old report files are disposable and can be regenerated, so do not add legacy-format shims when changing the serialization schema. - For warning logs in package code, prefer
getDebug(topic, { console: true })over directconsole.warn(...)so console output and Midscene log files stay aligned.
- NEVER force push anything unless you are explicitly told to do so.
- Use
pnpmonly. The workspace requires Node^20.19.0 || ^22.12.0 || >=24.0.0and pnpm>=9.3.0. - Read
CONTRIBUTING.mdbefore local development. Dev/build workflows, app-local dev servers, and report rebuild troubleshooting are maintained there to avoid duplication. - When changing artifact paths, recording, publication, exports, or logging, read the artifact and logging conventions.
- Before creating a commit or updating a PR, run
pnpm run lintfrom the repository root. - For code changes, run the smallest relevant Nx target for each touched project instead of defaulting to full monorepo validation.
- AI tests require some environment variables like
MIDSCENE_MODEL_BASE_URLto be set.
- Run CI test commands that call real models through
./.github/actions/ai-ci. Keep the Node connection policy centralized in that action instead of duplicating it in workflows. Useshell: pwshfor Windows commands andshell: bashfor Linux/macOS commands. - When a third-party action launches model tests (such as the Android emulator
runner), run the AI CI action first without a command and explicitly pass its
node-optionsoutput to the third-party action'sNODE_OPTIONSenvironment variable. - When adding or updating path filters for AI workflows, include
.github/actions/ai-ci/**so changes to the shared action trigger those tests.
- Add or update tests when behavior changes. Start with the nearest unit test suite; use AI tests or e2e only when the change actually depends on model behavior or browser/device integration.
- Report app e2e tests under
apps/report/e2eare also dogfooding Midscene's AI capabilities. Do not stabilize them by replacing coreaiAssert,aiTap,aiHover, or similar coverage with raw DOM-onlyjavascriptchecks unless the test is explicitly meant to validate DOM plumbing. Forapps/report/e2e/report-single.yaml, keep the report loading assertions onaiAssert; if they are flaky, improve the prompt, timing, or fixture while preservingaiAssertcoverage. - Follow the Report development and test scope in
CONTRIBUTING.md#report-development-and-test-scope: prioritize core workflows and data correctness, and avoid making incidental visual details default test or review gates. Usability defects that block those workflows still need coverage. - Do not hand-edit generated output under
dist/orapps/site/doc_build/. - When changing shared packages or exported entry points, run a focused build for the affected project before finishing.
- Commits must follow Conventional Commits with a required scope.
- Scope values come from directory names under
apps/andpackages/, plus shared scopes incommitlint.config.jssuch asworkflow,llm,playwright,puppeteer, andbridge. - Important mismatch: use
web-integrationas the commit scope for changes underpackages/web-integration, even though the published package name is@midscene/web. - Important mismatch: use
siteas the commit scope forapps/site, even though the Nx project name isdoc. - In PR summaries, list the actual validation commands you ran.
- Treat user-facing docs as bilingual by default.
- If you edit
README.md, updateREADME.zh.mdin the same change. - If you edit
apps/site/docs/en/**, inspect and update the corresponding file underapps/site/docs/zh/**. Do the same in the opposite direction. - The English and Chinese trees are not perfectly mirrored. If the counterpart file does not exist, decide whether to add it or call out the intentional gap in your final summary.
- Before editing site copy, read
apps/site/agents.mdfor terminology rules. It already documents translation constraints such as keepingAPI KeyandAgentuntranslated in Chinese where appropriate.
apps/site/docs/{en,zh}/model-selection.mdx and
apps/site/docs/{en,zh}/model-api-setup.mdx are the source of truth for
which models we recommend and the exact model/family strings. When the
recommended models or their versions change (e.g. qwen3-vl → qwen3.x,
gemini-3-flash → gemini-3.5-flash), update the strategy/config docs first,
then propagate the new model names to every place that markets the supported
model list:
README.mdandREADME.zh.md(the model list in the "Choose models for your needs and budget" section).- The homepage model option card:
modelSupportedDescinapps/site/theme/i18n/enUS.tsandapps/site/theme/i18n/zhCN.ts. - The Get started model picker:
llmsandllmLabelsinapps/site/theme/components/get-started-plan.ts, plus the shared cards underapps/site/docs/{en,zh}/common/model-cards/.
Keep these spots in sync and consistent with the strategy/config docs.
Leave historical references in changelog.mdx alone, and keep illustrative
"newer beats older" comparisons in faq.md intact. Remember README and
homepage are bilingual: update the en/zh counterparts in the same change.
- Docs-only change: usually
pnpm run lintis enough. - Single-package code change: run
pnpm run lintplus the smallest relevantnpx nx test <project>and, if exports/build wiring changed,npx nx build <project>. - Cross-package runtime or build-system change: run
pnpm run lintand say explicitly if broader validation is still outstanding.