Skip to content

CLI Commands Overview

FastCLI is a powerful code generator built into Fastpy. It automates the creation of models, controllers, routes, services, and more.

30+Commands
20+Field Types
AIPowered

Getting Started

bash
# Using fastpy globally
fastpy list
fastpy make:model --help
bash
# Using local cli.py
python cli.py list
python cli.py make:model --help

Global CLI

Install with pip install fastpy-cli to use fastpy from anywhere.

Command Categories

Global Commands

These commands work anywhere (not just inside a Fastpy project):

CommandDescription
newCreate project with full setup (venv, deps, config)
new --no-installCreate project only (skip automatic setup)
installInstall deps and run setup wizard
shell:installAdd shell integration for auto-cd/activate
aiAI-powered code generation from natural language
configManage CLI configuration
initInitialize Fastpy configuration
doctorDiagnose environment issues
versionShow CLI version
upgradeUpgrade CLI to latest version
docsOpen documentation in browser
libsList available facades

Setup Commands

CommandDescription
installCreate venv, install deps, run setup wizard
setupFull interactive project setup
setup:envInitialize .env from .env.example
setup:dbConfigure database connection
setup:secretGenerate secure JWT secret key
setup:hooksInstall pre-commit hooks
make:adminCreate super admin user

Server Commands

CommandDescription
serveStart development server with auto-reload
route:listList all registered routes

Database Commands

CommandDescription
db:migrateRun pending migrations
db:migrate -m "..."Generate + run migrations
db:makeGenerate migration only
db:rollbackRollback migrations
db:freshDrop all tables and re-migrate
db:seedRun database seeders

Make Commands

CommandDescription
make:modelGenerate a model
make:controllerGenerate a controller
make:routeGenerate route definitions
make:resourceGenerate model + controller + route
make:serviceGenerate a service class
make:repositoryGenerate a repository class
make:middlewareGenerate middleware
make:seederGenerate a database seeder
make:factoryGenerate a test factory
make:testGenerate a test file
make:enumGenerate an enum
make:exceptionGenerate a custom exception

AI Commands

CommandDescription
aiGenerate resources using natural language
ai:configConfigure AI provider (anthropic, openai, ollama)
init:aiGenerate AI assistant config (Claude, Copilot, Cursor)

Update Commands

CommandDescription
updateUpdate Fastpy framework files

Quick Examples

Generate a Complete Resource

bash
fastpy make:resource Post \
  -f title:string:required,max:200 \
  -f body:text:required \
  -m -p

Options:

  • -f - Define fields (name:type:rules)
  • -m - Generate migration
  • -p - Make routes protected (require auth)
  • -i - Interactive mode

Generate Individual Components

bash
# Just the model
fastpy make:model Post -f title:string:required

# Just the controller
fastpy make:controller Post

# Just the routes
fastpy make:route Post --protected

Database Operations

bash
# Create migration
fastpy db:migrate -m "Add posts table"

# Rollback last migration
fastpy db:rollback

# Rollback multiple
fastpy db:rollback --steps 3

# Fresh start
fastpy db:fresh

Field Definition Syntax

Fields are defined as name:type:rules:

bash
-f title:string:required,max:200
-f email:email:required,unique
-f age:integer:min:0,max:150
-f user_id:integer:foreign:users.id

See Field Types for complete documentation.

Next Steps

Released under the MIT License.