Backend-only CMS workflow

cms-lab can help before a frontend exists, but the workflow is different. Use it to document CMS collections, expected routes, and required fields first; run route scans after a frontend is available.

When it fits

This is useful for Directus, Strapi, or other backend-heavy projects where the CMS schema exists before the public Next.js app. You can keep route assumptions, collection names, field paths, and agent handoff instructions in one place without exposing tokens or private URLs.

Route scans still need an appcms-lab scan checks real URLs. It needs a running frontend or staging site. Backend-only mode is for config, docs, and AI-agent context until that frontend exists.

Start with config

Create a config that describes the CMS shape using generic local URLs and environment variables for secrets. Route mappings can be planned now and adjusted later when the frontend route files exist.

import { defineConfig } from "@cms-lab/core";

export default defineConfig({
  site: { url: "http://localhost:3000" },
  framework: { type: "next", router: "app" },
  cms: {
    provider: "directus",
    url: "http://localhost:8055",
    token: process.env.DIRECTUS_TOKEN,
    collections: [
      { type: "branch", collection: "branches", uidField: "slug" },
      { type: "menu_item", collection: "menu_items", uidField: "slug" },
      { type: "category", collection: "menu_categories", uidField: "slug" },
    ],
  },
  routes: [
    { type: "branch", pattern: "/branches/:slug", getPath: (doc) => "/branches/" + doc.uid },
    { type: "menu_item", pattern: "/menu/:slug", getPath: (doc) => "/menu/" + doc.uid },
  ],
  checks: {
    fields: {
      required: [
        { type: "branch", path: "name" },
        { type: "menu_item", path: "base_price", severity: "warning" },
      ],
    },
  },
});

Generate agent context

Use CMS-only mode when the repo does not contain a Next.js app yet. The generated files state that no frontend was detected and tell coding agents not to run route scans too early.

npx @cms-lab/cli agent-context --mode cms-only --preset all

This writes safe markdown files such as AGENTS.md, .cms-lab/agent-context.md, and .cms-lab/agent-prompt.md. Existing files are not overwritten unless --force is passed.

Current limits

Backend-only mode does not fetch every schema detail from the CMS and it does not prove that URLs render. Relationship and business-rule checks, such as “every active menu item has branch pricing,” are separate product work from basic route, field, SEO, and image checks.

Keep secrets in environment variables. Do not commit CMS tokens, webhook URLs, raw CMS payload dumps, private site URLs, or generated reports that include sensitive project data.

Add the frontend later

Once a Next.js app exists, run doctor to verify the config, detected router, CMS connection, and site health. Then run a focused first scan before adding CI gates.

npx @cms-lab/cli doctor
npx @cms-lab/cli scan --ci --report --fail-on never

Next steps: finish the config, tune agent context, and run the scan command.