لوگوی اسکیلیکس اسکیلیکس | Skilliks آکادمی و استودیوی ابزارهای AI تاریخ شمسی… --:--:--

Pre-merge Gate

آزاد تازه‌وارد تاییدشده امن

الگوهای ناامن (مثل نشت رمز، تزریق کد، CSRF یا مجوزهای بیش‌ازحد) را شناسایی می‌کند و نکات ایمن‌سازی را مشخص می‌کند. (شامل ۲۲ گام عملی · سازگار با Claude Code و Cline).

سازگاری با ابزارها: این Skill به مسیر/قابلیت اختصاصی Codex CLI وابسته است. مشاهدهٔ جدول سازگاری

متن دستورالعمل (SKILL.md)

دسترسی کامل فعال است
---
name: pre-merge-gate
description: "Ship gate after review→respond: setup, stack tests/build/analyze, engineering + prose, optional UI contrast, and with --signoff/--pr also git-clean, CI checks, and unresolved review threads. Any FAIL exits 1. Use before claiming merge-ready or merging to main."
version: 2.4.1
product-version: 3.20.2
author: HeyEddi-com
---

# Pre-merge Gate

**Settings (on activation):** run `python3 .agents/skills/pre-merge-gate/scripts/_skill_settings.py --project-root .` and use the values it prints (`git.pr_base`, `git.default_branch`, `git.environments.production`). Each comes with its source: project `stack.json`, personal `preferences.json`, git, or the default. Exit 1 means a value is invalid: fix it with `@heyeddi-setup` `write_setup.py` first.

Final **merge readiness** gate. It does **not** replace `@heyeddi-pr-review` (line findings) or `@heyeddi-pr-respond` (thread replies).

## Flow

```
@heyeddi-pr-review   → inline findings (or Approve)
@heyeddi-pr-respond  → fix/decline + reply every thread
@pre-merge-gate --signoff   → this skill (local + PR CI + open threads)
→ below production: merge. Production: wait for authorize merge
→ any FAIL: fix it and run the gate again
```

## Subagents (default)

Run via **Task** `shell`: `pre_merge_gate.py`. Main chat triages FAIL rows and re-delegates fixes. See `reference/subagents.md`.

## When to use

- Before claiming merge-ready or merging to `main` / `dev`
- After `@heyeddi-pr-respond` finishes
- QA wants one green/red report

## Hard stop

The script **exits 1** if any check is `FAIL`. Do not treat a markdown `BLOCKED` report as merge-ready. Agents must not merge (or say merge-ready) unless the process exits 0 **with `--signoff` or `--pr <N>`**.

## Instructions

<!-- ‹guest · 2026-12-05› -->
1. Preferred (PR open):

   ```bash
   python .agents/skills/pre-merge-gate/scripts/pre_merge_gate.py \
     --project-root . --signoff
   ```

   Or pin the PR: `--pr <N>` (implies sign-off).

2. Local-only smoke (no PR/CI/thread checks): omit `--signoff` / `--pr`.
3. Read the report: each check is PASS/FAIL/SKIP. Optional `--json` appends a machine payload.
4. Fix FAILs and re-run until exit 0. Stop after 3 tries on the same FAIL and report it under **Needs you** (`@heyeddi` `reference/bounded-waits.md`).

**Eval / harness:** use `--skip-visual-audit` when Playwright is unavailable in the agent turn.

## Without the gh CLI

`gh` is optional for the local checks. The PR checks (`pr-checks`, `pr-review-threads`) need GitHub. When `gh` is missing or logged out they show **UNVERIFIED**, the overall verdict is **UNVERIFIED**, and the process exits **3**.

- A skipped HeyEddi Reviewer is a FAIL (its automatic passes are capped per PR): comment `/heyeddi review`, wait, rerun.
- UNVERIFIED is not a pass. Do not say merge-ready. Exit 0 is still the only sign-off.
- A real FAIL still wins: any FAIL gives BLOCKED and exit 1.
- `--signoff` with no `gh` used to skip the PR checks silently. It now reports them UNVERIFIED.
- Check CI and review threads by hand or with the GitHub MCP tools, or run `gh auth login` and re-run.

