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 / task-runtime-and-system-adapters

Task runtime and system adapters

The task runtime presents generator work as a clear progress flow while system adapters connect that flow to local commands and files. Together they turn a selected template into a usable project by cloning it, applying its setup choices, installing its dependencies and skills, and optionally creating its first Git commit.

Task runtime

Task sequence

The task sequence is the generator's ordered work plan. createApp first places a template in the target directory, then prepares and transforms the project before it installs dependencies, runs setup work, installs skills, applies the init script, and initializes Git. Each task can be disabled by the user's options, so the same plan supports reduced runs such as skipping installation or Git setup.

The sequence matters because each stage prepares the input for the next stage. Option scripts run before dependency installation, while the init script uses a snapshot of its configuration taken before those scripts can change the project metadata.

flowchart TD
    A[Clone template] --> B[Prepare package manager metadata]
    B --> C[Run selected option scripts]
    C --> D[Install dependencies]
    D --> E[Run setup script]
    E --> F[Install coding skills]
    F --> G[Apply init script]
    G --> H[Initialize Git]

References: src/…/create-app.ts• L22-79 src/…/create-app-task-run-option-script.ts• L8-15 src/…/create-app-task-run-init-script.ts• L11-17

Progress presentation

The progress presenter gives each enabled task a spinner with a task-specific title. When the task ends, the spinner is replaced by a result message, and optional instructions are collected for the caller to show after the run. This keeps normal output short while allowing a task to return follow-up guidance.

The presenter does not decide what work a task performs. A task owns its work and reports a message through the shared task result callback, which keeps progress display separate from project creation rules.

References: src/…/clack-tasks.ts• L13-51

Failure handling

Task failures use a common error path that logs a user-facing message and stops the run. createApp removes the target directory only when it created that directory during the current run. An existing directory is therefore preserved when a later task fails.

This boundary protects user-owned files while still cleaning up a partially created project. Command failures also retain their output in a log file next to the target directory so cleanup does not remove the diagnostic record.

References: src/…/clack-tasks.ts• L54-57 src/…/create-app.ts• L22-26 src/…/create-app.ts• L74-78 src/…/child-process-utils.ts• L26-38

System adapters

Child process adapter

The child process adapter is the common bridge from generator tasks to commands run in the target directory. It passes through the current environment, returns standard output on success, and turns a non-zero command result into a structured CreateAppError with the command output and a durable log path.

Tasks use this adapter for package-manager scripts, dependency installation, setup scripts, and skill installation. The shared error shape lets each task add context without losing the original command diagnostics.

References: src/…/child-process-utils.ts• L15-41 src/…/create-app-task-run-option-script.ts• L39-53 src/…/create-app-task-install-dependencies.ts• L31-39

Package manager adapter

The package manager adapter gives the generator one model for the supported package managers: pnpm, npm, Yarn, and Bun. It detects the invoked tool when possible, detects a project's tool from its lock file when needed, and maps that choice to install, executable, global-add, and lock-file behavior.

The dependency task uses the selected package manager as the source of truth. Before installation it removes lock files that belong to other managers, then runs the matching install command. This prevents an old lock file from silently defining a different dependency result.

References: src/…/package-manager.ts• L16-35 src/…/package-manager.ts• L38-61 src/…/package-manager.ts• L66-113 src/…/package-manager.ts• L131-143 src/…/create-app-task-install-dependencies.ts• L10-42

Git adapter

The Git adapter makes version control setup optional and safe for both new and already managed directories. It first checks that Git is available and that the target is not already inside a work tree. If setup is needed, it creates a repository on the main branch, stages the generated files, and makes an initial commit.

The adapter uses the user's global Git identity when one exists. If no identity is configured, it supplies a bot identity so the initial commit can still complete. An existing repository is left unchanged.

References: src/…/git.ts• L23-35 src/…/git.ts• L42-67 src/…/git.ts• L70-94 src/…/create-app-task-initialize-git.ts• L6-26

