codex icon indicating copy to clipboard operation
codex copied to clipboard

Custom prompts - passing arguments

Open michalkos opened this issue 1 year ago • 31 comments

What feature would you like to see?

Please implement functionality to allow custom arguments (e.g., $ARGUMENTS) to be passed and rendered within the .md file when executing slash commands.

Additionally, the first line of the .md file could be used as a command title in the TUI. If the line exceeds the maximum allowed length, it should be truncated accordingly.

Image

Once [pull request #2471](https://github.com/openai/codex/pull/2471) is merged, it would be great to support this functionality in custom commands as well.

Example

# Create a git commit

Based on the code changes, create a single git commit.

If `--push` argument is present, you can run `git push`.

**DO NOT** run `git add` unless asked by argument `--add`.

**DO NOT** add information that the commit is generated by Codex.

## Context

- Current git status: !`git status`
- Current git diff (staged and unstaged changes): !`git diff HEAD`
- Current branch: !`git branch --show-current`
- Recent commits: !`git log --oneline -10`

## Passed arguments 

`$ARGUMENTS`

Are you interested in implementing this feature?

No response

Additional information

No response

michalkos avatar Aug 29 '25 07:08 michalkos

+1, would be really useful! i was just reading the source code to understand if this was already there!

cs-asimoes avatar Sep 01 '25 16:09 cs-asimoes

+1, arguments to saved prompts and adding additional content like this is super useful

suvam-jaiswal avatar Sep 02 '25 03:09 suvam-jaiswal

It would be nice to have a more Git centric approach where codex ask if you want to create a new branch for this change.

Also does appropriate Git commits along the way so if you leave it running the user and Codex can easily step back to a point where it was in a working state regardless of Codex running or not.

This way you can see in the Git logs the branches and iterative changes over time to pick up any mistakes or changes that may be important or may have caused problems.

As this also would you help diagnose issues and looking at the state of repository with the many, many tools available for Git repository viewing and analysis out there already.

SuperPauly avatar Sep 02 '25 09:09 SuperPauly

@SuperPauly, how you configure the command is entirely up to you. The example simply demonstrates how to use arguments in the setup.

michalkos avatar Sep 02 '25 14:09 michalkos

Thanks! Tracking this.

dedrisian-oai avatar Sep 03 '25 00:09 dedrisian-oai

+1 That would be very useful, thanks!

SystemicVoid avatar Sep 03 '25 13:09 SystemicVoid

This will make prompts much more powerful. Imo ideally we should be able to pass multiple arguments with $1, $2, ...

sergigp avatar Sep 05 '25 06:09 sergigp

i initially thought i could use something like: /code-review pass PR link and do it, but just found out, that it doesn't accept any args... Hope they will implement this soon.

avxkim avatar Sep 10 '25 11:09 avxkim

This will be a game changer for me. I rely on this a ton with Claude Code. +1

alexx-ftw avatar Sep 11 '25 19:09 alexx-ftw

Status update / proposal

  • Draft PR: #3565 (minimal, backward‑compatible).
  • Scope:
    • Arguments: $1..$9, $ARGUMENTS, and $$ (literal); simple quoting for paths with spaces.
    • “@” file picker: inserts quoted file paths (no content inlining, no auto‑exec).
    • Optional frontmatter: description and argument- hint shown in the slash palette; frontmatter is stripped before send.
  • Safety/back‑compat: no changes to approvals/ sandbox; protocol only adds optional fields; existing prompts continue to work.
  • Tests/docs: unit + TUI snapshot tests added; docs/ prompts.md updated.

If this approach aligns, I’ll mark #3565 ready for review. I’m happy to modify as needed.

evandavid1 avatar Sep 14 '25 05:09 evandavid1

Hi @dedrisian-oai and @aibrahim-oai - PR #3565 (https://github.com/openai/codex/pull/3565) mentioned above which shows high demand, delivers the full custom prompt update: $1..$9/$ARGUMENTS/$$ handling, @ file picker auto-quoting, inline description + argument-hint rendering, and the docs/tests refresh. It’s rebased on current main and the sweeps (formatting, per-crate tests, cargo test --all-features) are green. It’s still in draft mode and I can’t switch it back to active - could you unlock the PR and mark it ready for review? Please me know if you’d like any changes.

Image Image

evandavid1 avatar Sep 23 '25 00:09 evandavid1

See also, recent duplicate:

  • https://github.com/openai/codex/pull/4040

0xdevalias avatar Sep 23 '25 05:09 0xdevalias

Yeah, this high demand is justified: extensibility is key to creating prompt frameworks and libraries. The documentation of spec-kit itself names this issue as a blocker, while almost every other tool in the long list already supports it.

Codex CLI, despite offering arguably the best model and usage conditions, has the weakest extensibility of all. That is especially frustrating given that multiple pull requests have already been proposed to resolve it.

I hope the official maintainers will notice this issue soon and give it the priority it deserves.

dpolivaev avatar Sep 23 '25 11:09 dpolivaev

GPT5 is defiantly leading the model race, we need a top CLI agent with the GPT subscription :) @codex-maintainers please help here. Thank You.

abdull1986 avatar Sep 23 '25 21:09 abdull1986

From a personal point of view, I don't really like the $1...$9 args and $ARGUMENTS params.

I feel like people should use named params. In my proposal, we use something like:

My name is $NAME and I'm from $CITY in $STATE.

Would then manifest in the CLI as:

/custom-prompt NAME="" CITY="" STATE=""

This removes any ambiguity for the user, especially when the args are automatically rendered once you select the custom prompt. I also don't see the use for $ARGUMENTS -- is there a specific example that would make sense for it?

Thanks everyone!

dedrisian-oai avatar Sep 24 '25 17:09 dedrisian-oai

The use case I am interested in is not something I invented — it comes directly from the spec-kit README.

The README shows examples where a command is followed by arbitrary free-form text, not just named parameters. For example:

  • /specify Build an application that can help me organize my photos in separate photo albums. Albums are grouped by date and can be re-organized by dragging and dropping on the main page. Albums are never in other nested albums. Within each album, photos are previewed in a tile-like interface.
  • /plan The application uses Vite with minimal number of libraries. Use vanilla HTML, CSS, and JavaScript as much as possible. Images are not uploaded anywhere and metadata is stored in a local SQLite database.

This usage pattern is part of spec-kit’s own documentation, and it doesn’t map cleanly to named parameters. That’s why support for $ARGUMENTS is essential — it makes it possible to implement the examples shown in the referenced README.

dpolivaev avatar Sep 24 '25 18:09 dpolivaev

Alright fair! We can support both.

dedrisian-oai avatar Sep 24 '25 19:09 dedrisian-oai

What is the latest on Custom prompts - passing arguments? When will this feature be available?

LostPoE avatar Sep 25 '25 14:09 LostPoE

We need this now please :)

amynoox avatar Sep 26 '25 02:09 amynoox

A message above said this feature is now on a branch and should be merged into main soon.

I this this is this feat : #3565

We all hope for this. Codex is replacing CC for lot of us, and spec kit hype is growing fast :)

Hotion13 avatar Sep 26 '25 10:09 Hotion13