Skip to main content

Finish a thread with a pull request and auto-merge

You end with a thread whose pull request merged automatically once its conflict was resolved and the required test check passed.

  • SpecWithCode
  • 1:19
  • Codex
  • Narrated, with captions

Recorded on SpecWithCode 1.0.48 with SpecWeave 3.1.1, 18 October 2026, added 18 October 2026. The current release is SpecWithCode 1.0.44.

Before you start: SpecWithCode for Mac; a signed-in coding agent (Codex in this video); a GitHub repository with Git and GitHub sign-in on the machine that runs the thread; a SpecWeave increment planned (optional).

Length 1:19Captions

Steps

  1. Start a worker thread from the project coordinator, for example: Start a thread titled "Greet a team" in a new worktree from main. The thread gets its own worktree and branch (here greet/greet-a-team, from the branch prefix greet/).
  2. Let the thread finish its work with a clean worktree and nothing queued. With the project's rule set to Open PR and auto-merge, SpecWithCode pushes the branch, opens a pull request into the default branch and turns on the host's auto-merge. The thread shows each step as a notice: Opened #2 into main, then Auto-merge on for #2; it merges into main when checks pass.
  3. If the base branch changed the same lines, the thread shows #2 conflicts with main; not merging. Nothing is merged or force-pushed.
  4. Set the rule per project: open the project's settings (Applying settings for greet-app) and, under Repositories, choose When a thread finishes: Leave branch, Open PR or Open PR and auto-merge. The same card sets Default merge method (Squash and merge here) and Remove agent credits when merging.
  5. Open Code Review to see the pull request. Its summary shows Blocked, Conflicts with the base, and the armed Auto-merge (squash and merge); the Code tab shows the changed files.
  6. Send the conflict back to the thread that wrote the code, for example: main changed under this pull request. Merge main in, resolve the conflicts, run npm test, then commit and push.
  7. Auto-merge stays on. When the required checks pass, GitHub merges the pull request and the thread shows Merged #2 into main.

Transcript

Built from the caption file of the narration.

0:00 What you will see

Finish a thread with a pull request and auto-merge.

0:04 The thread finishes and opens a PR

In greet-app, the coordinator started a thread, Greet a team, in its own worktree. Codex does T-01 of increment 0002, commits, and stops with a clean tree. Then the project's finish rule runs: SpecWithCode opens pull request #2 into main, and turns on auto-merge. But main changed the same lines, so the thread reports a conflict and does not merge.

0:31 Open PR and auto-merge, per project

The rule is a project setting: When a thread finishes, Open PR and auto-merge. This project squashes on merge and removes agent credit lines.

0:42 Code Review

Code Review shows the pull request blocked by the conflict, with auto-merge armed. No review is required in this repo. The Code tab shows the thread's change.

0:52 Resolve the conflict in its thread

Send the conflict back to the thread that wrote the code. Codex merges main, keeps the new Hi wording for teams, runs npm test, and pushes.

1:03 Merged

Auto-merge is still on. The required test check passes, and GitHub merges it. The thread shows Merged #2 into main.

1:13 Next: sw-done

Next, sw-done verifies and closes the increment.

Download SpecWithCode for MacRead the reference

Learning path

Run SpecWithCode

Understand the setup, run a project through its coordinator, then add plans, memory and a second provider.

  1. See how SpecWithCode runs your agents

    2:54, SpecWithCode

  2. Start SpecWithCode with a coordinator and two workers

    1:48, SpecWithCode

  3. Run a project with a coordinator and workers

    1:29, SpecWithCode

  4. Plan, verify and schedule project work

    1:35, SpecWithCode

  5. Keep project memory and read honest usage

    1:06, SpecWithCode

  6. Continue a thread on Codex at a usage limit

    1:01, SpecWithCode

  7. Keep working when a provider runs out

    1:39, SpecWithCode

  8. Add a second machine

    1:13, SpecWithCode

  9. Finish a thread with a pull request and auto-merge (this guide)

    1:19, SpecWithCode

  10. Let agents use a browser

    1:10, SpecWithCode

One more guide is planned for this path.

All tutorials