> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude CLI

> Use Claude Code CLI as an external agent in PraisonAI

## Overview

<img src="https://mintcdn.com/praisonai/SX0Y8_-DRBjzOTnt/docs/cli/claude-cli-using-claude-model-for-creativ.gif?s=13984c71f30b7fd799ec376537bcba61" alt="Using Claude Model for Creative Tasks" width="1497" height="1104" data-path="docs/cli/claude-cli-using-claude-model-for-creativ.gif" />

Claude Code CLI is Anthropic's AI-powered coding assistant that can read files, run commands, search the web, edit code, and more. PraisonAI integrates with Claude CLI to use it as an external agent.

## Installation

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Install Claude Code CLI
curl -fsSL https://claude.ai/install.sh | bash

# Or using npm
npm install -g @anthropic-ai/claude-code
```

## Authentication

Set your Anthropic API key:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export ANTHROPIC_API_KEY=your-api-key
```

Or authenticate via Claude subscription:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
claude setup-token
```

## Basic Usage with PraisonAI

<Note>
  `--external-agent claude` invokes Claude CLI via a manager Agent by default. The manager reasons and calls Claude as a subagent tool. Use `--external-agent-direct` for pass-through proxy behavior.
</Note>

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Manager delegation (default — manager reasons + calls claude as subagent tool)
praisonai "Fix the bug in auth.py" --external-agent claude

# Direct proxy (escape hatch — no manager, passes prompt straight to claude)
praisonai "Fix the bug in auth.py" --external-agent claude --external-agent-direct

# With verbose output
praisonai "Refactor this module" --external-agent claude --verbose
```

## CLI Options Reference

### Print Mode (Non-Interactive)

| Option                       | Description                                               |
| ---------------------------- | --------------------------------------------------------- |
| `-p, --print`                | Print response and exit (useful for pipes/scripts)        |
| `--output-format <format>`   | Output format: `text` (default), `json`, or `stream-json` |
| `--include-partial-messages` | Include partial message chunks (with `stream-json`)       |
| `--input-format <format>`    | Input format: `text` (default) or `stream-json`           |

### Model Selection

| Option                     | Description                                                                |
| -------------------------- | -------------------------------------------------------------------------- |
| `--model <model>`          | Model alias (`sonnet`, `opus`) or full name (`claude-sonnet-4-5-20250929`) |
| `--fallback-model <model>` | Fallback model when default is overloaded                                  |

### System Prompts

| Option                            | Description                                   |
| --------------------------------- | --------------------------------------------- |
| `--system-prompt <prompt>`        | Custom system prompt for the session          |
| `--append-system-prompt <prompt>` | Append to default system prompt (recommended) |

### Tool Control

| Option                      | Description                                                              |
| --------------------------- | ------------------------------------------------------------------------ |
| `--allowedTools <tools>`    | Comma-separated list of allowed tools (e.g., `Bash,Edit,Read`)           |
| `--disallowedTools <tools>` | Comma-separated list of denied tools                                     |
| `--tools <tools>`           | Specify available tools: `""` (none), `default` (all), or specific names |

### Permission Modes

| Option                           | Description                                     |
| -------------------------------- | ----------------------------------------------- |
| `--permission-mode <mode>`       | Permission mode for the session                 |
| `--dangerously-skip-permissions` | Bypass all permission checks (use with caution) |

**Permission Mode Values:**

* `default` - Standard permission behavior
* `acceptEdits` - Auto-accept file edits
* `bypassPermissions` - Bypass all permission checks
* `plan` - Planning mode (no execution)
* `delegate` - Delegate decisions
* `dontAsk` - Don't ask for permissions

### Session Management

| Option                     | Description                           |
| -------------------------- | ------------------------------------- |
| `-c, --continue`           | Continue the most recent conversation |
| `-r, --resume [value]`     | Resume by session ID or open picker   |
| `--fork-session`           | Create new session ID when resuming   |
| `--no-session-persistence` | Disable session persistence           |
| `--session-id <uuid>`      | Use specific session ID               |

### Budget & Limits

| Option                      | Description                         |
| --------------------------- | ----------------------------------- |
| `--max-budget-usd <amount>` | Maximum dollar amount for API calls |

### MCP Integration

| Option                   | Description                              |
| ------------------------ | ---------------------------------------- |
| `--mcp-config <configs>` | Load MCP servers from JSON files         |
| `--strict-mcp-config`    | Only use MCP servers from `--mcp-config` |

### Additional Options

| Option                      | Description                                  |
| --------------------------- | -------------------------------------------- |
| `--add-dir <directories>`   | Additional directories for tool access       |
| `--verbose`                 | Override verbose mode setting                |
| `--debug`                   | Enable debug mode                            |
| `--json-schema <schema>`    | JSON Schema for structured output validation |
| `--agents <json>`           | JSON object defining custom agents           |
| `--settings <file-or-json>` | Path to settings JSON file                   |

## Commands

| Command                   | Description                      |
| ------------------------- | -------------------------------- |
| `claude mcp`              | Configure and manage MCP servers |
| `claude plugin`           | Manage Claude Code plugins       |
| `claude setup-token`      | Set up authentication token      |
| `claude doctor`           | Check auto-updater health        |
| `claude update`           | Check for and install updates    |
| `claude install [target]` | Install native build             |

## Examples

### Basic Query

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Simple question
praisonai "What files are in this directory?" --external-agent claude

# Code analysis
praisonai "Analyze the code quality of src/" --external-agent claude
```

### With Tool Restrictions

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Allow only read operations
claude -p --allowedTools "Read,Glob,Grep" "Find all TODO comments"

# Deny bash access
claude -p --disallowedTools "Bash" "Review this code"
```

### With Custom System Prompt

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
claude -p --append-system-prompt "You are a Python expert" "Optimize this function"
```

### JSON Output

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
claude -p --output-format json "List all functions in main.py"
```

### Continue Session

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Start a session
claude "Create a new feature"

# Continue the session
claude -c "Now add tests for it"
```

## Python Integration

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai.integrations import ClaudeCodeIntegration

# Create integration
claude = ClaudeCodeIntegration(
    workspace="/path/to/project",
    output_format="json",
    model="sonnet"
)

# Execute a task
result = await claude.execute("Refactor the auth module")
print(result)

# Stream output
async for event in claude.stream("Add error handling"):
    print(event)
```

## Environment Variables

| Variable            | Description                  |
| ------------------- | ---------------------------- |
| `ANTHROPIC_API_KEY` | Anthropic API key            |
| `CLAUDE_API_KEY`    | Alternative API key variable |

## Built-in Tools

Claude Code includes these built-in tools:

| Tool        | Description                                    |
| ----------- | ---------------------------------------------- |
| `Read`      | Read any file in the working directory         |
| `Write`     | Create new files                               |
| `Edit`      | Make precise edits to existing files           |
| `Bash`      | Run terminal commands, scripts, git operations |
| `Glob`      | Find files by pattern                          |
| `Grep`      | Search file contents with regex                |
| `WebSearch` | Search the web for information                 |
| `WebFetch`  | Fetch and parse web page content               |

## Related

* [External Agents Overview](/docs/cli/cli)
* [Gemini CLI](/docs/cli/gemini-cli)
* [Codex CLI](/docs/cli/codex-cli)
* [Cursor CLI](/docs/cli/cursor-cli)
