Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ralph ask Command

This document provides comprehensive documentation for the ralph ask command, which sends a single-shot prompt to Claude. Nothing is stored.

Code Locations

ComponentFileDescription
CLI argscrates/ralph/src/cli/mod.rsAskArgs struct definition
Permission modecrates/ralph/src/invoke.rs, crates/ralph/src/config.rsresolve_permission_mode(), AppConfig::ask_permission_mode()
Shared enginecrates/ralph/src/invoke.rsInvocationConfig, invoke(), command building
Prompt sourcecrates/ralph/src/prompt_source.rsclassify_prompt_source(), read_from_source()
Executioncrates/ralph/src/main.rsexecute_ask(), build_invocation_config(), resolve_ask_prompt()
Summarycrates/ralph/src/startup/display.rsdisplay_ask_summary()
Configcrates/ralph/src/config.rsAppConfig with AskSection

Purpose

The ralph ask command provides a streamlined interface for quick LLM interactions. ask sends a single prompt and displays the response. It keeps no session, history, or log on disk; each call is independent. Use ralph chat for a conversation that persists.

CLI Flags

FlagTypeDefaultDescription
[PROMPT]positionalstdinThe prompt to send (inline, file path, or - for stdin)
--themestringbase16-ocean.darkSyntax highlighting theme
--no-backgroundflagfalseDisable theme background colors
--timeoutu64600Subprocess timeout in seconds
--verbose-toolsstringnoneVerbose output for tools (omit value for all, or specify names)
--no-promptflagfalseSuppress prompt display before execution
--permission-modestringbypassPermissionsPermission mode for tool execution

Verbose Tools Examples

ralph ask --verbose-tools 'prompt'       # Enable for all tools
ralph ask --verbose-tools=grep,bash 'prompt'  # Enable for specific tools

Prompt Resolution

The prompt can be provided from multiple sources:

SourceExampleDescription
Positional argumentralph ask 'What is 2+2?'Inline prompt text
File pathralph ask /path/to/prompt.txtRead prompt from file (if path exists)
Stdin explicitralph ask -Read from stdin (explicit)
Stdin pipedecho 'prompt' | ralph askRead from stdin when piped (automatic)

Resolution Priority

  1. If argument is -, read from stdin
  2. If argument is a valid file path, read from file
  3. If argument is any other string, use as inline prompt
  4. If no argument and stdin is piped (non-terminal), read from stdin
  5. If no argument and stdin is terminal, error (no prompt provided)

Permission Modes

The --permission-mode flag sets claude --permission-mode. ask has its own setting, default bypassPermissions: the user is present, watching, and can stop the run with Ctrl+C. Chat and its workers use [chat] permission_mode and RALPH_CHAT_PERMISSION_MODE, default auto, which do not change ask. Choices are claude’s: acceptEdits, auto, bypassPermissions, manual, dontAsk, plan (see claude --help).

ralph ask --permission-mode plan 'Analyze this code'

Configuration Precedence

  1. CLI flag (--permission-mode)
  2. Environment variable (RALPH_ASK_PERMISSION_MODE, ignored when empty)
  3. [ask] permission_mode in ~/.config/ralph/config.toml
  4. Default (bypassPermissions)

Config file example:

[ask]
permission_mode = "acceptEdits"

Theme Configuration

Theme settings follow this precedence:

  1. CLI flag (--theme, --no-background)
  2. Environment variable (RALPH_THEME, RALPH_NO_BACKGROUND)
  3. Config file (if present)
  4. Default: base16-ocean.dark

Output Patterns

Prompt Display

Before execution (unless --no-prompt):

╭─── Prompt ────────────────────────────────────────────────────╮
│ What is Rust?                                                 │
╰───────────────────────────────────────────────────────────────╯

Streaming Response

Response is streamed with syntax highlighting for code blocks.

Summary

After completion:

✓ Ask Complete

─── Metrics ───
Cost: $0.0234
Duration: 5.2s
Tokens: 1.2K input | 567 output

Examples

Basic Usage

# Simple question
ralph ask 'What is the capital of France?'

# Multi-line prompt from heredoc
ralph ask <<'EOF'
Review this function for potential improvements:

fn add(a: i32, b: i32) -> i32 {
    a + b
}
EOF

# Prompt from file
ralph ask /path/to/detailed-prompt.txt

Piping

# Pipe prompt from another command
cat requirements.txt | ralph ask 'Analyze these dependencies'

# Pipe through multiple tools
git diff | ralph ask 'Review this diff'

# Use with process substitution
ralph ask < <(echo "Combined prompt from $(pwd)")

Permission Control

# Read-only exploration
ralph ask --permission-mode plan 'What files are in src/?'

# Trusted editing
ralph ask --permission-mode acceptEdits 'Add error handling to main.rs'

# Full automation (default)
ralph ask 'Refactor the test suite'

Theme and Display

# Custom theme
ralph ask --theme 'Solarized (dark)' 'prompt'

# No background colors
ralph ask --no-background 'prompt'

# Hide prompt display
ralph ask --no-prompt 'prompt'

# Verbose tool output
ralph ask --verbose-tools=bash 'Run the tests'