Skip to main content

Overview

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

# 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:
export ANTHROPIC_API_KEY=your-api-key
Or authenticate via Claude subscription:
claude setup-token

Basic Usage with PraisonAI

# Use Claude as external agent
praisonai "Fix the bug in auth.py" --external-agent claude

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

CLI Options Reference

OptionDescription
-p, --printPrint response and exit (useful for pipes/scripts)
--output-format <format>Output format: text (default), json, or stream-json
--include-partial-messagesInclude partial message chunks (with stream-json)
--input-format <format>Input format: text (default) or stream-json

Model Selection

OptionDescription
--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

OptionDescription
--system-prompt <prompt>Custom system prompt for the session
--append-system-prompt <prompt>Append to default system prompt (recommended)

Tool Control

OptionDescription
--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

OptionDescription
--permission-mode <mode>Permission mode for the session
--dangerously-skip-permissionsBypass 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

OptionDescription
-c, --continueContinue the most recent conversation
-r, --resume [value]Resume by session ID or open picker
--fork-sessionCreate new session ID when resuming
--no-session-persistenceDisable session persistence
--session-id <uuid>Use specific session ID

Budget & Limits

OptionDescription
--max-budget-usd <amount>Maximum dollar amount for API calls

MCP Integration

OptionDescription
--mcp-config <configs>Load MCP servers from JSON files
--strict-mcp-configOnly use MCP servers from --mcp-config

Additional Options

OptionDescription
--add-dir <directories>Additional directories for tool access
--verboseOverride verbose mode setting
--debugEnable 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

CommandDescription
claude mcpConfigure and manage MCP servers
claude pluginManage Claude Code plugins
claude setup-tokenSet up authentication token
claude doctorCheck auto-updater health
claude updateCheck for and install updates
claude install [target]Install native build

Examples

Basic Query

# 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

# 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

claude -p --append-system-prompt "You are a Python expert" "Optimize this function"

JSON Output

claude -p --output-format json "List all functions in main.py"

Continue Session

# Start a session
claude "Create a new feature"

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

Python Integration

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

VariableDescription
ANTHROPIC_API_KEYAnthropic API key
CLAUDE_API_KEYAlternative API key variable

Built-in Tools

Claude Code includes these built-in tools:
ToolDescription
ReadRead any file in the working directory
WriteCreate new files
EditMake precise edits to existing files
BashRun terminal commands, scripts, git operations
GlobFind files by pattern
GrepSearch file contents with regex
WebSearchSearch the web for information
WebFetchFetch and parse web page content