Skip to content

fix(templates): correct generated workflow guidance - #1500

Open
clay-good wants to merge 5 commits into
mainfrom
codex/fix-generated-workflow-guidance
Open

fix(templates): correct generated workflow guidance#1500
clay-good wants to merge 5 commits into
mainfrom
codex/fix-generated-workflow-guidance

Conversation

@clay-good

@clay-good clay-good commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Status

LGTM.

What was wrong

Generated workflows could lose a selected store because concrete command examples omitted the sticky --store <id> rule. The update workflow suggested expanded-only workflows before explaining that they might not be installed, and its /opsx:new CLI fallback reused the active change name. The sync workflow reported success without validating the main specs it had just changed.

How it was fixed

  • Make a selected store sticky for every applicable follow-up command and show the exact scoped form of an otherwise unscoped example.
  • Explain optional workflow availability and CLI fallbacks before update first suggests those workflows.
  • Require a distinct unused name when the CLI must start a fresh change.
  • Quote artifact placeholders so copied shell commands cannot interpret them as redirection.
  • Run openspec validate --specs with the selected root after applying deltas and before sync reports success.
  • Add regression coverage against the actual 12 files generated by openspec init --tools claude, then regenerate the committed skills and parity hashes.

Replication / proof

The regression assertions failed on current main for the reported behaviors, then passed with this patch.

  • 101 focused template, generation, parity, and initialization tests passed.
  • 3,478/3,478 tests passed across the full inventory. The sandbox-compatible suite passed 3,431/3,431; all 47 localhost-server tests passed separately with loopback permission.
  • A fresh openspec init --tools claude generated:
    • 12/12 files with sticky guidance and a concrete --store "<id>" command.
    • 2/2 update files with availability checks before later optional-workflow references.
    • 2/2 update files with the distinct fresh-change fallback and quoted artifact commands.
    • 2/2 sync files with validation after spec mutation and before success reporting.
  • ESLint, TypeScript build, generated-file parity, and git diff --check passed.
  • Three independent adversarial audits covered linked-issue completeness, implementation compatibility, and test false positives. All validated findings were fixed, and every final re-review reported no remaining actionable issue.

Notes / nits

This changes generated instructions only. It does not change CLI behavior, APIs, schemas, persisted data, or architecture.

Closes #1493

Summary by CodeRabbit

  • Improvements

    • Store selection now remains consistent across applicable workflow commands and follow-up actions.
    • Sync workflows validate updated specifications before reporting completion and clearly report failures.
    • Update guidance verifies optional workflow availability and provides CLI alternatives when unavailable.
    • Workflow instructions now preserve store settings during archive and continuation actions.
    • Artifact instructions quote identifiers and support distinct names for intent-changing requests.
  • Tests

    • Added coverage for store selection, validation, failure handling, quoting, and workflow availability guidance.

@clay-good
clay-good requested a review from a team as a code owner August 3, 2026 20:31
@clay-good
clay-good requested review from alfred-openspec and removed request for a team August 3, 2026 20:31
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Generated OpenSpec workflows retain the selected store across applicable commands, validate synced specs before reporting success, and check optional workflow availability before suggesting it. Tests and a patch changeset document the updated guidance.

Changes

Generated workflow guidance

Layer / File(s) Summary
Sticky store propagation
src/core/templates/workflows/store-selection.ts, skills/openspec-*/SKILL.md, test/core/templates/skill-templates-parity.test.ts
Store selection remains sticky across applicable OpenSpec commands, including context, view, and follow-up commands.
Sync validation before success
src/core/templates/workflows/sync-specs.ts, skills/openspec-sync-specs/SKILL.md, test/core/templates/skill-templates-parity.test.ts, test/core/init.test.ts, .changeset/fix-generated-workflow-guidance.md
Sync workflows run openspec validate --specs with selected-root flags before showing the summary. Validation failures prevent success reporting.
Optional workflow availability guidance
src/core/templates/workflows/update-change.ts, skills/openspec-update-change/SKILL.md, test/core/templates/update-change.test.ts, test/core/templates/skill-templates-parity.test.ts
Update workflows verify /opsx:continue and /opsx:new availability, quote artifact IDs, and provide CLI fallbacks when unavailable.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SyncWorkflow
  participant OpenSpecCLI
  participant MainSpecs
  SyncWorkflow->>OpenSpecCLI: Sync specs with selected-root flags
  OpenSpecCLI->>MainSpecs: Update main specs
  SyncWorkflow->>OpenSpecCLI: Validate specs with openspec validate --specs
  OpenSpecCLI-->>SyncWorkflow: Return validation result
  SyncWorkflow-->>MainSpecs: Show completion summary after successful validation
