feat: use --name as repository domain in repo create and init#180
feat: use --name as repository domain in repo create and init#180
Conversation
Previously `--name` was only sent as the display label while the domain was a random 8-char hex slug. The dashboard API accepts a caller-chosen domain, so derive it from user input (kebab-cased) and add a separate `--display-name` flag for the label. - `--name` is now required and defines the domain - Adds `--display-name` to set the display label (defaults to `--name`) - Validates the domain against the dashboard rule before POSTing - `prismic init` requires `--name` unless `--repo` is provided Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Drop the silent kebab-casing of --name. Validate it directly against the dashboard rule and error with guidance when it doesn't match. Users pass the exact domain they want. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Accept uppercase letters in --name to match the server-side rule
exactly (`^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$`). Wroom lowercases
the domain server-side, so any value the CLI accepts will be accepted
by the API.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Wroom lowercases the domain server-side. If the user passes `MyRepo`, the CLI was printing `Repository created: MyRepo` and `URL: https://MyRepo.prismic.io/`, both wrong. Lowercase after validation so the displayed output matches what was actually created. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
init is about connecting a project to a repository. Drop the --name/--display-name options added to init — repo creation with a custom display label belongs on `prismic repo create`. Instead, if --repo points to a domain the user doesn't have access to, check if it's available and create it with that name; if it's taken by another account, error clearly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Keep the original shape of the access check; just branch on availability when the user lacks access, and thread the name into createRepo. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
It's only used in one place (the createRepo function), so it doesn't need its own lib file. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b163f83. Configure here.
| ); | ||
| } | ||
|
|
||
| const available = await checkIsDomainAvailable({ domain: repo, token, host }); |
There was a problem hiding this comment.
Redundant domain availability check in init flow
Low Severity
When init creates a new repo, checkIsDomainAvailable is called at init.ts line 115, then createRepo at line 131 calls it a second time internally at repo-create.ts line 60. This is a redundant HTTP request on every init --repo <new-name> run. The first check provides a contextual error message, and the second is a general safety check inside createRepo — but both hit the same API endpoint with the same arguments, with getAdapter() running in between.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b163f83. Configure here.


Summary
prismic repo create --namenow sets the repository domain (URL slug), not just the display label. Previously the domain was a random 8-char hex string regardless of--name.--display-name(-d) onrepo createto control the human-readable label separately, matching the dashboard's two-field model.--nameis required onrepo createand validated against the same rule API uses: 4–63 chars,^[a-zA-Z0-9][-a-zA-Z0-9]{2,}[a-zA-Z0-9]$. Invalid input errors with guidance. Valid input is lowercased before submitting (API lowercases server-side).prismic init --repo <name>now creates the repository if it doesn't already exist in your account (and is available). If the name is taken by another account, it errors clearly.How to QA [^1]
npx prismic@pr-180 repo create --name my-test-repo→ Creates a repo atmy-test-reponpx prismic@pr-180 repo create --name foo-bar --display-name "Foo Bar"→ Sets domainfoo-barand labelFoo Barin the dashboardnpx prismic@pr-180 repo create --name "My Test Repo"→ Errors with validation guidance (spaces are not allowed)npx prismic@pr-180 repo create --name "!!"→ Errors with validation guidancenpx prismic@pr-180 init --repo my-new-repoin a fresh project → Createsmy-new-repoand writes it toprismic.config.jsonnpx prismic@pr-180 init --repo prismic→ Errors (name taken by another account)npx prismic@pr-180 init→ Errors asking for--repo🤖 Generated with Claude Code
Note
Medium Risk
Changes repository creation/selection flow in
prismic initandprismic repo create, which can affect onboarding behavior and error handling when creating or attaching to repos. Risk is moderate due to new validation and availability checks against remote services.Overview
prismic repo createnow requires--nameand uses it as the repository domain (lowercased), with a new--display-nameto set the human-readable label separately; it validates names via a sharedrepositoryNameSchemaand fails early if the domain is unavailable.prismic initnow requires--repo, lowercases it, and will create the repository automatically when the user doesn’t already have access (after validating the name and checking domain availability); it only enforces Type Builder being enabled when connecting to an existing accessible repo. The command framework adds optional per-option Zod schema validation, and tests are updated to cover the new required/validation behaviors and repo cleanup.Reviewed by Cursor Bugbot for commit b163f83. Bugbot is set up for automated code reviews on this repo. Configure here.