Visual Studio Code download existing code

Another option is to use the SFDX: Create Project With Manifest command in VS Code (equivalent to using sfdx force:project:create with the -x or --manifest option), which will create your project with a manifest/package.xml file, that includes wildcard selectors for all the custom code types: ApexClass, ApexComponent, ApexPage, ApexTestSuite, ApexTrigger, and AuraDefinitionBundle, as well as StaticResource. Once you've authorized to a dev org or sandbox org that has code in it, you can use SFDX: Retrieve Source in Manifest From Org within VS Code. You can right-click on the package.xml file or use the command palette to find the command. This command is equivalent to sfdx force:source:retrieve -x ./manifest/package.xml.


You don't need --sourcepath. It looks at where you are pointing and tries to pull items which match what you have there already.

What you do need is a package.xml file to get your entire metadata database; you might need help getting that file for your particular org.

Instead, you can do the following to get going with Apex or Lightning Component development:

force:project:create -n MyProject
cd MyProject
sfdx force:source:retrieve -m CustomObject
sfdx force:source:retrieve -m ApexClass
sfdx force:source:retrieve -m ApexPage
sfdx force:source:retrieve -m ApexClass
sfdx force:source:retrieve -m AuraDefinitionBundle
sfdx force:source:retrieve -m LightningComponentBundle

or you can use this nifty one-liner:

sfdx force:source:retrieve -m CustomObject,ApexClass,ApexPage,ApexTrigger,LightningComponentBundle,AuraDefinitionBundle

That will populate your source tree, and --sourcepath will work when it's pointed at one of those folders.