Loading

Possibly related PRs

Suggested reviewers: alfred-openspec, tabishb

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address all three objectives in issue #1493: sticky store selection, optional continuation fallback, and sync validation.
Out of Scope Changes check ✅ Passed The changes remain within the scope of correcting generated workflow templates, tests, hashes, and committed generated guidance.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the correction to generated workflow guidance, which matches the primary changes in the pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-generated-workflow-guidance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
test/core/templates/skill-templates-parity.test.ts (1)

207-214: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the expanded store-capable command list.

This test checks only the generic sticky wording. It would still pass if context or view were removed from STORE_SELECTION_GUIDANCE. Assert the newly added command entries directly.

Suggested assertion
   expect(STORE_SELECTION_GUIDANCE).toContain(
     'append it to every applicable command below, even when the example does not repeat the flag'
   );
+  expect(STORE_SELECTION_GUIDANCE).toContain('`context`, `view`');
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/core/templates/skill-templates-parity.test.ts` around lines 207 - 214,
Expand the test around STORE_SELECTION_GUIDANCE to assert that the store-capable
context and view command entries are present directly, in addition to the
existing sticky-selection wording checks. Use the exact command identifiers or
guidance text from STORE_SELECTION_GUIDANCE so the test fails if either entry is
removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/openspec-update-change/SKILL.md`:
- Line 18: Update both CLI fallback commands in the openspec-continue-change
guidance to quote the <name> and <artifact-id> placeholders, matching the
surrounding command syntax and preventing shell redirection when copied.

In `@src/core/templates/workflows/update-change.ts`:
- Line 93: Move the `/opsx:new` availability fallback from the end of the
guardrails into the intent-change steps at the locations represented by the
relevant template sections, placing the precondition immediately before
recommending `/opsx:new`; retain `openspec new change <name>` as the alternative
when unavailable. Update `test/core/templates/update-change.test.ts` to verify
both ordering and fallback text.

---

Nitpick comments:
In `@test/core/templates/skill-templates-parity.test.ts`:
- Around line 207-214: Expand the test around STORE_SELECTION_GUIDANCE to assert
that the store-capable context and view command entries are present directly, in
addition to the existing sticky-selection wording checks. Use the exact command
identifiers or guidance text from STORE_SELECTION_GUIDANCE so the test fails if
either entry is removed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 565f3baa-ce2b-45a1-93a7-bd53d8c93a43

📥 Commits

Reviewing files that changed from the base of the PR and between 45cca5d and 8c47fa0.

📒 Files selected for processing (18)
  • .changeset/fix-generated-workflow-guidance.md
  • skills/openspec-apply-change/SKILL.md
  • skills/openspec-archive-change/SKILL.md
  • skills/openspec-bulk-archive-change/SKILL.md
  • skills/openspec-continue-change/SKILL.md
  • skills/openspec-explore/SKILL.md
  • skills/openspec-ff-change/SKILL.md
  • skills/openspec-new-change/SKILL.md
  • skills/openspec-onboard/SKILL.md
  • skills/openspec-propose/SKILL.md
  • skills/openspec-sync-specs/SKILL.md
  • skills/openspec-update-change/SKILL.md
  • skills/openspec-verify-change/SKILL.md
  • src/core/templates/workflows/store-selection.ts
  • src/core/templates/workflows/sync-specs.ts
  • src/core/templates/workflows/update-change.ts
  • test/core/templates/skill-templates-parity.test.ts
  • test/core/templates/update-change.test.ts

Comment thread skills/openspec-update-change/SKILL.md Outdated
Comment thread src/core/templates/workflows/update-change.ts Outdated

@alfred-openspec alfred-openspec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at exact head 29431b9. Focused template, parity, and initialization coverage passes; the generated guidance now preserves selected stores, validates syncs before success, and keeps propose planning-only until a separate apply request.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploying openspec-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 19c648e
Status: ✅  Deploy successful!
Preview URL: https://6f184451.openspec-docs.pages.dev
Branch Preview URL: https://codex-fix-generated-workflow.openspec-docs.pages.dev

View logs

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.

init --tools claude generates workflows that drop --store, reference a nonexistent /opsx:continue, and skip validation on sync

2 participants