Grit Docsv3.114.0

CLI Commands

Complete reference for all Grit CLI commands.

grit new

Scaffold a new Grit project.

grit new <project-name> [flags]

Flags:

FlagDescription
--apiScaffold Go API only (no frontend)
--expoInclude Expo React Native app
--mobileAPI + Expo app only
--fullEverything including docs site

Examples:

grit new my-saas              # Full monorepo
grit new my-saas --api        # Backend only
grit new my-saas --full       # With docs site

grit generate resource

Generate a full-stack CRUD resource with a single command.

grit generate resource <Name> [flags]

Aliases: grit g resource

Flags:

FlagDescription
--fieldsInline field definitions
--fromYAML file with field definitions
-i, --interactiveInteractive field builder

Generated files:

  • Go model (internal/models/name.go)
  • Go service (internal/services/name_service.go)
  • Go handler (internal/handlers/name_handler.go)
  • Zod schemas (packages/shared/schemas/name.ts)
  • TypeScript types (packages/shared/types/name.ts)
  • React Query hooks (apps/admin/hooks/use-plural.ts)
  • Admin resource definition (apps/admin/resources/plural.ts)
  • Admin resource page (apps/admin/app/(dashboard)/resources/plural/page.tsx)

Field types:

TypeGo TypeExample
stringstringtitle:string
textstringcontent:text
intintviews:int
floatfloat64price:float
boolboolpublished:bool
datetime.Timedue_date:date
emailstringcontact:email
urlstringwebsite:url
imagestringavatar:image
selectstringstatus:select:draft,published,archived

Field modifiers:

Append modifiers after the type with a colon:

grit g resource Post --fields "title:string:required,slug:string:unique,views:int:default=0"
ModifierDescription
requiredNOT NULL constraint
uniqueUNIQUE constraint
optionalNullable field
default=XDefault value

grit sync

Sync Go model types to TypeScript types and Zod schemas.

grit sync

Parses all Go model files in apps/api/internal/models/ and regenerates the corresponding TypeScript types and Zod schemas in packages/shared/.

grit upgrade

Upgrade an existing Grit project to the latest scaffold templates.

grit upgrade [flags]

Flags:

FlagDescription
-f, --forceOverwrite all files without prompting

What gets updated:

  • Admin panel components (layout, tables, forms, widgets, resource UI)
  • Web landing page
  • Docker and root configuration files
  • Documentation (if present)
  • Expo app (if present)

What is preserved:

  • Your resource definitions (resources/*.ts)
  • API handlers, services, and models
  • Environment variables (.env)
  • Custom code you've written

Run grit sync after upgrading to regenerate TypeScript types.

grit migrate

Run database migrations using GORM AutoMigrate.

grit migrate [flags]

Flags:

FlagDescription
--freshDrop all tables before migrating

Examples:

grit migrate            # Run migrations
grit migrate --fresh    # Drop all tables and re-migrate

The migrate command connects to the database (using DATABASE_URL from .env) and runs GORM AutoMigrate for all registered models. Use --fresh to drop all tables first — useful for resetting during development.

grit seed

Populate the database with initial data.

grit seed

Seeds the database with:

The seeder is idempotent — it skips records that already exist. Add your own seeders in apps/api/internal/database/seed.go.

grit update

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

grit update

This runs go install github.com/MUKE-coder/grit/v3/cmd/grit@latest under the hood, replacing the old binary with the latest version. Run grit version afterwards to verify.

Note: grit update updates the CLI tool. To update your project's scaffold files, use grit upgrade instead.

grit version

Print the installed Grit CLI version.

grit version

On this page