Join
Intent
Run a continuous PR operator using gh commands only. Keep PRs created, green, and merge-ready with minimal-incision fixes. Do not approve or merge PRs unless explicitly instructed by the user.
Command boundary (hard rule)
- Use only
gh CLI commands (gh pr, gh run, gh api, gh repo).
- Do not run
git or any non-gh command.
- If a required action cannot be completed with
gh alone, apply auto:hold and leave a blocking comment.
Quick start
- Ensure
gh auth status succeeds.
- Ensure labels exist:
auto:manage, auto:hold.
- Start the monitor loop.
Auth preflight (required)
- Run these checks before any PR routing or mutation:
gh auth status
gh repo view <owner>/<repo> --json nameWithOwner --jq .nameWithOwner
- If either check fails:
- Fail fast for the current run.
- Apply
auto:hold on affected PRs (or emit hold outcome in cloud loop when no PR is selected yet).
- Record reason as
auth_unavailable.
Label contract
auto:manage: opt-in to automation.
auto:hold: pause automation.
Contributor guidance:
- Add
auto:manage to opt in.
- Add
auto:hold to stop the operator.
PR creation policy (gh-only)
- For every non-default branch discoverable via
gh api without an open PR, create a PR.
- Use the repo PR template if present; else use
assets/pr-template.md.
- Prefer
gh pr create --fill and apply auto:manage.
- Default to ready-for-review (no drafts unless configured).
Operating mode
Use one mode only:
gh-only remote mode: no local checkout assumptions and no local workspace mutations.
Cloud Join operator ($puff + seq -> join)
Use this when running Join as a cloud subagent loop:
- Launch with
$puff join-operator.
- For each patch artifact, route by weighted manifest-first scoring (include PR file-path hydration via
gh pr view <num> --json files): target_pr_hint (+5.0), touched_entities overlap (+0..4.5), changed_paths overlap (+0..3.0), base-branch match (+1.5), and issue_refs (+0.5 each, max +1.0). Compute confidence as min(0.99, (raw_score / 12.0) * risk_multiplier) where risk_multiplier={low:1.00, medium:0.95, high:0.80, critical:0.65}.
- If routing gates fail, run
$seq first to recover intent/context. Routing gates are: confidence below effective threshold (threshold * risk_threshold_multiplier where risk_threshold_multiplier={low:0.95, medium:1.00, high:1.15, critical:1.25}), top-two score margin < 0.75, no entity/path/hint signal, manifest entities exist but no entity match, or risk_level is high|critical.
- Then run
$join for gh-only PR operations and CI/handoff behavior.
Launch recipe:
"$PUFF_SCRIPT" join-operator --env <env-id-or-label> --repo <owner/repo> --patch-inbox <locator>
- Canary recipe (one bounded cycle):
"$PUFF_SCRIPT" join-operator --env <env-id-or-label> --repo <owner/repo> --patch-inbox <locator> --canary
Cloud auth note:
- In cloud environments, provide
GH_TOKEN (or GITHUB_TOKEN) with repo-scoped permissions needed for join operations.
Patch manifest contract
Patch producers should emit a manifest that validates against:
assets/cloud-join-manifest.schema.json
assets/cloud-join-manifest.example.minimal.json (copy-ready minimal example)
assets/cloud-join-manifest.example.full.json (copy-ready full example)
Required fields:
patch_id
producer
repo (owner/repo)
base_branch
changed_paths (non-empty)
intent_summary
Optional routing hints:
target_pr_hint
issue_refs
touched_entities (array of objects with entity; optional file and kind)
risk_level (low|medium|high|critical)
confidence
patch_file
Monitor loop
Process PRs sequentially (blocking per PR on CI):
- List open PRs:
gh pr list --state open --json number,title,headRefName,labels,isDraft.
- For each PR:
- Skip if
auto:hold.
- Skip if not
auto:manage and not agent-created.
- If draft, mark ready:
gh pr ready <num>.
- Keep the branch current with
gh pr update-branch <num> --rebase when available.
- Enforce CI gate (required checks only; see below).
- If failing, run the surgical fix loop.
- When green, publish merge-ready handoff status.
- Do not approve or merge.
CI gate (required checks only)
- Gate on required checks only (
gh pr checks --required). Optional checks do not block handoff.
- Detect “ungated” repos/PRs (no required checks):
- If
gh pr checks <num> --required --json name returns an empty list, treat CI as green and proceed to handoff.
- Wait for required checks (blocking):
gh pr checks <num> --required --watch --fail-fast
- This blocks until all required checks pass or the first required check fails.
- Stalled CI (10 minutes with no observable progress):
- Define “progress” as any change in the required-check snapshot (
name, bucket, startedAt, completedAt).
- While waiting, periodically sample:
gh pr checks <num> --required --json name,bucket,startedAt,completedAt.
- If the snapshot does not change for 10 minutes while not all checks are
bucket=pass, apply auto:hold and leave a summary comment with links to the stuck checks.
- Treat
bucket=pending, bucket=skipping, and bucket=cancel as “not green” (blocked) until resolved; do not mark as handoff-ready through them.
- Drill into GitHub Actions when needed:
- Identify check links:
gh pr checks <num> --required --json name,bucket,link,workflow
- Find likely runs:
gh run list --branch <headRefName> --limit 10
- Watch a run live:
gh run watch <run-id> --compact --exit-status
- Fetch failing step logs:
gh run view <run-id> --log-failed
Surgical fix loop (gh-only)
Smallest change that makes CI green using gh only:
- Read the failure from CI logs.
- Apply the minimal fix through GitHub APIs via
gh api on the PR head branch.
- Re-run checks and re-evaluate.
- Apply a hard regression floor before each new attempt:
- Snapshot required checks before and after each attempt (
gh pr checks <num> --required --json name,bucket).
- If required checks get worse (for example: more failing checks, fewer passing checks, or a new blocked required check), stop immediately, apply
auto:hold, and publish hold_reason=regression_floor_worsened.
- If two consecutive attempts show no reduction in failing required checks, stop, apply
auto:hold, and publish hold_reason=regression_floor_no_improvement.
- Limit attempts (default 3). On exhaustion, permission issues, or hard conflicts:
- Leave a summary comment.
- Request changes as last resort.
- Apply
auto:hold.
Handoff (no merge)
- When required checks are green (or no required checks exist) and no hold:
- Update status/comment to indicate: ready for human review/merge.
- Keep the PR open.
- Policy:
- Never run
gh pr merge (any flags).
- Never run
gh pr review --approve unless explicitly instructed by the user.
- Confirm handoff state:
gh pr view <num> --json state,mergeStateStatus,reviewDecision
Adaptive polling
- Poll under 60s unless CI is slow.
- Use recent CI duration to back off (cap at 120s).
- Exponential backoff on API errors.
Status reporting
- Maintain a single PR comment/check-run named
Join Operator.
- Update in place (avoid comment spam).
- Include machine-checkable fields in each status update:
raw_score
score_breakdown (target_pr_hint, entity_overlap, entity_hits, path_overlap, base_branch_match, issue_refs, risk_multiplier)
threshold_decision (confidence_threshold, effective_confidence_threshold, risk_threshold_multiplier, score_margin, needs_seq_reasons)
conflict_kind (none|routing|merge|policy|permission|ci)
complexity (low|medium|high)
confidence (0.00-1.00)
resolution_hint (actionable next step; none only when resolved)
action_taken
status (applied|hold|failed|no_match)
hold_reason
Gh-only block comment template
Join Operator: gh-only automation block
This PR needs an action outside the gh-only boundary (for example, manual conflict resolution or a local-only edit path).
Apply the needed commit manually, then remove `auto:hold`.
Stalled CI comment template
Join Operator: required checks stalled
Required checks showed no progress for 10 minutes.
Investigate the linked runs, unblock CI, then remove `auto:hold`.
Recipes (gh-only)
- Default branch:
gh repo view --json defaultBranchRef --jq .defaultBranchRef.name
- Branch discovery:
gh api repos/<owner>/<repo>/branches --paginate --jq '.[].name'
- Create:
gh pr create --fill --head <branch> --label auto:manage
- Open PRs:
gh pr list --state open --json number,title,headRefName,labels,isDraft
- Mark ready:
gh pr ready <num>
- Update branch:
gh pr update-branch <num> --rebase
- PR head OID:
gh pr view <num> --json headRefOid --jq .headRefOid
- Required checks (summary):
gh pr checks <num> --required
- Required checks (watch):
gh pr checks <num> --required --watch --fail-fast
- Required checks (links/JSON):
gh pr checks <num> --required --json name,bucket,link,workflow
- Actions runs (by branch):
gh run list --branch <branch> --limit 10
- Actions run logs:
gh run view <run-id> --log-failed
- Request changes:
gh pr review <num> --request-changes --body "<reason>"
- Handoff state:
gh pr view <num> --json state,mergeStateStatus,reviewDecision
- Handoff note (example):
gh pr comment <num> --body "Join Operator: required checks are green; ready for human merge."
Assets
assets/pr-template.md
assets/cloud-join-manifest.schema.json
assets/cloud-join-manifest.example.minimal.json
assets/cloud-join-manifest.example.full.json
assets/cloud-join-operator-prompt.md
scripts/build_cloud_join_prompt.py
scripts/manifest_router.py
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: tkersey-dotfiles-join3description: Join4---56# Join78## Intent9Run a continuous PR operator using `gh` commands only. Keep PRs created, green, and merge-ready with minimal-incision fixes. Do not approve or merge PRs unless explicitly instructed by the user.1011## Command boundary (hard rule)12- Use only `gh` CLI commands (`gh pr`, `gh run`, `gh api`, `gh repo`).13- Do not run `git` or any non-`gh` command.14- If a required action cannot be completed with `gh` alone, apply `auto:hold` and leave a blocking comment.1516## Quick start171. Ensure `gh auth status` succeeds.182. Ensure labels exist: `auto:manage`, `auto:hold`.193. Start the monitor loop.2021## Auth preflight (required)22- Run these checks before any PR routing or mutation:23 - `gh auth status`24 - `gh repo view <owner>/<repo> --json nameWithOwner --jq .nameWithOwner`25- If either check fails:26 - Fail fast for the current run.27 - Apply `auto:hold` on affected PRs (or emit hold outcome in cloud loop when no PR is selected yet).28 - Record reason as `auth_unavailable`.2930## Label contract31- `auto:manage`: opt-in to automation.32- `auto:hold`: pause automation.3334Contributor guidance:35- Add `auto:manage` to opt in.36- Add `auto:hold` to stop the operator.3738## PR creation policy (gh-only)39- For every non-default branch discoverable via `gh api` without an open PR, create a PR.40- Use the repo PR template if present; else use `assets/pr-template.md`.41- Prefer `gh pr create --fill` and apply `auto:manage`.42- Default to ready-for-review (no drafts unless configured).4344## Operating mode45Use one mode only:46- `gh`-only remote mode: no local checkout assumptions and no local workspace mutations.4748## Cloud Join operator (`$puff` + `seq -> join`)49Use this when running Join as a cloud subagent loop:501. Launch with `$puff` `join-operator`.512. For each patch artifact, route by weighted manifest-first scoring (include PR file-path hydration via `gh pr view <num> --json files`): `target_pr_hint` (+5.0), `touched_entities` overlap (+0..4.5), `changed_paths` overlap (+0..3.0), base-branch match (+1.5), and `issue_refs` (+0.5 each, max +1.0). Compute confidence as `min(0.99, (raw_score / 12.0) * risk_multiplier)` where `risk_multiplier={low:1.00, medium:0.95, high:0.80, critical:0.65}`.523. If routing gates fail, run `$seq` first to recover intent/context. Routing gates are: confidence below effective threshold (`threshold * risk_threshold_multiplier` where `risk_threshold_multiplier={low:0.95, medium:1.00, high:1.15, critical:1.25}`), top-two score margin `< 0.75`, no entity/path/hint signal, manifest entities exist but no entity match, or `risk_level` is `high|critical`.534. Then run `$join` for gh-only PR operations and CI/handoff behavior.5455Launch recipe:56- `"$PUFF_SCRIPT" join-operator --env <env-id-or-label> --repo <owner/repo> --patch-inbox <locator>`57- Canary recipe (one bounded cycle):58 - `"$PUFF_SCRIPT" join-operator --env <env-id-or-label> --repo <owner/repo> --patch-inbox <locator> --canary`5960Cloud auth note:61- In cloud environments, provide `GH_TOKEN` (or `GITHUB_TOKEN`) with repo-scoped permissions needed for join operations.6263## Patch manifest contract64Patch producers should emit a manifest that validates against:65- `assets/cloud-join-manifest.schema.json`66- `assets/cloud-join-manifest.example.minimal.json` (copy-ready minimal example)67- `assets/cloud-join-manifest.example.full.json` (copy-ready full example)6869Required fields:70- `patch_id`71- `producer`72- `repo` (`owner/repo`)73- `base_branch`74- `changed_paths` (non-empty)75- `intent_summary`7677Optional routing hints:78- `target_pr_hint`79- `issue_refs`80- `touched_entities` (array of objects with `entity`; optional `file` and `kind`)81- `risk_level` (`low|medium|high|critical`)82- `confidence`83- `patch_file`8485## Monitor loop86Process PRs sequentially (blocking per PR on CI):871. List open PRs: `gh pr list --state open --json number,title,headRefName,labels,isDraft`.882. For each PR:89 - Skip if `auto:hold`.90 - Skip if not `auto:manage` and not agent-created.91 - If draft, mark ready: `gh pr ready <num>`.92 - Keep the branch current with `gh pr update-branch <num> --rebase` when available.93 - Enforce CI gate (required checks only; see below).94 - If failing, run the surgical fix loop.95 - When green, publish merge-ready handoff status.96 - Do not approve or merge.9798## CI gate (required checks only)99- Gate on required checks only (`gh pr checks --required`). Optional checks do not block handoff.100- Detect “ungated” repos/PRs (no required checks):101 - If `gh pr checks <num> --required --json name` returns an empty list, treat CI as green and proceed to handoff.102- Wait for required checks (blocking):103 - `gh pr checks <num> --required --watch --fail-fast`104 - This blocks until all required checks pass or the first required check fails.105- Stalled CI (10 minutes with no observable progress):106 - Define “progress” as any change in the required-check snapshot (`name`, `bucket`, `startedAt`, `completedAt`).107 - While waiting, periodically sample: `gh pr checks <num> --required --json name,bucket,startedAt,completedAt`.108 - If the snapshot does not change for 10 minutes while not all checks are `bucket=pass`, apply `auto:hold` and leave a summary comment with links to the stuck checks.109 - Treat `bucket=pending`, `bucket=skipping`, and `bucket=cancel` as “not green” (blocked) until resolved; do not mark as handoff-ready through them.110- Drill into GitHub Actions when needed:111 - Identify check links: `gh pr checks <num> --required --json name,bucket,link,workflow`112 - Find likely runs: `gh run list --branch <headRefName> --limit 10`113 - Watch a run live: `gh run watch <run-id> --compact --exit-status`114 - Fetch failing step logs: `gh run view <run-id> --log-failed`115116## Surgical fix loop (gh-only)117Smallest change that makes CI green using `gh` only:1181. Read the failure from CI logs.1192. Apply the minimal fix through GitHub APIs via `gh api` on the PR head branch.1203. Re-run checks and re-evaluate.1214. Apply a hard regression floor before each new attempt:122 - Snapshot required checks before and after each attempt (`gh pr checks <num> --required --json name,bucket`).123 - If required checks get worse (for example: more failing checks, fewer passing checks, or a new blocked required check), stop immediately, apply `auto:hold`, and publish `hold_reason=regression_floor_worsened`.124 - If two consecutive attempts show no reduction in failing required checks, stop, apply `auto:hold`, and publish `hold_reason=regression_floor_no_improvement`.1255. Limit attempts (default 3). On exhaustion, permission issues, or hard conflicts:126 - Leave a summary comment.127 - Request changes as last resort.128 - Apply `auto:hold`.129130## Handoff (no merge)131- When required checks are green (or no required checks exist) and no hold:132 - Update status/comment to indicate: ready for human review/merge.133 - Keep the PR open.134- Policy:135 - Never run `gh pr merge` (any flags).136 - Never run `gh pr review --approve` unless explicitly instructed by the user.137- Confirm handoff state:138 - `gh pr view <num> --json state,mergeStateStatus,reviewDecision`139140## Adaptive polling141- Poll under 60s unless CI is slow.142- Use recent CI duration to back off (cap at 120s).143- Exponential backoff on API errors.144145## Status reporting146- Maintain a single PR comment/check-run named `Join Operator`.147- Update in place (avoid comment spam).148- Include machine-checkable fields in each status update:149 - `raw_score`150 - `score_breakdown` (`target_pr_hint`, `entity_overlap`, `entity_hits`, `path_overlap`, `base_branch_match`, `issue_refs`, `risk_multiplier`)151 - `threshold_decision` (`confidence_threshold`, `effective_confidence_threshold`, `risk_threshold_multiplier`, `score_margin`, `needs_seq_reasons`)152 - `conflict_kind` (`none|routing|merge|policy|permission|ci`)153 - `complexity` (`low|medium|high`)154 - `confidence` (`0.00-1.00`)155 - `resolution_hint` (actionable next step; `none` only when resolved)156 - `action_taken`157 - `status` (`applied|hold|failed|no_match`)158 - `hold_reason`159160## Gh-only block comment template161```162Join Operator: gh-only automation block163164This PR needs an action outside the gh-only boundary (for example, manual conflict resolution or a local-only edit path).165Apply the needed commit manually, then remove `auto:hold`.166```167168## Stalled CI comment template169```170Join Operator: required checks stalled171172Required checks showed no progress for 10 minutes.173Investigate the linked runs, unblock CI, then remove `auto:hold`.174```175176## Recipes (gh-only)177- Default branch: `gh repo view --json defaultBranchRef --jq .defaultBranchRef.name`178- Branch discovery: `gh api repos/<owner>/<repo>/branches --paginate --jq '.[].name'`179- Create: `gh pr create --fill --head <branch> --label auto:manage`180- Open PRs: `gh pr list --state open --json number,title,headRefName,labels,isDraft`181- Mark ready: `gh pr ready <num>`182- Update branch: `gh pr update-branch <num> --rebase`183- PR head OID: `gh pr view <num> --json headRefOid --jq .headRefOid`184- Required checks (summary): `gh pr checks <num> --required`185- Required checks (watch): `gh pr checks <num> --required --watch --fail-fast`186- Required checks (links/JSON): `gh pr checks <num> --required --json name,bucket,link,workflow`187- Actions runs (by branch): `gh run list --branch <branch> --limit 10`188- Actions run logs: `gh run view <run-id> --log-failed`189- Request changes: `gh pr review <num> --request-changes --body "<reason>"`190- Handoff state: `gh pr view <num> --json state,mergeStateStatus,reviewDecision`191- Handoff note (example): `gh pr comment <num> --body "Join Operator: required checks are green; ready for human merge."`192193## Assets194- `assets/pr-template.md`195- `assets/cloud-join-manifest.schema.json`196- `assets/cloud-join-manifest.example.minimal.json`197- `assets/cloud-join-manifest.example.full.json`198- `assets/cloud-join-operator-prompt.md`199- `scripts/build_cloud_join_prompt.py`200- `scripts/manifest_router.py`201202---203> Converted and distributed by [TomeVault](https://tomevault.io/claim/tkersey) — claim your Tome and manage your conversions.204<!-- tomevault:4.0:skill_md:2026-04-11 -->