Skip to content

Conversation

vultuk
Copy link

@vultuk vultuk commented Sep 4, 2025

This pull request introduces support for argument substitution in custom slash-style prompt invocations, enabling users to write commands like /name args... and have $ARGUMENTS replaced by the provided arguments. It also integrates this behavior into the chat composer UI and adds comprehensive tests to ensure correctness.

Custom prompt argument substitution:

  • Added the function expand_prompt_invocation_for_tests in codex-rs/core/src/custom_prompts.rs to parse slash-style commands and substitute $ARGUMENTS with the raw text following the command name.
  • Introduced multiple tests in codex-rs/core/src/custom_prompts.rs to verify correct argument substitution, including handling multiple occurrences and empty arguments.

Integration with chat composer:

  • Updated codex-rs/tui/src/bottom_pane/chat_composer.rs to use expand_prompt_invocation_for_tests when handling custom prompt invocations, ensuring $ARGUMENTS is expanded both when a user selects a prompt from the popup and when submitting text directly. [1] [2]
  • Added a test in codex-rs/tui/src/bottom_pane/chat_composer.rs to verify that argument substitution occurs correctly when submitting a slash-style prompt.

Copy link

github-actions bot commented Sep 4, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@vultuk
Copy link
Author

vultuk commented Sep 4, 2025

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Sep 4, 2025
Copy link
Contributor

@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 suggestions.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

@sergigp
Copy link

sergigp commented Sep 8, 2025

Hey, this is great!
Wouldn't be better to be able to pass multiple arguments and reference them in the command with something like $1, $2, ... ? Saying this bc I found $ARGUMENTS very limiting in Claude Code and they recently introduced this capability of being able to reference multiple arguments.

@vultuk
Copy link
Author

vultuk commented Sep 8, 2025

Hey, this is great! Wouldn't be better to be able to pass multiple arguments and reference them in the command with something like $1, $2, ... ? Saying this bc I found $ARGUMENTS very limiting in Claude Code and they recently introduced this capability of being able to reference multiple arguments.

I would potentially agree, but personally I would prefer to do this as a follow up PR rather than hold up this one longer. Happy to work on it though.

@MaurUppi
Copy link

MaurUppi commented Sep 8, 2025

@vultuk, Your PR fixed my issue, right? #3265

@vultuk
Copy link
Author

vultuk commented Sep 8, 2025

No I do not believe so. As previously highlighted, this only allows for one $ARGUMENTS value so a slash command like

/hello world out there

would result in hello.md outputting

Hello to the world out there

if the contents of hello.md were

Hello to the $ARGUMENTS

Based on your issue, you seem to require multiple named arguments which would not be supported. Even claude's recent updates wouldn't give you what you require as the arguments are numbered.

e.g. (with claude)

/hello world 2025 amazing

would output

Hi world. The year is 2025 and today I feel amazing

if the contents of hello.md were

Hi $1. The year is $2 and today I feel $3

@MaurUppi
Copy link

MaurUppi commented Sep 8, 2025

Thx for the explanation.

Claude Code slash command can set argument-hint: "[Accomplishment-report.md]" THEN, when you input /assessment, hints will display.
Therefore, my issue could be simply to /assessment $ARGUMENTS cause I'm intending to execute "/assessment @path/to/Accomplishment-report.md"

My workaround so far is to define

## Inputs
- Ask user for Literal ACCOMPLISHMENT_PATH (strip one leading @ if present).

@vultuk
Copy link
Author

vultuk commented Sep 8, 2025

Thx for the explanation.

Claude Code slash command can set argument-hint: "[Accomplishment-report.md]" THEN, when you input /assessment, hints will display. Therefore, my issue could be simply to /assessment $ARGUMENTS cause I'm intending to execute "/assessment @path/to/Accomplishment-report.md"

My workaround so far is to define

## Inputs
- Ask user for Literal ACCOMPLISHMENT_PATH (strip one leading @ if present).

I see.. I'm happy to open another PR to address this at a later date.

@3rd
Copy link

3rd commented Sep 15, 2025

Been using this for a while, works well. $ARGUMENTS works well, please don't switch to $PROMPT_ARGUMENT just to name it differently.

@vultuk
Copy link
Author

vultuk commented Sep 15, 2025

@3rd I have no intention of changing this to $PROMPT_ARGUMENT - It doesn't make sense to do so as cross compatibility with other services is something that should be strived for in my opinion.

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.

4 participants