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 / template-menu-and-prompts

Template menu and prompts

The template menu turns the fetched catalog into a small set of user-facing groups and templates. The prompt flow then combines a chosen template with a valid project name and passes those choices to app creation. Command-line template references and template-defined flags can bypass or extend this flow.

The menu configuration defines the groups that the CLI presents. Each menu item names a user-facing category and points to one or more catalog group paths. A menu item can also narrow its templates by keyword; an empty keyword list keeps every template in its matched groups. This separates the catalog's organization from the choices shown to a user.

The current menu presents framework, mobile, community, and Web3.js categories. The menu builder preserves the configured order and creates each item from the templates in its matching catalog groups.

References: src/…/get-menu-config.ts• L3-34 src/…/menu-utils.ts• L3-27 src/…/template-schema.ts• L51-64

The menu stage produces two related views of the catalog. Menu items retain the group structure for interactive selection, while a flat template list supports direct lookup and listing commands. Both views use the same selected catalog data, so a direct template name and an interactive template choice resolve to the same template record.

Verbose mode reports the menu items and their template identities for diagnosis. It does not change the choices or their order.

References: src/…/get-menu-items-from-template-groups.ts• L6-21 src/…/fetch-template-data.ts• L17-27 src/…/get-templates-from-items.ts• L5-18

Prompt flow

The prompt flow asks only for values that the command line did not already supply. It runs the template choice before the project-name prompt so the selected template can provide a useful name suggestion.

This diagram shows how catalog data and command-line values become the final selection inputs.

flowchart TD
    A[Template groups] --> B[Configured menu items]
    B --> C{Template supplied?}
    C -- No --> D[Choose menu group]
    D --> E[Choose template]
    C -- Yes --> F[Use resolved template]
    E --> G{Project name supplied?}
    F --> G
    G -- No --> H[Enter and validate project name]
    G -- Yes --> I[Use supplied project name]
    H --> J[Resolved template and project name]
    I --> J

Template choice

The template prompt has two levels. The user first selects a menu group and then selects a template from that group's templates. Each choice shows the configured name and description, while the returned value remains the full template record needed by later creation steps.

A template supplied through the command line skips both selections. The CLI resolves a registry name from the flat catalog list, or accepts an external or local template reference. The prompt layer then reports that template and returns it without showing a menu.

References: src/…/get-prompt-template.ts• L6-49 src/…/get-args.ts• L110-123 src/…/find-template.ts• L7-64

Project name choice

The project-name prompt runs after template selection unless a name was supplied as the positional command-line argument. It validates the name as a usable directory name and rejects an existing directory.

When a template is selected first, the prompt suggests the last path segment of the template name. This supports registry, external, and local references without proposing a path as the project directory. If that segment is not valid, the prompt starts empty instead of rewriting it.

References: src/…/get-prompt-name.ts• L6-29 src/…/validate-project-name.ts• L3-21 src/…/get-prompts.ts• L8-22

Prompt cancellation

Cancellation is treated as a stopped creation request. The prompt group shows a cancellation message and exits rather than returning partial template or name data to the scaffolding flow.

References: src/…/get-prompts.ts• L8-22 src/…/get-prompt-template.ts• L13-19

Selection handoff

Resolved creation inputs

The argument stage starts with command-line values, fills missing template and name values through the prompt flow, and then returns one resolved input object. A prompted name also updates the target directory, so downstream work uses the same name that the user accepted.

The selected template is required before creation can continue. This handoff keeps menu presentation separate from project generation while preserving the complete template identity and metadata needed by later stages.

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

Template option flags

Template options are a separate command-line choice channel. Before the standard argument parser runs, unknown boolean long flags are collected as template option names. Known CLI options and their values remain command-line inputs, while malformed unknown flags fail early.

The selected option names travel with the resolved template and are checked against that template's initialization-script options later. They do not alter the menu or the interactive prompt sequence.

References: src/…/extract-template-option-flags.ts• L3-57 src/…/get-args.ts• L21-65 src/…/get-args-result.ts• L15-19 src/…/create-app.ts• L50-69

Change checklist

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

  • Keep menu configuration group paths aligned with the catalog group paths. A mismatch creates an empty menu item without an obvious schema error.
  • Preserve the template-first prompt order when changing prompt fields. The project-name default depends on the earlier template result.
  • Keep direct template lookup and menu output based on the same template identity fields. Otherwise a template can appear in the menu but fail when selected by name.
  • Keep template option extraction aligned with the later option schema. A flag can be accepted at argument parsing time but still fail when the selected template validates its options.
  • Recheck target-directory assignment when changing name handling. The generated path must use the final prompted or supplied name.

Important failure modes

TriggerConsequenceGuard
A menu configuration group path does not match a fetched catalog groupThe category contains no templates and cannot produce a selectionKeep configured paths aligned with catalog paths and inspect verbose menu output
A user cancels a group or template selectionThe process stops instead of producing incomplete creation inputsThe prompt group handles cancellation and exits with a clear message
A project name contains unsupported characters or points to an existing directoryThe name prompt rejects it and app creation does not proceed with that targetUse the name validator before accepting the answer
A command-line template name is not in the catalogDirect selection fails before the creation flow receives a templateUse a catalog template name or a valid external or local reference
An unknown short flag or non-boolean template flag is suppliedArgument handling fails before template option resolutionUse template-defined boolean long flags such as --ollama

Key files

FileWhy to read it
src/…/get-menu-config.tsDefines the categories and catalog groups that shape the user menu
src/…/menu-utils.tsShows how catalog groups and keywords become menu items
src/…/get-prompt-template.tsShows the two-level interactive template choice and command-line bypass
src/…/get-prompt-name.tsShows name prompting, template-based defaults, and validation handoff
src/…/get-prompts.tsDefines prompt order and cancellation behavior
src/…/get-args.tsConnects command-line inputs, catalog selection, prompts, and resolved creation inputs
src/…/extract-template-option-flags.tsDefines the boundary for template-specific command-line flags
src/…/template-schema.tsDefines the shared shape of menu items and catalog templates