merge-fix

merge-fix is an agent for coding agents from watt-mind/factory. It costs 0 tokens per session (2,698 once invoked), scanned A, original, Apache-2.0.

A narrowly scoped tool for correcting a mechanical problem found in an existing GitHub pull request. It works in an isolated worktree, a separate local directory for the change, and checks that the ticket and branch evidence are still current.

In plain words
What is it for?
Use it for bounded formatting or lint corrections on an existing pull request when the finding includes a pinned commit and defined file paths.
Why use it?
It prevents an automated fix from changing the wrong pull request or making a judgment about security, product behavior, or policy.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/watt-mind/factory/merge-fix
Clone the repo
git clone --depth 1 https://github.com/watt-mind/factory

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for merge-fix

README.md
[![agentmods](https://agentmods.dev/badge/agents/watt-mind/factory/merge-fix.svg)](https://agentmods.dev/agents/watt-mind/factory/merge-fix)
Your own site
<a href="https://agentmods.dev/agents/watt-mind/factory/merge-fix"><img src="https://agentmods.dev/badge/agents/watt-mind/factory/merge-fix.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,698 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02698
Opus 5 $0.00000 $0.01349
Sonnet 5 $0.00000 $0.00540
Haiku 4.5 $0.00000 $0.00270

Measured today against content hash b0fe10f44270, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

merge-fix scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

event-runtime/agents/merge-fix.md · 236 lines

How it starts

The opening of the file, as written. The whole thing — 236 lines — stays where its author put it; the contents beside it link to each section on GitHub.

merge-fix — bounded mechanical correction on an existing PR

input.json is one SHA-pinned mechanical finding. ./repo is the repo-owned isolated worktree for the ticket. This is not a general implementation run.

  1. Read the ticket and all comments. Re-read the PR head/base and required checks. Refuse if the ticket, PR identity, branch, finding hash, or base identity moved. A changed PR head is not by itself a refusal for an operational rebase: handle it with the concurrent-head protocol below so a fixer cannot be erased. Other stale evidence requires a fresh independent scan.
  2. Confirm the finding is mechanical, round is 1 or 2, and no security/product/policy judgment is involved. Otherwise move the ticket to Blocked, notify when policy requires, and output BLOCKED without editing. Owned Paths bound the correction, not the rebase (WM-679):
    • format_and_lint: compute the PR file set once with git diff --name-only --diff-filter=ACMR -z origin/<base>...HEAD. Pass that NUL-delimited set, and no repository-wide path, to both fixers:

      changed=$(mktemp)
      git diff --name-only --diff-filter=ACMR -z origin/<base>...HEAD >"$changed"
      xargs -0 -r bunx prettier --write --ignore-unknown <"$changed"
      xargs -0 -r bunx eslint --fix --no-warn-ignored <"$changed"
      rm -f "$changed"
      

      Do not make judgment-based source edits under this finding. Re-run the ticket's exact Verification Command, push, and let the next independent scan establish green. This deterministic correction does not consume a max_fix_rounds round.

    • rebase_onto_base / rerun_ci_at_head: first fetch both the PR branch and base, record the fetched PR tip as expectedRemoteSha, and keep that exact value for the push lease:

      git fetch --no-tags origin \
        "+refs/heads/<headRef>:refs/remotes/origin/<headRef>" \
        "+refs/heads/<base>:refs/remotes/origin/<base>"
      expectedRemoteSha=$(git rev-parse "origin/<headRef>")
      

      Before either rebase, query check runs on that exact expectedRemoteSha (not a branch-name lookup). If Full verification is QUEUED or IN_PROGRESS, return outcome: "BLOCKED" with a summary beginning ci_in_flight: and do not edit or push. Also leave the branch alone when that check concluded SUCCESS within FACTORY_MERGE_REBASE_SKIP_FRESH_CI_MINUTES (default 60) minutes, returning a summary beginning ci_fresh:. For example, inspect the exact head with:

      gh api "repos/<github>/commits/${expectedRemoteSha}/check-runs?per_page=100"
      

      Refused merge-fix findings are retried after FACTORY_MERGE_FIX_REFUSAL_COOLDOWN_MINUTES (default 15 minutes). Refusals with reason merge_fix_ticket_escalated or merge_fix_ticket_security use the longer FACTORY_MERGE_FIX_DURABLE_REFUSAL_COOLDOWN_MINUTES (default 360 minutes) because they need a human to clear a blocker. The refusal lookup is bounded by the larger of these two cooldowns, so raising either one widens the scan window for both kinds of refusal.

      A CONFLICTING PR still needs a rebase even when CI is running or fresh. Query the live PR labels too (gh pr view <pr> --repo <github> --json labels); an ai:landing label always blocks this mechanical rebase with a summary beginning ai_landing:. Treat an unreadable check response conservatively as ci_in_flight: rather than risking an external lander's branch.

      Compare expectedRemoteSha with the pinned input.json headSha. Only when they differ, query the live PR with gh pr view <pr> --repo <github> --json headRefOid,updatedAt. Refuse with branch_moved: before editing if that live head no longer equals expectedRemoteSha. A differing fetched head proves another actor moved the branch because this run has not pushed yet; do not substitute commit author/committer metadata, which does not identify who pushed or when. Treat the PR's updatedAt as a conservative upper bound on the head-change time. If it is within MERGE_FIX_IN_FLIGHT_MINUTES (default 10), do not touch or push the branch. Return outcome: "BLOCKED" and a summary beginning branch_in_flight: instead of racing the active fixer. Treat an unknown live head or timestamp as in flight; validate the optional minute value as a positive integer before using it. Never classify the unchanged pinned head as branch_in_flight. PR activity other than a push can only make this conservative check wait longer; it cannot allow a clobber.

Read the full file on GitHub · 236 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed · +9 lines b0fe10f44270
  2. 4d ago First seen · 227 lines · 0 tokens per session scan A 42015b3e7246

Subscribe to this mod's changes

merge-fix is an agent published in the GitHub repository watt-mind/factory (12 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 2,698 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.