Dynamic Expressions, Command Substitution, and Context Variables in Custom Prompts
I’d like to see support for dynamic content in Codex Custom Prompts, allowing them to include real-time data, shell command output, and contextual variables at runtime.
Currently, Codex Custom Prompts work as static Markdown files that support simple argument substitution ($1..$9, $ARGUMENTS). This is powerful for reusable templates but limited when prompts need dynamic or contextual data — such as current time, Git branch, project name, system status and many more.
---
Proposal
Introduce a system for evaluating dynamic expressions or substituting shell command output directly within a prompt file before submission.
Possible syntaxes:
- Command substitution (shell-like)
``markdown$(git rev-parse --abbrev-ref HEAD)`
Current branch:
- Expression blocks
``markdown``
Today’s date: {{ now() }}
Open files: {{ exec('ls -1 | wc -l') }}
- Environment variable expansion
``markdown``
Project: $PROJECT_NAME
User: $USER
The idea is that when a custom prompt is invoked, Codex evaluates these expressions dynamically and replaces them with their current values before sending the message.
---
Example Use Cases
- Code review automation
``markdown$(git rev-parse --abbrev-ref HEAD)
Review code changes for branch: ``
- Documentation generation
``markdown``
Generate release notes for version {{ exec('cat VERSION') }}
Date: {{ now(format='%Y-%m-%d') }}
- System or context-aware prompts
``markdown``
Summarize logs from directory: $(pwd)
Additional information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