Dynamic Expressions, Command Substitution, and Context Variables in Custom Prompts

Resolved 💬 5 comments Opened Oct 9, 2025 by nikhil-pandey Closed Dec 23, 2025

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:

  1. Command substitution (shell-like)

``markdown
Current branch:
$(git rev-parse --abbrev-ref HEAD)`

  1. Expression blocks

``markdown
Today’s date: {{ now() }}
Open files: {{ exec('ls -1 | wc -l') }}
``

  1. 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
Review code changes for branch:
$(git rev-parse --abbrev-ref HEAD)
``

  • 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_

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