Skip to content

feat: add --base flag to sequant run for custom base branches #122

Closed

Description

@admarble

Summary

Currently sequant run always creates worktrees from main branch (hardcoded in scripts/dev/new-feature.sh). This prevents using sequant run for workflows that need a different base branch, such as:

  • Feature integration branches (e.g., feature/dashboard)
  • Release branches
  • Team-specific branches in monorepos

Design Decision

Base branch resolution priority:

1. --base <branch> flag      →  Explicit override (highest priority)
2. .sequant/settings.json    →  defaultBase field (project config)
3. Repository default branch →  main/master (safe fallback)

No magic detection from current branch - explicit is better than implicit.

Acceptance Criteria

Core Implementation

  • AC-1: Add --base <branch> option to sequant run command in bin/cli.ts
  • AC-2: Read defaultBase from .sequant/settings.json if no flag provided
  • AC-3: Update src/commands/run.ts to resolve base branch (flag → config → default)
  • AC-4: Update scripts/dev/new-feature.sh to accept base branch argument (default: main)
  • AC-5: Add defaultBase to settings schema in src/lib/settings.ts

Skill Updates

  • AC-6: Update /solve skill to recommend --base when issues are linked to a feature branch
  • AC-7: Update /exec skill to pass base branch when creating worktrees
  • AC-8: Update /spec skill to detect feature branch context and note in plan output

Documentation

  • AC-9: Update CLI help text (sequant run --help)
  • AC-10: Update README.md with --base usage examples
  • AC-11: Add feature branch workflow guide to docs/

Implementation Plan

Phase 1: Core Infrastructure

  1. Settings schema - Add defaultBase to src/lib/settings.ts
  2. Script update - Modify scripts/dev/new-feature.sh to accept $2 as base branch
  3. CLI option - Add --base to bin/cli.ts run command
  4. Run command - Update src/commands/run.ts to resolve and pass base branch

Phase 2: Skill Integration

  1. /exec skill - Update to use base branch when invoking new-feature.sh

    • File: .claude/skills/exec/skill.md
    • Pass base branch to worktree creation commands
  2. /solve skill - Detect feature branch workflows and recommend --base

    • File: .claude/skills/solve/skill.md
    • Add detection logic for issues linked to feature branches
    • Update output template to include --base when appropriate
  3. /spec skill - Note feature branch context in planning output

    • File: .claude/skills/spec/skill.md
    • Detect if defaultBase is set or feature branch context exists
    • Include in "Recommended Workflow" section

Phase 3: Documentation

  1. CLI help - Ensure --base appears in sequant run --help
  2. README.md - Add section on feature branch workflows
  3. Workflow guide - Create docs/feature-branch-workflow.md explaining:
    • When to use --base vs config vs default
    • Integration branch patterns
    • Example: dashboard feature development

Example Usage

# Explicit flag (one-off override)
npx sequant run 117 --base feature/dashboard

# Project config (persistent for all runs)
# .sequant/settings.json: { "defaultBase": "feature/dashboard" }
npx sequant run 117  # Uses feature/dashboard from config

# Default behavior (no config, no flag)
npx sequant run 117  # Uses main

# Chain mode with custom base
npx sequant run 117 118 119 --sequential --chain --base feature/dashboard

Technical Notes

Files to Modify

File Change
bin/cli.ts Add --base option to run command
src/commands/run.ts Resolve base branch, pass to worktree creation
src/lib/settings.ts Add defaultBase to SettingsSchema
scripts/dev/new-feature.sh Accept base branch as $2, default to main
.claude/skills/exec/skill.md Document base branch usage
.claude/skills/solve/skill.md Add --base recommendation logic
.claude/skills/spec/skill.md Detect and report feature branch context
README.md Document --base flag and feature branch workflows

Settings Schema Addition

// src/lib/settings.ts
export const SettingsSchema = z.object({
  // ... existing fields
  defaultBase: z.string().optional(), // New field
});

Script Modification

# scripts/dev/new-feature.sh
BASE_BRANCH="${2:-main}"  # Accept base branch as second arg, default main
git fetch origin "$BASE_BRANCH"
git checkout "$BASE_BRANCH"
git pull origin "$BASE_BRANCH"

Context

