ChatCLI’s one-shot mode allows you to run prompts in a single line, ideal for scripts, CI/CD pipelines, and automations.
Basic One-Shot Mode
Use the -p flag to send a prompt and exit immediately:
chatcli -p "Briefly explain this repository."
All context features work within the prompt:
chatcli -p "@git @env Create a concise release note."
chatcli -p "@file ./src --mode summary Provide an architecture overview."
Pipes and stdin
ChatCLI accepts input via pipe, combining the output of other commands with your prompt:
# Analyze Git diff
git diff | chatcli -p "Summarize the changes and list possible impacts."
# Diagnose errors
cat error.log | chatcli -p "Explain the root cause and suggest a solution."
# Analyze command output
kubectl get pods -n production | chatcli -p "Which pods are having issues?"
# Review code
cat src/auth.go | chatcli -p "Review this code and point out vulnerabilities."
Available Flags
| Flag | Description | Example |
|---|
-p, --prompt | Text to send to the LLM | -p "Explain this" |
--provider | Override the AI provider | --provider CLAUDEAI |
--model | Override the model | --model gpt-4o |
--max-tokens | Token limit for the response | --max-tokens 1000 |
--timeout | Call timeout (Go duration) | --timeout 30s |
--no-anim | Disable animations (useful in scripts) | --no-anim |
--agent-auto-exec | Automatically execute the first suggested command | --agent-auto-exec |
--realm | Realm/tenant for StackSpot | --realm my-tenant |
--agent-id | Agent ID for StackSpot | --agent-id xxx |
One-Shot Agent Mode
Combine /agent in the prompt to delegate tasks:
# Dry-run: only suggests the command and exits
chatcli -p "/agent list all .go files in this directory"
# Automatic execution: runs the first safe command
chatcli -p "/agent create a file called test_file.txt" --agent-auto-exec
With --agent-auto-exec, dangerous commands are automatically blocked. Only commands considered safe will be executed.
Automation Examples
Generate release notes automatically
#!/bin/bash
chatcli -p "@git Create detailed release notes for the latest tag." \
--provider CLAUDEAI \
--no-anim > RELEASE_NOTES.md
Review PR in CI
#!/bin/bash
git diff main...HEAD | chatcli -p "Review this diff. List security issues, potential bugs, and suggestions." \
--no-anim \
--max-tokens 2000
Analyze logs in a cron job
#!/bin/bash
tail -100 /var/log/nginx/error.log | chatcli -p "Summarize the errors and suggest corrective actions." \
--no-anim >> /var/log/ai-analysis.log
One-shot with a specific provider
chatcli -p "@file ./src --mode summary Describe the architecture" \
--provider STACKSPOT \
--agent-id "your-agent-id"
Tips
Create an alias in your shell for quick access: alias c='chatcli' and alias ai='chatcli -p'. Then use: ai "Explain what this command does: iptables -t nat -L"
- Use
--no-anim in all scripts to avoid escape characters in the output
- Combine with
> to redirect output to files
- Use
--timeout to prevent scripts from hanging while waiting for a response
- Double quotes are important:
chatcli -p "text with @file and @git" (protects against shell interpretation)