Template and filesystem adapter

Template acquisition is the first filesystem-facing task because all later work acts on its output. It rejects an occupied target, copies local templates without common build and dependency directories, or downloads a remote template. It also rejects an empty result and retries a corrupt cached archive before returning an actionable error.

The task layer performs the other direct filesystem changes that shape the generated project. It removes incompatible lock files before installation, and the top-level flow removes a newly created target after failure. These operations keep the target aligned with the selected package manager and avoid leaving a false partial project behind.

References: src/…/create-app-task-clone-template.ts• L9-41 src/…/create-app-task-clone-template.ts• L43-99 src/…/create-app-task-install-dependencies.ts• L19-29 src/…/create-app.ts• L74-78

Generator-facing adapters

Script adapters

Script tasks connect template-defined behavior to the task runtime. Selected template options can run named package scripts before installation, a setup script can build or generate project output after installation, and an init script can apply version checks, option actions, renames, instructions, and deletions.

These tasks use the chosen package manager for package scripts. They report missing optional scripts as a task result where the flow allows it, while command or validation errors fail the generator with task context.

References: src/…/create-app-task-run-option-script.ts• L15-55 src/…/create-app-task-run-setup.ts• L7-31 src/…/create-app-task-run-init-script.ts• L18-54

Skill adapter

The skill task adds coding-agent skills declared by the template. When a template does not declare a list, it uses the generator's default Solana development skill. Skill installs run one at a time and report partial success instead of hiding which installs failed.

Skill installation is enabled with dependency installation. A skill failure does not throw from the individual install path, but the task result records whether none, some, or all requested skills were installed.

References: src/…/create-app-task-install-skills.ts• L8-35 src/…/create-app-task-install-skills.ts• L37-67

Change checklist

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

  • Keep the task order aligned with the dependencies between package metadata, option scripts, dependency installation, setup work, init transformations, and Git creation.
  • Keep every package manager's install command and lock-file name paired so stale lock files cannot select a different manager.
  • Keep command failures connected to the durable log path because target cleanup can remove the failed directory.
  • Keep task skip conditions consistent with the generator options so a skipped stage does not leave a later stage without its required input.
  • Keep init-script snapshots stable when option scripts can rewrite package.json.

Important failure modes

TriggerConsequenceGuard
The target directory already existsGeneration stops without changing that directoryThe clone task rejects an occupied target before copying files
A command exits with an errorThe task fails and command output is saved outside the targetThe child process adapter writes <target>.error.log and raises CreateAppError
Lock files for another package manager remain in the targetDependency state can follow the wrong package managerThe install task removes all known non-selected lock files first
Git is unavailable or the target is already a work treeGit setup is skipped or left unchangedThe Git adapter checks tool availability and repository state before initialization
A cached template archive is corruptThe first extraction fails and may leave partial filesThe clone task retries with a clean download and returns a specific archive error if needed
Some skill sources failThe project is created with an incomplete skill setThe skill task reports the installed count rather than treating partial work as complete

Key files

FileWhy to read it
src/…/create-app.tsShows the complete task lifecycle and cleanup boundary
src/…/clack-tasks.tsDefines task skipping, progress display, result collection, and shared task failure
src/…/child-process-utils.tsDefines the common command boundary and durable error reporting
src/…/package-manager.tsDefines package-manager detection and command differences
src/…/git.tsDefines safe repository detection and initial commit behavior
src/…/create-app-task-clone-template.tsShows how local and remote templates become the target project
src/…/create-app-task-install-dependencies.tsShows lock-file alignment and dependency installation
src/…/create-app-task-run-option-script.tsShows how template choices affect package scripts before install
src/…/create-app-task-run-init-script.tsShows the final template transformation and instruction flow
src/…/create-app-task-install-skills.tsShows default and template-defined coding-agent skill installation