feat: add prismic init --new to create a repository and push local models#222
feat: add prismic init --new to create a repository and push local models#222angeloashmore wants to merge 1 commit into
prismic init --new to create a repository and push local models#222Conversation
395f3d5 to
88359d1
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 4 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 88359d1. Configure here.
`--new` creates a new empty repository, points prismic.config.json at it (preserving an existing config's libraries and routes), and pushes the project's local models instead of pulling. This enables a fast setup from a template that already ships models and framework files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
88359d1 to
8d1ec0b
Compare
levimykel
left a comment
There was a problem hiding this comment.
I left a couple of comments/questions and pre-approved.
| throw new CommandError( | ||
| "A prismic.config.json file exists. This project is already initialized.", | ||
| ); | ||
| } |
There was a problem hiding this comment.
❓ If I have a fully-initialized project pointing at a real repo and run init --new by accident, this would repoint my config at a fresh empty repo without asking, yeah? Is this low risk or should we guard against it?
| await insertSlice(slice.model, { repo, token, host }); | ||
| } | ||
| for (const customType of localCustomTypes) { | ||
| await insertCustomType(customType.model, { repo, token, host }); |
There was a problem hiding this comment.
❓ What happens if an insert fails halfway? The config would point at the half-populated repo, so re-running init would say “already initialized” and re-running init --new would create a second repo. Is that acceptable for now, or should we catch and say something more helpful?

Resolves:
Description
Adds a
--newflag toprismic init.The default
prismic initcreates or connects to a repository and pulls its models.--newinstead:prismic.config.jsonat it, preserving an existing config'slibrariesandroutes,This enables a fast setup path from a template: clone a starter that already ships models and framework files, then run one command to get a matching repository — instead of scaffolding and modeling everything from scratch.
--newcannot be combined with--repo(it always creates a repository).Checklist
Additive flag only; existing
initbehavior is unchanged (all existing tests pass).Preview
How to QA
Once this PR publishes its
prismic@pr-<number>prerelease:Expected: a new repository is created,
prismic.config.json'srepositoryNameis repointed (routes/libraries preserved), and thepagetype +RichTextslice are pushed to the new repo.npx prismic@pr-<number> init --new --repo fooshould error.🤖 Generated with Claude Code
Note
Medium Risk
New remote-write path during init can publish local models to a fresh repo and repoint config; mistakes could target the wrong account/repo, though scope is limited to the newly created repository and default init is unchanged.
Overview
Adds
prismic init --new, an alternate init path for template/starter workflows: it always creates a new empty repository, reads local custom types and slices from the adapter, and pushes them withinsertSlice/insertCustomTypeinstead of pulling remote models.Init rules change so an existing
prismic.config.jsonis allowed only with--new(to repoint a starter at a new repo); otherwise init still errors if a config exists.--newcannot be used with--repo. For starters,repositoryName(and optional CDN endpoint) is updated after a successful push so a failed push does not leave the config switched; greenfield projects get a new config before the push. FrameworkinitProjectscaffolding is skipped when a config already exists (unless--no-setup), while types generation and optional dependency install still run.The default init flow (create/connect repo and sync models from remote) is unchanged in behavior; legacy Slice Machine migration and pull/sync logic are simply moved behind the non-
--newbranch.Reviewed by Cursor Bugbot for commit 8d1ec0b. Bugbot is set up for automated code reviews on this repo. Configure here.