Skip to content

Merge Command

Quick Start: Run batch-level integration checks on feature branches after sequant run completes. Catches cross-issue gaps that per-issue QA misses — merge conflicts, template mirroring gaps, residual patterns, and file overlaps — at zero AI cost.

  • Command: npx sequant merge [issues...] [options]
  • Requirements:
    • Feature branches exist (pushed to remote or in local worktrees)
    • GitHub CLI authenticated (gh auth login) for --post flag
  • Relationship: Runs AFTER sequant run, BEFORE /merger
sequant run 265 298 299 300 # implement
sequant merge --check # verify (this command)
/merger 265 298 299 300 # merge
Terminal window
npx sequant merge 265 298 299 300 --check

Runs Phase 1 deterministic checks: combined branch test, template mirroring, and file overlap detection.

Terminal window
npx sequant merge --check

Reads the most recent run log from .sequant/logs/ and auto-detects which issues to check.

Terminal window
npx sequant merge 265 298 299 300 --scan

Runs Phase 1 + Phase 2: adds residual pattern detection that finds instances of removed code patterns still present elsewhere in the codebase.

Terminal window
npx sequant merge 265 298 299 300 --check --post

Posts per-issue merge readiness reports as comments on each PR.

Terminal window
npx sequant merge 818 --watch

--watch kills the “merge after green” polling loop: instead of running merge-check against checks that are still in flight, it polls each resolved PR’s CI rollup until every check reaches a terminal state, then runs the normal merge-check phases and prints the usual report. When the command exits, the verdict is real.

Key properties:

  • It never merges. --watch only decides when the existing report runs — the human merge gate is unchanged.
  • Foreground only. A plain in-process poll loop — no daemon, no background process, no OS notifications. Chain on the exit code if you want a notification (sequant merge 818 --watch && notify-send ready).
  • Composes with the depth flags and --post — e.g. sequant merge 818 --watch --scan --post waits for CI, then runs the Phase 1+2 checks and posts the report.
  • Dispatch blocks short-circuit to BLOCKED instead of polling until timeout: a CONFLICTING mergeable state (merge conflicts block CI dispatch), zero checks after a dispatch-blocking condition, and a uniformly-failing board whose check-run annotations show the runner was never started (GitHub Actions billing/spending-limit lockout) are each detected and reported with the cause.

Uses GitHubProvider with statusCheckRollup (the --json checks field is known-broken).

OptionDescriptionDefault
--checkRun Phase 1 deterministic checksDefault if no flag specified
--scanRun Phase 1 + Phase 2 residual pattern detection-
--reviewRun Phase 1 + 2 + 3 AI briefing (stub)-
--allRun all phases-
--postPost report to GitHub as PR comments-
--watchWait for each PR’s CI checks to reach a terminal state before running merge-check (never merges)-
--interval <seconds>Watch poll interval (whole seconds, minimum 1)30
--timeout <seconds>Watch give-up timeout (whole seconds, minimum 1)1800 (30 min)

--interval and --timeout accept whole seconds only. A value that is not a positive integer is rejected with an error rather than silently coerced — note that --timeout 30m is not 30 minutes and is refused, so write --timeout 1800. | --json | Output as JSON (for scripting) | - | | -v, --verbose | Enable verbose output | - |

CodeMeaning
0All checks pass (READY)
1Warnings found (NEEDS_ATTENTION)
2Failures found, or a dispatch block detected under --watch (BLOCKED)
3--watch timed out before CI reached a terminal state
CheckWhat It DoesVerdict
Combined Branch TestCreates temp branch, merges all feature branches, reinstalls dependencies if the merge moved a lockfile, then runs the detected package manager’s test and build scriptsFAIL if merge conflict, dependency install failure, or test/build failure
Template MirroringVerifies .claude/skills/ changes have matching templates/skills/ updates (and vice versa for hooks/)WARN if unmirrored changes found
File Overlap DetectionFlags files modified by multiple issues in the batch, classifies as additive vs conflictingWARN if overlaps found

