Skip to main content
ChatCLI was not designed only for interactive conversations. It can be a powerful tool in your automation scripts, CI/CD pipelines, and shell aliases thanks to its “one-shot” mode. In this mode, you can ask a single question, get the answer, and exit, all in a single command, making it perfect for integration with other tools.

Using the -p or --prompt Flags

The most straightforward way to use one-shot mode is with the -p or --prompt flags. ChatCLI will execute the question, print the AI’s response to stdout, and exit.
The output will be only the AI’s response, ready to be read or processed by another script.

Integrating with Pipes ( | )

One of the most powerful ways to use one-shot mode is by combining it with other command-line tools through pipes. ChatCLI automatically detects if it is receiving data via stdin and uses it as context.

Available Flags in One-Shot Mode

You can customize the behavior of one-shot mode with the following flags:

Agent Mode in One-Shot

You can also invoke Agent Mode non-interactively. This is extremely useful for complex automations. When using /agent or /run with the -p flag, ChatCLI will ask the AI for an action plan and print it. By default, it will not execute the commands.
This will display the plan suggested by the AI (e.g., find /tmp -name "*.tmp" -delete).
Use --agent-auto-exec with caution. Although the security validator blocks known dangerous commands, always review the behavior in production environments.