Setting Up Your Development Environment

Page 0 — Prerequisites

Before You Start: Setting Up Your Development Environment

Series: Build a Salesforce Guide App with AI

Page: 0 of 10

Time to complete: 20–30 minutes

Who this is for: Anyone who hasn’t used VS Code or the Salesforce CLI before. If you already have both installed and have connected them to a Salesforce org, skip to Page 1.


What You’re Installing and Why

When you build Lightning Web Components or write Apex code, you can’t do it entirely inside Salesforce’s browser-based tools. You need two things on your computer:

Visual Studio Code is a free code editor made by Microsoft. It’s where you’ll write and manage all the files for your app. On its own it knows nothing about Salesforce — that’s where the next piece comes in.

The Salesforce CLI (command line interface) is a tool that lets your computer talk directly to your Salesforce org. It can push code you’ve written locally into Salesforce, pull existing code back down, and run tests — all from a single terminal command.

Together they give you a proper development workflow. You write code locally, deploy it to your org, test it, and iterate. This is how every Salesforce developer works.


Step 1 — Install VS Code

  1. Go to code.visualstudio.com
  2. Download the installer for your operating system
  3. Run the installer — all defaults are fine
  4. Open VS Code when it finishes

Step 2 — Install the Salesforce Extension Pack

This gives VS Code the ability to understand Salesforce code and syntax.

  1. In VS Code, click the Extensions icon in the left sidebar (it looks like four squares)
  2. Search for Salesforce Extension Pack
  3. Click Install on the result published by Salesforce
  4. Wait for it to finish — it installs several extensions at once

Step 3 — Install the Salesforce CLI

  1. Go to developer.salesforce.com/tools/salesforcecli
  2. Download the installer for your operating system
  3. Run the installer — all defaults are fine
  4. Restart VS Code completely after the CLI installs

To verify it worked, open the Terminal in VS Code (Terminal → New Terminal) and run:

sf --version

You should see a version number. If you get an error saying the command isn’t found, restart VS Code and try again.


Step 4 — Create Your SFDX Project

An SFDX project is a folder on your computer that holds all the code for your app, organised in the way Salesforce expects.

  1. Open the Command Palette: Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows)
  2. Type SFDX: Create Project and select it
  3. Choose Standard template
  4. Name the project guide-hub
  5. Choose a location — your Documents folder works well
  6. Click Create Project

VS Code opens your new project automatically. The folder you care about most is force-app/main/default/ — all your code lives here.


Step 5 — Connect to Your Salesforce Org

  1. Open the Command Palette again (Cmd+Shift+P or Ctrl+Shift+P)
  2. Type SFDX: Authorize an Org and select it
  3. When asked for a login URL:
    • If you’re using a Trailhead Developer Edition or production org, select Production
    • If you’re using a sandbox, select Sandbox

⚠️ Common mistake: Trailhead Developer Edition orgs use the Production login URL, not Sandbox. This catches a lot of people out.

  1. Give the org an alias — type guide-hub-org and press Enter
  2. A browser window opens — log in with your Salesforce credentials and click Allow
  3. Switch back to VS Code — you should see a success message in the terminal

Verify the connection by running this in the terminal:

sf org display

You should see your org’s username, ID, and a status of Connected.


Windows Users: Two Things to Know

If you’re on Windows, two gotchas will save you significant frustration later.

PowerShell file writing

When writing files from PowerShell scripts, always use [System.IO.File]::WriteAllBytes() with base64-encoded content. The simpler Set-Content -Encoding UTF8 command writes a hidden character at the start of the file (called a BOM) that causes Salesforce to reject the file with a cryptic error.

All the PowerShell scripts in this tutorial use the correct approach — but if you ever write your own scripts, remember this.

Downloaded scripts are blocked by default

When you download a .ps1 script file, Windows blocks it from running. Before running any downloaded script, unblock it first:

Unblock-File -Path .\your-script.ps1

Then run it:

.\your-script.ps1

Key Terminal Commands

You’ll use these throughout the tutorial. Keep this page bookmarked.

# Deploy your code to Salesforce
sf project deploy start --source-dir force-app/main/default

# Deploy just Apex classes
sf project deploy start --source-dir force-app/main/default/classes

# Deploy just LWC components
sf project deploy start --source-dir force-app/main/default/lwc

# Run your Apex test class
sf apex run test --class-names GuideServiceTest --result-format human --wait 5

# Pull a class from the org into your local project
sf project retrieve start --metadata ApexClass:ClassName

# Re-authorise if your session expires (deploy hangs for 30+ seconds)
sf org login web --alias guide-hub-org

Check Your Work

Before moving to Page 1, confirm:

  • sf --version returns a version number in the terminal
  • sf org display shows your org connected
  • ✅ You can see the force-app/main/default/ folder structure in VS Code’s left panel

If all three are true, you’re ready. Move to Page 1.