Best Practices

Tips and recommendations for getting the most out of CortexPrism.

Configuration

Use Environment Variables for API Keys

Instead of storing API keys directly in config.json, use environment variables:

export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."

The config file can reference these via provider configuration.

Set Up Multiple Providers

Configure multiple providers for redundancy and cost optimization:

{
  "defaultProvider": "anthropic",
  "providers": {
    "anthropic": { "kind": "anthropic", "model": "claude-sonnet-4-20250514", "apiKey": "..." },
    "ollama": { "kind": "ollama", "model": "llama3.2", "baseUrl": "http://localhost:11434" }
  }
}

Use the Vault for Secrets

Always store sensitive credentials in the vault rather than plaintext config:

export CORTEX_VAULT_KEY="strong-passphrase"
cortex vault store "openai-key" --service openai

Memory

Add Important Context to Semantic Memory

Proactively store important information:

cortex memory add "Project deploy URL: https://staging.example.com"
cortex memory add "The team uses pnpm for package management"

This makes persistent knowledge available across all future sessions.

Use Precise Memory Queries

For better memory retrieval, use specific keywords:

# Good
cortex memory search "deployment config staging environment"

# Less effective
cortex memory search "thing about setup"

Security

Review Policy Rules Regularly

cortex policy list

Audit your policy rules periodically to ensure they match your security needs.

Use Approval Gates for Sensitive Operations

Configure approval gates for operations that modify the system or access sensitive data. The shell and code_exec tools have built-in approval gates.

Development

Use the Auto-Fix Loop

When running code, enable the auto-fix loop to automatically correct errors:

cortex run script.py --fix

Run the Server for Complex Workflows

For multi-session workflows or monitoring, use the web UI:

cortex serve -d

Then access the dashboard at http://localhost:3000 with Chat, Lens, Memory, and Jobs tabs.

Use Daemon Mode for Scheduled Tasks

Keep the daemon running for scheduled jobs and periodic memory consolidation:

cortex daemon start
cortex jobs add --schedule "0 9 * * 1" --task "weekly-report"