Conduct

Profile Management

Overview

Profiles allow you to work with multiple Conduct backends, such as:

  • Local development environment
  • Staging environment
  • Production environment
  • Team-specific backends

Each profile stores:

  • Backend URL
  • API key
  • Project identifier
  • Active status

Profile Storage

Profiles are stored in ~/.conduct/credentials.json:

{
  "profiles": {
    "local": {
      "url": "http://localhost:3000/conduct",
      "apiKey": "sk_admin_xxx",
      "project": "myproject"
    },
    "staging": {
      "url": "https://staging.example.com/conduct",
      "apiKey": "sk_staging_xxx",
      "project": "myproject"
    }
  },
  "activeProfile": "local"
}

Adding Profiles

Interactive Mode

conduct profile add

Prompts for:

  1. Profile name
  2. Backend URL
  3. API key
  4. Project identifier

With Flags

conduct profile add \
  --name production \
  --url https://api.example.com/conduct \
  --key sk_prod_xxx \
  --project myproject

Listing Profiles

conduct profile list

Output:

Available profiles:
* local (http://localhost:3000/conduct) - myproject
  staging (https://staging.example.com/conduct) - myproject
  production (https://api.example.com/conduct) - myproject

* = active profile

Switching Profiles

Change the active profile:

conduct profile use staging

Now all commands use the staging backend:

conduct list  # Lists from staging
conduct spec list  # Lists from staging

Switch back:

conduct profile use local

Using Specific Profile

Override active profile for a single command:

# Use production profile for this command only
conduct spec list --profile production
 
# Active profile remains unchanged
conduct list  # Still uses local

Testing Profiles

Test Active Profile

conduct profile test

Test Specific Profile

conduct profile test staging

Output on success:

Testing profile: staging
Connection: OK
Backend URL: https://staging.example.com/conduct
Project: myproject

Output on failure:

Testing profile: staging
Connection: FAILED
Error: Request timeout

Viewing Profile Details

conduct profile show staging

Output:

Profile: staging
URL: https://staging.example.com/conduct
Project: myproject
API Key: sk_staging_*** (hidden)

Removing Profiles

conduct profile remove staging

With confirmation prompt:

Remove profile 'staging'? (y/N)

Skip confirmation:

conduct profile remove staging --force

Common Setups

Local Development

conduct profile add \
  --name local \
  --url http://localhost:3000/conduct \
  --key sk_dev_xxx \
  --project myproject
 
conduct profile use local

Team Staging

conduct profile add \
  --name staging \
  --url https://staging.company.com/conduct \
  --key sk_staging_xxx \
  --project myproject
 
conduct profile use staging

Production (Read-Only)

conduct profile add \
  --name production \
  --url https://api.company.com/conduct \
  --key sk_prod_readonly_xxx \
  --project myproject
 
# Use only for reading
conduct profile use production
conduct list --profile production

Multi-Project Setup

Different projects can use different backends:

# Project A
cd ~/projects/project-a
conduct profile use project-a-dev
 
# Project B
cd ~/projects/project-b
conduct profile use project-b-dev

Security Best Practices

Protect Credentials

Set proper file permissions:

chmod 600 ~/.conduct/credentials.json

Use Environment-Specific Keys

  • Development: Full permissions
  • Staging: Read-write permissions
  • Production: Read-only permissions

Rotate Keys Regularly

  1. Create new API key on backend
  2. Update profile with new key
  3. Test profile
  4. Revoke old key
# Update key
conduct profile add \
  --name production \
  --url https://api.example.com/conduct \
  --key sk_prod_new_xxx \
  --project myproject
 
# Test it
conduct profile test production
 
# Revoke old key on backend

Never Commit Credentials

Add to .gitignore:

~/.conduct/credentials.json
.conduct/credentials.json

Troubleshooting

Profile Not Found

Error: Profile 'staging' not found

Solution: List profiles and check name:

conduct profile list

Connection Failed

Error: Failed to connect to backend

Solutions:

  1. Test profile:
conduct profile test
  1. Verify backend is running:
curl https://api.example.com/conduct/health
  1. Check API key is valid

Permission Denied

Error: Permission denied for this operation

Solution: API key lacks required permissions. Check key permissions on backend or use key with appropriate permissions.

Profile Already Exists

Error: Profile 'local' already exists

Solution: Remove existing profile first:

conduct profile remove local
conduct profile add --name local ...

Next Steps