template generate project

Generate a Salesforce DX project.

A Salesforce DX project has a specific structure and a configuration file (sfdx-project.json) that identifies the directory as a Salesforce DX project. This command generates the necessary configuration files and directories to get you started.

By default, the generated sfdx-project.json file sets the sourceApiVersion property to the default API version currently used by Salesforce CLI. To specify a different version, set the apiVersion configuration variable. For example: “sf config set apiVersion=57.0 –global”.

force:project:create

project:generate

Flag Name (Long)Flag Name (Short)Description
‑‑api‑versionN/AType: Value

Will set this version as sourceApiVersion in the sfdx-project.json file

Override the api version used for api requests made by this command
‑‑default‑package‑dir‑pType: Value
Default value: force-app

Default package directory name.

Metadata items such as classes and Lightning bundles are placed inside this folder.
‑‑flags‑dirN/AType: Value

Import flag values from a directory.
‑‑jsonN/AType: Boolean

Format output as json.
‑‑lwc‑languageN/AType: Value
Valid Values: javascript, typescript

Language of the Lightning Web Components. If not specified, “javascript” is used.

When set to 'typescript', generates TypeScript configuration files (tsconfig.json, package.json with TypeScript dependencies, and TypeScript-aware ESLint config). When you deploy the TypeScript-based Lightning Web Components, the TypeScript files are first compiled locally for validation and then the .ts files are deployed to your org for server-side type stripping.
‑‑manifest‑xType: Boolean

Generate a manifest (package.xml) for change-set based development.

Generates a default manifest (package.xml) for fetching Apex, Visualforce, Lightning components, and static resources.
‑‑name‑nType: Value
Required

Name of the generated project.

Generates a project directory with this name; any valid directory name is accepted. Also sets the “name” property in the sfdx-project.json file to this name.
‑‑namespace‑sType: Value

Namespace associated with this project and any connected scratch orgs.
‑‑output‑dir‑dType: Value
Default value: .

Directory for saving the created files.

The location can be an absolute path or relative to the current working directory. The default is the current directory.
‑‑template‑tType: Value
Valid Values: standard, empty, analytics, reactinternalapp, reactexternalapp, agent
Default value: standard

Template to use for project creation.

The template determines the sample configuration files and directories that this command generates. For example, the empty template provides these files and directory to get you started.

  • .forceignore
  • config/project-scratch-def.json
  • sfdx-project.json
  • package.json
  • force-app (basic source directory structure)


The standard template provides a complete force-app directory structure so you know where to put your source. It also provides additional files and scripts, especially useful when using Salesforce Extensions for VS Code. For example:

  • .gitignore: Use Git for version control.
  • .prettierrc and .prettierignore: Use Prettier to format your Aura components.
  • .vscode/extensions.json: When launched, Visual Studio Code, prompts you to install the recommended extensions for your project.
  • .vscode/launch.json: Configures Replay Debugger.
  • .vscode/settings.json: Additional configuration settings.


The analytics template provides similar files and the force-app/main/default/waveTemplates directory.

The reactinternalapp and reactexternalapp templates provide React-based project scaffolding for internal and external UI bundle use cases.

The agent template provides project scaffolding for building Agentforce agents and includes a sample agent called Local Info Agent.

Generate a project called “mywork”:

Similar to previous example, but generate the files in a directory called “myapp”:

Similar to prevoius example, but also generate a default package.xml manifest file:

Generate a project with the minimum files and directories:

Generate a project in which the Lightning Web Components use TypeScript rather than the default JavaScript: