Skip to content

Latest commit

 

History

History
250 lines (195 loc) · 4.79 KB

File metadata and controls

250 lines (195 loc) · 4.79 KB
title description
Quickstart
Get started with Cortex CLI in 5 minutes

Prerequisites

  • A modern terminal emulator (iTerm2, Alacritty, Windows Terminal, etc.)
  • API key from your chosen AI provider (Anthropic, OpenAI, Google, etc.)

Step 1: Install Cortex

```bash curl -fsSL https://cortex.foundation/install | bash ``` ```bash brew install cortexlm/tap/cortex ``` ```bash cargo install cortex-cli ```

Verify the installation:

cortex --version

Step 2: Configure Authentication

Option A: API Key (Recommended)

Set your API key as an environment variable:

# Anthropic (Claude)
export ANTHROPIC_API_KEY="your-api-key"

# OpenAI
export OPENAI_API_KEY="your-api-key"

# Google (Gemini)
export GOOGLE_API_KEY="your-api-key"

Or login using the CLI:

# Interactive login
cortex login

# Login with API key from stdin
echo "your-api-key" | cortex login --with-api-key

Option B: Device Code Flow

For OAuth-based providers:

cortex login --device-auth

Follow the on-screen instructions to complete authentication.

Step 3: Start Using Cortex

Interactive Mode (TUI)

Start the terminal user interface:

cortex

This opens an interactive chat interface where you can:

  • Ask questions about your codebase
  • Request code changes
  • Run commands
  • Use slash commands

With Initial Prompt

Start with a specific task:

cortex "explain the architecture of this project"

Non-Interactive Mode

For quick, one-off tasks:

cortex run "add error handling to the main function"

Step 4: Initialize Your Project (Optional)

Create an AGENTS.md file to help Cortex understand your project:

# In your project root
cortex run "create an AGENTS.md file documenting this project"

Or use the /init slash command in the TUI.

Basic Usage Examples

```bash cortex "explain how the authentication system works" ``` ```bash cortex "add input validation to the user registration form" ``` ```bash cortex "the tests are failing, diagnose and fix the issue" ``` ```bash cortex "review the recent changes for potential issues" ``` ```bash cortex "write unit tests for the user service" ```

Keyboard Shortcuts (TUI)

Shortcut Action
Enter Send message
Shift+Enter New line
Ctrl+C Cancel current operation
Ctrl+D Exit Cortex
/ Open command menu
/ Navigate history
Tab Autocomplete

Slash Commands

Command Description
/help Show available commands
/model Change AI model
/agent Switch agent
/clear Clear conversation
/compact Compact conversation history
/edit Edit a file
/undo Undo last change
/redo Redo last undone change
/diff Show changes
/share Share session

Next Steps

Learn all available commands Customize your setup Create custom agents Extend with MCP servers

Troubleshooting

Common Issues

Ensure your API key is set correctly: ```bash # Check if variable is set echo $ANTHROPIC_API_KEY
# Or use cortex login
cortex login status
```
For shell commands, Cortex requires explicit approval. Use: ```bash # Lower approval threshold cortex --ask-for-approval medium
# Or full auto mode (use with caution)
cortex --full-auto
```
Check available models: ```bash cortex models ```

Getting Help