This came up while planning the dashboard feature work (#114, #116, #117, #118, #119, #120) where all issues should branch from feature/dashboard instead of main.

Priority

Medium - Enables automated workflows on feature branches.

Labels

enhancement, cli, planned

Activity

  1. added
    enhancement
    cli
    on Jan 19, 2026
  2. admarble commented on Jan 19, 2026

    @admarble
    ContributorAuthor

    Design Decision: Base Branch Resolution

    Recommended approach (explicit + config + default):

    Priority:
    1. --base <branch> flag      →  Explicit override (highest priority)
    2. .sequant/settings.json    →  defaultBase field (project config)
    3. Repository default branch →  main/master (safe fallback)
    

    Example Usage

    # Explicit flag (one-off)
    npx sequant run 117 --base feature/dashboard
    
    # Project config (persistent)
    # .sequant/settings.json: { "defaultBase": "feature/dashboard" }
    npx sequant run 117  # Uses feature/dashboard
    
    # Default behavior (no config, no flag)
    npx sequant run 117  # Uses main

    Why Not Detect from Current Branch?

    Magic detection from git branch --show-current is tempting but problematic:

    • Easy to accidentally branch from wrong place
    • Surprising behavior when you forget which branch you're on
    • Violates "explicit is better than implicit"

    This matches gh pr create --base behavior - explicit flag, sensible default, no surprises.

  3. added
    planned
    on Jan 19, 2026
  4. admarble commented on Jan 19, 2026

    @admarble
    ContributorAuthor

    Relationship with --chain Flag

    Question: Does --base make --chain obsolete?

    Answer: No, they're complementary:

    Flag What it does
    --base Sets the starting point for worktrees
    --chain Each issue branches from the previous issue's completed branch

    Visual Comparison

    --base feature/dashboard (no chain):
    feature/dashboard → #117
    feature/dashboard → #118
    feature/dashboard → #119
    (all independent, same starting point)
    
    --chain (no base):
    main → #117 → #118 → #119
    (sequential dependency chain from main)
    
    --base feature/dashboard --chain:
    feature/dashboard → #117 → #118 → #119
    (sequential chain starting from feature/dashboard)
    

    When to Use Each

    Scenario Flags
    Independent issues on feature branch --base feature/dashboard
    Dependent issues from main --chain --sequential
    Dependent issues on feature branch --base feature/dashboard --chain --sequential

    Summary

    • --base sets where the work starts
    • --chain sets how issues relate to each other
    • Use both together for dependent issues on a feature branch
  5. admarble commented on Jan 19, 2026

    @admarble
    ContributorAuthor

    Spec Review - Verification Criteria & Implementation Plan

    Acceptance Criteria with Verification

    AC-1: Add --base <branch> option to CLI

    Verification: Manual Test
    Scenario: npx sequant run 123 --base feature/dashboard → option parsed correctly

    AC-2: Read defaultBase from settings

    Verification: Integration Test
    Scenario: Settings has defaultBase: "feature/dashboard" → resolved without flag

    AC-3: Resolve base branch (flag → config → default)

    Verification: Unit Test
    Scenarios:

    • Flag=develop, Config=feature/x → Returns develop
    • Flag=undefined, Config=feature/x → Returns feature/x
    • Flag=undefined, Config=undefined → Returns main

    AC-4: Script accepts base branch argument

    Verification: Manual Test
    Scenario: ./scripts/dev/new-feature.sh 123 feature/dashboard → worktree from feature branch

    AC-5: Settings schema update

    Verification: Unit Test
    Scenario: getSettings() returns defaultBase when configured

    AC-6-8: Skill updates (/solve, /exec, /spec)

    Verification: Manual Test
    Scenarios:

    • /exec passes base branch to worktree creation
    • /solve recommends --base when feature branch context detected
    • /spec uses correct base for in-flight conflict detection

    AC-9-11: Documentation

    Verification: Manual Review


    Implementation Plan

    Phase 1: Core Infrastructure

    File Change
    src/lib/settings.ts Add defaultBase?: string to RunSettings
    scripts/dev/new-feature.sh Accept $2 as base branch, update git commands
    bin/cli.ts Add --base <branch> option
    src/commands/run.ts Add resolution logic, pass to worktree creation

    Phase 2: Skill Integration

    File Change
    .claude/skills/exec/SKILL.md Pass base branch to new-feature.sh
    .claude/skills/solve/SKILL.md Add --base to example commands
    .claude/skills/spec/skill.md Fix hardcoded main in conflict detection

    Phase 3: Documentation

    • README.md - Feature branch examples
    • docs/feature-branch-workflow.md - When to use flag vs config

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Well-defined AC with clear patterns to follow


    Consolidated Assumptions

    • Second positional arg in script doesn't conflict with --stash flag
    • Optional defaultBase field works with existing configs (no migration)
    • Resolution priority: flag → config → main

    🤖 Generated with Claude Code via /spec

  6. added a commit that references this issue on Jan 19, 2026
  7. admarble commented on Jan 19, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #122

    AC Coverage

    AC Description Status Notes
    AC-1 Add --base <branch> option to CLI ✅ MET Added in bin/cli.ts:133-136 with proper description
    AC-2 Read defaultBase from settings ✅ MET Resolution in run.ts:1227-1229: options.base ?? settings.run.defaultBase ?? undefined
    AC-3 Resolve base branch (flag → config → default) ✅ MET Priority chain implemented correctly with fallback to main
    AC-4 Update new-feature.sh to accept base branch ✅ MET templates/scripts/new-feature.sh updated with --base <branch> flag parsing
    AC-5 Add defaultBase to settings schema ✅ MET Added in src/lib/settings.ts:78-83 with JSDoc
    AC-6 Update /solve skill for --base recommendation ✅ MET Added feature branch detection and --base examples in SKILL.md
    AC-7 Update /exec skill for base branch passing ✅ MET Added SEQUANT_BASE_BRANCH env var and documentation
    AC-8 Update /spec skill for feature branch context ✅ MET Added feature branch context detection section
    AC-9 Update CLI help text ✅ MET sequant run --help shows --base with proper description
    AC-10 Update README.md with examples ✅ MET Added --base example and defaultBase config option
    AC-11 Add feature branch workflow guide ✅ MET Created docs/feature-branch-workflow.md (166 lines)

    Coverage: 11/11 AC items fully met ✅


    Quality Metrics

    Metric Value Status
    Type issues (any) 0 ✅ OK
    Deleted tests 0 ✅ OK
    Files changed 9 ✅ OK
    Lines added +350 -
    Lines deleted -28 -

    Code Review

    Strengths:

    • Clean resolution priority chain: CLI flag → config → default (main)
    • Proper handling of local vs remote branches in ensureWorktree()
    • Comprehensive documentation with visual diagrams and examples
    • Good error messaging and user feedback (shows base branch in console output)
    • Consistent JSDoc comments explaining the resolution priority
    • Shell script properly handles --base flag with any position

    Issues:

    • None found

    Suggestions:

    • None - implementation is clean and complete

    Self-Evaluation

    • Verified working: Yes - CLI help shows --base flag, code paths reviewed, build passes
    • Test efficacy: Medium - no unit tests added for --base resolution, but existing tests pass
    • Likely failure mode: Remote branch doesn't exist (handled with warning message)
    • Verdict confidence: High - all AC items verified in code, implementation follows spec exactly

    Verdict: READY_FOR_MERGE

    All 11 acceptance criteria are fully met. The implementation:

    • Follows the exact resolution priority from the design decision
    • Updates all required files (CLI, settings, run command, script, skills, docs)
    • Maintains backward compatibility (default behavior unchanged)
    • Includes comprehensive documentation

    Documentation

    • README updated (new flag and config)
    • docs/ updated (feature-branch-workflow.md created)
    • CHANGELOG entry - recommend adding before merge

    Next Steps

    1. Add CHANGELOG entry for the new --base flag feature
    2. Merge to main

    🤖 Generated with Claude Code via /qa

  8. added
    ready-for-review
    on Jan 19, 2026
  9. admarble commented on Jan 19, 2026

    @admarble
    ContributorAuthor

    Documentation Complete

    Documentation was created as part of the implementation (AC-9 through AC-11):

    Files:

    • docs/feature-branch-workflow.md (166 lines) - Comprehensive workflow guide
    • README.md - Quick start example and config option
    • CLI help text - sequant run --help shows --base flag

    Coverage:

    • ✅ When to use custom base branches
    • ✅ CLI flag usage (--base <branch>)
    • ✅ Config option (run.defaultBase)
    • ✅ Resolution priority (flag → config → default)
    • ✅ Visual workflow diagrams
    • ✅ Chain mode integration
    • ✅ Example workflows

    Status: Documentation complete and merged with PR #123.


    🤖 Generated with Claude Code via /docs

  10. added a commit that references this issue on Jan 19, 2026
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

    clienhancementplannedready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions