Auth Commands

Complete reference for all Forge CLI authentication commands

Published: 1/15/2025

CLI Authentication Commands

The Forge CLI provides several commands for managing authentication profiles:

Getting Your API Credentials

Before using any authentication commands, you need to obtain API credentials from the Hive dashboard:

1. Create API Keys in the Dashboard

  1. Visit forgehive.dev
  2. Log in to your account or create a new account
  3. Navigate to Dashboard → Settings
  4. In the API Keys section, click Create
  5. Enter a descriptive name for your API key (e.g., "My Local Development")
  6. Click Create

2. Copy Your Credentials

After creating the API key, you'll see:

  • API Key: A public identifier for your application
  • API Secret: A private secret (keep this secure!)
  • CLI Login Command: A ready-to-use command for quick setup

Adding a New Profile

Use the auth:add command to create a new authentication profile:

forge auth:add <profile-name> --apiKey <your-api-key> --apiSecret <your-api-secret> --url <hive-url>

Example:

forge auth:add "work" --apiKey "hk_1234abcd..." --apiSecret "hs_5678efgh..." --url "https://forgehive.dev"

What happens:

  • Creates a new profile with the given name
  • Stores your credentials securely in ~/.forge/profiles.json
  • Sets the new profile as the default active profile
  • If a profile with the same name exists, it will be updated

Listing Available Profiles

View all your configured authentication profiles:

forge auth:list

Example output:

Available profiles:
* work - API Key: hk_1234abcd...
  personal - API Key: hk_9876zyxw...
  local-dev - API Key: hk_5555cccc...

Use auth:add to create or update a profile
Use auth:switch to switch to a profile

The asterisk (*) indicates the currently active (default) profile.

Switching Between Profiles

Change which profile is currently active:

forge auth:switch --profileName <profile-name>

Common Use Case: Personal vs Work

The switch functionality is especially useful when you have separate personal and work profiles:

# Switch to your work profile for company projects
forge auth:switch --profileName "work"

# Switch to your personal profile for side projects
forge auth:switch --profileName "personal"

Example:

forge auth:switch --profileName "work"

What happens:

  • Sets the specified profile as the default
  • All subsequent CLI commands will use this profile's credentials
  • Displays confirmation: "Switched to profile: work"
  • Perfect for separating personal and professional accounts

Removing a Profile

Delete a profile you no longer need:

forge auth:remove --profileName <profile-name>

Example:

forge auth:remove --profileName "old-dev"

What happens:

  • Removes the specified profile from your configuration
  • If the removed profile was the default, automatically sets the first remaining profile as default
  • If no profiles remain, sets the default to empty
  • Displays confirmation of the removal