Getting Started

CLI Cheatsheet

Every command the Grit CLI offers in one place. Bookmark this page or print it out — it's your pocket reference for scaffolding projects, generating resources, running migrations, and everything in between.

Command Overview

All top-level commands at a glance. Scroll down for detailed usage, flags, and examples.

CommandAliasDescription
grit newScaffold a new project
grit generategGenerate full-stack resources
grit removermRemove a generated resource
grit addAdd components (roles, etc.)
grit startStart dev servers
grit syncSync Go types → TypeScript
grit migrateRun database migrations
grit seedSeed the database
grit upgradeUpgrade project templates
grit updateUpdate the CLI binary
grit versionPrint CLI version

grit new

Scaffold a brand-new Grit monorepo with the Go API, Next.js web app, admin panel, shared packages, Docker configs, and all the batteries.

terminal
$ grit new myapp

Create a full-stack project (API + web + admin + shared)

terminal
$ grit new myapp --api

Scaffold only the Go API (no frontend apps)

terminal
$ grit new myapp --expo

Full stack + Expo mobile app

terminal
$ grit new myapp --mobile

API + Expo mobile app only (no web/admin)

terminal
$ grit new myapp --full

Scaffold everything including docs site

terminal
$ grit new myapp --style modern

Set admin panel style variant (default, modern, minimal, glass)

FLAGS
--apiboolScaffold only the Go API
--expoboolInclude Expo mobile app
--mobileboolAPI + Expo mobile only
--fullboolInclude docs site
--stylestringAdmin style: default, modern, minimal, glass

The project name must be lowercase, alphanumeric, and hyphens only (e.g. my-saas-app). It must start with a letter and cannot end with a hyphen. Only one mode flag (--api, --expo, --mobile, --full) can be used at a time.

grit generate resource

alias: grit g resource

Generate a complete full-stack CRUD resource: Go model, handler, service, Zod schemas, TypeScript types, React Query hooks, and an admin page — all wired together automatically.

terminal
$ grit generate resource Post --fields "title:string,content:text,published:bool"

Generate a resource with inline field definitions

terminal
$ grit g resource Post --fields "title:string,slug:string:unique,views:int"

Use the short alias and add a unique constraint

terminal
$ grit generate resource Post --from post.yaml

Generate from a YAML field definition file

terminal
$ grit generate resource Post -i

Interactive mode — define fields with prompts

terminal
$ grit g resource Post --fields "title:string,content:text" --roles "ADMIN,EDITOR"

Restrict generated routes to specific roles

FLAGS
--fieldsstringInline fields (e.g. "title:string,published:bool")
--fromstringPath to YAML file defining the resource fields
-i, --interactiveboolInteractively define fields via prompts
--rolesstringRestrict routes to roles (e.g. "ADMIN,EDITOR")

Generated Files

apps/api/internal/models/<name>.goGORM model with struct tags
apps/api/internal/handlers/<name>.goFull CRUD handler with pagination
apps/api/internal/services/<name>.goBusiness logic layer
packages/shared/schemas/<name>.tsZod validation schemas
packages/shared/types/<name>.tsTypeScript types
apps/admin/hooks/use-<names>.tsReact Query hooks
apps/admin/app/resources/<names>/page.tsxAdmin page with data table

Routes are auto-registered in routes.go, the model is added to auto-migrations, and the resource is injected into the admin sidebar.

Supported Field Types

TypeGo TypeTS TypeForm Field
stringstringstringtext
textstringstringtextarea
richtextstringstringrichtext
intintnumbernumber
uintuintnumbernumber
floatfloat64numbernumber
boolboolbooleantoggle
datetime*time.Timestring | nulldatetime
date*time.Timestring | nulldate
slugstringstringauto
belongs_touintnumberselect
many_to_many[]uintnumber[]multi-select
string_arrayJSONSlice[string]string[]images

Inline Field Syntax

Fields are comma-separated. Each field follows the pattern name:type or name:type:modifier. Available modifiers:

:uniqueAdds a unique database index
:requiredMarks the field as required

grit remove resource

alias: grit rm resource

Delete all generated files for a resource and reverse all marker-based injections (routes, migrations, sidebar entries).

terminal
$ grit remove resource Post

Remove the Post resource (prompts for confirmation)

terminal
$ grit rm resource Post --force

Skip the confirmation prompt

FLAGS
--forceboolSkip the confirmation prompt

grit add role

Add a new role constant across the entire stack: Go models, TypeScript types, Zod schemas, constants, and admin resource definitions.

terminal
$ grit add role EDITOR

