Skip to content

Support default values for prompt template arguments #5507

@dannote

Description

@dannote

What do you want to change?

Add a small default-value form to prompt template argument substitution, e.g. ${1:-7}.

Prompt templates currently support $1, $@, $ARGUMENTS, ${@:N}, and ${@:N:L}. That is enough to pass arguments through, but optional arguments cannot have clean defaults.

Example:

Summarize the current state in ${1:-7} bullet points.

This would make both /summary and /summary 3 expand cleanly.

Why?

Optional prompt arguments are useful for prompt shortcuts with a sensible default.

Without defaults, templates have to expose prompt mechanics to the model, e.g. “Requested count: $1; if blank use 7”. That works, but it is awkward and less reliable than expanding the default before the prompt reaches the model.

How? (optional)

Extend substituteArgs in packages/coding-agent/src/core/prompt-templates.ts with a narrow Bash-like default form:

  • ${1:-default} → use arg 1 if present/non-empty, otherwise default

No full Bash parameter expansion needed; just this one form plus docs/tests.

If this sounds welcome, I can try a PR after approval.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions