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

# Configuration

> Configure NikCLI for optimal performance with API keys, preferences, and advanced settings

# Configuration Guide

Configure NikCLI to match your development workflow with comprehensive settings for API keys, agent behavior, security, and performance.

## 🔑 API Keys Setup

### Supported AI Providers

NikCLI supports multiple AI providers for maximum flexibility:

<CardGroup cols={2}>
  <Card title="Anthropic Claude" icon="brain">
    **Recommended** - Best for complex reasoning and code generation
  </Card>

  <Card title="OpenAI GPT" icon="sparkles">
    **Popular** - Excellent for general tasks and creativity
  </Card>

  <Card title="Google Gemini" icon="zap">
    **Efficient** - Great for analysis and optimization
  </Card>

  <Card title="Ollama Local" icon="server">
    **Private** - Run models locally for complete privacy
  </Card>
</CardGroup>

### Setting API Keys

```bash theme={null}
# Set Anthropic API key (recommended)
/set-key anthropic sk-ant-api03-...

# Set OpenAI API key
/set-key openai sk-...

# Set Google API key
/set-key google AIza...

# Set Ollama endpoint
/set-key ollama http://localhost:11434
```

### Environment Variables

You can also set API keys via environment variables:

```bash theme={null}
# Set environment variables
export ANTHROPIC_API_KEY="sk-ant-api03-..."
export OPENAI_API_KEY="sk-..."
export GOOGLE_API_KEY="AIza..."

# Or in .env file
echo "ANTHROPIC_API_KEY=sk-ant-api03-..." >> .env
echo "OPENAI_API_KEY=sk-..." >> .env
```

### Verify Configuration

```bash theme={null}
# Check current configuration
/config

# Test API connectivity
/debug

# List available models
/models
```

## ⚙️ Agent Configuration

### Universal Agent Settings

Configure the Universal Agent for optimal performance:

```bash theme={null}
# Set agent behavior style
/agent-config universal-agent --style collaborative
/agent-config universal-agent --style autonomous
/agent-config universal-agent --style guided

# Set verbosity level
/agent-config universal-agent --verbosity detailed
/agent-config universal-agent --verbosity concise
/agent-config universal-agent --verbosity minimal

# Configure permissions
/agent-config universal-agent --permissions "read:src/,write:src/,execute:npm,git"

# Set context paths
/agent-config universal-agent --context "src/,tests/,docs/"
```

### VM Agent Settings

Configure the VM Agent for secure development:

```bash theme={null}
# Set isolation level
/agent-config vm-agent --isolation-level strict
/agent-config vm-agent --isolation-level moderate
/agent-config vm-agent --isolation-level permissive

# Configure container resources
/agent-config vm-agent --container-resources "memory:4GB,cpu:2,storage:10GB"

# Set token budget
/agent-config vm-agent --token-budget 50000
```

## 🎛️ System Preferences

### Model Selection

```bash theme={null}
# Switch to specific model
/model claude-3-5-sonnet
/model gpt-4o
/model gemini-1.5-pro
/model ollama:llama3.1:8b

# View current model
/model

# List all available models
/models
```

### Creativity Settings

```bash theme={null}
# Set temperature (creativity level)
/temp 0.7    # Balanced creativity
/temp 0.3    # More focused
/temp 1.2    # More creative

# View current temperature
/temp
```

### Session Management

```bash theme={null}
# Enable/disable chat history
/history on
/history off

# Set system prompt
/system "You are a senior React developer specializing in TypeScript and performance optimization"

# Clear current session
/clear

# Start new session
/new "React Authentication Project"
```

## 🔒 Security Configuration

### Approval System

Configure the approval system for sensitive operations:

```bash theme={null}
# Set approval level
/security --approval-level strict
/security --approval-level moderate
/security --approval-level permissive

# Configure approval timeout
/security --approval-timeout 300

# Enable/disable specific approvals
/security --enable-file-write-approval
/security --enable-command-execution-approval
/security --enable-network-access-approval
```

### Sandbox Settings

```bash theme={null}
# Enable sandbox mode
/sandbox --enable

# Configure file system access
/sandbox --allow-file-system
/sandbox --restrict-paths "/home/user/projects"

# Configure command execution
/sandbox --allow-commands "npm,git,node"
/sandbox --block-commands "rm,rmdir,sudo"

# Configure network access
/sandbox --allow-network
/sandbox --restrict-domains "github.com,npmjs.com"
```

### Developer Mode

```bash theme={null}
# Enable developer mode (reduces security restrictions)
/dev-mode

# Disable developer mode
/dev-mode --disable

# Check current mode
/dev-mode --status
```

## 📊 Performance Settings

### Caching Configuration

```bash theme={null}
# Enable response caching
/cache --enable

# Set cache size
/cache --size 100MB

# Clear cache
/cache --clear

# Configure cache TTL
/cache --ttl 3600
```

### Memory Management

```bash theme={null}
# Set memory limits
/memory --limit 2GB

# Configure garbage collection
/memory --gc-interval 300

# Monitor memory usage
/memory --stats
```

### Parallel Execution

```bash theme={null}
# Configure parallel execution
/parallel --max-concurrent 3
/parallel --timeout 300

# Enable parallel mode
/parallel --enable

# Disable parallel mode
/parallel --disable
```

## 🎨 UI Customization

