Repository navigation
Description
Summary
When .claude/skills/ is missing, sequant run provisions a worktree and hands the phase agent a prompt ending "Run the /spec {issue} workflow." (src/lib/workflow/phase-registry.ts:178). The skill does not resolve, the agent spends the whole phase hunting for a command that does not exist, never posts a SEQUANT_PHASE marker, and the runner reports the phase as failed — surfacing as ⟳ Spec phase failed, retrying with 5000ms backoff... (spec retry 1/1).
That message points at transient GitHub flake, which is the registry's own stated reason for spec's retry policy (phase-registry.ts:180-184). The actual cause is a missing directory that doctor already detects in ~5ms.
Field report (downstream project, 2026-07-26)
A project whose .claude/skills/ had been removed — it was never git-tracked there, so an untracked-file cleanup silently deleted it — ran sequant run 115. Observed over ~30 minutes:
- Phase agent searched
~/.claude/commands/, thenfind / -path "*commands/exec*", thenToolSearch— never found/exec, never did the work - Worktree clean, no commits, no PR
sequant doctorin that project reported it plainly:✖ Skills: Missing .claude/skills/ directory/✖ Core Skills: Missing skills: spec, exec, qa
Every one of those 30 minutes was spent on a condition detectable before the first worktree was provisioned.
Why the existing global channel does not save you
The sequant plugin was installed at user scope in that environment (the session reached plugin:sequant:sequant for MCP), and the plugin bundles all skills. It still did not resolve /spec for the phase agent. The driver passes settingSources: ["project"] (src/lib/workflow/drivers/claude-code.ts:122, per #19 AC-3), so user-scope and plugin-scope skills are not loaded into the phase session — only .claude/skills/. #711 established the three native discovery scopes; the driver opts into exactly one.
So "install skills globally" is not an available mitigation, and the project-scope directory is a hard runtime dependency for the claude-code driver.
Proposed fix
Reuse the check that already exists. src/commands/doctor.ts:215-234 does precisely this:
const skillsExist = await fileExists(".claude/skills");
// ...
if (!(await fileExists(`.claude/skills/${skill}/SKILL.md`))) {Run it in run's pre-flight, before worktree provisioning, and fail with the remedy named (sequant sync).
Two constraints worth designing around rather than ignoring:
- Driver-scoped. Only the
claude-codedriver depends on skill resolution.phase-registry.tscarriesdriverOverrides.aiderprompt templates that do the work inline viaghand never invoke a slash command, so the guard must not fire for non-skill drivers. - Check the phases actually being run. Doctor checks the core three. A run with
--testgenor--security-reviewneeds those skills too, and a--phases exec,qarun does not needspec.
Acceptance criteria
- AC-1:
sequant runperforms a skills pre-flight before any worktree is provisioned, and exits non-zero with a message naming the missing skills and the remedy (sequant sync) instead of proceeding. - AC-2: The pre-flight checks the skills required by the phases resolved for that run (including additive phases from
--testgen/--security-review), not a hardcodedspec, exec, qatriple. - AC-3: The pre-flight is skipped for drivers that do not resolve skills — an
aider-driver run with no.claude/skills/still executes, matching the inlinedriverOverridesprompts inphase-registry.ts. - AC-4: The check reuses doctor's existing logic rather than duplicating the path list, so the two cannot drift.
- AC-5: A test asserts that a run against a tree with no
.claude/skills/exits non-zero without creating a worktree or writing a state entry. - AC-6: Docs note that
.claude/skills/is a runtime dependency and is worth committing, since it is untracked by default in consumer projects.
Related, not in scope
Two further defects surfaced in the same incident. Recording them here so they are not lost; neither belongs in this issue's ACs, and both need confirmation before filing:
- Runaway self-invocation. 13 extra runs for the same issue were launched 30-60s apart, all
phases:["spec"]in an MCP-shaped call rather than the CLI's label auto-detect, all dying at the instant the spec agent was torn down. The shape suggests the flailing agent found the sequant MCP server in its config and began callingsequant_runon itself. This is inference from timing and config shape, not something logged explicitly. - False terminal state.
.sequant/state.jsonended up claiming the issue wasready_for_mergewithnextAction: gh pr merge, with no PR in existence.
Both are downstream symptoms of the same root cause, and both would have been prevented by AC-1. If the pre-flight lands first, they may not be independently reachable.
Activity
admarble commentedon Jul 26, 2026
Plan (spec) — #813 skills pre-flight for
sequant runComplexity: Standard (6 ACs, 4 directories)
Scope Assessment
Verdict:⚠️ SCOPE_WARNING (quality loop will be enabled). Non-Goals are effectively present as the "Related, not in scope" section.
Acceptance Criteria
sequant syncremedy — Integration Test.claude/skills/→ Whensequant run <N>→ Then exit 1, message lists missing skills andsequant sync, no worktree created--testgen/--security-review), not a hardcoded triple — Unit Test--phases exec,qa→ only exec/qa skills required; given--testgen→ testgen skill requiredagent: "aider"and no.claude/skills/→ run proceeds past pre-flight.claude/skills/<skill>/SKILL.mdpath check) — Unit Test + code review.claude/skills/exits non-zero, no worktree, no state entry — Integration Test.claude/skills/is a runtime dependency worth committing — Manual Test (docs review)Implementation Plan
Phase A — shared check (AC-4)
src/lib/skills-check.ts:checkSkills(requiredSkills: string[]): Promise<{ skillsDirExists: boolean; missing: string[] }>usingfileExistsfromlib/fs.ts— the one place that knows the.claude/skills/<skill>/SKILL.mdlayout.doctor.tsChecks 2+3 (lines 214–250) to call it, preserving output text.Phase B — driver capability (AC-3)
3. Add
resolvesSkills: booleanto theAgentDriverinterface (drivers/agent-driver.ts);ClaudeCodeDriver→true,AiderDriver→false. Aider's phases run inlinedriverOverridesprompts and never invoke slash commands.Phase C — pre-flight in the orchestrator (AC-1, AC-2)
4. In
RunOrchestrator.run()after theissueInfoMapfetch and beforeensureWorktrees(~line 963–970 today): skip whenconfig.dryRunor!getDriver(config.agent, …).resolvesSkills; otherwise compute the union of per-issue phases:determinePhasesForIssue(config.phases, labels, {testgen, securityReview})detectPhasesFromLabels(labels).phases+ the same additive flagsloopwhen the quality loop is enabled (its skill is invoked the same way)phaseRegistry.get(phase).skill, callcheckSkills, and on any missing: print✖ Missing skills: <list> — run \sequant sync`and return a syntheticRunResultwithexitCode: 1(same pattern as the #762--strict-preflight` abort), before any worktree or per-issue state write.Phase D — tests + docs (AC-5, AC-6)
6. Tests: unit tests for
skills-check.tsand phase→skill resolution; integration test asserting exit-non-zero + no worktree + no.sequant/state.jsonentry on a skills-less tree; aider-driver bypass test.7. Docs: README +
docs/getting-started/installation.md+docs/troubleshooting.md—.claude/skills/is a hard runtime dependency of the claude-code driver (settingSources: ["project"], #19/#711), commit it; remedy issequant sync.Design Review
lib/skills-check.ts(shared by doctor + run). The gate itself inRunOrchestrator.run()— so MCP-initiated runs (sequant_run) get the same protection as the CLI, which matters given the incident's runaway MCP self-invocations.fileExistschecks; no new config. Rejected: duplicating doctor's loop in run.ts (drift, violates AC-4); running fulldoctorin pre-flight (too broad, pulls version checks into every run).parseRecommendedWorkflow) whose skill is missing." Accepted gap: unknowable pre-run; the realistic failure (whole directory missing) is fully covered because spec/exec/qa are always in the resolvable set.Open Questions
loopskill whenever quality loop is enabled? Recommendation: yes (cheap, same failure mode). Impact if wrong: one extra name in the required set for consumers who disabled nothing.Recommended Workflow
Phases: spec → exec → qa
Quality Loop: enabled (scope warning)
Reasoning: CLI-only change, no UI labels → no browser test. Testgen skipped:
buglabel and AC-5 already prescribes the exact test to write.admarble commentedon Jul 26, 2026
QA Review for Issue #813
AC Coverage
✖ Skills pre-flight failed: missing .claude/skills/ directory (needs: exec, qa)+run \sequant sync`, exit code 1, no worktree, no.sequant/state.json`resolveRequiredSkillsunit-tested:--phases exec,qarequires only exec/qa (smoke confirmed: "needs: exec, qa");--testgen/--security-reviewadd their skills; UI labels addtest; quality loop addsloop; auto-detect resolves per-issue label pipelinesAgentDriver.resolvesSkills(claude-code true, aider false). Integration test: aider run on a skills-less tree reaches worktree provisioning and executes; unit test covers the gatesrc/lib/skills-check.tsowns the.claude/skills/<skill>/SKILL.mdlayout; doctor Checks 2+3 refactored to consume it (doctor.ts no longer contains the path literal); doctor's 34 tests pass unchangedskills-preflight.integration.test.tsasserts exitCode 1,ensureWorktreesnever called, no../worktrees/on disk, no state entry, no phase executed.claude/skills/is a runtime dependency worth committingdocs/getting-started/installation.md(directory structure),docs/troubleshooting.md(new "Skills pre-flight failed" entry with both remedies)Coverage: 6/6 AC items fully met
Quality Metrics
any)Execution Evidence
sequant run 1 --phases exec,qain repo with no.claude/skills/sequant sync(built CLI) then re-runEvidence status: Complete
Risk Assessment
/specoutput (parseRecommendedWorkflow) isn't knowable at pre-flight time, so a missing skill for a spec-recommended-only phase (e.g. testgen) could still flail. Accepted gap documented in the plan — the motivating incident (whole directory missing) is fully covered since spec/exec/qa are always in the resolvable set.--batchmulti-issue pre-flight union is covered by unit tests only (no end-to-end batch smoke). Chain mode shares the same single call site before bothensureWorktrees*branches..claude/skillsliterals intemplates.ts/init.ts(installers),skill-version.ts(version markers),merge-check/types.ts(mirror map) are different concerns, not install-presence checks; no drift risk with doctor/pre-flight.skill-version.ts:51keeps its owninstalledDirliteral — could adoptSKILLS_DIRas a trivial follow-up, not blocking.run-orchestrator.ts, placed before both the chain and non-chain worktree provisioning branches — no other provisioning paths exist inrun().Adversarial Re-Read
Findings: No gaps found because: (1) the issue's verbatim fixture (doctor's
fileExistssnippet) is now literally the shared code path — doctor importscheckSkillsInstalledrather than the pattern being re-implemented; (2) all evidence above is post-fix validation (smoke of the new failure path AND the sync-remedy loop), not bug reproduction; (3) process state inspected — worktree clean, branch pushed, no divergence; (4) sibling sites cited above; (5) the issue's "Related, not in scope" items (runaway MCP self-invocation, falseready_for_mergestate) were kept out of scope — no changes touch state reconciliation or the MCP server. One observation while validating the remedy: runningsyncfrom source viatsxresolvesgetTemplatesDir()one level too high (calibrated fordist/src/lib), so a source-treesyncsilently installs nothing — pre-existing, dev-invocation-only, unrelated to this diff; noting rather than filing since consumers run the compiled CLI.Status: Clean
CHANGELOG Verification
[Unreleased]→### Addedentry present for #813, follows house style. ✅CI Status
No PR exists yet — CI will run on PR creation (fullsolve Phase 5).
Verdict: READY_FOR_MERGE
All 6 ACs met with literal verification, execution evidence complete including the full remedy loop, quality gates green (build, lint, 4120 tests), docs and CHANGELOG in place.
admarble commentedon Jul 26, 2026
/fullsolve Complete
Issue: #813
Status: READY_FOR_MERGE
Summary
sequant syncremedy loopKey changes
src/lib/skills-check.ts— shared.claude/skills/<skill>/SKILL.mdcheck, consumed by bothdoctorand the new pre-flightsrc/lib/workflow/skills-preflight.ts— resolves required skills from the run's actual phases;RunOrchestrator.run()aborts with exit 1 + remedy before any worktree/state writeAgentDriver.resolvesSkills— claude-code gates on the pre-flight, aider bypasses it.claude/skills/as a runtime dependency worth committingIterations
PR: #821
Ready for human review and merge.
fix(#813): cover late-added phases and harden the pre-flight driver l…
feat(#813): pre-flight the skills install — missing .claude/skills/ f…
feat(#813): pre-flight the skills install so a missing .claude/skills…
fix(#813): cover late-added phases and harden the pre-flight driver l…