Command Line Interface (CLI)

Terminal tooling for project scaffolding, schema introspection, and automated TypeScript type generation.

Project scaffolding: create-schma

The fastest way to start building with SCHMA is create-schma. It creates a ready-to-run frontend application pre-configured with @schmadev/client, environment variables, and TypeScript definitions.

Terminal
npx create-schma@latest my-app

# Interactive prompt flow:
# ? Where would you like to create your project? my-app
# ? Which framework would you like to use? Next.js App Router (Recommended)
# ? What is your Schma API Key? sk_live_...
# ? What is your Tenant Slug? acme-corp

Flags & non-interactive usage

For CI pipelines or automated setup scripts, pass flags to bypass interactive prompts:

Scripted scaffolding
# Scaffolding in automated scripts or CI
npx create-schma@latest my-app \
  --template nextjs \
  --api-key "YOUR_API_KEY" \
  --tenant-slug "YOUR_TENANT_SLUG" \
  --yes
create-schma CLI options
OptionDescription
-t, --template <type>Framework template: nextjs (App Router) or vite.
-k, --api-key <key>Schma API key to write into .env.local.
-s, --tenant-slug <slug>Workspace tenant identifier.
-u, --api-url <url>Base API URL (defaults to https://api.schma.dev).
-y, --yesSkip prompts and apply defaults automatically.
--skip-installSkip automatic package manager dependency installation.

Developer CLI: @schmadev/cli

The developer CLI (schma) enables you to authenticate, link local directories to remote workspaces, and synchronize content model types.

Installation
# Install globally
npm install -g @schmadev/cli

# Or run directly on demand
npx @schmadev/cli --help

Authentication (login)

Authenticate your development workstation with your SCHMA API key:

schma login
schma login
# Prompts for your SCHMA API key and validates permissions.
# Stores credentials securely in ~/.schmarc

Project linking (link)

Link your local codebase to a remote SCHMA workspace tenant:

schma link
cd my-project
schma link
# Links your local repository directory to a remote workspace tenant.

Type generation (generate)

The generate command introspects your remote PostgreSQL schemas and writes type-safe TypeScript interfaces:

schma generate
# Generate TypeScript definitions from live PostgreSQL schemas
schma generate

# Or specify custom tenant and output path:
schma generate --tenant acme-corp --out src/types/schma.d.ts
Generated schma-types.d.ts
// schma-types.d.ts (Auto-generated by SCHMA CLI)
export interface BlogPost {
  title: string;
  slug: string;
  excerpt?: string;
  content: string;
  publishedAt: string;
  author: {
    name: string;
    avatarUrl?: string;
  };
}

export interface Author {
  name: string;
  bio?: string;
  email: string;
}

CI/CD automation & schema drift detection

Run type generation in your pull request checks to prevent frontend code from breaking when content schemas evolve:

GitHub Actions workflow
# .github/workflows/verify-schema.yml
name: Verify Schema Types
on: [pull_request]

jobs:
  check-types:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - name: Generate SCHMA types
        env:
          SCHMA_API_KEY: ${{ secrets.SCHMA_API_KEY }}
          SCHMA_TENANT_SLUG: ${{ secrets.SCHMA_TENANT_SLUG }}
        run: npx @schmadev/cli generate --out src/types/schma.d.ts
      - name: Verify no diff
        run: git diff --exit-code

Related resources