DEV Community

Cover image for How to Connect a Trailhead Org to Salesforce CLI
Exploring Agentforce
Exploring Agentforce

Posted on

How to Connect a Trailhead Org to Salesforce CLI

Take Trailhead Learning beyond the browser

Salesforce Trailhead is a great way to learn Agentforce. You can level up this experience by connecting your Trailhead org to Salesforce CLI and working with AgentScript metadata locally in VS Code. Here’s a quick setup flow for connecting a Trailhead Agentforce org to Salesforce CLI πŸ‘‡

Prerequisites:
β€’ VS Code
β€’ Salesforce CLI installed
β€’ Trailhead org with Agentforce enabled

Step 1. Open your Trailhead org

Launch the Trailhead playground or developer org that you want to connect.

Step 2. Find your username

Profile β†’ Settings

Step 3. Set password (if not set already)

Settings β†’ Change My Password

Step 4. Connect org via CLI

Authenticate via browser, setting up alias for the org and providing your Trailhead org url:


# Authenticate with your Trailhead org

sf org login web --alias your-org-alias --instance-url https://your-org-name.develop.my.salesforce.com

Enter fullscreen mode Exit fullscreen mode

Step 5. Verify connection

Confirm that the org was added successfully:


sf org list

Enter fullscreen mode Exit fullscreen mode

Step 6. Set the default org

To avoid specifying the org in every command, set it as the default target:


sf config set target-org your-org-alias

Enter fullscreen mode Exit fullscreen mode

Important: Use the Correct Login URL

Trailhead org URLs used for login usually look like:

https://your-org-name.develop.my.salesforce.com

NOT:
β€’ login.salesforce.com
β€’ develop.lightning.force.com

Once connected, you can retrieve AgentScript metadata locally in VS Code, experiment faster, and work with Agentforce in a more development-oriented workflow.

Top comments (0)