You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
QA skill: add stale worktree detection to pre-flight check #304
The /qa pre-flight sync check only verifies that main is in sync with origin/main. It does not check whether the feature worktree branch has diverged from main.
This means QA can run a full review on a feature branch that is dozens of commits behind main, give a READY_FOR_MERGE verdict, and then fail at merge time with conflicts — or worse, merge stale content.
Current pre-flight check
git fetch origin 2>/dev/null
git status -sb | head -1 # Only checks current branch vs its remote
This tells you nothing about whether the feature branch is current with main.
What's missing
cd<worktree-path>
behind=$(git log --oneline HEAD..main | wc -l | xargs)if [[ $behind-gt 0 ]];thenecho"STALE: Feature branch is $behind commits behind main. Rebase before QA."fi
Impact
Wasted QA cycles reviewing code that can't cleanly merge
False READY_FOR_MERGE verdicts
Wasted tokens and sessions when the merge fails and work needs to be redone
Acceptance Criteria
QA pre-flight checks how far behind main the feature branch is
If behind > 0, emit a warning with the count
If behind > N (configurable threshold, default ~5), block QA with STALE_BRANCH and recommend rebase
Same check should be added to /exec and /test pre-flight as well
Document the check in the skill's pre-flight section
QA Review: #304 — Stale Worktree Detection for Pre-flight Checks
PR:#350 Branch:feature/304-qa-skill-add-stale-worktree-detection-to-pre-fligh Commit:d40c115 — feat(#304): add stale branch detection to pre-flight checks
Stale Branch Check
Check
Value
Commits behind main
0
Threshold
5
Status
OK
Phase 0b: Quality Plan Verification
Spec plan exists (comment from 2026-03-12T03:53:29Z). Plan calls for:
Add staleBranchThreshold to RunSettings — Done
Add stale detection to QA skill — Done
Add stale detection to exec skill (warn only) — Done
Add stale detection to test skill (block) — Done
Document in pre-flight section — Done
Verdict: Spec plan fully followed.
Phase 1: CI Status
Job
Status
build (18.x)
FAILURE (Lint)
build (20.x)
CANCELLED
build (22.x)
FAILURE (Lint)
validate-skills
SUCCESS
typecheck
SUCCESS
validate-plugin
SUCCESS
Lint failures are PRE-EXISTING — 5 warnings in src/commands/run.ts and src/lib/workflow/batch-executor.ts (unused vars from prior refactor #347). None of the warnings reference files changed in this PR. This PR's changes compile cleanly (typecheck passes).
AC Verification
AC
Description
Status
Evidence
AC-1
QA pre-flight checks how far behind main the feature branch is
MET
.claude/skills/qa/SKILL.md — Stale Branch Detection section with git rev-list --count HEAD..origin/main
AC-2
If behind > 0, emit a warning with the count
MET
Warning row in behavior table for 1-to-threshold range in all three skills
AC-3
If behind > N (configurable threshold, default ~5), block QA with STALE_BRANCH
MET
QA and test skills block with exit 1; threshold configurable via staleBranchThreshold (default: 5)
AC-4
Same check added to /exec and /test pre-flight
MET
.claude/skills/exec/SKILL.md (warn only) and .claude/skills/test/SKILL.md (warn + block)
AC-5
Document the check in the skill's pre-flight section
MET
Each skill file includes Detection, Threshold Configuration, Behavior table, Implementation, and Output Format subsections
Code Review Findings
Type Safety
staleBranchThreshold: number properly typed in RunSettings interface
Default value 5 set in DEFAULT_SETTINGS
JSDoc comment explains the field's purpose
Scope & Size
5 files changed, +249 lines, 0 deletions — appropriate for the scope
Pure additions (no deletions) — low regression risk
Changes are self-contained: settings type + skill documentation
Security
No secrets, credentials, or sensitive data exposed
Bash snippets use 2>/dev/null || true and || echo "0" for safe error handling
exec warns, qa/test block — correct per spec and AC. Starting implementation on a stale branch is acceptable; running QA/tests on stale code is wasteful.
SEQUANT_ORCHESTRATOR skip — all three skills correctly skip the check when orchestrated.
Consistent output format across all three skills (markdown table).
BLOCKING ISSUE: Skill Directory Sync
The templates/skills/ and skills/ directories were NOT updated.
Per project convention (documented in CLAUDE.md memory), three directories must stay in sync:
.claude/skills/ (updated)
templates/skills/ (NOT updated)
skills/ (NOT updated)
This means sequant init will regenerate skill files WITHOUT the stale branch detection, and the skills/ reference copies will be stale.
Files missing changes:
templates/skills/qa/SKILL.md
templates/skills/exec/SKILL.md
templates/skills/test/SKILL.md
skills/qa/SKILL.md
skills/exec/SKILL.md
skills/test/SKILL.md
CHANGELOG
CHANGELOG.md updated with clear entry under [Unreleased] > Added. Describes the feature, per-skill behavior, and configurability.
Anti-Pattern Check
Pattern
Status
Hardcoded secrets
None
TODO/FIXME left behind
None
Console.log debugging
None
Overly broad catch
N/A (skill docs, not runtime code)
Missing error handling in bash
Handled with `
Adversarial Self-Evaluation
Could I have missed something? The bash code in skill files is illustrative (not executed as code), so runtime bugs are unlikely. However, the missing sync across skill directories is a real correctness issue.
Am I being too lenient on CI? No — the lint warnings are clearly pre-existing in unrelated files (run.ts, batch-executor.ts), confirmed by examining the failure output. Typecheck and validate-skills both pass.
Is the threshold of 5 reasonable? Yes — it's a sensible default and is configurable, so users can adjust.
Verdict
REVISE — 1 blocking issue
The implementation correctly addresses all 5 acceptance criteria, but the skill file changes were only applied to .claude/skills/ and not mirrored to templates/skills/ and skills/. This is a known sync requirement for this codebase. The fix is straightforward: copy the stale branch detection sections to the corresponding files in both templates/skills/ and skills/.
Action items:
Add stale branch detection sections to templates/skills/{qa,exec,test}/SKILL.md
Add stale branch detection sections to skills/{qa,exec,test}/SKILL.md
Spec plan exists (comment from 2026-03-12T03:53:29Z). All 4 phases followed:
Configuration (staleBranchThreshold in settings) — Done
QA skill stale detection — Done
exec/test skill stale detection — Done
Documentation in pre-flight sections — Done
Verdict: Spec plan fully followed.
Phase 1: CI Status
Job
Status
Notes
build (18.x)
FAILURE (Lint)
Pre-existing: unused vars in run.ts, batch-executor.ts
build (20.x)
FAILURE (Lint)
Same pre-existing lint warnings
build (22.x)
FAILURE (Lint)
Same pre-existing lint warnings
validate-skills
SUCCESS
typecheck
SUCCESS
validate-plugin
SUCCESS
Hooks Validation
FAILURE
Pre-existing: hooks test exit code handling
Plugin Structure
FAILURE
Pre-existing: --local flag not available
All failures are pre-existing and unrelated to this PR. The 5 lint warnings are in src/commands/run.ts (lines 24, 57) and src/lib/workflow/batch-executor.ts (lines 29, 34) — none of which are touched by this PR. Typecheck and validate-skills both pass.
AC Verification
AC
Description
Status
Evidence
AC-1
QA pre-flight checks how far behind main the feature branch is
MET
.claude/skills/qa/SKILL.md — Stale Branch Detection section with git rev-list --count HEAD..origin/main
AC-2
If behind > 0, emit a warning with the count
MET
Warning row in behavior table for 1-to-threshold range in all three skills
AC-3
If behind > N (configurable threshold, default ~5), block QA with STALE_BRANCH
MET
QA and test skills block with exit 1; threshold from staleBranchThreshold (default: 5)
AC-4
Same check added to /exec and /test pre-flight
MET
exec SKILL.md (warn only) and test SKILL.md (warn + block)
AC-5
Document the check in each skill's pre-flight section
MET
Detection, Threshold Configuration, Behavior table, Implementation, Output Format subsections in each skill
Previous Blocking Issue: Template Sync — RESOLVED
Directory Pair
qa
exec
test
.claude/skills/ vs skills/
Identical
Identical
Identical
.claude/skills/ vs templates/skills/
Identical
Identical
Identical
All six directory pairs confirmed identical via diff. The sync commit b61cde0 correctly resolved the previous blocking issue.
Code Review Findings
Type Safety:
staleBranchThreshold: number properly typed in RunSettings interface
Default value 5 set in DEFAULT_SETTINGS
JSDoc comment explains purpose
Scope & Size:
11 files changed — 5 unique changes (settings.ts + 3 skills + CHANGELOG) x 3 directories for skills
Pure additions — no regressions possible
No scope creep beyond the issue requirements
Security:
No secrets, credentials, or sensitive data
Bash snippets use 2>/dev/null || true and || echo "0" for safe error handling
exec warns only (correct — don't block implementation start)
qa and test block above threshold (correct — wasteful to review/test stale code)
SEQUANT_ORCHESTRATOR skip in all three (correct — orchestrator manages freshness)
Consistent output format across all three skills (markdown table)
Anti-Pattern Check
Pattern
Status
Hardcoded secrets
None
TODO/FIXME left behind
None
Console.log debugging
None
Missing error handling in bash
Handled with `
CHANGELOG
Updated under [Unreleased] > Added with clear entry describing the feature, per-skill behavior, and configurability.
Adversarial Self-Evaluation
Template sync: Verified all 6 pairs are byte-identical. The previous blocking issue is fully resolved.
CI failures: Confirmed pre-existing by examining failure output — all 5 lint warnings reference files not touched by this PR.
Bash safety: All skill bash snippets use proper error suppression (|| true, || echo "0", 2>/dev/null) — consistent with project conventions.
Threshold default: 5 is reasonable and configurable — no hardcoded magic numbers.
Edge case: What if origin/main doesn't exist? git rev-list will fail silently via 2>/dev/null || echo "0", defaulting to 0 (proceed). This is acceptable — if remote is unavailable, the check is skipped gracefully.
Verdict
READY_FOR_MERGE
All 5 acceptance criteria are met. The previous blocking issue (template sync) has been fully resolved — all three skill directories are confirmed identical. No new issues found. CI failures are pre-existing and unrelated.
Activity
admarble commentedon Mar 12, 2026
Solve Analysis
Recommended Phases: spec → exec → qa
Skip Spec: No (needs pre-flight check design across multiple skills)
Browser Testing: No (skill file changes, not UI)
Quality Loop: Yes (part of 3-issue chain modifying QA skill)
Reasoning
Flags
📝 Generated by
/solveadmarble commentedon Mar 12, 2026
Spec Plan: Stale Worktree Detection for Pre-flight Checks
Acceptance Criteria (with Verification)
mainthe feature branch isSTALE_BRANCH/execand/testpre-flightImplementation Plan
Phase 1: Configuration
staleBranchThreshold: numbertoRunSettingsinsrc/lib/settings.tsPhase 2: QA Skill
3. Add "Stale Branch Detection" section to
.claude/skills/qa/SKILL.md4. Implement: warn if 1-5 behind, block if >5 behind
Phase 3: exec/test Skills
5. Add stale detection to
.claude/skills/exec/SKILL.md(warn only)6. Add stale detection to
.claude/skills/test/SKILL.md(warn + block)Phase 4: Documentation
7. Document behavior, thresholds, and rebase recommendations
Files Changed
src/lib/settings.tsstaleBranchThresholdtoRunSettings.claude/skills/qa/SKILL.md.claude/skills/exec/SKILL.md.claude/skills/test/SKILL.mdDesign Decisions
staleBranchThresholdin settings (default: 5)SEQUANT_ORCHESTRATORis setConflict Risk
.claude/skills/qa/SKILL.mdQuality Loop
✅ Enabled — Part of chain with #254, #307 modifying QA skill
Assumptions to Validate
main(notmaster)origingit worktree listReady for implementation. Run
/exec 304to begin.feat(#304): add stale branch detection to pre-flight checks
admarble commentedon Mar 12, 2026
Implementation Progress Update
AC Coverage
main.claude/skills/qa/SKILL.md:230-290STALE_BRANCH/execand/testFiles Changed
src/lib/settings.tsstaleBranchThreshold: number(default: 5).claude/skills/qa/SKILL.md.claude/skills/exec/SKILL.md.claude/skills/test/SKILL.mdCHANGELOG.mdCheck Results
npm run buildnpm run lintnpm teststate-utils.test.tsSelf-Evaluation
PR Status
✅ PR Created: #350
Next Steps
/qa 304to verify implementation🤖 Generated by
/exec 304admarble commentedon Mar 12, 2026
QA Review: #304 — Stale Worktree Detection for Pre-flight Checks
PR: #350
Branch:
feature/304-qa-skill-add-stale-worktree-detection-to-pre-flighCommit:
d40c115—feat(#304): add stale branch detection to pre-flight checksStale Branch Check
Phase 0b: Quality Plan Verification
Spec plan exists (comment from 2026-03-12T03:53:29Z). Plan calls for:
staleBranchThresholdtoRunSettings— DoneVerdict: Spec plan fully followed.
Phase 1: CI Status
Lint failures are PRE-EXISTING — 5 warnings in
src/commands/run.tsandsrc/lib/workflow/batch-executor.ts(unused vars from prior refactor #347). None of the warnings reference files changed in this PR. This PR's changes compile cleanly (typecheck passes).AC Verification
mainthe feature branch is.claude/skills/qa/SKILL.md— Stale Branch Detection section withgit rev-list --count HEAD..origin/mainSTALE_BRANCHexit 1; threshold configurable viastaleBranchThreshold(default: 5)/execand/testpre-flight.claude/skills/exec/SKILL.md(warn only) and.claude/skills/test/SKILL.md(warn + block)Code Review Findings
Type Safety
staleBranchThreshold: numberproperly typed inRunSettingsinterface5set inDEFAULT_SETTINGSScope & Size
Security
2>/dev/null || trueand|| echo "0"for safe error handlingjq -r '.run.staleBranchThreshold // 5'uses jq default operator — safe fallbackDesign Review
BLOCKING ISSUE: Skill Directory Sync
The
templates/skills/andskills/directories were NOT updated.Per project convention (documented in CLAUDE.md memory), three directories must stay in sync:
.claude/skills/(updated)templates/skills/(NOT updated)skills/(NOT updated)This means
sequant initwill regenerate skill files WITHOUT the stale branch detection, and theskills/reference copies will be stale.Files missing changes:
templates/skills/qa/SKILL.mdtemplates/skills/exec/SKILL.mdtemplates/skills/test/SKILL.mdskills/qa/SKILL.mdskills/exec/SKILL.mdskills/test/SKILL.mdCHANGELOG
CHANGELOG.md updated with clear entry under
[Unreleased] > Added. Describes the feature, per-skill behavior, and configurability.Anti-Pattern Check
Adversarial Self-Evaluation
run.ts,batch-executor.ts), confirmed by examining the failure output. Typecheck and validate-skills both pass.Verdict
REVISE — 1 blocking issue
The implementation correctly addresses all 5 acceptance criteria, but the skill file changes were only applied to
.claude/skills/and not mirrored totemplates/skills/andskills/. This is a known sync requirement for this codebase. The fix is straightforward: copy the stale branch detection sections to the corresponding files in bothtemplates/skills/andskills/.Action items:
templates/skills/{qa,exec,test}/SKILL.mdskills/{qa,exec,test}/SKILL.mdGenerated by
/qa 304admarble commentedon Mar 12, 2026
RE-QA Review: #304 — Stale Worktree Detection for Pre-flight Checks
PR: #350
Branch:
feature/304-qa-skill-add-stale-worktree-detection-to-pre-flighCommits:
d40c115(feat),b61cde0(template sync fix)Previous QA Verdict: REVISE (template sync missing)
Stale Branch Check
Phase 0b: Quality Plan Verification
Spec plan exists (comment from 2026-03-12T03:53:29Z). All 4 phases followed:
staleBranchThresholdin settings) — DoneVerdict: Spec plan fully followed.
Phase 1: CI Status
run.ts,batch-executor.ts--localflag not availableAll failures are pre-existing and unrelated to this PR. The 5 lint warnings are in
src/commands/run.ts(lines 24, 57) andsrc/lib/workflow/batch-executor.ts(lines 29, 34) — none of which are touched by this PR. Typecheck and validate-skills both pass.AC Verification
mainthe feature branch is.claude/skills/qa/SKILL.md— Stale Branch Detection section withgit rev-list --count HEAD..origin/mainSTALE_BRANCHexit 1; threshold fromstaleBranchThreshold(default: 5)/execand/testpre-flightPrevious Blocking Issue: Template Sync — RESOLVED
.claude/skills/vsskills/.claude/skills/vstemplates/skills/All six directory pairs confirmed identical via
diff. The sync commitb61cde0correctly resolved the previous blocking issue.Code Review Findings
Type Safety:
staleBranchThreshold: numberproperly typed inRunSettingsinterface5set inDEFAULT_SETTINGSScope & Size:
Security:
2>/dev/null || trueand|| echo "0"for safe error handlingjq -r '.run.staleBranchThreshold // 5'uses jq default operator — safe fallbackDesign:
SEQUANT_ORCHESTRATORskip in all three (correct — orchestrator manages freshness)Anti-Pattern Check
CHANGELOG
Updated under
[Unreleased] > Addedwith clear entry describing the feature, per-skill behavior, and configurability.Adversarial Self-Evaluation
|| true,|| echo "0",2>/dev/null) — consistent with project conventions.origin/maindoesn't exist?git rev-listwill fail silently via2>/dev/null || echo "0", defaulting to 0 (proceed). This is acceptable — if remote is unavailable, the check is skipped gracefully.Verdict
READY_FOR_MERGE
All 5 acceptance criteria are met. The previous blocking issue (template sync) has been fully resolved — all three skill directories are confirmed identical. No new issues found. CI failures are pre-existing and unrelated.
feat(#304): add stale branch detection to pre-flight checks (#350)
admarble commentedon Mar 12, 2026
Documentation Generated
File:
docs/features/stale-branch-detection.mdSections Included:
staleBranchThresholdconfigurationKey Details Covered:
.sequant/settings.json/qa+/test(blocks) vs/exec(warns only)SEQUANT_ORCHESTRATORbypass during orchestrated runsNext Steps:
Ready to merge!
docs: add stale branch detection feature documentation (#304)