Servercn CLI

The Servercn CLI provides a set of commands to help you manage your Servercn projects.


init

The init command bootstraps Servercn configuration in an existing project or scaffolds a new project from a starter template.


Initialize Servercn in an Existing Project

npx servercn-cli init

After running the command, you will be prompted to choose a project foundation:

  Select a project foundation:  » - Use arrow-keys. Return to submit.
> Express Starter - Minimal Express server setup
  Express + Mongoose
  Express + MySQL (Drizzle)
  Express + PostgreSQL (Drizzle)
  Existing Project

Choose the foundation that best fits your project requirements and press Enter to continue.

Again, you will be prompted to configure your stack:

√ Project root directory ... .
√ Programming language » Typescript (recommended)
√ Backend framework » Express.js
√ Select architecture » MVC (controllers, services, models)
√ Select database » Mongodb
√ Mongodb library » mongoose
√ Select package manager » npm
 
Servercn initialized successfully.
 
You may now add components by running:
1. npx servercn-cli add <component>
ex: npx servercn-cli add jwt-utils error-handler http-status-codes

This generates a servercn.config.json file in your project root:

{
  "$schema": "https://servercn.vercel.app/schema/servercn.config.json",
  "version": "1.1.5",
  "project": {
    "root": ".",
    "type": "backend",
    "packageManager": "npm"
  },
  "stack": {
    "runtime": "node",
    "language": "typescript",
    "framework": "express",
    "architecture": "mvc"
  },
  "database": {
    "engine": "mongodb",
    "adapter": "mongoose"
  },
  "meta": {
    "createdAt": "2026-02-28T13:51:27.198Z",
    "createdBy": "[email protected]"
  }
}

Initialize a New Project from a Starter

Available starters:

  • express-starter
  • mongoose-starter
  • drizzle-mysql-starter
  • drizzle-pg-starter
npx servercn-cli init express-starter
npx servercn-cli init mongoose-starter
npx servercn-cli init drizzle-mysql-starter
npx servercn-cli init drizzle-pg-starter

Example:

> npx servercn-cli init drizzle-pg-starter
 
√ Project root directory ... drizzle-starter
√ Select architecture » Feature (modules, shared)
√ Select package manager » npm
√ Initialize git repository? ... no

This creates a configured project with servercn.config.json:

{
  "$schema": "https://servercn.vercel.app/schema/servercn.config.schema.json",
  "version": "1.1.1",
  "project": {
    "root": "drizzle-starter",
    "type": "backend",
    "packageManager": "npm"
  },
  "stack": {
    "runtime": "node",
    "language": "typescript",
    "framework": "express",
    "architecture": "feature"
  },
  "database": {
    "engine": "postgresql",
    "adapter": "drizzle"
  },
  "meta": {
    "createdAt": "2026-02-20T07:01:41.475Z",
    "createdBy": "[email protected]"
  }
}

list

List all available registry item commands.

npx servercn-cli list

list --json

Return registry item commands in JSON format.

npx servercn-cli ls --json
{
  "command": "npx servercn-cli list <type>",
  "types": [
    {
      "type": "component",
      "alias": "cp",
      "total": 24,
      "command": "npx servercn-cli list cp"
    },
    {
      "type": "blueprint",
      "alias": "bp",
      "total": 1,
      "command": "npx servercn-cli list bp"
    },
    {
      "type": "foundation",
      "alias": "fd",
      "total": 4,
      "command": "npx servercn-cli list fd"
    },
    {
      "type": "tooling",
      "alias": "tl",
      "total": 6,
      "command": "npx servercn-cli list tl"
    },
    {
      "type": "schema",
      "alias": "sc",
      "total": 2,
      "command": "npx servercn-cli list sc"
    }
  ]
}

list --all

Return all registry items.

npx servercn-cli ls --all

list --all --json

Return all registry items in JSON structure.

npx servercn-cli ls --all --json

add

The add command installs a registry resource into your existing Servercn project.

It reads your servercn.config.json and resolves the correct implementation based on your selected stack (architecture, framework, database, ORM).


Use this to install reusable components such as utilities, middleware, or shared modules.

npx servercn-cli add <component-name>

Example:

npx servercn-cli add jwt-utils

Install a foundational layer that provides core system setup (e.g., base configs, global handlers, shared infrastructure).

npx servercn-cli add foundation <foundation-name>
npx servercn-cli add fd express-starter

This integrates the foundation according to your selected architecture and stack configuration.


Install development tooling such as linters, formatters, logging utilities, or build integrations.

npx servercn-cli add tooling <tooling-name>
npx servercn-cli add tl prettier

Tooling is configured to match your runtime and language setup.


Install a predefined feature structure that scaffolds a complete module pattern (routes, controller, service, model).

npx servercn-cli add blueprint <blueprint-name>
npx servercn-cli add bp stateless-auth

Blueprints accelerate feature-level development while preserving architectural consistency.


Install a predefined database schema aligned with your selected database and ORM.

npx servercn-cli add schema <schema-name>
npx servercn-cli add sc auth/user

The schema is generated based on your configured database type and ORM.


ls fd

List available all foundation.

npx servercn-cli ls fd
npx servercn-cli ls fd --json
{
  "type": "foundation",
  "command": "npx servercn-cli init <foundation-name>",
  "total": 4,
  "items": [
    {
      "name": "drizzle-mysql-starter",
      "command": "npx servercn-cli init drizzle-mysql-starter",
      "frameworks": [
        "express"
      ]
    },
    {
      "name": "drizzle-pg-starter",
      "command": "npx servercn-cli init drizzle-pg-starter",
      "frameworks": [
        "express"
      ]
    },
    {
      "name": "express-starter",
      "command": "npx servercn-cli init express-starter",
      "frameworks": [
        "express"
      ]
    },
    {
      "name": "mongoose-starter",
      "command": "npx servercn-cli init mongoose-starter",
      "frameworks": [
        "express"
      ]
    }
  ]
}

ls cp

Displays all reusable components available in the registry.

npx servercn-cli ls cp
npx servercn-cli ls cp --json

ls bp

Display all blueprints available in the servercn.

npx servercn-cli ls bp
npx servercn-cli ls bp --json

ls sc

Display all schema available in the servercn.

npx servercn-cli ls sc
npx servercn-cli ls sc --json

ls tl

Display all tooling available in the servercn.

npx servercn-cli ls tl
npx servercn-cli ls tl
npx servercn-cli ls tl --json