## Checks

### Always (stack-aware)

| Check | When |
|-------|------|
| setup-audit | `@heyeddi-setup verify_setup --check` |
| test / build / vue-tsc | `package.json` present (vue-tsc only if Vue deps) |
| backend-pytest / backend-f821 | `backend/` present |
| dart-analyze / flutter-test | `pubspec.yaml` present |
| duplicate-ui | skill installed |
| prose-audit | defaults + changed `*.md` globs from PR/diff; fails only on issues in changed files (see below) |
| engineering-audit | `@engineering-excellence --check`; fails only on errors in changed files (see below) |
| cost-estimate | `@engineering-excellence estimate_change_cost --check` (over budget → FAIL until the user approves, then pass `--cost-approved "<reason>"`) |
| contrast-audit | product routes (see visual rules) |
<!-- ‹guest · 2026-12-05› -->

### Sign-off (`--signoff` or `--pr`)

| Check | Rule |
|-------|------|
| git-clean | dirty tree → FAIL. Gate reports, contrast audits, and skill auto-sync files do not count |
| git-pushed | unpushed commits → FAIL |
| pr-checks | `gh pr checks` failing/pending → FAIL. No checks reported passes only when the repo configures no CI |
| pr-review-threads | unresolved review threads → FAIL (run respond), except those declined as below |
| signoff-emergency-skips | `--skip-backend` / setup / engineering / cost → FAIL |
| visual | with a frontend, routes, and `.heyeddi/product.md`: no reachable app → FAIL. No Python with Playwright → FAIL when the PR changes UI files, SKIP with the reason when it does not |

### Declined threads

An unresolved thread passes only when its last reply is the PR author's and starts with `**Declined:**` followed by a reason. The report lists every such thread with its link and reason; repeat that list in the final summary. A later comment by anyone else makes the thread block again.

### Pending checks

Run `@heyeddi-ci-fails` `watch_checks --pr <N>` in the background and read its JSON result, then rerun the gate. A `pending` or `none` outcome goes under **Needs you** with the check names. Rules: `@heyeddi` `reference/bounded-waits.md`.

### Backend runner

With `uv.lock` / `[tool.uv]` or `poetry.lock` / `[tool.poetry]` (in `backend/` or the root), pytest and ruff run through `uv run` / `poetry run`. Install missing dependencies with the same tool. Otherwise `backend/.venv` or the system Python is used.

### Changed files only

The prose and engineering audits still scan the whole repo, but only findings in files the PR changes block the merge. The rest shows as `repo-wide N (info)` in the row. Changed means the PR's file list (`gh pr diff --name-only`), or without a PR everything that differs from the merge base with the branch PRs target (`git.pr_base` or `git.default_branch` in `.heyeddi/stack.json`, else `origin/HEAD`, else main or master), including uncommitted and untracked files. Gate reports and auto-sync files do not count. Editing a file that already breaks a rule, such as a file over 800 lines, still fails: fix it while you are there. When git cannot tell what changed, the whole repo is judged. `--all-files` restores whole-repo judging.

Run on their own, `verify_prose.py` and `audit_engineering.py` judge the whole repo. Pass `--files <path>...` to judge only those files.

### Visual audit

SKIP when there is no frontend or `.heyeddi/product.md` lists no routes. The audit runs with the first Python that can import Playwright: `$HEYEDDI_PLAYWRIGHT_PYTHON`, the Python running the gate, the project `.venv`, the project Poetry environment, then `python3` and `python` on PATH. The probe runs in the project folder, so a pyenv shim picks the project's version. With `DEV_SERVER_URL` set, that server is audited. Otherwise the gate starts `npm run dev` on a free port and stops it afterwards. A frontend without an `npm run dev` script (Flutter web): start it yourself, set `DEV_SERVER_URL`, and stop it when done.

### Approved cost

Only after the user approved the spend: `pre_merge_gate.py --signoff --cost-approved "<their reason>"`. The approval is recorded in `.heyeddi/docs/engineering/decisions.md`. Commit that entry and push, then rerun with the same flag; it is not recorded twice.

