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-catalog-and-selection

Template catalog and selection

Template catalog and selection turns a remote list of starter projects into one template for app creation. It keeps the remote group structure for menu use, creates a filtered flat view for lookup and listing, and resolves either an interactive choice or a command-line reference into a template with an acquisition ID.

Selection system

The selection system is the boundary between template discovery and project generation. home/…/fetch-template-data.ts coordinates the stages so that the same catalog data supports menus, direct lookup, catalog listings, and the final creation input.

The system follows this sequence:

  1. Choose a catalog URL from the command line, an environment override, or the default remote source.
  2. Fetch and validate the remote catalog as template groups.
  3. Apply the menu configuration to map group paths and keyword filters to user-facing menu items.
  4. Flatten the templates in those menu items for name lookup and ID listing.
  5. Resolve a command-line template reference or collect a group and template through prompts.
  6. Pass the selected template to the app creation flow.

The retrieval and validation rules are described in Template catalog retrieval. The interactive menu and prompt behavior are described in Template menu and prompts. The data contract and template-specific flags are described in Template schema and option flags.

Catalog model

The remote catalog is an ordered list of groups. Each group has a path used for matching, a display name and description, and a list of templates. Each template has a display name, description, keywords, source path, and ID; optional display metadata can improve how a catalog presents it.

The catalog keeps two identities separate. A template name is the human-facing value used for menu labels and catalog lookup. A template id identifies the source that later cloning uses. The path and keywords fields help decide where a template appears, but they do not select the source by themselves.

References: src/…/template-schema.ts• L3-25 src/…/template-schema.ts• L46-64 src/…/template.ts• L1-6

Menu policy converts catalog groups into the categories shown to a user. home/…/get-menu-config.ts defines categories such as Kit Framework, Solana Mobile, Community, and Web3.js. Each category points to catalog group paths and can provide keywords that narrow its templates.

The menu builder preserves the configuration order. It includes every template from a matched group when the category has no keywords. When keywords exist, it includes a template if at least one configured keyword appears in that template’s keyword list. A group-path or keyword mismatch can therefore remove a choice without changing the remote catalog.

This relationship is shown below.

flowchart LR
    A[Remote groups] --> B{Group path matches?}
    B -- Yes --> C{Keyword filter}
    B -- No --> D[Not shown in category]
    C -- No keywords --> E[Menu item templates]
    C -- Any keyword matches --> E
    C -- No keyword matches --> D
    E --> F[Interactive choice]

References: src/…/get-menu-config.ts• L3-34 src/…/menu-utils.ts• L3-27 src/…/get-menu-items-from-template-groups.ts• L6-21

Template views

The pipeline produces a structured menu view and a flat template view from the same filtered data. The structured view keeps categories and their descriptions for interactive selection. The flat view supports direct name lookup, human-readable listing, and machine-readable ID listing.

This shared source prevents the menu and direct selection paths from using different catalog rules. Verbose output reports the groups, menu items, and templates at each boundary so an engineer can locate a missing choice in the source or in menu filtering.

ViewPurposeMain consumer
Template groupsPreserve the remote catalog structureMenu transformation
Menu itemsPresent configured categories with filtered templatesInteractive prompts
Flat templatesProvide one lookup and listing setDirect selection and catalog output

References: src/…/fetch-template-data.ts• L6-26 src/…/get-templates-from-items.ts• L5-19 src/…/list-templates.ts• L4-8 src/…/list-template-ids.ts• L3-5

Template identity

Template identity resolves the value supplied to the template option into a descriptor that downstream creation can use. A plain name must match a template in the flat catalog. A value with a slash is treated as an external repository reference, while an absolute or relative path is treated as a local template reference.

The resulting descriptor keeps an ID for acquisition and a description for user output. Catalog entries keep their remote ID. External references receive a gh: prefix when they do not already include a source prefix. Local references must exist and receive a local: ID so the cloning stage can copy them instead of downloading them.

Reference formSelection meaningResulting identity
template-nameNamed entry in the filtered catalogCatalog template and its catalog ID
org/repositoryExternal repository sourcegh:org/repository, unless already prefixed
./path, ../path, or /pathLocal development sourcelocal:<absolute path>

