Issue to pr

From JayFarei/opentraces · View interactive version

Issue to pr is an AI agent skill from the GitHub repository JayFarei/opentraces. Take one or more GitHub issues and drive each to a review-ready pull request, holding one belief throughout: an issue is a hypothesis, not a spec. The pipeline VERIFIES BEFORE IT TRUSTS and runs TWO ADVERSARIES before it commits: multi-agent investigation of the real cause (flagging any "landmine" —

How to use this skill

Skill file

issue-to-pr

Distilled from the issue-#85 run. The load-bearing belief: an issue is a hypothesis, not a spec. Issues drift from the code, cite functions that no longer exist, and assert causes that aren't the real cause. So the pipeline verifies before it trusts, and runs two independent adversarial passes before committing to a plan — because on #85 both the codex pass and the self red-team independently caught the same real defects that a single reviewer missed.

Leading words (leitwörter)

A handful of leading words carry this skill. Use them by name — in your plan, your commits, your PR body, and your own reasoning. Each compresses a whole behavior into one token you can repeat to keep yourself honest, and each is borrowed from a discipline whose instincts you want to borrow with it. They recur on purpose.

Anti-patterns (the failure modes these words name)

State the leitwort, then catch yourself in its opposite:

This skill is the main-loop spine: it owns judgment, the worktree/PR lifecycle, the codex MCP calls, the human gate, and multi-issue orchestration. It delegates the bounded, read-only parallel fan-out to the Workflow tool (Stage 1), and expresses the implementation as a forged /goal (Stage 4) whose verify loop runs the otbox acceptance journey — so the implement↔verify and otbox-verify loops are one. Implementation is sequential in one worktree — a deliberate v1 choice: parallel file-editing across worktrees is conflict-prone and rarely pays off for a typical issue, so parallelism is confined to the phases where it is free and safe (investigation + multi-lens review).

Effort policy

Reasoning depth is a lever — spend it where judgment matters. Max for planning and adversarial testing; xhigh for normal development.

| Phase | Effort | Why |

|---|---|---|

| Plan (Stage 2) · both adversarial gates (3a self/ethos, 3b + 6 codex) · final synthesis | max | judgment and adversarial reasoning is where depth pays off — two adversaries, then commit |

| Implementation (Stage 4) and other normal dev work | xhigh | thorough, but mechanical |

| Investigation (Stage 1, read-only fan-out) | high | bounded evidence-gathering; reasoning needn't be maxed for grep-and-report |

Apply it through whatever lever the phase uses:

Model policy

Opus across the board. Run the main loop — planning, the adversarial gates, implementation, synthesis — on the latest Opus (the session default; don't downgrade it). The only exception is cheap, high-volume, mechanical work, where the latest Sonnet is appropriate: the Stage-1 investigation lenses (read-only grep-and-verify fan-out — N per issue, the highest fan-out in the pipeline, especially across multiple issues) run on model: 'sonnet', while their judgment-bearing synthesis runs on Opus. codex (Stages 3b/6) is GPT — Claude model selection doesn't apply there.

Inputs

/issue-to-pr <n> or /issue-to-pr <n> <m> ... — accepts issue numbers, #n, or full GitHub issue URLs. The repo is the current repo (gh repo view). No issue argument → ask which issue(s).

Multi-issue orchestration


Per-issue pipeline

Stage 0 — Intake & worktree (preflight; fail fast and honestly)

  1. Resolve the issue: gh issue view <n> --json number,title,body,state,labels,comments. If it's not OPEN, or not a real/actionable issue (discussion, duplicate, "wontfix"), STOP for this issue and report why — do not invent work.
  2. Preflight the environment (each is a terminal outcome for this issue if it fails, with a clear message — never half-start):
  1. Create the worktree off a FRESH base — fetch first, branch off the remote-tracking ref, so the fix never starts from a stale local main:

```bash

base=$(gh repo view --json defaultBranchRef -q .defaultBranchRef.name) # usually main

git fetch origin "$base"

git worktree add -b fix/issue-<n>-<slug> ../<repo>-issue-<n> "origin/$base"

```

(feat/… if the issue is labeled feature/enhancement.) Build/reuse a venv inside it (python3 -m venv .venv + pip install -e packages/opentraces-schema + pip install -e ".[dev]") — run it in the background while you investigate. The #85 lesson: in-process tests can't isolate import-bound $HOME paths, so the worktree + a fresh venv + $HOME-isolated / subprocess tests are the reliable substrate.

  1. All file work for this issue happens in that worktree from here on.

Stage 1 — Investigate (multi-agent, read-only) → Workflow · effort: high

Run the bundled investigation workflow, scoped to this issue:

Workflow({
  scriptPath: ".claude/skills/issue-to-pr/issue-investigate.workflow.js",
  args: { issue: <n>, title: "<title>", body: "<issue body>", repoRoot: "<worktree path>" }
})

Pass args as a real JSON object (the workflow also defensively parses a JSON-string form). Keep body to the issue's substance — the workflow re-reads the repo itself, so a multi-KB body isn't needed and risks the stringified-args footgun.

It fans out read-only Explore agents to produce three things (see references/stage-contracts.md for the exact return schema). Throughout, hold the line: an issue is a hypothesis — the workflow's job is to confirm, correct, or refute it against the current tree.

Read the consolidated report. If investigation shows the issue is invalid / already-fixed / misdiagnosed, that is a terminal outcome: report it (with evidence) and stop — a correct "this isn't a bug, here's why" beats a fabricated fix.

Stage 2 — Plan · effort: max

Create the plan at <worktree>/kb/plans/issue-<n>.md (mkdir -p <worktree>/kb/plans first — kb/ is gitignored, so a fresh worktree has no kb/; the plan is a working doc that won't be committed, which is correct). Use the absolute worktree path everywhere downstream (the forged goal references it). It MUST contain (template in references/stage-contracts.md):

Stage 3 — Dual adversarial gate on the plan · effort: max

Two adversaries, then commit. Two independent passes each try to BREAK the plan; fold both in before any code. Run this stage at max effort (and codex at its top tier) — adversarial reasoning is exactly where depth earns its cost.

3a — Self / ethos (main-loop checklist). Score the plan against references/ethos-checklist.md (the product-direction rubric derived from CLAUDE.md "Key Decisions"). Resolve every ❌. This is your own adversarial pass — be harsh.

3b — Codex pure adversarial (Plan Reviewer). Delegate read-only to a different model:

Fold both passes into the plan. Convergence between 3a and 3b on the same defect is the strongest signal. Re-run a pass only if a blocker materially reshaped the plan.

Stage 4 — Implement as a forged `/goal`, with otbox verify *inside* the goal loop · effort: xhigh

Implementation is not ad-hoc coding — it is a persistent goal whose verification surface includes the otbox acceptance journey, so the implement↔verify loop and the otbox verify loop are the same loop. The goal is not DONE until the journeys are green. (goal-forge's rule: the evaluator judges only what lands in the transcript — so the verification surface must be commands that run and report, which is precisely what folds the otbox run into the goal's completion check.)

4a — Forge the implementer goal with /goal-forge --claude --fast. Supply the six slots from the hardened plan so goal-forge drafts without interviewing (template in references/stage-contracts.md):

4b — The goal contract (the loop):

4c — Run it. Run the forged Goal as the session /goal (Claude Code /goal, v2.1.139+ — needs workspace trust + hooks enabled; see goal-forge's harness notes) and work it to DONE; or, when the session's single goal slot is needed elsewhere or issues run in parallel, hand the forged prompt to an implementer subagent for an isolated run. If /goal is unavailable (no trust / hooks disabled), run the SAME forged contract by hand — the DONE / NOT-DONE / BLOCKED conditions + the run log still drive the loop; only the Stop-hook evaluator is missing. Either way the loop is the same: implement → run mechanism tests + the otbox journey(s) → triage → repeat. Match surrounding code; reuse the reversers/registries the investigation surfaced. otbox authoring gotchas (#85): path_exists doesn't expand ~ (use {opentraces_dir} / {project}); stdout_json_contains is substring (use stdout_json exact / stdout_json_set_contains for arrays); a shell step expected to exit non-zero needs expect_returncode = N; run the catalogue lint; a new CLI verb/flag/envelope trips the surface-sweep / snapshot tests (update GLOBAL_JSON_ONLY + regenerate json_envelope_shapes.json — part of the work).

Stage 5 — Tests green + docs + PR

  1. /docs-update FIRST — always a step (standing directive). It self-scopes: if the change touches no doc surface it's a clean no-op; if it adds/changes a CLI verb, flag, schema field, or install/uninstall flow, it syncs README / installation / commands / SKILL.md / llms.txt. Never hand-edit llms.txt — regenerate it.
  2. Then re-confirm the relevant suite + the acceptance journey are green — docs-update may have mutated tracked files (llms.txt, docs), so verify after it, not before, or you commit an unverified state.
  3. Commit (conventional-commit subject; end the message with the Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> trailer).
  4. Push the branch; open the PR:

```bash

gh pr create --base <base> --head fix/issue-<n>-<slug> --title "..." --body-file <body>

```

The body MUST contain Closes #<n> (so the merge auto-closes the issue), a cause→fix→tests narrative, the test-completeness evidence, the otbox acceptance journey(s) added + their tier and CI status (acceptance is an otbox journey), and any unmet ACs (honesty). If gh pr create fails (no remote / perms), report the pushed branch + the exact command for the user to run.

Stage 6 — Final codex adversarial pass at the PR · effort: max (codex: high)

Stage 7 — Present (human gate — never merge)


Worktree lifecycle & cleanup

What this skill does NOT do

Failure / terminal outcomes (report, don't force)

issue-not-actionable (closed/discussion/duplicate) · issue-invalid (investigation refutes it) · gh-unauthenticated · dirty/colliding-worktree (resolve or rename) · tests-cannot-run (env broken) · codex-unavailable (substitute a Workflow red-team) · pr-create-failed (report branch + command). Each ends THIS issue's pipeline cleanly and moves to the next issue.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.