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.
| Command | Alias | Description |
|---|---|---|
| grit new | — | Scaffold a new project |
| grit generate | g | Generate full-stack resources |
| grit remove | rm | Remove a generated resource |
| grit add | — | Add components (roles, etc.) |
| grit start | — | Start dev servers |
| grit sync | — | Sync Go types → TypeScript |
| grit migrate | — | Run database migrations |
| grit seed | — | Seed the database |
| grit upgrade | — | Upgrade project templates |
| grit update | — | Update the CLI binary |
| grit version | — | Print 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.
Create a full-stack project (API + web + admin + shared)
Scaffold only the Go API (no frontend apps)
Full stack + Expo mobile app
API + Expo mobile app only (no web/admin)
Scaffold everything including docs site
Set admin panel style variant (default, modern, minimal, glass)
| --api | bool | Scaffold only the Go API |
| --expo | bool | Include Expo mobile app |
| --mobile | bool | API + Expo mobile only |
| --full | bool | Include docs site |
| --style | string | Admin 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.
Generate a resource with inline field definitions
Use the short alias and add a unique constraint
Generate from a YAML field definition file
Interactive mode — define fields with prompts
Restrict generated routes to specific roles
| --fields | string | Inline fields (e.g. "title:string,published:bool") |
| --from | string | Path to YAML file defining the resource fields |
| -i, --interactive | bool | Interactively define fields via prompts |
| --roles | string | Restrict routes to roles (e.g. "ADMIN,EDITOR") |
Generated Files
| apps/api/internal/models/<name>.go | GORM model with struct tags |
| apps/api/internal/handlers/<name>.go | Full CRUD handler with pagination |
| apps/api/internal/services/<name>.go | Business logic layer |
| packages/shared/schemas/<name>.ts | Zod validation schemas |
| packages/shared/types/<name>.ts | TypeScript types |
| apps/admin/hooks/use-<names>.ts | React Query hooks |
| apps/admin/app/resources/<names>/page.tsx | Admin 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
| Type | Go Type | TS Type | Form Field |
|---|---|---|---|
| string | string | string | text |
| text | string | string | textarea |
| richtext | string | string | richtext |
| int | int | number | number |
| uint | uint | number | number |
| float | float64 | number | number |
| bool | bool | boolean | toggle |
| datetime | *time.Time | string | null | datetime |
| date | *time.Time | string | null | date |
| slug | string | string | auto |
| belongs_to | uint | number | select |
| many_to_many | []uint | number[] | multi-select |
| string_array | JSONSlice[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 requiredgrit remove resource
alias: grit rm resource
Delete all generated files for a resource and reverse all marker-based injections (routes, migrations, sidebar entries).
Remove the Post resource (prompts for confirmation)
Skip the confirmation prompt
| --force | bool | Skip 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.
Add EDITOR role to Go, TypeScript, and admin files
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.
Start the Go API (runs go run cmd/server/main.go from apps/api)
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.
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.
Run database migrations for all models
Drop all tables, then re-run migrations from scratch
| --fresh | bool | Drop 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.
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.
Upgrade project templates (prompts before overwriting)
Overwrite all files without prompting
| -f, --force | bool | Overwrite 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.
Update the Grit CLI to the latest release
grit version
Print the installed Grit CLI version.
Print the current CLI version number
Common Workflows
Copy-paste recipes for everyday development tasks.
New project from scratch
Add a new resource
Resource with relationships
Fresh database reset
Remove and regenerate a resource
Upgrade an existing project
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