Skip to content

feat: Add --chain flag for dependent sequential issues #88

Closed

Description

@admarble

Summary

Add a --chain flag to sequant run that creates cascading worktrees where each issue branches from the previous issue's completed branch, rather than from main.

sequant run 1 2 3 --sequential --chain

Current behavior: Each issue branches from origin/main
Proposed behavior with --chain: Issue 2 branches from feature/1-xxx, issue 3 from feature/2-xxx


Motivation

When implementing related features in sequence, later issues often depend on earlier ones. Currently, each issue starts fresh from main, requiring manual rebasing or re-implementation of dependencies.

With --chain:

  • Issue 2 automatically has access to issue 1's implementation
  • No manual rebasing between issues
  • Natural workflow for dependent features

Technical Design

Worktree Creation

origin/main
    └─→ feature/1-add-auth (issue 1)
            └─→ feature/2-add-login-page (issue 2, depends on auth)
                    └─→ feature/3-add-logout (issue 3, depends on login)

Execution Flow

  1. Issue 1: Branch from origin/main, run phases, pass QA
  2. Issue 2: Branch from feature/1-xxx, run phases, pass QA
  3. Issue 3: Branch from feature/2-xxx, run phases, pass QA

If any issue fails, the chain stops (already handled by --sequential).


Merge Strategy Considerations

Several options for merging a completed chain:

Option A: Sequential Merge to Main

feature/1-xxx → main (PR #1)
feature/2-xxx → main (PR #2, after #1 merged)
feature/3-xxx → main (PR #3, after #2 merged)

Pros: Standard PR workflow, individual reviews
Cons: Requires rebasing between merges, slow

Option B: Stacked PRs

PR #1: feature/1-xxx → main
PR #2: feature/2-xxx → feature/1-xxx
PR #3: feature/3-xxx → feature/2-xxx

Merge in order: #1 first, GitHub auto-updates #2's base, etc.

Pros: Native GitHub support, parallel reviews possible
Cons: Complex to set up, GitHub's stacked PR UX is rough

Option C: Chain Squash

Merge entire chain as single PR with combined changes.

Pros: Simple, single review
Cons: Loses granularity, may be too large for review

Recommendation

Option A (Sequential) for initial implementation. Consider /merge-chain skill that:

  1. Creates PRs for each issue in order
  2. Merges them sequentially
  3. Handles rebase automatically between merges

Review Considerations

For Short Chains (2-3 issues)

Standard /qa per issue is sufficient. Each QA sees the accumulated changes in context.

For Long Chains (4+ issues)

Consider:

  • Checkpoints: Push/commit after each issue passes QA (recovery point)
  • Chain summary: /qa-chain skill that reviews entire chain holistically
  • Length limit: Warn or require confirmation for chains > 5 issues
  • Incremental review: Allow human review between issues

Risk Mitigation

Risk Mitigation
Issue 1 changes invalidate issue 2+ Checkpoint commits allow recovery
Merge conflicts accumulate /merge-chain handles rebasing
Single failure blocks chain --sequential already stops on failure
Chain too long to review Warn at 5+ issues, suggest breaking up

New Skills/Commands Needed

/merge-chain (or extend /merger)

Handles merging a chain of dependent PRs:

  • Detects chain structure from branch names
  • Creates PRs in dependency order
  • Merges sequentially with auto-rebase
  • Reports conflicts for human resolution

/qa-chain (optional, for long chains)

Reviews entire chain holistically:

  • Sees all changes across issues
  • Identifies cross-issue inconsistencies
  • Validates the chain as a cohesive unit

Acceptance Criteria

  • --chain flag implemented in sequant run
  • Chain issues branch from previous issue's branch
  • Chain stops on first failure (via --sequential)
  • Documentation updated with chain workflow
  • Warning shown for chains > 5 issues
  • Checkpoint commits after each issue passes QA

Future (separate issues)

  • /merge-chain skill for merging dependent PRs
  • /qa-chain skill for holistic chain review
  • --chain-base <branch> to start chain from non-main branch

Related

  • Fresh baseline fix (worktrees now fetch and branch from origin/main)
  • Existing dependency detection in parseDependencies()
  • /merger skill for post-QA integration

Activity

  1. added
    enhancement
    on Jan 14, 2026
  2. added a commit that references this issue on Jan 17, 2026
  3. admarble commented on Jan 17, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Status: READY_FOR_MERGE

    Summary

    • AC: 6/6 met
    • Tests: 369/369 passed
    • Build: ✅ Success

    AC Coverage

    AC Status
    --chain flag implemented ✅ MET
    Chain issues branch from previous ✅ MET
    Chain stops on first failure ✅ MET
    Documentation updated ✅ MET
    Warning for chains > 5 issues ✅ MET
    Checkpoint commits after QA pass ✅ MET

    Key Changes

    1. CLI: Added --chain flag to sequant run
    2. Worktree Chaining: New ensureWorktreesChain() creates worktrees branching from previous
    3. Checkpoint Commits: Automatic commit after each issue passes QA
    4. Validation: Chain requires --sequential, incompatible with --batch
    5. Documentation: Full chain mode docs in docs/run-command.md

    Self-Evaluation

    • Worked as expected: Yes
    • Test coverage confidence: High - all existing tests pass, chain logic is straightforward git operations
    • Weakest part: No unit tests specifically for chain mode (relies on integration testing)
    • Honest assessment: Implementation is solid. Consider adding unit tests for ensureWorktreesChain and createCheckpointCommit in a follow-up.

    PR: #110


    Ready for human review and merge.

  4. added a commit that references this issue on Jan 17, 2026
  5. admarble commented on Jan 17, 2026

    @admarble
    ContributorAuthor

    Update: Added 10 unit tests for chain mode. Total tests: 379 passing. PR #110 updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions