Use the ! prefix to execute bash commands directly within Ona Agent conversations. This provides immediate command execution and automatically adds the output to the conversation context, making it a powerful tool for sharing specific information with the agent.

Running bash commands with ! prefix in Ona Agent

How bash commands work

When you type ! followed by a command in the chat interface, Ona Agent executes the command immediately and includes both the command and its output in the conversation context.

Basic syntax

!command [arguments]
The command runs in your current environment and the results become part of the agent’s context for the entire conversation.

Common use cases

Quick information gathering

Get immediate context without asking the agent to run commands:
!pwd
!ls -la
!git status
!npm list --depth=0

Sharing specific output

Provide exact command output for the agent to analyze:
!npm test
!docker ps
!kubectl get pods
!cat package.json

Environment verification

Confirm your environment state before asking for help:
!node --version
!python --version
!which docker
!env | grep NODE

File system exploration

Share directory structure or file contents:
!find . -name "*.js" | head -10
!tree -L 2
!cat src/config.js
!grep -r "TODO" src/

Benefits of using ! commands

Immediate execution

  • Commands run instantly without agent interpretation
  • No waiting for the agent to understand and execute
  • Direct access to your environment state

Shared context

  • Command output becomes part of conversation history
  • Agent can reference the exact output in responses
  • Ensures agent and user see the same information

Efficiency

  • Faster than asking the agent to run commands
  • Reduces back-and-forth communication
  • Provides precise, unfiltered output

Verification

  • Confirm environment state before making changes
  • Share exact error messages for troubleshooting
  • Validate assumptions with real data

Best practices

Use for context sharing

Perfect for providing specific information to the agent:
!cat error.log
!npm run test 2>&1 | tail -20
!git log --oneline -5

Combine with questions

Share command output then ask for analysis:
!docker logs myapp
The container keeps crashing. Can you help me understand what's wrong?

Verify before changes

Check current state before asking for modifications:
!git branch
!git status
Can you help me create a new feature branch?

Share configuration

Provide exact configuration for troubleshooting:
!cat .env.example
!npm run build 2>&1
The build is failing. What might be wrong?

Command execution details

Working directory

  • Commands execute in your current environment’s working directory
  • Use !pwd to confirm your location

Environment variables

  • Commands have access to your environment variables
  • Use !env to see available variables
  • Environment-specific tools and configurations are available

Output handling

  • Both stdout and stderr are captured
  • Long output is included in full
  • Binary output is handled appropriately

Security considerations

  • Commands run with your user permissions
  • Be cautious with destructive commands
  • Output is visible in the conversation history

Examples in practice

Debugging a failing test

!npm test
!cat test/failing-test.js
The test is failing with this error. Can you help me fix it?

Troubleshooting

Command not found

If a command isn’t recognized:
  • Verify the command exists with !which commandname
  • Check your PATH with !echo $PATH
  • Ensure required tools are installed in your environment

Long-running commands

For commands that take time to complete:
  • The interface will wait for completion
  • press ESC or click stop if you need to cancel

Comparison with agent commands

When to use ! commands

  • Quick information gathering
  • Sharing exact output for analysis
  • Verifying environment state
  • Providing specific context

When to ask the agent

  • Complex multi-step operations
  • Code generation and modification
  • Analysis and interpretation of results
  • Planning and decision-making tasks

Next steps

Need help with bash commands in Ona Agent? Reach out to your account manager if you’re an enterprise customer.