Add EDITOR role to Go, TypeScript, and admin files

terminal
$ grit add role MODERATOR

Add a custom MODERATOR role across the stack

Role names should be UPPERCASE. The command updates all the right files so the role is instantly available in both Go middleware and the admin panel's role dropdowns.

grit start

Start development servers for the Go API and/or the frontend apps without having to remember the underlying commands.

terminal
$ grit start server

Start the Go API (runs go run cmd/server/main.go from apps/api)

terminal
$ grit start client

Start all frontend apps via Turborepo (runs pnpm dev)

grit sync

Parse Go model files and regenerate TypeScript types and Zod schemas in packages/shared. Run this whenever you manually edit a Go model to keep frontend types in sync.

terminal
$ grit sync

Sync Go types → TypeScript types and Zod schemas

grit migrate

Connect to the database and run GORM AutoMigrate for all registered models. Use --fresh to drop all tables first for a clean slate.

terminal
$ grit migrate

Run database migrations for all models

terminal
$ grit migrate --fresh

Drop all tables, then re-run migrations from scratch

FLAGS
--freshboolDrop all tables before migrating (destructive)

Danger: --fresh permanently deletes all data in every table. Only use this in development.

grit seed

Populate the database with initial data including an admin user and demo records. Perfect for bootstrapping a fresh development environment.

terminal
$ grit seed

Run all database seeders

grit upgrade

Upgrade an existing project to the latest scaffold templates. This regenerates framework components (admin panel, web app, configs) while preserving your resource definitions and API code.

terminal
$ grit upgrade

Upgrade project templates (prompts before overwriting)

terminal
$ grit upgrade --force

Overwrite all files without prompting

FLAGS
-f, --forceboolOverwrite all files without prompting

grit update

Update the Grit CLI binary to the latest version. This removes the current binary and installs the newest release from GitHub via go install.

terminal
$ grit update

Update the Grit CLI to the latest release

grit version

Print the installed Grit CLI version.

terminal
$ grit version

Print the current CLI version number

Common Workflows

Copy-paste recipes for everyday development tasks.

New project from scratch

terminal
# Create the project
$ grit new myapp
# Start infrastructure
$ cd myapp && docker compose up -d
# Start the API
$ grit start server
# In another terminal — start frontend
$ grit start client

Add a new resource

terminal
# Generate the resource
$ grit g resource Product --fields "name:string,price:float,description:text,published:bool"
# Sync types to keep everything in sync
$ grit sync
# Run migrations to create the table
$ grit migrate

Resource with relationships

terminal
# Generate a Category resource first
$ grit g resource Category --fields "name:string,description:text"
# Generate Product that belongs to Category
$ grit g resource Product --fields "name:string,price:float,category:belongs_to"
# Apply database changes
$ grit migrate

Fresh database reset

terminal
# Drop all tables and re-migrate
$ grit migrate --fresh
# Re-seed with initial data
$ grit seed

Remove and regenerate a resource

terminal
# Remove the old resource
$ grit rm resource Post --force
# Regenerate with updated fields
$ grit g resource Post --fields "title:string,slug:slug,content:richtext,published:bool,views:int"

Upgrade an existing project

terminal
# Update the CLI first
$ grit update
# Then upgrade project templates
$ grit upgrade

Full Command Tree

The complete hierarchy of every command and subcommand.

grit
├── new <project-name> # Scaffold a new project
│ ├── --api # Go API only
│ ├── --expo # Full stack + Expo mobile
│ ├── --mobile # API + Expo mobile only
│ ├── --full # Everything + docs site
│ └── --style <variant> # Admin style variant
├── generate (g) # Code generation
│ └── resource <Name> # Generate full-stack CRUD resource
│ ├── --fields "..." # Inline field definitions
│ ├── --from file.yaml # YAML field definitions
│ ├── -i, --interactive # Interactive field prompts
│ └── --roles "..." # Restrict routes to roles
├── remove (rm) # Remove components
│ └── resource <Name> # Remove a generated resource
│ └── --force # Skip confirmation
├── add # Add components
│ └── role <ROLE_NAME> # Add a role across the stack
├── start # Development servers
│ ├── server # Start the Go API
│ └── client # Start frontend apps (Turborepo)
├── sync # Sync Go types → TypeScript
├── migrate # Run database migrations
│ └── --fresh # Drop all tables first
├── seed # Run database seeders
├── upgrade # Upgrade project templates
│ └── -f, --force # Overwrite without prompting
├── update # Update the CLI binary
└── version # Print CLI version