Skip to content

fix(codex): prefer skills over deprecated prompts#1143

Open
SIGMAREAL wants to merge 4 commits into
Fission-AI:mainfrom
SIGMAREAL:fix/codex-skills-first
Open

fix(codex): prefer skills over deprecated prompts#1143
SIGMAREAL wants to merge 4 commits into
Fission-AI:mainfrom
SIGMAREAL:fix/codex-skills-first

Conversation

@SIGMAREAL
Copy link
Copy Markdown

@SIGMAREAL SIGMAREAL commented May 31, 2026

Summary

  • stop generating Codex ~/.codex/prompts/opsx-*.md custom prompts and remove existing managed Codex prompt files during init/update
  • rewrite generated Codex skill instructions from /opsx:* and /opsx-* references to $openspec-* skill invocations
  • centralize per-tool delivery/skill-transform decisions so Codex remains skills-first even when global delivery is commands
  • update supported-tools docs and README wording for skills plus slash commands

Tests

  • pnpm run lint
  • pnpm run build
  • pnpm test test/utils/command-references.test.ts test/core/init.test.ts test/core/update.test.ts test/core/profile-sync-drift.test.ts test/core/workspace/skills.test.ts
  • pnpm test test/core/update.test.ts test/core/workspace/skills.test.ts test/commands/workspace.test.ts
  • manual Codex init --tools codex --profile core generation check: 5 skills generated, deprecated prompt removed, no /opsx: or /opsx- references in .codex/skills
  • pnpm test (fails locally only in existing test/commands/artifact-workflow.test.ts > creates skills for Cursor tool: this machine's global OpenSpec config has delivery: skills, while that legacy test expects .cursor/commands/opsx-explore.md)

Fixes #1129
Addresses #1110

Summary by CodeRabbit

  • Documentation

    • README: notes compatibility with 20+ AI assistants and clearer refresh/update instructions.
    • Supported tools: documents Codex custom prompts are deprecated and not generated.
  • Changes

    • Per-tool delivery: generation now varies by tool, improving “Getting started” hints and restart guidance (“restart your IDE or agent”).
    • Codex: treated as skill-only where applicable; legacy Codex prompts are detected and removed.
    • Command references: added mapping to translate legacy slash references into Codex skill invocations.
  • Tests

    • Added/updated tests covering per-tool delivery, Codex cleanup, and command-reference conversions.

@SIGMAREAL SIGMAREAL requested a review from TabishB as a code owner May 31, 2026 12:10
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Centralizes per-tool delivery decisions, migrates Codex to skills-only artifacts, adds OPSX→Codex skill mapping and transformers, and applies per-tool generation and cleanup across init, update, workspace skills, profile-sync drift, legacy-cleanup, tests, and docs.

Changes

Codex Skill Migration and Per-Tool Delivery

Layer / File(s) Summary
Tool-delivery routing predicates and transformer selector
src/core/tool-delivery.ts
New shouldGenerateSkillsForTool, shouldGenerateCommandsForTool, and getSkillInstructionTransformer functions centralize per-tool generation decisions and instruction-transformer selection.
OPSX→Codex mapping, transform, and exports
src/utils/command-references.ts, src/utils/index.ts, test/utils/command-references.test.ts
Adds OPSX_TO_CODEX_SKILL mapping, transformToCodexSkillReferences, re-exports it, and tests conversions of /opsx: and /opsx-* patterns into $openspec-* skill invocations.
Legacy Codex prompt discovery & cleanup
src/core/legacy-cleanup.ts
Detects legacy Codex prompt files under CODEX_HOME (default ~/.codex), adds helpers to find them defensively, supports absolute vs project-relative deletions, and maps detected prompt files to codex tool id.
Init command per-tool delivery refactor
src/core/init.ts, test/core/init.test.ts
Applies per-tool shouldGenerateSkillsForTool/shouldGenerateCommandsForTool, uses getSkillInstructionTransformer(tool.value) for SKILL.md, conditionally writes/removes skills and command artifacts per tool, updates success/getting-started/restart messaging, and adds Codex init tests.
Update/upgrade per-tool artifact management
src/core/update.ts, test/core/update.test.ts
Prepares skill templates and command contents unconditionally, then conditionally writes or removes artifacts per tool using per-tool flags; uses centralized transformer and updates messages/tests (including Codex upgrade/cleanup tests).
Workspace skills transformer wiring
src/core/workspace/skills.ts
Uses getSkillInstructionTransformer(tool.value) in generateWorkspaceAgentSkills and updateWorkspaceAgentSkills instead of inline conditional logic.
Profile-sync-drift per-tool integration
src/core/profile-sync-drift.ts, test/core/profile-sync-drift.test.ts
Uses per-tool predicates when detecting profile/delivery drift, refactors test helpers to accept tool dirs/adapters, and adds Codex-specific drift tests (including environment-dependent detection).
Docs, README, and Codex adapter notes
README.md, docs/supported-tools.md, src/core/command-generation/adapters/codex.ts
README adds explicit openspec update guidance and invocation examples ($openspec-* vs /opsx:*), supported-tools marks Codex prompts as not generated (deprecated), and Codex adapter comments reframe it as legacy prompt cleanup.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • #881: Per-tool instruction transformer and routing changes overlap with this issue's objective to convert /opsx:* references for skills-only delivery.
  • #1103: Codex instruction transformation and artifact generation concerns are addressed by the added transformers and mapping utilities.

Possibly related PRs

Suggested reviewers

  • TabishB
  • alfred-openspec

Poem

🐰 I hop through code and sweep the lair,
Old /opsx prompts I tidy with care,
Skills now hum where slashes fade,
Per-tool paths guide each upgrade,
A carrot cheer — $openspec leads the pair.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.37% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: Codex integration now prioritizes skills over deprecated custom prompts, which is the core objective of this pull request.
Linked Issues check ✅ Passed The pull request comprehensively addresses #1129 by stopping deprecated Codex prompt generation, migrating to skills-based workflow, and updating documentation to reflect these changes.
Out of Scope Changes check ✅ Passed All changes directly support the linked issue objectives: centralizing delivery logic, removing prompt generation, migrating to skills, and updating documentation accordingly.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
README.md (1)

152-152: ⚡ Quick win

Clarify tool-dependent refresh behavior.

This wording implies all tools get both artifacts; Codex is skills-only now. Consider “latest skills and/or slash commands (tool-dependent)” to avoid confusion.

🤖 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 `@README.md` at line 152, Update the sentence that reads "Run this inside each
project to regenerate AI guidance and ensure the latest skills and slash
commands are active:" to clarify tool-dependent behavior by changing it to
something like "Run this inside each project to regenerate AI guidance and
ensure the latest skills and/or slash commands (tool-dependent) are active:" so
readers understand Codex may only update skills while other tools may update
slash commands.
🤖 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 `@src/core/init.ts`:
- Around line 714-719: The current boolean gate using hasCommandSurface causes
only /opsx:* guidance to be printed even when Codex-style tools are present;
update the logic in the getting-started output (use the existing
gettingStartedTools and shouldGenerateCommandsForTool) to compute two
flags—hasCommandSurface (tools where shouldGenerateCommandsForTool(...) is true)
and hasCodexSurface (tools where it is false or explicitly Codex-capable)—and
when both are true print both invocation styles (e.g., show both the /opsx:* and
the $openspec-* variants) instead of choosing one; adjust the variables/strings
currently named commandPrefix and newInvocation (and the similar block at
722-725) to emit dual guidance when mixed surfaces are detected.

In `@src/core/update.ts`:
- Around line 194-195: The summary message currently uses the global delivery
value when reporting Codex command file removals even though per-tool predicates
(shouldGenerateSkillsForTool and shouldGenerateCommandsForTool) decide removal;
update the reporting logic that builds the removal summary (the code that reads
toolShouldGenerateSkills and toolShouldGenerateCommands) so it does not
hard-code "(delivery: skills)" from the global delivery variable — instead
compute and include the actual per-tool reason (e.g., "removed: per-tool
override (commands disabled)" or a neutral "removed: per-tool setting") or
attach the specific predicate result for each tool; apply the same change to the
other occurrences that use toolShouldGenerateSkills/toolShouldGenerateCommands
(including the blocks referenced around the other occurrence at the same file).
- Around line 687-703: The shared post-upgrade onboarding text still emits the
legacy opsx prompts for all tools; update the onboarding generation to be
tool-aware by branching on the tool identifier/value (use the same key used by
shouldGenerateSkillsForTool/shouldGenerateCommandsForTool and tool.value) and
emit the correct next-step instructions for Codex vs other tools. Locate the
shared onboarding block that currently hardcodes the `/opsx:new`,
`/opsx:continue`, `/opsx:apply` prompts and replace it with logic that selects
the appropriate command set based on toolId/tool.value (or a helper like
getSkillInstructionTransformer), so upgraded users receive the new Codex flow
when tool.value indicates Codex and the legacy opsx prompts for other tools.
Ensure the conditional lives alongside the existing generation calls (e.g.,
where you call generateSkillContent/getSkillInstructionTransformer and write
files with FileSystemUtils.writeFile) so the produced onboarding SKILL.md
reflects the tool-aware instructions.

---

Nitpick comments:
In `@README.md`:
- Line 152: Update the sentence that reads "Run this inside each project to
regenerate AI guidance and ensure the latest skills and slash commands are
active:" to clarify tool-dependent behavior by changing it to something like
"Run this inside each project to regenerate AI guidance and ensure the latest
skills and/or slash commands (tool-dependent) are active:" so readers understand
Codex may only update skills while other tools may update slash commands.
🪄 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

Run ID: 9e5d782d-9774-4e8c-84c0-9d35dfa07ba2

📥 Commits

Reviewing files that changed from the base of the PR and between 9aded17 and 6eb0ef5.

📒 Files selected for processing (14)
  • README.md
  • docs/supported-tools.md
  • src/core/command-generation/adapters/codex.ts
  • src/core/init.ts
  • src/core/profile-sync-drift.ts
  • src/core/tool-delivery.ts
  • src/core/update.ts
  • src/core/workspace/skills.ts
  • src/utils/command-references.ts
  • src/utils/index.ts
  • test/core/init.test.ts
  • test/core/profile-sync-drift.test.ts
  • test/core/update.test.ts
  • test/utils/command-references.test.ts

Comment thread src/core/init.ts
Comment thread src/core/update.ts
Comment thread src/core/update.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

150-156: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify the Codex invocation here as well.

This now says the active surface is tool-dependent, but the same README still teaches /opsx:* as the default quick-start path. That leaves Codex users with contradictory guidance. Please add a matching $openspec-* example here or explicitly scope the slash-command examples to non-Codex tools.

🤖 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 `@README.md` around lines 150 - 156, Clarify the README's "Refresh agent
instructions" so Codex users aren't left with contradictory guidance: update the
paragraph that currently shows "openspec update" and references "/opsx:*" to
either (a) add a matching Codex invocation example (use the $openspec-* form as
a concrete example) or (b) explicitly state that slash-command examples (e.g.,
/opsx:*) apply only to non-Codex tools and show the equivalent Codex command;
edit the sentence and the example block that contains "openspec update" and the
referenced "/opsx:*" to include the $openspec-* example or an explicit scoping
note so readers can clearly see the correct command for Codex vs other tools.
🤖 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 `@test/core/update.test.ts`:
- Around line 1199-1205: The test "should show Codex skill invocations when
upgrading legacy Codex artifacts" currently seeds a project-local
.codex/prompts/openspec-new.md but the migration looks for the managed global
prompt; create the real legacy artifact under CODEX_HOME by setting up
CODEX_HOME/prompts and writing an opsx-*.md file (e.g. opsx-openspec-new.md)
with the same 'old codex prompt' content before exercising update. Use the same
helpers (fs.mkdir and fs.writeFile) but target path.join(process.env.CODEX_HOME
|| testDir, 'prompts', 'opsx-openspec-new.md') (or set process.env.CODEX_HOME =
testDir) so the upgrade logic that expects CODEX_HOME/prompts/opsx-*.md is
exercised.

---

Outside diff comments:
In `@README.md`:
- Around line 150-156: Clarify the README's "Refresh agent instructions" so
Codex users aren't left with contradictory guidance: update the paragraph that
currently shows "openspec update" and references "/opsx:*" to either (a) add a
matching Codex invocation example (use the $openspec-* form as a concrete
example) or (b) explicitly state that slash-command examples (e.g., /opsx:*)
apply only to non-Codex tools and show the equivalent Codex command; edit the
sentence and the example block that contains "openspec update" and the
referenced "/opsx:*" to include the $openspec-* example or an explicit scoping
note so readers can clearly see the correct command for Codex vs other tools.
🪄 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

Run ID: b3060f94-a8ee-4d4b-b16c-41bd75866bbc

📥 Commits

Reviewing files that changed from the base of the PR and between 6eb0ef5 and 8290600.

📒 Files selected for processing (5)
  • README.md
  • src/core/init.ts
  • src/core/update.ts
  • test/core/init.test.ts
  • test/core/update.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/update.ts

Comment thread test/core/update.test.ts Outdated
@SIGMAREAL SIGMAREAL force-pushed the fix/codex-skills-first branch from 70a358b to 8227157 Compare May 31, 2026 15:34
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/supported-tools.md (1)

32-32: ⚡ Quick win

Consider adding explicit migration guidance for existing Codex users.

The deprecation note is clear, but existing users with Codex prompt files may not realize they should run openspec update to remove deprecated prompts and regenerate skills. Consider adding a brief note like:

Not generated (Codex custom prompts are deprecated; existing users should run openspec update to clean up old prompts and use $openspec-* skills)

🤖 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 `@docs/supported-tools.md` at line 32, Update the Codex table entry to include
explicit migration guidance: amend the note for "Codex (`codex`) |
`.codex/skills/openspec-*/SKILL.md`" to state that Codex custom prompts are
deprecated and instruct existing users to run `openspec update` to remove
deprecated prompts and regenerate skills (e.g., "Not generated (Codex custom
prompts are deprecated; existing users should run `openspec update` to clean up
old prompts and use `$openspec-*` skills)").
🤖 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 `@src/utils/command-references.ts`:
- Around line 42-44: The regex in the replacement (the line returning
text.replace(...)) can partially match identifiers like "/opsx:apply2" and
replace only the alphabetic prefix; update the pattern to enforce a trailing
token boundary so the whole identifier must match (for example add a negative
lookahead such as (?![a-z0-9-]) or an appropriate \b check after the capture).
Modify the regex used in the text.replace call that references
OPSX_TO_CODEX_SKILL so only full valid command ids are captured and substituted,
leaving invalid tokens untouched.

---

Nitpick comments:
In `@docs/supported-tools.md`:
- Line 32: Update the Codex table entry to include explicit migration guidance:
amend the note for "Codex (`codex`) | `.codex/skills/openspec-*/SKILL.md`" to
state that Codex custom prompts are deprecated and instruct existing users to
run `openspec update` to remove deprecated prompts and regenerate skills (e.g.,
"Not generated (Codex custom prompts are deprecated; existing users should run
`openspec update` to clean up old prompts and use `$openspec-*` skills)").
🪄 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

Run ID: 05c533ad-d094-4469-95e0-e431c15c15ab

📥 Commits

Reviewing files that changed from the base of the PR and between 70a358b and 8227157.

📒 Files selected for processing (15)
  • README.md
  • docs/supported-tools.md
  • src/core/command-generation/adapters/codex.ts
  • src/core/init.ts
  • src/core/legacy-cleanup.ts
  • src/core/profile-sync-drift.ts
  • src/core/tool-delivery.ts
  • src/core/update.ts
  • src/core/workspace/skills.ts
  • src/utils/command-references.ts
  • src/utils/index.ts
  • test/core/init.test.ts
  • test/core/profile-sync-drift.test.ts
  • test/core/update.test.ts
  • test/utils/command-references.test.ts
✅ Files skipped from review due to trivial changes (3)
  • src/core/command-generation/adapters/codex.ts
  • README.md
  • src/utils/index.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • test/utils/command-references.test.ts
  • src/core/profile-sync-drift.ts
  • test/core/update.test.ts
  • test/core/init.test.ts
  • src/core/workspace/skills.ts
  • src/core/init.ts
  • test/core/profile-sync-drift.test.ts
  • src/core/update.ts
  • src/core/legacy-cleanup.ts

Comment thread src/utils/command-references.ts Outdated
alfred-openspec
alfred-openspec previously approved these changes Jun 1, 2026
Copy link
Copy Markdown
Collaborator

@alfred-openspec alfred-openspec left a comment

Choose a reason for hiding this comment

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

Direction is exactly right. Codex skills-first, legacy prompt cleanup, centralized per-tool delivery in tool-delivery.ts — all clean.

Tests cover the key flows: Codex-only init, mixed tools, legacy prompt removal, drift detection, and command-reference transformation. Docs are updated.

One real issue (minor): the regex in transformToCodexSkillReferences can partially match identifiers. /opsx:apply2 becomes $openspec-apply-change2 instead of being left unchanged, because the capture group [a-z][a-z-]* matches apply and stops at 2.

Fix: add a trailing boundary assertion:

text.replace(/\/opsx[:\-]([a-z][a-z-]*)(?![a-z0-9-])/g, ...)

Unlikely to bite in practice since command IDs are well-known, but worth fixing since the function is new in this PR.

Nit: getCodexHome() is now duplicated between legacy-cleanup.ts and codex.ts adapter. Could extract to a shared utility.

LGTM pending the regex fix.

@SIGMAREAL SIGMAREAL force-pushed the fix/codex-skills-first branch from 9146383 to 086231d Compare June 1, 2026 08:23
Copy link
Copy Markdown
Collaborator

@alfred-openspec alfred-openspec left a comment

Choose a reason for hiding this comment

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

Re-reviewed the latest commit, including the boundary fix for /opsx:apply2; Codex now stays skills-first, removes legacy prompts, and generated skills no longer leak /opsx: or /opsx- references.

Verified with pnpm run lint, pnpm test, and a manual Codex init smoke check with CODEX_HOME pointed at a temp legacy prompt.

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.

The Codex CLI integration continues to generate a deprecated slash-command workflow (/opsx:*).

2 participants