### Flags

<!-- ‹guest · 2026-12-05› -->
- `--cost-approved "<reason>"`: pass the user's cost approval to `estimate_change_cost --approved`

- `--all-files`: prose and engineering audits fail on findings anywhere in the repo, as before
- `--base <ref>`: without a PR, judge files changed since the merge base with `<ref>` (for example `origin/dev` when PRs target dev)
- `--skip-duplicate-ui`, `--skip-prose-audit`, `--skip-visual-audit`, `--skip-flutter`, `--skip-git-clean`
- Emergency only (blocked under sign-off): `--skip-backend`, `--skip-engineering-audit`, `--skip-setup-audit`, `--skip-cost-estimate`
- `--no-pr` with `--signoff`: local sign-off without PR/CI/thread checks (still git-clean + emergency ban)

## Never

- Claim merge-ready without exit 0 under `--signoff` or `--pr`
- Use emergency skips for real merge sign-off
- Substitute this skill for code review or thread replies
- Treat SKIP as PASS when a required tree exists but tooling is missing

## When the task is complete: suggest next skills

```bash
python .agents/skills/heyeddi/scripts/suggest_next_skill.py --current-skill pre-merge-gate --project-root .
```

Add `--route /path` or `--mode <sub-command>` when you know them. If the suggested skill is still part of the user's request, run it now; do not hand it back. What happens after the request is done (backlog, merges, the final summary) follows `@heyeddi` `reference/autonomy.md`. Anything from the request you could not finish goes under **Needs you** with the reason. See `@heyeddi` `reference/next-skill-handoff.md`.

این نسخه با نشانه‌گذاری اختصاصی حساب شما نمایش داده می‌شود. برای نصب سریع، به تب نصب و راه‌اندازی بروید.

مهارت‌های مشابه و پیشنهادی

مشاهدهٔ همه ←
عامل‌های هوش مصنوعی
✦ Pro

REA

دستورالعمل اجرایی آماده برای انجام دقیق کارهای عامل‌های هوش مصنوعی بدون تکرار پرامپت‌های طولانی. (شامل ۶۵ گام عملی · سا…

⚡ /reverse-engineer-anything SKILL.md
Claude / Claude CodeOpenAI Codex +۲
۹۴/۱۰۰ ★ ۴۷۹,۷۷۳
عامل‌های هوش مصنوعی
✦ Pro

Verification Before Completion

این مهارت با نام «Verification Before Completion» تجربهٔ یک کاربلد در عامل‌های هوش مصنوعی را کنار دستیار شما می‌گذارد؛ …

⚡ /verification-before-completion SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

Dispatching Parallel Agents

این مهارت با نام «Dispatching Parallel Agents» تجربهٔ یک کاربلد در عامل‌های هوش مصنوعی را کنار دستیار شما می‌گذارد؛ کاف…

⚡ /dispatching-parallel-agents SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

Using Git Worktrees

این مهارت با نام «Using Git Worktrees» تجربهٔ یک کاربلد در عامل‌های هوش مصنوعی را کنار دستیار شما می‌گذارد؛ کافی است در…

⚡ /using-git-worktrees SKILL.md
Cline
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

Subagent-Driven Development

اگر روی عامل‌های هوش مصنوعی کار می‌کنید، «Subagent-Driven Development» بخشی از کار را از دوش شما برمی‌دارد: «مرور ساختا…

⚡ /subagent-driven-development SKILL.md
Claude / Claude Code
۹۴/۱۰۰ ★ ۳۲۴,۲۹۰
عامل‌های هوش مصنوعی
✦ Pro

The Rule

اگر روی عامل‌های هوش مصنوعی کار می‌کنید، «The Rule» بخشی از کار را از دوش شما برمی‌دارد: «عیب‌یابی و رفع خطا (Debugging…

⚡ /using-superpowers SKILL.md
Claude / Claude CodeOpenAI Codex +۱
۹۱/۱۰۰ ★ ۳۲۴,۲۹۰