Introducing a new way to review your PRs.

Read the announcement

solana-foundation / create-solana-dapp

The fastest way to create Solana apps 🚀 Templates 👉 https://github.com/solana-foundation/templates

View on GitHub

18 documents · Updated Nov 6, 2026

docs / app-creation-orchestration

App creation orchestration

App creation turns one resolved set of user choices into a project directory and a short set of next steps. The workflow acquires the chosen template, lets the template set safe defaults, applies optional setup and customization work in a fixed order, and reports the result through the CLI or the public createApp API. See CLI and public API surface for the entrypoint boundary and CLI invocation and argument handling for how the resolved input is built.

Resolved creation input

The orchestration layer receives a GetArgsResult after command-line values and prompts have been combined. This value is the handoff between input handling and project creation. It contains the selected template, project name, destination, package manager, skip decisions, template option flags, and output settings (src/…/get-args-result.ts• L5-19).

Template choice is resolved before creation starts. The input flow loads the template catalog, accepts a named or prompted template, and rejects creation when no template is available; local paths and external template identities are converted into template records before they reach the workflow (src/…/get-args.ts• L64-65, src/…/get-args.ts• L110-157, src/…/find-template.ts• L16-64).

The package manager begins with the invoked manager or an explicit choice. A template can later replace that choice when its initialization metadata declares a required manager and the user did not explicitly select a different one (src/index.ts• L61-70, src/…/get-args.ts• L84-105, src/…/init-script-package-manager.ts• L8-32).

Creation stages

createApp runs progress tasks in sequence. The first task creates the destination from the selected template. The remaining tasks run only after that first stage succeeds, so every later decision reads the generated project rather than the source catalog (src/…/create-app.ts• L22-30, src/…/clack-tasks.ts• L31-51).

The workflow follows this order:

  1. Acquire the template in the target directory.
  2. Apply the template package-manager rule and remove an incompatible package-manager pin.
  3. Read and snapshot the template initialization metadata and selected options.
  4. Run selected option scripts.
  5. Install dependencies when enabled.
  6. Run the optional setup script when dependency installation is enabled.
  7. Install coding-agent skills when dependency installation is enabled.
  8. Run the optional initialization script when initialization is enabled.
  9. Initialize Git when Git setup is enabled.

The following diagram shows the main handoff from resolved input to the user-facing result.

flowchart TD
    A[Resolved creation input] --> B[Acquire template]
    B --> C[Resolve package manager]
    C --> D[Snapshot init metadata and options]
    D --> E[Run option scripts]
    E --> F{Install enabled?}
    F -- Yes --> G[Install dependencies]
    G --> H[Run setup]
    H --> I[Install skills]
    F -- No --> J[Skip install-bound stages]
    I --> K{Init enabled?}
    J --> K
    K -- Yes --> L[Run initialization]
    K -- No --> M[Skip initialization]
    L --> N{Git enabled?}
    M --> N
    N -- Yes --> O[Initialize Git]
    N -- No --> P[Skip Git]
    O --> Q[Completion result]
    P --> Q

Template acquisition

Template acquisition makes a new project directory from either a local source or a remote template identity. The target must not exist, and the resulting directory must contain files before the workflow can continue (src/…/create-app-task-clone-template.ts• L43-99).

Remote acquisition retries once when a cached archive is corrupt. If the retry fails for the same archive problem, the workflow raises an actionable error; other errors pass through to the common failure path (src/…/create-app-task-clone-template.ts• L20-41). Local sources are copied while common generated and dependency directories are left out (src/…/create-app-task-clone-template.ts• L60-83).

Template setup decisions

After acquisition, the workflow treats the generated package.json as the template's control point. The create-solana-dapp field defines optional rules for the package manager, version checks, option flags, renames, skills, and final instructions (src/…/init-script-schema.ts• L4-5, src/…/init-script-schema.ts• L67-74).

The package-manager decision protects later commands from a mismatch. A required manager must be available, and an explicit conflicting selection stops creation. If a template pins a different manager in its package metadata, that pin is removed after the template rule is applied so dependency installation can use the selected manager (src/…/init-script-package-manager.ts• L16-32, src/…/remove-incompatible-package-manager.ts• L5-35).

Option flags are resolved before any option script runs. Requested flags must exist in the template metadata. Default options are added unless their group has a requested member, and a group cannot contain more than one selected option (src/…/init-script-options.ts• L11-62). This early resolution keeps the workflow from doing partial work for invalid flags.

