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 / cli-invocation-and-arguments

CLI invocation and argument handling

The CLI input layer turns process arguments and, when needed, user answers into one resolved set of app-creation options. It separates arguments owned by the CLI from template-specific flags, checks names at the prompt boundary, and passes a stable result to the creation flow. See the CLI and public API surface page for the entrypoint context and App creation orchestration for the next stage.

Invocation boundary

Executable entry point

The published create-solana-dapp command receives the Node process argument array and sends it to main. The library entrypoint then supplies app metadata and the detected package manager to the argument resolver before any project work starts.

References: src/…/index.ts• L1-10 src/index.ts• L61-70

Argument ownership

The argument resolver owns the command name, the optional project name, and the flags that control template choice, package-manager choice, setup work, output, and utility actions. Commander parses these known values after the input layer removes template-defined flags that the CLI cannot know in advance.

References: src/…/get-args.ts• L21-54 src/…/extract-template-option-flags.ts• L10-16

Command-line input model

Positional project name

The first positional value is the optional project name. If it is present, the resolver uses it as the project name and builds the target path from the current working directory; if it is absent, the interactive name prompt supplies both values later.

References: src/…/get-args.ts• L57-58 src/…/get-args.ts• L124-150

Registered option groups

The CLI exposes options in groups that map to distinct decisions in app creation:

GroupPurposeExamples
Template choice and discoverySelect a starter or inspect available choices--template, --minimal, --list-templates, --list-template-ids
Package managerSelect or inherit the tool used for dependency work--package-manager, --pnpm, --yarn, --bun
Setup controlsSkip selected setup steps or preview the result--skip-git, --skip-init, --skip-install, --dry-run
Runtime and catalog controlsControl diagnostics, update checks, and catalog source--verbose, --skip-version-check, --templates-url

Discovery options are handled before normal project creation. A discovery action prints its result and exits instead of producing a resolved creation result. The --minimal shortcut selects the built-in minimal template and cannot be combined with --template.

References: src/…/get-args.ts• L25-51 src/…/get-args.ts• L64-83 src/…/get-args.ts• L103-123

Template-defined flags

Templates can add boolean choices without changing the global CLI contract. The input layer keeps known options and their values for Commander, while it collects unknown long flags such as --ollama into templateOptions for later template-specific handling.

The boundary accepts only boolean long flags. It rejects short unknown flags and long flags with an inline value. It also preserves option values that look like flags, positional values after a template flag, and arguments after --; repeated template flags become one option name.

References: src/…/extract-template-option-flags.ts• L3-57 src/…/extract-template-option-flags.ts• L60-74 test/extract-template-option-flags.test.ts• L9-61

Project name validation

Directory name rules

The shared name policy accepts a non-empty project name of up to 214 characters. The name must start with a lowercase letter and contain only lowercase letters, numbers, and single dashes. The prompt also rejects a name that already exists as a path in the current working directory.

The format schema can be used without checking the filesystem. The full validator adds the destination-directory check for an actual proposed project.

References: src/…/validate-project-name.ts• L4-31 test/validate-project-name.test.ts• L11-63

Supplied and proposed names

An explicit CLI name is treated as supplied input and skips the name prompt. A missing name enters the prompt flow, where the selected template can provide an initial value and the full validator checks the final answer. This creates a clear boundary: interactive answers receive prompt validation, while programmatic callers of getArgs must decide whether to validate an explicit name before invoking the next stage.

References: src/…/get-prompt-name.ts• L6-28 src/…/get-args.ts• L141-150

Argument resolution

Package manager precedence

The resolver starts with the package manager detected from the invoking package tool or the supplied default. An explicit package-manager option marks the choice as intentional, while the shorthand flags take precedence over the named option. More than one shorthand flag is an error.

References: src/index.ts• L61-64 src/…/get-args.ts• L84-101 src/…/package-manager.ts• L16-35

Resolved argument contract

