# AutoHedge REPL Commands: Complete Interactive Shell Reference

> Explore the AutoHedge REPL commands for interactive shell access. Learn about help, quit, and how to execute financial hedging tasks directly. Master AutoHedge today.

- Repository: [Swarms/AutoHedge](https://github.com/The-Swarm-Corporation/AutoHedge)
- Tags: api-reference
- Published: 2026-09-09

---

**The AutoHedge REPL recognizes three built-in command types: `help` (or `?`, `h`) to display usage tips, `quit` (or `exit`, `q`) to terminate the session, and arbitrary text inputs that are interpreted as financial hedging tasks and passed to the core engine.**

The AutoHedge repository by The-Swarm-Corporation provides a lightweight command-line interface for automated financial analysis. The interactive REPL is implemented in [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py), offering a deliberately minimal command set that routes user inputs efficiently between the interface and the core hedging engine.

## Built-in AutoHedge REPL Commands

The REPL normalizes all input to lower-case and matches it against three specific command categories before processing.

### Navigation and Control Commands

The shell recognizes two groups of control commands for user assistance and session management:

- **`help`, `?`, `h`** — Displays the REPL tip list, showing available commands and usage hints. This logic resides in lines 64–68 of [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py).

- **`quit`, `exit`, `q`** — Gracefully terminates the REPL session. The exit handler is implemented in lines 60–62 of [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py).

### Task Execution Mode

Any input that does not match the control commands above is treated as a **task prompt**. The REPL forwards this text directly to `AutoHedge.run()` for processing. This design routes research queries, stock analysis requests, and hedging calculations through the core engine without requiring specific command prefixes.

## REPL Implementation Details

The command parsing logic in [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py) follows a straightforward conditional structure after displaying the welcome screen. The implementation converts user input to lower-case to ensure case-insensitive command matching.

When the input matches exit commands, the loop breaks cleanly. Help commands trigger a print statement displaying the tip list. All other inputs fall through to lines 69–78, where the text is passed to the `AutoHedge` class for execution. This architecture keeps the interface lightweight while allowing the underlying hedging logic in [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py) to evolve independently.

## Practical Usage Examples

### Start the REPL

Launch the interactive shell from your terminal:

```bash
autohedge

```

### Display Help Information

Request usage tips at the prompt:

```text
> help
  • Enter a task prompt to run (e.g. 'Analyze NVDA for 50k allocation')
  • Type 'quit' or 'exit' to leave
  • Type 'help' or '?' for commands

```

### Execute a Hedging Task

Submit natural language prompts directly to the engine:

```text
> Analyze NVDA for 50k allocation
[Result] … (output from AutoHedge.run())

```

### Terminate the Session

Exit the REPL gracefully:

```text
> quit
Goodbye.

```

## Key Source Files

Understanding the REPL architecture requires familiarity with these components:

- **[`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py)** — Implements the REPL loop, command normalization, and the welcome screen interface.

- **[`autohedge/__init__.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/__init__.py)** — Exposes the `AutoHedge` class that the REPL instantiates to process task prompts.

- **[`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py)** — Contains the core `AutoHedge.run()` method that executes hedging logic for non-command inputs.

- **[`autohedge/prompts.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/prompts.py)** — Stores default templates and prompt structures leveraged by the REPL and engine.

## Summary

- The AutoHedge REPL supports exactly **three command types**: help variants, exit variants, and free-form task prompts.
- **Control commands** (`help`, `quit` and their aliases) are handled directly in [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py) at lines 60–68.
- **Task prompts** bypass command parsing and route to `AutoHedge.run()` in [`autohedge/main.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/main.py) via lines 69–78 of the CLI module.
- Input is **case-insensitive** due to lower-case normalization before command matching.
- The minimalist design separates interface concerns from hedging logic, allowing the core engine to evolve without CLI changes.

## Frequently Asked Questions

### How do I exit the AutoHedge REPL?

Type `quit`, `exit`, or the alias `q` at the prompt. The REPL detects these commands in lines 60–62 of [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py) and breaks the input loop gracefully, printing "Goodbye." before returning to the terminal.

### What happens if I type a command not recognized by the REPL?

Any text that does not match the help or quit aliases is treated as a task prompt. The REPL passes this input unchanged to `AutoHedge.run()`, which interprets the text as a financial analysis or hedging request. There are no "unknown command" errors in the AutoHedge REPL.

### Where is the REPL command logic implemented?

All REPL functionality resides in [`autohedge/cli.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/cli.py). The command dispatch logic spans lines 60–78, with exit handlers at lines 60–62, help display at lines 64–68, and task delegation at lines 69–78.

### Can I use the REPL for batch processing or scripts?

No, the REPL is designed exclusively for interactive use. For programmatic access, import the `AutoHedge` class directly from [`autohedge/__init__.py`](https://github.com/The-Swarm-Corporation/AutoHedge/blob/main/autohedge/__init__.py) and call `AutoHedge.run()` with your task string, bypassing the CLI interface entirely.