Ordered project customization

Customization uses two kinds of template behavior. Option scripts can change the generated project before dependency installation. The initialization script then applies version checks, option and project renames, user instructions, and cleanup after the install-bound work (src/…/create-app-task-run-option-script.ts• L8-14, src/…/create-app-task-run-init-script.ts• L11-17).

The task gates create three independent choices:

ChoiceDisabled workEffect
skipInstallDependency installation, setup, and skill installationThe project is left without the workflow's install-bound preparation.
skipInitOption scripts and the initialization scriptTemplate option flags are not applied during creation.
skipGitGit initializationThe project is not placed under version control by this workflow.

When installation is enabled, the selected package manager removes lock files for other supported managers before it installs dependencies. The optional setup script runs after installation, while skill installation is best effort and records partial or failed skill installs without stopping the full workflow (src/…/create-app-task-install-dependencies.ts• L10-42, src/…/create-app-task-run-setup.ts• L7-31, src/…/create-app-task-install-skills.ts• L10-35).

The initialization script applies the selected option transformations and project-wide renames. It then turns template instructions into completion text and removes its own metadata from the generated package.json, so the setup contract does not remain in the finished application (src/…/create-app-task-run-init-script.ts• L18-54, src/…/init-script-options.ts• L65-74, src/…/init-script-rename.ts• L101-164, src/…/init-script-delete.ts• L7-14).

Completion result

The public creation operation returns instruction lines collected from the ordered tasks. The CLI passes those lines to finalNote, which shows the target directory and the actions needed after creation. If the template provides no instructions, the CLI falls back to a detected dev or start script; when installation was skipped, it also tells the user to install dependencies (src/…/create-app.ts• L57-73, src/…/final-note.ts• L6-27, src/…/get-start-script.ts• L1-10).

The CLI owns the outer success and failure experience. A successful workflow ends with an installation note and a closing message. Any thrown error becomes a canceled CLI operation with a non-zero process exit, while a newly created target is removed so a failed run does not leave a partial project behind (src/index.ts• L83-95, src/…/create-app.ts• L74-79).

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the task order aligned with the dependency and file-state assumptions: option scripts run before installation, and initialization runs after installation and skill setup.
  • Keep every skipInstall, skipInit, and skipGit decision consistent between task gates and the completion text shown to the user.
  • Keep the create-solana-dapp schema and the code that snapshots, applies, and deletes that metadata in step with each other.
  • Keep package-manager precedence consistent across invoked-manager detection, explicit CLI choices, template requirements, package metadata pins, and install commands.
  • Keep the returned instruction lines compatible with finalNote, including the + convention used for formatted command lines.
  • Preserve target cleanup semantics when changing acquisition or task failure behavior. Existing directories must not be removed after a failed run.

Important failure modes

TriggerConsequenceGuard
The target directory already existsCreation stops before template files are copied.Require a new target path in the acquisition stage.
A requested template option is unknown or conflicts with another option in its groupCreation stops before option scripts or other setup work runs.Resolve and validate option metadata immediately after reading package.json.
A template requires a package manager that is unavailable or conflicts with an explicit user choiceCreation stops before install-bound tasks run.Check the template requirement and manager availability after acquisition.
A selected option names a script that the template does not provideThe option stage fails and the run enters cleanup.Validate the script name against generated package.json before execution.
Dependency installation or setup failsThe run stops and a newly created target is removed.Use the common task failure path and retain pre-existing directories.
A template archive is corruptThe first download is retried; a repeated archive failure becomes an actionable acquisition error.Force a clean retry and report the template identity.
Git is missing or initialization failsGit setup reports an error and can fail the overall creation run.Allow skipGit when version control is not part of the requested result.

Key files

FileWhy to read it
src/index.tsShows the CLI boundary from resolved arguments through creation to the final user message.
src/…/create-app.tsDefines the central lifecycle and the order of all creation stages.
src/…/get-args-result.tsDefines the resolved input contract passed into orchestration.
src/…/create-app-task-clone-template.tsExplains target creation and recovery from corrupt remote archives.
src/…/init-script-package-manager.tsShows how template package-manager requirements affect the selected manager.
src/…/init-script-options.tsShows how template option flags become validated selected behavior.
src/…/create-app-task-install-dependencies.tsShows the install gate and lock-file policy for the selected manager.
src/…/create-app-task-run-init-script.tsShows the final template customization stage and emitted instructions.
src/…/final-note.tsShows how task output becomes the user's next-step message.