GetArgsResult is the handoff object between input collection and app creation. It contains the app identity, project name, target path, selected template, package-manager decision, setup switches, output mode, and any template-specific boolean options.

The resolver always returns a selected template and a concrete target path after prompts finish. It represents a missing initial name as an empty string, then replaces it with the prompt answer and updates the target path to match.

References: src/…/get-args-result.ts• L5-19 src/…/get-args.ts• L124-157

Resolution sequence

The following flow shows how supplied CLI values and interactive answers meet at the single result passed to app creation.

flowchart TD
    A[Process argv] --> B[Separate CLI options from template flags]
    B --> C[Parse known options]
    C --> D[Load template catalog]
    D --> E{Discovery action?}
    E -->|Yes| F[Print result and exit]
    E -->|No| G[Resolve package manager and template]
    G --> H{Project name supplied?}
    H -->|Yes| I[Use CLI name]
    H -->|No| J[Prompt for name and validate it]
    I --> K[Build GetArgsResult]
    J --> K
    K --> L[Dry run or app creation]

References: src/…/get-args.ts• L54-157 src/index.ts• L68-84

Interactive boundary

Template and name prompts

Interactive collection runs only for values that are missing from the supplied options. The template prompt runs first so its choice can seed the project-name prompt; a supplied template or name is shown as accepted input instead of being asked again.

References: src/…/get-prompts.ts• L8-22 src/…/get-prompt-template.ts• L6-19 src/…/get-prompt-name.ts• L16-28

Creation handoff

After parsing and prompting, main treats the result as the input contract for the rest of the command. Dry-run mode displays the resolved arguments and stops; normal mode passes the same result to app creation, so downstream code does not need to distinguish whether each value came from argv or a prompt.

References: src/index.ts• L68-84 src/…/get-args-result.ts• L5-19

Change checklist

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

  • Keep the template-flag extraction rules aligned with the registered Commander options. A new global option must not be captured as a template option.
  • Preserve the GetArgsResult contract when adding an input. The creation entrypoint and dry-run output both consume this shape.
  • Keep package-manager shorthand precedence and mutual exclusion aligned with the explicit package-manager field.
  • If name policy changes, review both the prompt validator and template-derived initial values. The format schema and full validator serve different stages.
  • Keep template selection before name prompting when a template name is intended to seed the project name.

Important failure modes

TriggerConsequenceGuard
Two or more of --pnpm, --yarn, and --bun are suppliedArgument resolution stops with an errorSelect one shorthand or use the named package-manager option
--minimal is combined with --templateTemplate resolution stops with an errorUse one template-selection mode
An unknown short flag or a template flag with an inline value is suppliedInput extraction rejects the command before normal parsingUse a boolean long template flag such as --ollama
An interactive name is empty, exceeds 214 characters, uses an invalid character or case, or names an existing pathThe name prompt remains invalidEnter a new name of up to 214 characters that starts with a lowercase letter and uses lowercase letters, numbers, and single dashes
No template is available after supplied and interactive selectionThe resolver cannot create a valid resultSupply a valid template or select one from the catalog
A discovery option is used with creation optionsThe discovery action prints its result and exits before creationRun discovery as a separate command when creation is also needed

Key files

FileWhy to read it
src/…/index.tsShows the published executable boundary and the handoff of process.argv.
src/index.tsShows how resolved arguments enter dry-run or app creation.
src/…/get-args.tsDefines the main parsing, precedence, prompt, and result-resolution flow.
src/…/extract-template-option-flags.tsDefines the boundary between global CLI flags and template-defined boolean flags.
src/…/validate-project-name.tsDefines the shared project-name format and destination checks used by interactive input.
src/…/get-prompts.tsShows the order in which missing template and name values become interactive input.
src/…/get-args-result.tsDefines the normalized argument contract passed to app creation.
test/validate-project-name.test.tsShows the accepted name format, length boundary, filesystem check, and schema-only behavior.