Kit für selbst verwaltete Next.js-Websites: /admin für Seiten mit Blöcken, Medien, Menüs, Einstellungen und Nutzer
Installieren
genpm add @core/kit-cmsWas du bekommst
- Quellcode in src/app/(cms)/, 39 Dateien. (40,8 kB)
- KI-Regeln in src/app/(cms)/AGENTS.md, dazu Regeldateien für die IDE.
- Löst @core/admin, @core/blocks, @core/content, @core/forms, @core/media, @core/rich-text, @core/search, @core/seo, @core/site für dich auf.
README
@core/kit-cms
Self-managed website kit for Next.js: /admin to edit pages with blocks, media, menus, settings, forms and users
A GenPM module: source code + AI rules + MCP config, injected into your project instead of hidden in node_modules. The code lands in src/app/(cms), pinned to a verified commit, and you own it.
Install
genpm add @core/kit-cmsNo genpm yet? curl -fsSL https://genpm.net/install.sh | sh (macOS/Linux), irm https://genpm.net/install.ps1 | iex (Windows), or one-off with npx @genpm-net/cli add @core/kit-cms.
Or let your AI agent do it: run genpm mcp setup once, then ask "add @core/kit-cms with genpm" in Claude Code, Cursor, VS Code, Windsurf, Codex or Gemini CLI. It shows you a dry-run plan before writing anything.
What it does
Turns a Next.js (App Router) site into a self-managed one: /admin where non-technical people edit pages built with
blocks, images, menus, site settings, forms, redirects and users, with drafts, signed previews, scheduled publishing
and roles. Glue only: all logic lives in @core/admin, content, media, rich-text, blocks, site, seo, forms, search,
auth and rbac (the last two arrive through @core/admin). Public routes: pages created in the admin (/[...slug]), /search, /sitemap.xml, /robots.txt,
/llms.txt. Base for kit-blog, kit-landing and kit-store.
Setup
After genpm add, follow these steps (your AI agent finds the same steps in src/app/(cms)/AGENTS.md and can do them for you):
- Check Next ≥ 15.5 with App Router,
src/appand the@/*→src/*alias. Withoutsrc/: install with--dest app/(cms)and adapt@/imports. GenPM packages import each other with.tsextensions:tsconfig.jsonneeds"allowImportingTsExtensions": true(Next projects already have"noEmit": true). Works with webpack and Turbopack. Innext.configsethtmlLimitedBots: /.*/: metadata comes from the database, and without it Next 15 streams<title>, description and canonical into<body>for every client except a few bots (Lighthouse, link previews and some crawlers miss them). Next 16:create-next-appturns oncacheComponents, which this kit does not support yet (pages read the database per request and routes useexport const dynamic): setcacheComponents: falseand removepartialPrefetching. - Env:
genpm addalready wrote agenpm:envblock with bare variable names to.env.example; replace that block with_templates/env.example(every variable, optional ones and defaults; Next's default.gitignorehas.env*, so add a line!.env.example) and the real values to.env.local. Required:DATABASE_URL,AUTH_SECRET, one OAuth provider (GITHUB_CLIENT_ID/SECRETorGOOGLE_…),STORAGE_*,EMAIL_FROM+RESEND_API_KEY,SITE_URL,CONTENT_PREVIEW_SECRET(≥ 32 chars),ANTISPAM_SECRET,CRON_SECRET. WithSTORAGE_DRIVER=localalso mount the storage route (src/lib/storage/AGENTS.md, Integration 1). - Mount the @core/auth routes (
app/auth/login/[provider],app/auth/callback/[provider],app/auth/logout) as its AGENTS.md says. - Copy
_templates/genpm/*.tstosrc/genpm/(skip files that exist and merge by hand). These files belong to the project: later kits add lines to them. Copy_templates/middleware.tstosrc/middleware.ts(or merge into the existing one); on Next 16 copy it tosrc/proxy.ts, rename the function toproxyand removeruntimefromconfig. - Migrations: GenPM does not install dev tools — run
src/lib/db/AGENTS.mdsteps 3–5 (drizzle-kit+tsx, thedb:generate/db:migratescripts), generate one migration for all packages and apply it where a database exists. - Schedule
GET /api/cronevery minute withAuthorization: Bearer $CRON_SECRET(e.g.vercel.jsoncrons). Once the database is migrated, the person runsnpx tsx "src/app/(cms)/_scripts/setup-schedules.ts"(idempotent; it schedules the daily jobs of every installed kit, so run it again after adding another kit). - The person signs in once at
/admin/login(it needs a real OAuth app: create one with the callback<SITE_URL>/auth/callback/github— there is no password or dev login), then runsnpx tsx "src/app/(cms)/_scripts/create-owner.ts" <their email>. Never run it for them with an email they did not give you. - New site: create
src/app/page.tsxwithexport { default, generateMetadata } from './(cms)/_lib/home';and create thehomepage in the admin (blocks: hero, features, cta…). Existing site: follow "Retrofit" below. - Root layout: new site → copy
_templates/layout.tsxtosrc/app/layout.tsx(<html lang>comes fromCONTENT_DEFAULT_LOCALE; translate built-in form and UI texts with theirlabelsprops). Existing layout → import@/lib/ui/ui.cssand@/lib/blocks/blocks.css, render menus withgetMenu('header')/getMenu('footer')and the site name withgetSiteSettings()(@core/site), and addexport const dynamic = 'force-dynamic'(it reads the database; without itnext buildtries to prerender and fails withoutDATABASE_URL). - Verify:
npx tsc --noEmitandnpx next buildpass without a database. Then, with one: sign in at/admin, edit a page, open "Preview", publish, and see the change on the public URL. - Delete every
src/lib/*/adapters/hono.ts(rm src/lib/*/adapters/hono.ts): they importhono, which a Next project does not install, andtscchecks every file. Keepadapters/next.ts.genpm listthen shows those packages with "1 file changed": that is this deletion, expected.
What's inside
Paths are relative to src/app/(cms).
admin/[[...path]]/page.tsx— panel (server checks session +admin:access).admin/login/page.tsx— OAuth sign-in.api/admin/[...path]— admin API.api/media/uploads…— uploads.api/preview,api/exit-preview— draft mode.api/forms/[key]— form posts.api/cron— @core/jobs.api/search— JSON search.[...slug]/page.tsx— pages of thepagescollection (redirects before the 404).search/page.tsx— results._lib/page.tsx—CmsPage,pageMetadata._lib/home.tsx— home page from thehomeentry._lib/session.ts._components/— admin client app, themedia/richTextfield editors andSiteChrome(hides the site header and footer on/admin)._templates/genpm/*.ts— the project's registration files._templates/middleware.ts— redirects middleware._templates/layout.tsx— root layout for a new site._templates/env.example— every variable the kit and its packages read._lib/maintenance.ts— dailycms.maintenancejob (prunes rate limits and old jobs), loaded byapi/cron._scripts/create-owner.ts— gives the first signed-in user theownerrole (and creates the default roles)._scripts/setup-schedules.ts— schedules the daily jobs of the installed kits (cms.maintenance,search.reindex,store.maintenance,experiments.prune) and queues the first reindex.
At a glance
- GenPM dependencies (installed with it): @core/admin, @core/content, @core/media, @core/rich-text, @core/blocks, @core/site, @core/seo, @core/forms, @core/search
- npm dependencies (proposed, never installed without asking):
next,react,zod - AI rules:
AGENTS.md, loaded by your agent only when it works insrc/app/(cms)
Security
GenPM installs a 40-character commit SHA (never a branch), verifies an Ed25519-signed manifest, never runs install scripts and scans AI rules for prompt injection. Details: genpm.net/docs/security.
License
Genau das liest deine KI, wenn sie in src/app/(cms) arbeitet. Sonst wird ihrem Kontext nichts hinzugefügt.
@core/kit-cms — rules for AI agents
Purpose
Turns a Next.js (App Router) site into a self-managed one: /admin where non-technical people edit pages built with
blocks, images, menus, site settings, forms, redirects and users, with drafts, signed previews, scheduled publishing
and roles. Glue only: all logic lives in @core/admin, content, media, rich-text, blocks, site, seo, forms, search,
auth and rbac (the last two arrive through @core/admin). Public routes: pages created in the admin (/[...slug]), /search, /sitemap.xml, /robots.txt,
/llms.txt. Base for kit-blog, kit-landing and kit-store.
Map
admin/[[...path]]/page.tsx— panel (server checks session +admin:access).admin/login/page.tsx— OAuth sign-in.api/admin/[...path]— admin API.api/media/uploads…— uploads.api/preview,api/exit-preview— draft mode.api/forms/[key]— form posts.api/cron— @core/jobs.api/search— JSON search.[...slug]/page.tsx— pages of thepagescollection (redirects before the 404).search/page.tsx— results._lib/page.tsx—CmsPage,pageMetadata._lib/home.tsx— home page from thehomeentry._lib/session.ts._components/— admin client app, themedia/richTextfield editors andSiteChrome(hides the site header and footer on/admin)._templates/genpm/*.ts— the project's registration files._templates/middleware.ts— redirects middleware._templates/layout.tsx— root layout for a new site._templates/env.example— every variable the kit and its packages read._lib/maintenance.ts— dailycms.maintenancejob (prunes rate limits and old jobs), loaded byapi/cron._scripts/create-owner.ts— gives the first signed-in user theownerrole (and creates the default roles)._scripts/setup-schedules.ts— schedules the daily jobs of the installed kits (cms.maintenance,search.reindex,store.maintenance,experiments.prune) and queues the first reindex.
Integration
- Check Next ≥ 15.5 with App Router,
src/appand the@/*→src/*alias. Withoutsrc/: install with--dest app/(cms)and adapt@/imports. GenPM packages import each other with.tsextensions:tsconfig.jsonneeds"allowImportingTsExtensions": true(Next projects already have"noEmit": true). Works with webpack and Turbopack. Innext.configsethtmlLimitedBots: /.*/: metadata comes from the database, and without it Next 15 streams<title>, description and canonical into<body>for every client except a few bots (Lighthouse, link previews and some crawlers miss them). Next 16:create-next-appturns oncacheComponents, which this kit does not support yet (pages read the database per request and routes useexport const dynamic): setcacheComponents: falseand removepartialPrefetching. - Env:
genpm addalready wrote agenpm:envblock with bare variable names to.env.example; replace that block with_templates/env.example(every variable, optional ones and defaults; Next's default.gitignorehas.env*, so add a line!.env.example) and the real values to.env.local. Required:DATABASE_URL,AUTH_SECRET, one OAuth provider (GITHUB_CLIENT_ID/SECRETorGOOGLE_…),STORAGE_*,EMAIL_FROM+RESEND_API_KEY,SITE_URL,CONTENT_PREVIEW_SECRET(≥ 32 chars),ANTISPAM_SECRET,CRON_SECRET. WithSTORAGE_DRIVER=localalso mount the storage route (src/lib/storage/AGENTS.md, Integration 1). - Mount the @core/auth routes (
app/auth/login/[provider],app/auth/callback/[provider],app/auth/logout) as its AGENTS.md says. - Copy
_templates/genpm/*.tstosrc/genpm/(skip files that exist and merge by hand). These files belong to the project: later kits add lines to them. Copy_templates/middleware.tstosrc/middleware.ts(or merge into the existing one); on Next 16 copy it tosrc/proxy.ts, rename the function toproxyand removeruntimefromconfig. - Migrations: GenPM does not install dev tools — run
src/lib/db/AGENTS.mdsteps 3–5 (drizzle-kit+tsx, thedb:generate/db:migratescripts), generate one migration for all packages and apply it where a database exists. - Schedule
GET /api/cronevery minute withAuthorization: Bearer $CRON_SECRET(e.g.vercel.jsoncrons). Once the database is migrated, the person runsnpx tsx "src/app/(cms)/_scripts/setup-schedules.ts"(idempotent; it schedules the daily jobs of every installed kit, so run it again after adding another kit). - The person signs in once at
/admin/login(it needs a real OAuth app: create one with the callback<SITE_URL>/auth/callback/github— there is no password or dev login), then runsnpx tsx "src/app/(cms)/_scripts/create-owner.ts" <their email>. Never run it for them with an email they did not give you. - New site: create
src/app/page.tsxwithexport { default, generateMetadata } from './(cms)/_lib/home';and create thehomepage in the admin (blocks: hero, features, cta…). Existing site: follow "Retrofit" below. - Root layout: new site → copy
_templates/layout.tsxtosrc/app/layout.tsx(<html lang>comes fromCONTENT_DEFAULT_LOCALE; translate built-in form and UI texts with theirlabelsprops). Existing layout → import@/lib/ui/ui.cssand@/lib/blocks/blocks.css, render menus withgetMenu('header')/getMenu('footer')and the site name withgetSiteSettings()(@core/site), and addexport const dynamic = 'force-dynamic'(it reads the database; without itnext buildtries to prerender and fails withoutDATABASE_URL). - Verify:
npx tsc --noEmitandnpx next buildpass without a database. Then, with one: sign in at/admin, edit a page, open "Preview", publish, and see the change on the public URL. - Delete every
src/lib/*/adapters/hono.ts(rm src/lib/*/adapters/hono.ts): they importhono, which a Next project does not install, andtscchecks every file. Keepadapters/next.ts.genpm listthen shows those packages with "1 file changed": that is this deletion, expected.
Retrofit (make an existing site editable)
Follow the @core/content procedure page by page, one commit per page: inventory visible literals → a singleton per
page (or a collection when repeated) defined in src/genpm/content.ts → seed with the current values (seedEntry) →
replace literals with typed reads → compare the rendered HTML before/after (must be identical). Keep markup and design;
only the data source changes: skip className="ui-root" on <body> and don't add buildMetadata tags the site did not
have (keep its titles and descriptions, now read from the CMS). Local images go to @core/media with their alt text;
SVG (which @core/media rejects) stays in public/ with its path in a text field. Keep the root layout's existing
header/footer markup and feed it from getSiteSettings() / getMenu(); wrap the header and the footer in
<SiteChrome> (@/app/(cms)/_components/site-chrome) so they don't show over the admin panel. Existing routes keep priority over
[...slug]. Non-Next sites (static HTML, Astro, Vite): out of scope for 1.0 — say so.
Conventions
- Page sections are blocks registered in
src/genpm/blocks.ts; add new blocks there, never per-page components. - Admin resources are registered in
src/genpm/admin.ts; never write a custom admin page for a resource. - The
pagesentry with slughomeis/; other slugs map to/<slug>. - Default roles:
editorpublishes pages but cannot see users or settings beyond content;authoredits only own entries.
Don't
- Don't invent legal texts (privacy, terms, imprint): create the pages empty with a "pending review" note for the owner.
- Don't expose
/adminor/apiin the sitemap, and don't removerobots: noindexfrom admin pages. - Don't bypass
CRON_SECRETor callrunDue()from a public route. - Don't grant roles or create owners from code paths reachable by visitors.
# @core/kit-cms — rules for AI agents
## Purpose
Turns a Next.js (App Router) site into a self-managed one: `/admin` where non-technical people edit pages built with
blocks, images, menus, site settings, forms, redirects and users, with drafts, signed previews, scheduled publishing
and roles. Glue only: all logic lives in @core/admin, content, media, rich-text, blocks, site, seo, forms, search,
auth and rbac (the last two arrive through @core/admin). Public routes: pages created in the admin (`/[...slug]`), `/search`, `/sitemap.xml`, `/robots.txt`,
`/llms.txt`. Base for kit-blog, kit-landing and kit-store.
## Map
- `admin/[[...path]]/page.tsx` — panel (server checks session + `admin:access`). `admin/login/page.tsx` — OAuth sign-in.
- `api/admin/[...path]` — admin API. `api/media/uploads…` — uploads. `api/preview`, `api/exit-preview` — draft mode.
`api/forms/[key]` — form posts. `api/cron` — @core/jobs. `api/search` — JSON search.
- `[...slug]/page.tsx` — pages of the `pages` collection (redirects before the 404). `search/page.tsx` — results.
- `_lib/page.tsx` — `CmsPage`, `pageMetadata`. `_lib/home.tsx` — home page from the `home` entry. `_lib/session.ts`.
- `_components/` — admin client app, the `media` / `richText` field editors and `SiteChrome` (hides the site header and
footer on `/admin`).
- `_templates/genpm/*.ts` — the project's registration files. `_templates/middleware.ts` — redirects middleware.
`_templates/layout.tsx` — root layout for a new site. `_templates/env.example` — every variable the kit and its packages read.
- `_lib/maintenance.ts` — daily `cms.maintenance` job (prunes rate limits and old jobs), loaded by `api/cron`.
- `_scripts/create-owner.ts` — gives the first signed-in user the `owner` role (and creates the default roles).
- `_scripts/setup-schedules.ts` — schedules the daily jobs of the installed kits (`cms.maintenance`, `search.reindex`,
`store.maintenance`, `experiments.prune`) and queues the first reindex.
## Integration
1. Check Next ≥ 15.5 with App Router, `src/app` and the `@/*` → `src/*` alias. Without `src/`: install with `--dest app/(cms)` and adapt `@/` imports.
GenPM packages import each other with `.ts` extensions: `tsconfig.json` needs `"allowImportingTsExtensions": true`
(Next projects already have `"noEmit": true`). Works with webpack and Turbopack. In `next.config` set
`htmlLimitedBots: /.*/`: metadata comes from the database, and without it Next 15 streams `<title>`, description and
canonical into `<body>` for every client except a few bots (Lighthouse, link previews and some crawlers miss them).
Next 16: `create-next-app` turns on `cacheComponents`, which this kit does not support yet (pages read the database
per request and routes use `export const dynamic`): set `cacheComponents: false` and remove `partialPrefetching`.
2. Env: `genpm add` already wrote a `genpm:env` block with bare variable names to `.env.example`; replace that block
with `_templates/env.example` (every variable, optional ones and defaults; Next's default `.gitignore`
has `.env*`, so add a line `!.env.example`) and the real values to `.env.local`. Required: `DATABASE_URL`, `AUTH_SECRET`, one OAuth provider
(`GITHUB_CLIENT_ID/SECRET` or `GOOGLE_…`), `STORAGE_*`, `EMAIL_FROM` + `RESEND_API_KEY`, `SITE_URL`,
`CONTENT_PREVIEW_SECRET` (≥ 32 chars), `ANTISPAM_SECRET`, `CRON_SECRET`. With `STORAGE_DRIVER=local` also mount the
storage route (`src/lib/storage/AGENTS.md`, Integration 1).
3. Mount the @core/auth routes (`app/auth/login/[provider]`, `app/auth/callback/[provider]`, `app/auth/logout`) as its AGENTS.md says.
4. Copy `_templates/genpm/*.ts` to `src/genpm/` (skip files that exist and merge by hand). These files belong to the project:
later kits add lines to them. Copy `_templates/middleware.ts` to `src/middleware.ts` (or merge into the existing one);
on Next 16 copy it to `src/proxy.ts`, rename the function to `proxy` and remove `runtime` from `config`.
5. Migrations: GenPM does not install dev tools — run `src/lib/db/AGENTS.md` steps 3–5 (`drizzle-kit` + `tsx`, the
`db:generate` / `db:migrate` scripts), generate one migration for all packages and apply it where a database exists.
6. Schedule `GET /api/cron` every minute with `Authorization: Bearer $CRON_SECRET` (e.g. `vercel.json` crons). Once the
database is migrated, the person runs `npx tsx "src/app/(cms)/_scripts/setup-schedules.ts"` (idempotent; it schedules
the daily jobs of every installed kit, so run it again after adding another kit).
7. The person signs in once at `/admin/login` (it needs a real OAuth app: create one with the callback
`<SITE_URL>/auth/callback/github` — there is no password or dev login), then runs `npx tsx "src/app/(cms)/_scripts/create-owner.ts" <their email>`.
Never run it for them with an email they did not give you.
8. New site: create `src/app/page.tsx` with `export { default, generateMetadata } from './(cms)/_lib/home';` and create
the `home` page in the admin (blocks: hero, features, cta…). Existing site: follow "Retrofit" below.
9. Root layout: new site → copy `_templates/layout.tsx` to `src/app/layout.tsx` (`<html lang>` comes from
`CONTENT_DEFAULT_LOCALE`; translate built-in form and UI texts with their `labels` props). Existing layout → import `@/lib/ui/ui.css`
and `@/lib/blocks/blocks.css`, render menus with `getMenu('header')` / `getMenu('footer')` and the site name with
`getSiteSettings()` (@core/site), and add `export const dynamic = 'force-dynamic'` (it reads the database; without it
`next build` tries to prerender and fails without `DATABASE_URL`).
10. Verify: `npx tsc --noEmit` and `npx next build` pass without a database. Then, with one: sign in at `/admin`, edit a
page, open "Preview", publish, and see the change on the public URL.
11. Delete every `src/lib/*/adapters/hono.ts` (`rm src/lib/*/adapters/hono.ts`): they import `hono`, which a Next
project does not install, and `tsc` checks every file. Keep `adapters/next.ts`. `genpm list` then shows those
packages with "1 file changed": that is this deletion, expected.
## Retrofit (make an existing site editable)
Follow the @core/content procedure page by page, one commit per page: inventory visible literals → a singleton per
page (or a collection when repeated) defined in `src/genpm/content.ts` → seed with the current values (`seedEntry`) →
replace literals with typed reads → compare the rendered HTML before/after (must be identical). Keep markup and design;
only the data source changes: skip `className="ui-root"` on `<body>` and don't add `buildMetadata` tags the site did not
have (keep its titles and descriptions, now read from the CMS). Local images go to @core/media with their alt text;
SVG (which @core/media rejects) stays in `public/` with its path in a text field. Keep the root layout's existing
header/footer markup and feed it from `getSiteSettings()` / `getMenu()`; wrap the header and the footer in
`<SiteChrome>` (`@/app/(cms)/_components/site-chrome`) so they don't show over the admin panel. Existing routes keep priority over
`[...slug]`. Non-Next sites (static HTML, Astro, Vite): out of scope for 1.0 — say so.
## Conventions
- Page sections are blocks registered in `src/genpm/blocks.ts`; add new blocks there, never per-page components.
- Admin resources are registered in `src/genpm/admin.ts`; never write a custom admin page for a resource.
- The `pages` entry with slug `home` is `/`; other slugs map to `/<slug>`.
- Default roles: `editor` publishes pages but cannot see users or settings beyond content; `author` edits only own entries.
## Don't
- Don't invent legal texts (privacy, terms, imprint): create the pages empty with a "pending review" note for the owner.
- Don't expose `/admin` or `/api` in the sitemap, and don't remove `robots: noindex` from admin pages.
- Don't bypass `CRON_SECRET` or call `runDue()` from a public route.
- Don't grant roles or create owners from code paths reachable by visitors.
Der genaue Baum, der nach .genpmignore eingebunden wird. Gepinnt an
// Qué se indexa en la búsqueda del sitio.
import { blocksToText } from '@/lib/blocks';
import { contentSearchSource } from '@/lib/content';
import type { BlockInstance } from '@/lib/blocks';
import { toPlainText } from '@/lib/rich-text';
import { registerSearchSource } from '@/lib/search';
import { blocks } from './blocks';
import { pagePath } from './content';
registerSearchSource(
contentSearchSource('pages', {
path: pagePath,
text: (d) => blocksToText(d.blocks as BlockInstance[], blocks, (doc) => toPlainText(doc as never)),
}),
);
Dieses Paket deklariert keine MCP-Server.
- genpm
- @core/admin ^1.0.0@core/blocks ^1.0.0@core/content ^1.1.0@core/forms ^1.0.0@core/media ^1.0.0@core/rich-text ^1.0.0@core/search ^1.0.0@core/seo ^1.0.0@core/site ^1.0.0
- vorgeschlagen
- GenPM schlägt den npm-Befehl vor und führt ihn nur aus, wenn du zustimmst.
- Verwendet von (3)
- @core/kit-blog ^1.0.0@core/kit-landing ^1.0.0@core/kit-store ^1.0.0
- Prüfung
- Prüfung bestanden · 0 Befunde
- Commit
- v1.0.3 → e44820b2967a2f29af15191a89856ed9052ba2bb · nach dem Abruf verifiziert
- Skripte
- Keine. GenPM führt niemals Paketcode aus.
- Lizenz
- MIT
- Qualität
- 100/100
- Anerkannte Lizenzerfüllt
- AGENTS.md erklärt den Zweckerfüllt
- AGENTS.md enthält Integrationsschritteerfüllt
- AGENTS.md nennt Konventionen oder Verboteerfüllt
- Enthält Testserfüllt
- Sicherheitsscan bestandenerfüllt
- In den letzten 6 Monaten veröffentlichterfüllt
- Verifizierter Herausgebererfüllt
- Zusammenfassung und Schlagwörtererfüllt
- Meldung
- Stimmt etwas nicht?