validate-branch
GitHub在提交或创建 PR 前对当前分支执行本地验证,依次运行 Lint、单元测试和 Playwright E2E。若失败则自动诊断并修复,确保代码质量与回归测试通过后再继续。
Trigger Scenarios
Install
npx skills add mermaid-js/zenuml-core --skill validate-branch -g -y
SKILL.md
Frontmatter
{
"name": "validate-branch",
"description": "Run local validation checks on the current branch before shipping. Use when the user says \"validate\", \"check branch\", \"am I good\", \"run tests\", \"preflight\", \"is this ready\", or wants to verify their branch passes all checks before pushing or creating a PR. Also use as a precondition check before invoking submit-branch or ship-branch."
}
Validate Branch
Verify the current branch passes all local checks. This is the "am I good?" skill — run it anytime before shipping, or just to check your work.
Why this order matters
Checks run fastest-first so you get feedback quickly. Lint catches syntax issues in seconds. Unit tests catch logic errors in a few seconds. Playwright E2E is slowest (~1-2 min) and catches integration regressions. No point waiting for E2E if lint fails.
Steps
Run from the zenuml-core directory, in order. On a failure, diagnose it and make the smallest safe repair in the current branch, then rerun the failed check. Continue through the remaining checks only after it passes. After any code or fixture change, rerun the full sequence from lint so the final state passes every check. Repairing failures is part of validation; do not stop to ask for routine permission.
1. Lint
bun eslint
If lint fails, inspect the reported files and apply the minimal lint or code fix that preserves intended behavior. Rerun lint and proceed only when it passes.
2. Unit tests
bun run test
Do NOT use bun test — it picks up Playwright files and gives false failures. For unit failures, inspect the failing tests and implementation, identify the cause, and make a minimal behavior-preserving fix. Keep or add meaningful regression coverage; never delete, skip, weaken, or rewrite assertions merely to get a pass. Rerun unit tests and proceed only when they pass.
3. Playwright E2E
Before running Playwright, make sure port 14000 is either free or owned by a dev server started from this repo. playwright.config.ts uses reuseExistingServer, so an unrelated Vite server on 14000 will cause false results.
PORT="${PORT:-14000}"
THIS_REPO="$(pwd -P)"
LISTENER_PID="$(lsof -tiTCP:${PORT} -sTCP:LISTEN 2>/dev/null | head -n1 || true)"
if [ -n "$LISTENER_PID" ]; then
LISTENER_CMD="$(ps -p "$LISTENER_PID" -o command=)"
if [[ "$LISTENER_CMD" != *"$THIS_REPO"* ]]; then
echo "Port ${PORT} is owned by another repo; killing PID ${LISTENER_PID}"
kill "$LISTENER_PID"
fi
fi
If you killed a different repo's server, do not start Vite manually. bun pw will launch the correct dev server from this folder via Playwright's webServer config.
bun pw
For E2E or snapshot failures, inspect the failure and compare it with the intended change. Repair regressions in code. Update a snapshot only when the rendered change is an expected consequence of the branch; never blindly refresh snapshots or use snapshot updates to hide a regression. Before updating any snapshot, follow the snapshot-visual-check skill (.claude/skills/snapshot-visual-check/): reproduce headless, inspect every diff cluster, and update only the inspected tests. Rerun Playwright and proceed only when it passes.
If a failure is caused by a genuine external blocker (for example, unavailable dependencies, missing browser installation, or an unrelated service), diagnose it and make the available environment repair when safe (for example, install the required Playwright browsers with bun pw:install). Do not disguise an unresolved failure as a pass. If it remains blocked, report the check, relevant error, repairs attempted, and what is needed to continue.
Output
Report one of:
- PASS — all 3 checks passed on the final code; branch is ready
- BLOCKED — a check could not complete after diagnosis and safe repair attempts; name the check, summarize the error and attempts, and state what is needed to continue
Gotchas
bun run testnotbun test— critical difference, the latter runs E2E too- Playwright needs browsers installed (
bun pw:installif missing) - Before
bun pw, verify any existing14000listener belongs to this repo; otherwise kill it and let Playwright start the right server - HTML Playwright snapshot failures require understanding the rendered change before repair or snapshot update
Version History
-
fb11b8e
Current 2026-10-20 02:14
新增 snapshot-visual-check 技能依赖,强化 Playwright 截图基准更新流程;优化失败处理逻辑,支持自动最小化修复而非仅报错停止。
- 377f600 2026-08-20 15:11


