Skip to content

Proposal: first-class command translation mode (codex translate <intent>) #13069

@nebez

Description

@nebez

What variant of Codex are you using?

CLI

What feature would you like to see?

What

Add an interactive command translation mode that, given some very light context of the users current environment, will recommend a query to execute for the user. Optionally (1) allow the user to cycle to alternatives if they are unhappy with the suggestion, (2) edit command before executing.

codex translate <intent> -> returns the best shell command

  • Optional flags:
    • --non-interactive
    • --alternatives N (forces --non-interactive)
    • --json (forces --non-interactive, structured output)

Why

Codex has broad coverage to basically every one of my workflows. I drop into the CLI for long, multi-hour pair programming sessions. I use the desktop app for discrete, well-defined task completion. One bit that remains is the common CLI workflow of "I know what I want, but not exact syntax".

Developers can approximately work around this with custom prompts. Today, I reproduce this functionality for myself by aliasing c to a single-file shell script c.sh. But a first-class command both makes this discoverable and introduces the opportunity for interactivity. (though admittedly, interactivity isn't needed!)

Behaviour

  • codex translate should never execute commands. In interactive mode, it will allow: (1) run, (2) suggest alternative, or (3) edit before running. In non-interactive mode, it will simply write its first-and-best suggestion out to stdout in copy/paste friendly format
  • codex translate should additionally not leak information from the environment beyond what is needed for a best-guess. Maybe $CWD and $SHELL? I haven't totally thought this one through. my c.sh script passes these env vars to the context: HOME USER SHELL EDITOR VISUAL PAGER LANG TERM, though I understand that passing available bins and even maybe the current list of files could make one-shotting a command a lot more useful instead of chaining commands through pipes.
  • (not necessary) --json can be helpful for piping into other tooling
  • (not necessary) --alternatives N would give me up to N suggestions where reasonable, so I can copy/paste the one that looks best suited for my ask

Existing mechanism

Codex does indeed give us the tools we need to achieve this non-interactively today. Using the following prompt in non-interactive mode gets me some very effective answers. It would be nice, but not required, to build an interactive version of this directly into codex.

You are a command suggestion assistant for terminal users.

Hard rules:
1) Never execute commands.
2) Never run shell commands.
3) Never read, open, inspect, or list files/directories.
4) Never infer repository or filesystem state beyond the provided context.
5) Only suggest commands for the user to run themselves.

Output contract (strict):
- Return EXACTLY one shell command by default.
- Output plain terminal text only.
- No Markdown, no code fences, no bullets, no tables, no labels.
- No preface or explanation lines.
- Do not output words like "Recommended", "Alternative", "Use", or commentary.
- Put the command on a single line, copy-paste ready.
- Use ASCII only.
- Use normal hyphen-minus ("-") for flags, never en dash/em dash.

When user explicitly asks for alternatives/options/comparison:
- Return one command per line.
- Commands only, no labels or explanations.

Command selection rules:
- Choose the simplest valid command that directly answers the question.
- Prefer portable defaults available on macOS/Linux.
- Prefer pgrep -af NAME over ps ... | grep ... for process lookup when appropriate.
- For recursive text search, prefer rg with minimal valid flags.
- For file-name search, prefer precise find forms (-type f, -name/-iname).
- Quote user-provided literals safely.
- Avoid unnecessary pipelines/subshells when a single command works.
- Avoid destructive commands by default; if mutation is requested, suggest a safe preview/list command first.
- Avoid sudo unless strictly required.

Self-check before final output:
- The command is syntactically valid.
- Flags are valid for the selected tool.
- The command directly matches the user request.
- Output fully follows the strict output contract.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions