Configuration Overview

NikCLI offers extensive configuration options to customize its behavior for your development workflow. Configuration can be managed through environment variables, configuration files, and interactive commands.

Configuration Methods

Environment Variables

Set API keys and global settings via environment variables

Config Files

Persistent settings stored in JSON configuration files

Interactive Commands

Use built-in commands to modify settings on the fly

Environment Variables

AI Provider Configuration

# Primary API key
export ANTHROPIC_API_KEY="sk-ant-api03-..."

# Optional: Custom base URL
export ANTHROPIC_BASE_URL="https://api.anthropic.com"

# Optional: Default model
export ANTHROPIC_MODEL="claude-3-sonnet-20240229"

General Configuration

# Logging level (debug, info, warn, error)
export NIKCLI_LOG_LEVEL="info"

# Cache directory
export NIKCLI_CACHE_DIR="~/.nikcli/cache"

# Configuration directory
export NIKCLI_CONFIG_DIR="~/.nikcli"

# Default mode (chat, autonomous, plan)
export NIKCLI_DEFAULT_MODE="chat"

# Enable/disable auto-approval for certain operations
export NIKCLI_AUTO_APPROVE="false"

# Token limit for context management
export NIKCLI_TOKEN_LIMIT="100000"

Configuration Files

NikCLI stores configuration in JSON files located in ~/.nikcli/:

Main Configuration (config.json)

{
  "defaultProvider": "anthropic",
  "defaultModel": "claude-3-sonnet-20240229",
  "autoApprove": false,
  "logLevel": "info",
  "tokenLimit": 100000,
  "defaultMode": "chat",
  "colorScheme": "auto",
  "enableTelemetry": true,
  "cacheEnabled": true,
  "cacheTTL": 3600,
  "mcpServers": []
}

Provider Configuration (providers.json)

{
  "anthropic": {
    "apiKey": "encrypted:...",
    "baseUrl": "https://api.anthropic.com",
    "models": ["claude-3-opus-20240229", "claude-3-sonnet-20240229"],
    "defaultModel": "claude-3-sonnet-20240229",
    "tokenLimits": {
      "claude-3-opus-20240229": 200000,
      "claude-3-sonnet-20240229": 200000
    }
  },
  "openai": {
    "apiKey": "encrypted:...",
    "baseUrl": "https://api.openai.com/v1",
    "models": ["gpt-4", "gpt-3.5-turbo"],
    "defaultModel": "gpt-4"
  }
}

Agent Configuration (agents.json)

{
  "universal": {
    "enabled": true,
    "permissions": {
      "fileRead": true,
      "fileWrite": true,
      "commandExecution": true,
      "networkAccess": false
    },
    "securityPolicies": {
      "allowedCommands": ["npm", "git", "node"],
      "blockedCommands": ["rm -rf", "sudo"],
      "allowedPaths": ["."],
      "blockedPaths": ["/etc", "/usr"]
    }
  },
  "specialized": {
    "react": { "enabled": true },
    "backend": { "enabled": true },
    "devops": { "enabled": false }
  }
}

Interactive Configuration

Configuration Commands

Use built-in commands to view and modify settings:
# View all configuration
nikcli config list

# View specific setting
nikcli config get defaultProvider

# View provider settings
nikcli config get providers.anthropic

In-Chat Configuration

You can also modify settings during a chat session:
> /config set defaultModel claude-3-opus-20240229
> /config enable autoApprove
> /config list providers

Advanced Configuration

Security Policies

Configure execution policies for safe autonomous operation:
{
  "executionPolicies": {
    "allowedCommands": [
      "npm",
      "yarn",
      "git",
      "node",
      "tsc",
      "eslint",
      "prettier"
    ],
    "blockedCommands": [
      "rm -rf",
      "sudo",
      "chmod 777",
      "curl | sh"
    ],
    "allowedPaths": [
      ".",
      "./src",
      "./tests",
      "./docs"
    ],
    "blockedPaths": [
      "/etc",
      "/usr",
      "/var",
      "~/.ssh"
    ],
    "requireApproval": [
      "package.json",
      "tsconfig.json",
      ".gitignore"
    ]
  }
}

Token Management

Configure context and token limits:
{
  "tokenManagement": {
    "globalLimit": 100000,
    "perProviderLimits": {
      "anthropic": 200000,
      "openai": 128000,
      "google": 32000
    },
    "contextWindow": 32000,
    "reserveTokens": 4000,
    "compressionEnabled": true,
    "cacheStrategy": "lru"
  }
}

MCP (Model Context Protocol) Servers

Configure external MCP servers for extended functionality:
{
  "mcpServers": [
    {
      "name": "filesystem",
      "command": "node",
      "args": ["./mcp-servers/filesystem.js"],
      "env": {
        "ALLOWED_PATHS": "./src,./docs"
      }
    },
    {
      "name": "git",
      "command": "git-mcp-server",
      "args": ["--repo", "."]
    },
    {
      "name": "web-search",
      "command": "web-search-mcp",
      "env": {
        "SEARCH_API_KEY": "your-key"
      }
    }
  ]
}

Profile-Based Configuration

Create different configuration profiles for various workflows:

Development Profile

# Create development profile
nikcli profile create development

# Configure for local development
nikcli profile set development defaultProvider ollama
nikcli profile set development defaultModel llama2
nikcli profile set development autoApprove true
nikcli profile set development logLevel debug

# Switch to development profile
nikcli profile use development

Production Profile

# Create production profile
nikcli profile create production

# Configure for production use
nikcli profile set production defaultProvider anthropic
nikcli profile set production defaultModel claude-3-opus-20240229
nikcli profile set production autoApprove false
nikcli profile set production logLevel warn

# Switch to production profile
nikcli profile use production

Project-Specific Configuration

Create .nikcli.json in your project root for project-specific settings:
{
  "extends": "~/.nikcli/config.json",
  "projectName": "my-awesome-app",
  "defaultAgent": "react",
  "preferences": {
    "codeStyle": "typescript",
    "testFramework": "vitest",
    "uiLibrary": "tailwindcss"
  },
  "customPrompts": {
    "component": "Create a React component following our design system patterns",
    "api": "Implement API endpoint with proper error handling and validation"
  },
  "workflowTemplates": {
    "feature": [
      "Create component",
      "Add tests",
      "Update documentation",
      "Run linting and formatting"
    ]
  }
}

Configuration Validation

NikCLI validates configuration on startup and provides helpful error messages:
# Validate current configuration
nikcli config validate

# Check specific provider configuration
nikcli config validate providers.anthropic

# Verbose validation with suggestions
nikcli config validate --verbose

Configuration Backup and Restore

Backup Configuration

# Backup all configuration
nikcli config backup ~/nikcli-backup.json

# Backup specific profile
nikcli config backup ~/dev-profile.json --profile development

Restore Configuration

# Restore from backup
nikcli config restore ~/nikcli-backup.json

# Restore specific profile
nikcli config restore ~/dev-profile.json --profile development

Troubleshooting Configuration

Next Steps

Configuration changes take effect immediately. You don’t need to restart NikCLI for most settings to apply.