### Display Settings

```bash theme={null}
# Set compact mode
/set compact true

# Enable clean chat mode
/set clean-chat true

# Configure live updates
/set live-updates ephemeral

# Set minimal stream mode
/set minimal-stream true
```

### Color Themes

```bash theme={null}
# Set color theme
/theme dark
/theme light
/theme auto

# Customize colors
/theme --primary "#4EC5F1"
/theme --secondary "#1f39ff"
```

## 🔧 Advanced Configuration

### LSP Integration

```bash theme={null}
# Enable LSP integration
/lsp --enable

# Configure LSP servers
/lsp --add typescript
/lsp --add python
/lsp --add rust

# Set LSP timeout
/lsp --timeout 5000
```

### Context Management

```bash theme={null}
# Configure context retention
/context --retention 7d
/context --max-files 1000

# Enable context indexing
/context --indexing true

# Set context paths
/context --paths "src/,tests/,docs/"
```

### Logging Configuration

```bash theme={null}
# Set log level
/log --level debug
/log --level info
/log --level warn
/log --level error

# Enable structured logging
/log --structured true

# Set log file
/log --file ~/.nikcli/logs/nikcli.log
```

## 📁 Configuration Files

### Main Configuration

NikCLI stores configuration in `~/.nikcli/config.json`:

```json theme={null}
{
  "defaultProvider": "anthropic",
  "defaultModel": "claude-3-5-sonnet",
  "temperature": 0.7,
  "historyEnabled": true,
  "approvalLevel": "moderate",
  "sandbox": {
    "enabled": true,
    "allowFileSystem": true,
    "allowCommands": true,
    "allowNetwork": true
  },
  "agents": {
    "universal": {
      "style": "collaborative",
      "verbosity": "detailed",
      "maxConcurrentTasks": 3
    },
    "vm": {
      "isolationLevel": "moderate",
      "tokenBudget": 50000,
      "containerResources": {
        "memory": "4GB",
        "cpu": "2"
      }
    }
  }
}
```

### Environment Variables

Set these environment variables for advanced configuration:

```bash theme={null}
# API Keys
export ANTHROPIC_API_KEY="sk-ant-api03-..."
export OPENAI_API_KEY="sk-..."
export GOOGLE_API_KEY="AIza..."

# Performance
export NIKCLI_COMPACT=1
export NIKCLI_CLEAN_CHAT=1
export NIKCLI_MINIMAL_STREAM=1

# Embedding Optimization
export EMBED_BATCH_SIZE=300
export EMBED_MAX_CONCURRENCY=6
export EMBED_INTER_BATCH_DELAY_MS=25
export INDEXING_BATCH_SIZE=300
export EMBED_ADAPTIVE_BATCHING=true
```

## 🔍 Configuration Validation

### Check Configuration

```bash theme={null}
# Validate current configuration
/config --validate

# Test all API connections
/debug --full

# Check agent status
/agents --status

# Verify permissions
/security --check
```

### Troubleshooting

<AccordionGroup>
  <Accordion title="API Key Issues">
    **Problem:** API keys not working

    **Solutions:**

    ```bash theme={null}
    # Check API key format
    /config

    # Test API connectivity
    /debug

    # Re-set API key
    /set-key anthropic sk-ant-api03-...
    ```
  </Accordion>

  <Accordion title="Permission Errors">
    **Problem:** Permission denied errors

    **Solutions:**

    ```bash theme={null}
    # Check current permissions
    /security --check

    # Adjust sandbox settings
    /sandbox --allow-file-system

    # Enable developer mode temporarily
    /dev-mode
    ```
  </Accordion>

  <Accordion title="Performance Issues">
    **Problem:** Slow performance

    **Solutions:**

    ```bash theme={null}
    # Check memory usage
    /memory --stats

    # Clear cache
    /cache --clear

    # Adjust parallel execution
    /parallel --max-concurrent 2
    ```
  </Accordion>
</AccordionGroup>

## 🎯 Best Practices

### 1. Start with Defaults

Begin with default configuration and adjust as needed:

```bash theme={null}
# Use default configuration
/config --reset

# Gradually customize
/temp 0.7
/agent-config universal-agent --style collaborative
```

### 2. Use Environment Variables

For team projects, use environment variables:

```bash theme={null}
# Create .env file
echo "ANTHROPIC_API_KEY=sk-ant-api03-..." > .env
echo "NIKCLI_COMPACT=1" >> .env
```

### 3. Regular Configuration Review

Periodically review and optimize configuration:

```bash theme={null}
# Check current settings
/config

# Review performance metrics
/stats

# Optimize based on usage patterns
/agent-config universal-agent --optimize
```

## 🚀 Next Steps

<CardGroup cols={2}>
  <Card title="Agent System" icon="robot" href="/agent-system/architecture">
    Learn about cognitive orchestration
  </Card>

  <Card title="Command Reference" icon="terminal" href="/cli-reference/commands-overview">
    Master all commands
  </Card>

  <Card title="Advanced Features" icon="zap" href="/features/vim-mode">
    Explore advanced capabilities
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/troubleshooting/common-issues">
    Solve common problems
  </Card>
</CardGroup>

<Tip>
  **Pro Tip:** Use `/config --export` to save your configuration and `/config --import` to restore it on other machines.
</Tip>