Phase 2: Residual Pattern Detection (--scan)

Section titled “Phase 2: Residual Pattern Detection (--scan)”
CheckWhat It DoesVerdict
Residual Pattern ScanExtracts removed patterns from each PR’s diff, searches codebase for remaining instancesWARN if residuals found

The residual scan uses literal string matching (minimum 8 characters) with git grep. It excludes files already modified by the PR, test files, and node_modules.

Not yet implemented. Returns a stub message directing you to use --check or --scan.

After sequant run completes a batch:

Terminal window
# 1. Run merge checks
npx sequant merge --scan
# 2. Review the report
# READY → safe to merge
# NEEDS_ATTENTION → review warnings
# BLOCKED → fix before merging
# 3. Merge passing issues
/merger 265 298 299 300

Use JSON output and exit codes for automation:

Terminal window
npx sequant merge --check --json > report.json
exit_code=$?
if [ $exit_code -eq 0 ]; then
echo "All clear to merge"
elif [ $exit_code -eq 1 ]; then
echo "Warnings found — review report.json"
else
echo "Blocked — fix issues before merging"
fi

Share results with reviewers by posting to GitHub:

Terminal window
npx sequant merge 265 298 299 300 --scan --post

Each PR receives a per-issue report showing its specific findings and the batch-level verdict.

# Merge Readiness Report
**Generated:** 2026-02-21T19:30:00.000Z
**Batch Verdict:** NEEDS_ATTENTION
## Per-Issue Verdicts
| Issue | Title | Verdict |
|-------|-------|---------|
| #265 | Audit skill files | WARN |
| #298 | Add test tautology | PASS |
## Combined Branch Test
- Lockfile changed in the combined state — reinstalled dependencies with `npm ci`
- `npm run test` passed on combined state
- `npm run build` passed on combined state
## Mirroring
- Modified .claude/skills/qa/SKILL.md but not templates/skills/qa/SKILL.md
## Overlap Detection
- src/commands/run.ts modified by issues #298, #299 (additive)
## Summary
- Errors: 0
- Warnings: 2
- Issues in batch: 4
- Checks run: 3

Returns structured JSON with all check results, per-issue verdicts, and the batch verdict. Useful for scripting and CI integration.

VerdictMeaning
PASSNo issues found for this issue
WARNWarnings found (mirroring gaps, residuals, overlaps)
FAILCritical issues (merge conflicts, test/build failures)
VerdictMeaningExit Code
READYAll issues pass, safe to merge0
NEEDS_ATTENTIONWarnings found, review before merging1
BLOCKEDCritical failures, fix before merging2

Symptoms: Error when running sequant merge without issue numbers.

Solution: Either specify issues explicitly or run sequant run first to generate a run log:

Terminal window
# Explicit issues
npx sequant merge 265 298 --check
# Or run first
npx sequant run 265 298
npx sequant merge --check

Symptoms: Error saying no branches found for specified issues.

Solution: Ensure feature branches exist — either pushed to remote or in local worktrees:

Terminal window
# Check remote branches
git branch -r | grep feature/265
# Check worktrees
git worktree list

Combined branch test reports merge conflict

Section titled “Combined branch test reports merge conflict”

Symptoms: BLOCKED verdict due to merge conflict between feature branches.

Solution: This means two feature branches modify the same file in incompatible ways. Options:

  1. Merge one branch first, then rebase the other
  2. Manually resolve the conflict before merging both
  3. If the conflict is in auto-generated files, it may resolve after merging one branch

Mirroring warnings for intentional divergences

Section titled “Mirroring warnings for intentional divergences”

Symptoms: WARN for a .claude/skills/ file that intentionally differs from templates/skills/.

Solution: Mirroring warnings are advisory. If the divergence is intentional (e.g., project-specific paths), note it in your PR description and proceed with merge.


Generated for Issue #313 on 2026-02-22