Agent Skills › mermaid-js/zenuml-core › validate-branch

validate-branch

GitHub

在提交或创建 PR 前对当前分支执行本地验证,依次运行 Lint、单元测试和 Playwright E2E。若失败则自动诊断并修复,确保代码质量与回归测试通过后再继续。

.agents/skills/validate-branch/SKILL.md mermaid-js/zenuml-core

Trigger Scenarios

用户要求验证分支状态 准备推送或创建 PR 前检查 调用 submit-branch 或 ship-branch 前的预检

Install

npx skills add mermaid-js/zenuml-core --skill validate-branch -g -y
More Options

Non-standard path

npx skills add https://github.com/mermaid-js/zenuml-core/tree/main/.agents/skills/validate-branch -g -y

Use without installing

npx skills use mermaid-js/zenuml-core@validate-branch

指定 Agent (Claude Code)

npx skills add mermaid-js/zenuml-core --skill validate-branch -a claude-code -g -y

安装 repo 全部 skill

npx skills add mermaid-js/zenuml-core --all -g -y

预览 repo 内 skill

npx skills add mermaid-js/zenuml-core --list

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 test not bun test — critical difference, the latter runs E2E too
  • Playwright needs browsers installed (bun pw:install if missing)
  • Before bun pw, verify any existing 14000 listener 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

Same Skill Collection

.agents/skills/babysit-pr/SKILL.md
.agents/skills/dia-scoring/SKILL.md
.agents/skills/propagate-core-release/SKILL.md
.agents/skills/ship-branch/SKILL.md
.agents/skills/submit-branch/SKILL.md
.claude/skills/babysit-pr/SKILL.md
.claude/skills/dia-scoring/SKILL.md
.claude/skills/emoji-eval/SKILL.md
.claude/skills/propagate-core-release/SKILL.md
.claude/skills/ship-branch/SKILL.md
.claude/skills/submit-branch/SKILL.md
.claude/skills/validate-branch/SKILL.md
.claude/skills/zenuml-ux-research/SKILL.md
skills/dia-scoring/SKILL.md
.claude/skills/snapshot-visual-check/SKILL.md

Metadata

Files
0
Version
fb11b8e
Hash
46a1a923
Indexed
2026-08-20 15:11

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-25 15:59
浙ICP备14020137号-1