Skip to content

feat: add /codex:run-skill command to invoke Codex skillsFeat/run skill#201

Closed
xiaolutang wants to merge 1 commit intoopenai:mainfrom
xiaolutang:feat/run-skill
Closed

feat: add /codex:run-skill command to invoke Codex skillsFeat/run skill#201
xiaolutang wants to merge 1 commit intoopenai:mainfrom
xiaolutang:feat/run-skill

Conversation

@xiaolutang
Copy link
Copy Markdown

Summary

  • Add /codex:run-skill slash command to discover and execute Codex skills through the shared App Server runtime
  • New lib/skills.mjs module: skill discovery (listAvailableSkills), validation with path traversal protection
    (validateSkill), and path resolution
  • Skill definitions are embedded in the prompt to avoid Codex running shell commands that cause turn failures
  • 23 new tests (15 skills unit + 6 runtime e2e + 2 security)

Changes

File Change
plugins/codex/commands/run-skill.md New slash command with AskUserQuestion guidance
plugins/codex/scripts/codex-companion.mjs handleRunSkill + executeSkillRun
plugins/codex/scripts/lib/skills.mjs Skill discovery, validation, path resolution
tests/skills.test.mjs 15 unit tests for skills module
tests/runtime.test.mjs 6 e2e tests for run-skill failure/happy paths
tests/commands.test.mjs Command file validation + regex fix
tests/fixtures/test-companion-skill/SKILL.md Test fixture for integration testing
README.md Usage documentation

Test plan

  • node --test tests/skills.test.mjs — 15/15 pass
  • node --test tests/commands.test.mjs — 8/8 pass
  • node --test tests/runtime.test.mjs (run-skill tests) — 6/6 pass
  • Real Codex integration verified with test-companion-skill
  • Path traversal security validated (rejects /, \, ..)
  • AskUserQuestion interactive flow verified in live Claude Code session

@xiaolutang xiaolutang requested a review from a team April 10, 2026 04:35
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@xiaolutang xiaolutang force-pushed the feat/run-skill branch 2 times, most recently from 36541a1 to 236edc8 Compare April 10, 2026 07:36
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +20 to +22
- 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:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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)
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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.

1 participant