Tools & Environment Setup
Every Apex class has a companion -meta.xml that sets its API version and status:
3.1 Tool overview
Salesforce CLI (sf) Command-line interface for orgs, source, tests, packages, data
Everything in a source-driven workflow, CI/CD VS Code + Salesforce Extension Pack
Official IDE experience: Apex language server, debugger, LWC tooling, org browser Developer Console
Browser-based IDE inside the org (*Setup → gear icon → Developer Console*)
Quick edits, Execute Anonymous, logs, query editor Code Builder
Browser-hosted VS Code environment (based on Code-OSS) with the extensions preinstalled Development without local installs Workbench / Salesforce Inspector
Community tools for queries, metadata, API exploration Ad-hoc data and API work Setup → Apex Classes
Read-only view (in production) and simple editor (in Developer Edition) Viewing code, setting class versions
The old sfdx command family (sfdx force:...) is replaced by sf (v2). Most old commands still map to new ones, but new examples should use sf.
3.2 Installing the toolchain
Install Node.js LTS (optional but useful) and Java JDK 11, 17, or 21 (required by the Apex language server).
Install the Salesforce CLI: download the installer from developer.salesforce.com/tools/salesforcecli, or npm install --global @salesforce/cli.
Verify: sf --version, then sf update.
Install VS Code and the Salesforce Extension Pack (or *Salesforce Extension Pack (Expanded)*, which adds ESLint, Prettier, and Apex PMD helpers).
3.3 Creating a project and connecting an org
# create a project in source format
sf project generate --name acme-crm --template standard
cd acme-crm
# authorize an org (opens browser); alias it
sf org login web --alias devorg --set-default
# or authorize a Dev Hub and create a scratch org
sf org login web --alias DevHub --set-default-dev-hub
sf org create scratch --definition-file config/project-scratch-def.json --alias scratch1 --duration-days 7 --set-default
# generate an Apex class
sf apex generate class --name HelloWorld --output-dir force-app/main/default/classes
# deploy / retrieve source
sf project deploy start --source-dir force-app
sf project retrieve start --metadata ApexClass:HelloWorld
# open the org in a browser
sf org open3.4 Project structure (source format)
Every Apex class has a companion -meta.xml that sets its API version and status:
acme-crm/
├── sfdx-project.json # package directories, API version, namespace
├── config/project-scratch-def.json
├── force-app/main/default/
│ ├── classes/ # HelloWorld.cls + HelloWorld.cls-meta.xml
│ ├── triggers/ # AccountTrigger.trigger + .trigger-meta.xml
│ ├── lwc/ # Lightning Web Components
│ ├── objects/ # custom objects & fields (decomposed)
│ ├── flows/ permissionsets/ customMetadata/ staticresources/
├── scripts/apex/ # anonymous Apex scripts (*.apex)
└── scripts/soql/ # saved queries (*.soql)<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>65.0</apiVersion>
<status>Active</status>
</ApexClass>3.5 Useful VS Code commands (Ctrl+Shift+P)
SFDX: Create Apex Class / Trigger SFDX: Deploy This Source to Org (or enable *deploy on save*)
SFDX: Execute Anonymous Apex with Editor Contents / Currently Selected Text
SFDX: Run Apex Tests, or click *Run Test* above test methods
SFDX: Turn On Apex Debug Log for Replay Debugger SFDX: Open Default Org