The selected ID becomes the source input for template acquisition. This makes ID changes a cross-stage contract rather than a display-only change.

References: src/…/find-template.ts• L7-64 src/…/template.ts• L1-6 src/…/create-app-task-clone-template.ts• L20-39 src/…/create-app-task-clone-template.ts• L43-98

Selection paths

Selection can begin with a command-line reference or with the interactive menu. Both paths end with one resolved template before project creation continues. The command-line path uses the flat view; the interactive path uses the menu view.

Interactive selection

Interactive selection first asks for a configured menu group and then asks for a template from that group. The prompt returns the complete template record, not only its display name or ID. If the user cancels, the operation stops instead of passing partial data to app creation.

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

Direct selection

Direct selection resolves a catalog name before prompts run. It can also accept an external repository or a local path, so these sources do not need to appear in the remote catalog. The --minimal choice maps to a named catalog template, while --template and --minimal cannot be used together.

References: src/…/find-template.ts• L7-64 src/…/get-args.ts• L110-122

Selection handoff

The argument stage combines the selected template with the project name and other creation choices. If the name is not supplied, the name prompt runs after template selection and can suggest a usable final path segment from the selected template name. The stage rejects the request if no template remains selected.

References: src/…/get-args.ts• L124-157 src/…/get-prompts.ts• L8-15 src/…/get-prompt-name.ts• L16-29

The selection paths and their handoff are shown below.

flowchart TD
    A[Catalog URL] --> B[Validated groups]
    B --> C[Menu items]
    C --> D[Flat templates]
    D --> E{Template input}
    E -- Catalog name --> F[Catalog template]
    E -- External repository --> G[External template]
    E -- Local path --> H[Local template]
    C --> I[Choose group and template]
    F --> J[Resolved template]
    G --> J
    H --> J
    I --> J
    J --> K[Resolved creation inputs]

References: src/…/get-args.ts• L110-157 src/…/get-prompt-template.ts• L6-49

Change checklist

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

  • Keep catalog group paths and keyword values aligned with menu configuration. A mismatch can silently remove templates from a category.
  • Keep template names unique within the filtered flat view. Direct lookup uses the first exact name match and does not report duplicate names.
  • Preserve the distinction between display names and acquisition IDs. Menus and lookup use names, while cloning uses IDs.
  • Keep local and external ID prefixes aligned with the acquisition path. A prefix change can send a template to the wrong source handler.
  • Preserve the structured and flat outputs from catalog normalization. Prompt selection needs groups, while direct selection and listing need the flat set.
  • Keep template selection before project-name prompting. The selected name can supply the project-name default and the final target directory.

Important failure modes

TriggerConsequenceGuard
The remote response is unavailable or fails catalog validationNo groups reach menu generation and selection stopsCheck the response and validate the complete catalog before transformation
A configured group path or keyword matches no catalog dataA visible category can contain no usable templatesCoordinate menu policy values with the remote catalog and inspect verbose output
Two catalog entries use the same nameDirect lookup silently selects the first matching entryKeep catalog names unique in the filtered template set
A catalog template has an unusable or empty acquisition IDSelection may succeed but cloning cannot acquire the sourceTreat each catalog ID as a required source contract and verify it before publication
A requested catalog name is absentDirect selection fails before app creationUse an exact filtered catalog name or a supported external or local reference
A local path does not existLocal selection fails before cloningResolve and check the path before returning the local template descriptor
The user cancels an interactive choiceThe command exits without resolved creation inputsKeep prompt cancellation connected to the top-level failure path

Key files

FileWhy to read it
src/…/fetch-template-data.tsShows the main boundary from remote groups to menu and flat template views
src/…/fetch-templates.tsDefines remote response checks and catalog validation
src/…/template-schema.tsDefines the group, template, and menu data contract
src/…/get-menu-config.tsDefines the product-facing categories and their catalog filters
src/…/menu-utils.tsShows how groups and keywords become menu items
src/…/find-template.tsDefines catalog, external, and local template identity resolution
src/…/get-prompt-template.tsShows interactive selection and the command-line bypass
src/…/get-args.tsConnects retrieval, listing, lookup, prompts, and the final creation inputs
src/…/create-app-task-clone-template.tsShows how the selected ID is consumed by source acquisition