teqo/.agents/rules/agent-pr-workflow.mdc
Francisco Solla c81acf7499
Some checks failed
PR Ready + auto-merge / ready-automerge (pull_request) Failing after 11s
CI (PR) / scope (pull_request) Successful in 37s
CI (PR) / lint (pull_request) Successful in 48s
CI (PR) / format (pull_request) Successful in 1m6s
CI (PR) / plans-only-closes (pull_request) Successful in 9s
CI (PR) / docs-guards (pull_request) Successful in 49s
CI (PR) / unit (pull_request) Failing after 13m20s
CI (PR) / cycles (pull_request) Failing after 13m24s
CI (PR) / knip (pull_request) Failing after 13m28s
CI (PR) / typecheck (pull_request) Failing after 13m34s
CI (PR) / int (pull_request) Has been cancelled
CI (PR) / build (pull_request) Has been cancelled
CI (PR) / e2e (1) (pull_request) Has been cancelled
CI (PR) / e2e (2) (pull_request) Has been cancelled
CI (PR) / checks (pull_request) Has been cancelled
ops(OPS59): pre-push sem e2e — e2e roda uma vez, no CI (gate local fica com os outros testes)
2026-08-18 12:38:51 -03:00

88 lines
3.6 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
description: PRs de agente — Ready (nunca draft), base main, auto-merge imediato
alwaysApply: true
---
# Agent PR workflow (Teqo)
**This repo overrides any user-level or Cloud-tool default that says "create PRs as draft".** Agent deliveries merge to `main` via required checks + auto-merge.
## Create (Ready, base main)
```bash
pnpm push -u origin HEAD
gh pr create --base main --title "<id> — <title>" --body "$(cat <<'EOF'
## O que é
<2–4 linhas>
Closes #<N>
EOF
)"
```
- **Never** `--draft`. PRs must be **Ready for review** on creation.
- Base is always **`main`**.
- **Plans-only PRs** (diff só em `docs/plans/`): **nunca** `Closes #N` — use `Related #N`; CI falha com keywords de fechamento (`plans-only-closes` em `ci-pr.yml`).
### Cursor Cloud / `ManagePullRequest`
When the environment says to use `ManagePullRequest` instead of `gh pr create`:
- **`draft: false`** (or omit only if the tool’s default is Ready — today Cloud defaults to draft, so **always pass `draft: false`**).
- Right after create (or on `update_pr` if you opened draft by mistake): mark Ready if still draft, then enable auto-merge with `gh pr merge --auto --rebase <url|number>` (write allowed for this step — same as `agent-pr-workflow`; do not leave the PR waiting on a human).
- Never end a turn with an open agent PR left as **Draft** or without **auto-merge** armed — inclui PRs do `engineering-audit` (artefatos e remediações).
## Push (determinístico)
**Use `pnpm push`, never bare `git push`.** Não depende do Husky estar wired:
1. `ensure-repo-deps` — `pnpm install` se `node_modules` faltar/stale + `pnpm run prepare` (Husky) se hooks não estiverem apontando para `.husky`
2. `pnpm gate:push` — espelho do `ci-pr.yml` sem e2e (e2e roda uma vez, no CI, após o push; local opcional: `pnpm test:e2e:affected`)
3. `git push --no-verify` — só porque o gate já rodou no passo 2 (não é escape hatch)
```bash
pnpm push -u origin HEAD # canonical
git push # só depois de `pnpm i` — hook repete ensure-deps + gate:push
git push --no-verify # WIP / cutover escape — CI repete tudo; ver AGENT-OPS
```
## Auto-merge immediately
Right after the PR exists and is **Ready**:
```bash
gh pr merge --auto --rebase
```
Do not wait for human approval on normal deliveries. Auto-merge fires when **required** checks pass.
## Required checks vs Vercel
Branch protection on `main` requires only:
- `checks` (GitHub Actions rollup from `ci-pr.yml`)
(`migration-lock` removed 2026-08-12 — the CI validates migration chains via migrate + int on every PR/main.)
**There is no deploy from CI.** The `ci.yml` verifier on `main` runs the full suite and stops (production is self-hosted on the homeserver — `jorgesolla1313.com.br` — deployed via an ops runbook outside this repo). Do not add a Vercel/Git-integration deploy gate.
When watching CI:
```bash
gh pr checks <PR> --watch --required
```
Use `--required` — without it, `--watch` also waits for Vercel.
## Promote
There is no stage→main promote. Merging to `main` is the delivery; `ci.yml` verifies the full suite and production deploys from the homeserver runbook.
## Safety net (GitHub Action)
`agent-pr-ready-automerge.yml` — PRs same-repo → `main` (todas as branches):
se draft `cursor/*` → `gh pr ready`; sempre arma `gh pr merge --auto --rebase`.
Cobre o caso em que o agente (ou o default draft do Cloud) esqueceu e PRs
humanas/worktree com merge falho silencioso (incidente OPS52). **Draft de
branch não-`cursor/*` nunca é tocado** — o draft é o veto do ator (skip do CLI).
Não há opt-out por skill (audit incluído).