The command line
bearminion ships a command line next to the library. It adds sections to a site that was created earlier, tells you which of a site’s files differ from the installed release, and adds a form handler, and keeps the list of a site’s sections in step with its directories. It runs in the folder of your site (or with --cwd) and needs nothing but the bearminion package you already have.
Add a section
A site is a copy of the starter, so it does not get new sections when the starter does. add copies a section, and the files it imports, from the installed bearminion into your site:
npx bearminion add --list # what can be added; * marks what the site already hasnpx bearminion add gallery text # copy two sectionsnpx bearminion add gallery --dry-run # show what would be written, write nothingNames are the section’s directory (logo-strip) or its type in content files (logoStrip). The files come from the same release as the bearminion you run, so what you get always matches the library, and nothing is fetched from the network. Sites created before sync existed list their sections by hand and cannot use add until they move over; see Add a section type in the template guide.
What happens to each file
A section is more than its own directory: it imports atoms, molecules and helpers that you may have changed. So add looks at every file it would write and decides one of four things:
| It says | Because | What add does |
|---|---|---|
create | The site has no such file | Writes it |
same | The site’s file is this release’s | Leaves it |
update | The site’s file is an earlier release’s and you did not change it | Replaces it with this release’s |
conflict | The site’s file is neither: you changed it | Stops. Nothing is written |
It knows an earlier release’s file because bearminion carries the hash of every file of every release since add was introduced. That works on any site, with or without a lock file.
An update is the one to look at: other sections use the same shared file, and the new version may look a little different. add says so, and a git diff and your build show the rest. Commit before you add, so git is the undo.
When a file conflicts:
npx bearminion add gallery --diff # how your file differs from this releasenpx bearminion add gallery --overwrite # replace your version with this release's--overwrite is the only way add replaces a file you changed.
Everything that follows
After the files are written, add:
- Lists the new directories in
definitions.gen.tsandcomponents.gen.ts, the same asnpx bearminion sync. - Records the files in
bearminion.lock.json. - Prints the npm packages the sections import that your
package.jsondoes not list, with the command that installs them.--installruns it for you, with the package manager your lock file names.
It never edits definitions.ts, astro.config.ts or a content file.
Options
| Option | |
|---|---|
--list | List the sections that can be added |
--dry-run | Show the plan and write nothing |
-y, --yes | Do not ask before writing. Without it, a terminal asks; anything else (a script, CI) stops and tells you to pass --yes or --dry-run |
--overwrite | Replace files you changed |
--diff | Show how files you changed differ from this release |
--install | Install the npm packages the sections need |
--json | Print one JSON document instead of text. It needs --yes or --dry-run, and is made for scripts and AI agents |
--cwd <dir> | Run as if started in this folder |
Exit code 0 is a section added, or already there. 1 is a conflict, an unknown section, a site add cannot work on, or a failed install. 2 is a command that was not understood.
With --json the document has ok, version, sections, files (each with its path and action), npm (what is missing), dirty (files to be overwritten that git shows as changed), and, after a write, written.
Add a form handler
The Contact form posts to /api/contact, and a handler in src/forms/contact.ts answers there. add form writes it, and the few lines of glue your host needs to run it. A new site has no Contact section: add form adds it too, so one command gives you the section, the handler and the glue. Then put the section on a page in the editor (Add section, Contact).
npx bearminion add form --list # what can be addednpx bearminion add form resend --host vercel # the handler and the gluenpx bearminion add form resend # the host is read from the projectnpx bearminion add form --host vercel # glue only, for a handler you already haveToday that is one service, resend (email), and three hosts: vercel (api/contact.ts), netlify (netlify/functions/contact.mts) and cloudflare (a Worker: worker.ts and wrangler.jsonc, the second only when the site has no Wrangler config). A real message has gone through Resend on each of them. The other services are in Forms as files to copy by hand, and join the command one at a time, after a real message has gone through each.
Set the addresses in the environment. The handler reads the sender and the receiver from
CONTACT_FROMandCONTACT_TO, so no address is written into your repository, and it refuses to send until both are set along withRESEND_API_KEY.CONTACT_FROMhas to be on a domain you verified with Resend.
Without --host, the command looks for vercel.json, netlify.toml, wrangler.toml and an Astro server adapter. If it finds none or two, it asks which host you use when it runs in a terminal (a numbered list; Enter writes the handler only). Without a terminal, with --json, or for a host it has no glue for (an Astro server adapter, say), it writes the handler only and says so. A file that is already there and differs from the recipe stops the command; --overwrite replaces it. --dry-run, --yes and --json work as for sections. The files are noted in bearminion.lock.json, and the command prints the three values to set. Forms explains the handler.
Set up the hosted editor
The hosted editor is a second deployment of your site that signs people in with GitHub and edits the repository (Edit online is the full guide). add hosted prepares the repository for it:
npx bearminion add hosted --dry-run # look firstnpx bearminion add hosted --install # write, and install the Vercel adapterIt writes three kinds of file:
- The starter’s files the editor depends on, from this release, like a section’s files:
src/lib/editing.ts,src/lib/image-url.ts,src/env.d.ts, the image components (Image.astro,MediaFrame.astro),Seo.astro, the page routes ([...slug].astro,404.astro) and, for a site that has them, the Media and Logo strip sections. A file of an earlier release that you did not change is replaced; one you changed stops the command (--diffshows how,--overwritereplaces it). A site made before 1.9 or without a lock file is recognised by the release history, so an untouched file is replaced, not reported as yours. Page routes you customised are the usual stop: merge the lines that readAstro.locals.bearminion. - Two files that are yours from then on:
src/editor.ts(the editor, reading its settings from the environment) andastro.editor.config.ts(the build of the editor deployment: yourastro.config.tsmerged with the adapter and the editor). A different file that is already there is kept, not overwritten, unless you pass--overwrite. - A
build:editorscript inpackage.json, added as one line without reformatting the file.
Your astro.config.ts is never edited. The editor build is a separate config, so the public site’s build cannot load any editor code. A site whose own config already adds bearminionHostedEditor (an environment-variable gate) is left as it is: the command writes the starter files and src/editor.ts and says so.
The command ends with what is left to do outside the repository: the GitHub App, a second Vercel project whose Build Command is npm run build:editor, and four environment variables. Today the only host is vercel (the default); for Cloudflare see the integration guide. --dry-run, -y, --overwrite, --install, --diff, --json and --cwd work as for sections.
Add a content type
npx bearminion add type # asks what the type isnpx bearminion add type news --field date:date --sort date:desc # or says it with flagsnpx bearminion add blog # a ready blog, no questionsadd type declares one content type: a blog, case studies, events, a fixed About page. In a terminal it asks for the id, many entries or one page, the address, the fields, a listing page and the order. Any of --kind, --path, --label, --field, --sort or --listing turns the questions off, so scripts and assistants can run it:
| Option | What it does |
|---|---|
--kind <kind> | multi, many entries (the default), or single, one page at a fixed address |
--path <path> | /news/{slug} for entries, /about for a single. Default: from the id |
--label <text> | The name the editor shows. Default: from the id |
--field <field> | Once per field: name:kind, name?:kind when optional, name:choice=a|b|c. Kinds: text, long-text, date, number, switch, choice, image, list |
--sort <field> | The order of entries: date:desc. Default: title, A to Z |
--listing <n> | Entries on one listing page (default 10), or none |
--files-only | Only bring the site’s own files up to date and declare nothing, for types you write by hand (below) |
It writes the type to src/lib/types/<id>.ts, adds it to src/lib/types/index.ts, and the first time passes those to src/lib/content-model.ts with types: siteTypes. A content model that is not shaped like the starter’s, or declares types some other way, is left alone and gets the lines to add. Before writing, it checks the type the way astro dev would and that no page or other type has its address. It also updates the site’s own files first, as below. add blog is add type with the blog already answered: posts at /blog/<slug> with a date, an excerpt, a cover and a draft switch, newest first, listed at /blog. More in Content types.
--dry-run, -y, --overwrite, --diff, --json and --cwd work as for sections.
Update a site for content types
A site made before 1.21 has a route file that knows only pages. Content types need the starter’s current files. add type brings them in on its way; --files-only brings them in alone, for a site whose types you declare by hand:
npx bearminion add type --files-only --dry-run # look firstnpx bearminion add type --files-only # writeIt writes the starter’s own files, from this release, like a section’s files: the page route (src/pages/[...slug].astro), src/content.config.ts, src/lib/content.ts, src/lib/sitemap.ts, and the two components a listing page uses (EntryList.astro, Pagination.astro). A file of an earlier release that you did not change is replaced; one you changed stops the command (--diff shows how, --overwrite replaces it).
Your astro.config.ts and your content model are never edited. The command tells you when your config still builds the sitemap from pages only.
You only need this when you declare a type. A site with no types in its content model builds exactly as before with its old files, and astro build stops with the list of missing addresses if you declare a type without running it. --dry-run, -y, --overwrite, --diff, --json and --cwd work as for sections.
Add a language
npx bearminion add locale de # declare German, copy the home and 404 pagesnpx bearminion add locale --files-only # only bring the site's files up to dateadd locale adds one language: any lowercase tag, such as de, fr or pt-br. It declares the languages in src/lib/content-model.ts with defineLocales (the site’s own language first, from lang in content/site.json), copies the home page to content/<code>/pages/ as a draft and the 404 page next to it, and copies src/i18n/en.json to src/i18n/<code>.json to translate. A content model of another shape is left alone and gets the lines to add. Before writing, it checks that the code is a language tag Node knows (--force takes one it does not), is not the site’s language, and that no page or content type has its address (/de, content/de/).
First it brings the starter’s files that publish more than one language up to this release, as for content types: the page route, the content readers, Base.astro, the header, footer and mobile menu, Seo.astro, LanguageSwitcher.astro, src/lib/i18n.ts and src/i18n/en.json. --files-only does that alone. A site with no languages builds the same pages before and after. Your astro.config.ts is never edited; the command tells you when its sitemap has no alternates yet. status lists the declared languages. More in Locales.
--dry-run, -y, --overwrite, --diff, --json and --cwd work as for sections.
Check the form
When the Contact form does not deliver, start here:
npx bearminion check form # the host is read from the projectnpx bearminion check form --host netlifynpx bearminion check form --jsonIt reads your files and writes nothing. It finds a missing handler or glue file; an import without .js (the error that stops a first Vercel deploy); a Netlify function in a folder Netlify does not read, or without path: '/api/contact'; a Wrangler config without main, with the placeholder Worker name, or without CONTACT_FROM and CONTACT_TO under vars. Each problem comes with the fix, and the exit code is 1 when there is one.
It cannot see the host’s own settings: the environment variables on Vercel and Netlify, the secrets on Cloudflare. It lists the names to set there. No problems found means the files are right, not that a message gets through; send one from the deployed site.
See what is out of date
status compares every file of the sections your site has with the installed release. It reads, and writes nothing:
npx bearminion statusnpx bearminion status --jsonEach file is in one of these states:
| State | Meaning | What add does |
|---|---|---|
current | It is this release’s file | Nothing to do |
outdated | You did not change it, and the release has | Replaces it |
edited | You changed it, and the release has not changed it since you got it | Leaves it alone |
conflict | You and the release both changed it | Stops |
differs | It is not this release’s, and there is no lock file to say who changed it | Stops |
status ends with the command that brings the outdated sections up to date. A section with a conflict or differs file is left out of that command, because add would stop on it: look at it with add <name> --diff.
Versions and updates
The starter and bearminion ship together, in one numbered release, and create-bearminion has the same number. A release is a package on npm; your site records nothing about it except the files and bearminion.lock.json.
- A minor release (1.8 to 1.9) can bring a new section, a new form recipe or a changed shared file. Run
npx bearminion@latest statusto see what moved, thennpx bearminion@latest add <name>for a new section or to update an outdated one. - A patch release fixes things inside the package. It does not change the files that
addcopies, unless the fix is in one of them. - A major release can change how sites are built. It comes with its own upgrade notes.
Update your site is the whole routine, step by step. Running npx bearminion@latest uses the latest release’s files, whatever your site started from. Run npm update bearminion as well when you want the library itself to move; the files add copies and the library are meant to match.
add never edits a file you changed, never edits definitions.ts, astro.config.ts or a content file, and there is no command that updates everything at once. Sections are copied, not linked: once a file is yours, it stays yours.
The lock file
bearminion.lock.json sits in the site’s root and is committed with it. For each file add handles it records the release the file came from and its hash. A new site starts with one. add keeps it up to date and creates it when a site has none; it is how add and status tell a file you left alone from one you changed, even when the release it came from is not in the history this version of bearminion carries.
Do not edit it by hand. Delete it and the next add writes a new one for the files it touches.
Keep the section list in step
sync rewrites definitions.gen.ts and components.gen.ts from the directories under src/components/sections/. Run it after you add, rename or remove a section directory by hand:
npx bearminion sync # rewritenpx bearminion sync --check # write nothing; exit 1 when they are stale (for CI)A section is a directory with a definition.ts that exports its definition under the camelCase name, and a component named after the directory. logo-strip/ exports logoStrip from definition.ts and has LogoStrip.astro. astro build, astro check and astro sync stop with a reminder when the generated files are stale, and astro dev warns.
How it knows
For people who want to check the reasoning: the registry is generated from the starter at release time, with each section’s import graph walked and its npm packages read from the starter’s package.json; the hash of every file of every release is kept in the repository’s packages/editor/registry-history.json. Nothing is downloaded when you run add.