Skip to content

fix(speckit): harden dirty-tree check with explicit AskUserQuestion tool call - #396

Merged
jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:opsx/fix-speckit-dirty-tree-check
Jul 31, 2026
Merged

jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:opsx/fix-speckit-dirty-tree-check

Conversation

@jflowers

Copy link
Copy Markdown
Contributor

Summary

Replaces the prose-only dirty-tree guard in speckit.specify.md (step 2) with an explicit AskUserQuestion tool call. The previous prose instruction ("STOP and ask the user for confirmation") was vulnerable to context compression — agents could skip the check entirely and create a branch despite uncommitted changes, risking work applied to the wrong branch or lost.

The hardened guard now presents two structured options:

  • "Stash changes and continue" — runs git stash, with failure handling (non-zero exit → abort) and recovery notification at workflow completion (git stash pop)
  • "Abort -- keep changes as-is" — stops the workflow immediately

This is a T1+T3 weakness fix from audit #346. Sibling issues #350 and #353 address the same pattern in other files.

Fixes #358

How to Test

  1. Open .opencode/commands/speckit.specify.md and verify lines 40-67
  2. Confirm AskUserQuestion tool is explicitly referenced (line 44)
  3. Confirm the two option strings appear verbatim (lines 53-54)
  4. Confirm git stash failure handling (lines 57-59): non-zero exit → STOP
  5. Confirm stash recovery notification (lines 61-62): git stash pop
  6. Confirm exception clause preserved (lines 66-67)
  7. Run make check — all tests pass (no Go code changed)

How to Demo

This is an agent instruction hardening fix (Markdown only). To observe the behavioral change, invoke /speckit.specify with uncommitted changes in the working tree — the agent should now present a structured AskUserQuestion instead of relying on prose interpretation.

Key Files Changed

File Change Description
.opencode/commands/speckit.specify.md +29/-6 Core fix: prose → AskUserQuestion
CHANGELOG.md +8 New Fixed entry
openspec/changes/fix-speckit-dirty-tree-check/.openspec.yaml +2 Change metadata
openspec/changes/fix-speckit-dirty-tree-check/proposal.md +88 What & why, constitution alignment
openspec/changes/fix-speckit-dirty-tree-check/design.md +89 Decisions D1-D3, risks/trade-offs
openspec/changes/fix-speckit-dirty-tree-check/specs/dirty-tree-guard.md +90 Delta spec, 6 Given/When/Then scenarios
openspec/changes/fix-speckit-dirty-tree-check/tasks.md +58 Implementation tasks (all complete)

This PR was generated by /finale (AI-assisted).

…ool call

Replace prose-only dirty-tree guard in speckit.specify.md with an
explicit AskUserQuestion tool call presenting structured options
("Stash changes and continue" / "Abort -- keep changes as-is").
Includes git stash failure handling and stash recovery notification.

- Harden speckit.specify.md step 2 against context compression (T1+T3)
- Add OpenSpec change artifacts (proposal, design, specs, tasks)
- File follow-up issue unbound-force#395 for speckit-workflow/SKILL.md parallel guard
- Add CHANGELOG.md entry

Fixes unbound-force#358

Assisted-by: claude-opus
Generated with AI assistance (claude-opus)
@jflowers
jflowers force-pushed the opsx/fix-speckit-dirty-tree-check branch from 43cd008 to 8df3b53 Compare July 31, 2026 19:51
@jflowers
jflowers merged commit 93daf46 into unbound-force:main Jul 31, 2026
5 checks passed
jflowers added a commit that referenced this pull request Aug 1, 2026
…cit AskUserQuestion gate

Replace the prose-only "STOP and ask the user for
confirmation" instruction in speckit-workflow/SKILL.md
Pre-conditions section with an explicit AskUserQuestion
tool call pattern matching the sibling files hardened in
PRs #396 and #406.

- Add AskUserQuestion with stash/abort options
- Add stash failure handling (non-zero exit → abort)
- Add post-stash re-verification via git status --short
- Add post-workflow stash restore reminder
- Update scaffold copy in lockstep
- Add OpenSpec change artifacts

Fixes #395

Assisted-by: claude-opus
Generated with AI assistance (claude-opus)
@jflowers
jflowers deleted the opsx/fix-speckit-dirty-tree-check branch November 15, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(speckit.specify): dirty-tree check before branch creation is prose only

1 participant