feat: add /codex:run-skill command to invoke Codex skillsFeat/run skill#201
feat: add /codex:run-skill command to invoke Codex skillsFeat/run skill#201xiaolutang wants to merge 1 commit intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cf288f62b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
3cf288f to
eb4d756
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb4d756498
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
eb4d756 to
7926755
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 792675551d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| Foreground flow: | ||
| - Run: | ||
| ```bash | ||
| node "${CLAUDE_PLUGIN_ROOT}/scripts/codex-companion.mjs" run-skill "$ARGUMENTS" |
There was a problem hiding this comment.
Build skill arguments before invoking companion
When the user omits --skill, this command asks a free-text question (lines 25–27) but still executes run-skill "$ARGUMENTS" here, and the same file also says to preserve raw arguments exactly. In that flow, $ARGUMENTS stays missing --skill, so codex-companion.mjs run-skill exits with "Specify a skill with --skill " instead of running the selected skill. This breaks the guided path for users who start with /codex:run-skill and rely on the prompt to supply the skill name.
Useful? React with 👍 / 👎.
36541a1 to
236edc8
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 236edc8d4b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| - If the raw arguments include `--wait`, do not ask. Run the skill in the foreground. | ||
| - If the raw arguments include `--background`, do not ask. Run the skill in a Claude background task. | ||
| - If the raw arguments do not include `--skill <name>` and do not include `--list`, use `AskUserQuestion` exactly once to ask: |
There was a problem hiding this comment.
Require skill selection before honoring run mode flags
The execution rules prioritize --wait/--background before the missing-skill branch, so /codex:run-skill --background (or --wait) without --skill skips AskUserQuestion and forwards incomplete args to the companion, which then fails with “Specify a skill…”. This breaks the documented guided flow for users who choose mode first; the command should still collect --skill <name> whenever --list is not present.
Useful? React with 👍 / 👎.
… Code Add run-skill command that lets users invoke Codex's internal skills directly from Claude Code. Skills are discovered from ~/.codex/skills/ and their SKILL.md definitions are embedded in the prompt sent to Codex. - Add skill discovery and validation module (skills.mjs) - Add handleRunSkill + executeSkillRun to codex-companion.mjs - Add path traversal protection for skill names (rejects /, \, ., ..) - Unexport resolveSkillPath — validateSkill is the sole entry point - Include skill directory path in prompt for bundled resource access - Add --write flag to allow write-capable skill execution - Use distinct jobClass "skill" to avoid rescue resume confusion - Report failure details when skill turn returns no final message - Support --list, --wait, --background flags - Add 22 tests with sandbox/prompt assertions (skills + runtime)
236edc8 to
d7f3e89
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d7f3e899b2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| Argument handling: | ||
| - When `--skill` is provided in `$ARGUMENTS`, preserve the user's arguments exactly. | ||
| - When `--skill` was obtained via AskUserQuestion, build the command from the user's answer instead of `$ARGUMENTS`. |
There was a problem hiding this comment.
Preserve non-skill flags in interactive skill selection
When --skill is omitted, this flow rebuilds the command solely from the AskUserQuestion response and explicitly avoids $ARGUMENTS, which drops previously supplied flags like --write. In practice, /codex:run-skill --write will prompt for a skill, then execute without --write, forcing read-only sandboxing and breaking write-capable skills. Carry forward non-skill flags from the original arguments when constructing the post-question command.
Useful? React with 👍 / 👎.
Summary
/codex:run-skillslash command to discover and execute Codex skills through the shared App Server runtimelib/skills.mjsmodule: skill discovery (listAvailableSkills), validation with path traversal protection(
validateSkill), and path resolutionChanges
plugins/codex/commands/run-skill.mdplugins/codex/scripts/codex-companion.mjshandleRunSkill+executeSkillRunplugins/codex/scripts/lib/skills.mjstests/skills.test.mjstests/runtime.test.mjstests/commands.test.mjstests/fixtures/test-companion-skill/SKILL.mdREADME.mdTest plan
node --test tests/skills.test.mjs— 15/15 passnode --test tests/commands.test.mjs— 8/8 passnode --test tests/runtime.test.mjs(run-skill tests) — 6/6 passtest-companion-skill/,\,..)