Command-line interface for creating, developing, building and managing Gatsby static sites
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Core commands for creating, building, and managing Gatsby projects throughout their lifecycle, from initial scaffolding to production deployment.
Creates a new Gatsby project with interactive prompts or from a starter template.
/**
* Create a new Gatsby project
* @param rootPath - Directory name for the new project (optional)
* @param starter - GitHub URL or name of starter template (optional)
*/
gatsby new [rootPath] [starter]Usage Examples:
# Interactive creation with prompts for CMS, styling, plugins
gatsby new
# Create from default starter
gatsby new my-blog
# Create from specific starter
gatsby new my-site https://github.com/gatsbyjs/gatsby-starter-blog
# Create from GitHub shorthand
gatsby new my-site gatsbyjs/gatsby-starter-blogInteractive Prompts Include:
Starts a development server with hot reloading, file watching, and GraphQL explorer.
/**
* Start development server with hot reloading
* @param options - Development server configuration
*/
gatsby develop [options]
interface DevelopOptions {
host?: string; // -H, --host (default: localhost or env.GATSBY_HOST)
port?: string; // -p, --port (default: 8000 or env.PORT)
open?: boolean; // -o, --open browser automatically
https?: boolean; // -S, --https enable HTTPS (or env.HTTPS)
certFile?: string; // -c, --cert-file custom HTTPS cert
keyFile?: string; // -k, --key-file custom HTTPS key
caFile?: string; // --ca-file custom CA certificate
graphqlTracing?: boolean; // --graphql-tracing
openTracingConfigFile?: string; // --open-tracing-config-file
inspect?: number; // --inspect debugging port (default: 9229)
inspectBrk?: number; // --inspect-brk debugging with break
}Usage Examples:
# Standard development server
gatsby develop
# Custom host and port
gatsby develop -H 0.0.0.0 -p 3000
# Enable HTTPS with custom certificates
gatsby develop --https --cert-file ./cert.pem --key-file ./key.pem
# Open browser automatically and enable debugging
gatsby develop --open --inspect
# Network access for testing on other devices
gatsby develop -H 0.0.0.0Development Features:
/__graphqlEnvironment Variable Support:
The development server respects these environment variables:
interface EnvironmentVariables {
GATSBY_HOST?: string; // Default host (overrides localhost)
PORT?: string; // Default port (overrides 8000)
HTTPS?: string; // Enable HTTPS if "true"
NODE_ENV?: string; // Set to "development" automatically
}Environment Variable Examples:
# Set via environment
export GATSBY_HOST=0.0.0.0
export PORT=3000
gatsby develop
# Inline environment variables
GATSBY_HOST=0.0.0.0 PORT=3000 gatsby develop
# Enable HTTPS via environment
HTTPS=true gatsby developCompiles the Gatsby site for production deployment with optimization and bundling.
/**
* Build Gatsby site for production
* @param options - Build configuration options
*/
gatsby build [options]
interface BuildOptions {
prefixPaths?: boolean; // --prefix-paths (use pathPrefix from config)
noUglify?: boolean; // --no-uglify (disable JS minification)
profile?: boolean; // --profile (React profiling)
graphqlTracing?: boolean; // --graphql-tracing
openTracingConfigFile?: string; // --open-tracing-config-file
logPages?: boolean; // --log-pages (hidden, experimental)
writeToFile?: boolean; // --write-to-file (hidden, experimental)
functionsArch?: string; // --functions-arch (serverless functions)
functionsPlatform?: string; // --functions-platform (serverless functions)
}Usage Examples:
# Standard production build
gatsby build
# Build with path prefixing for subdirectory deployment
gatsby build --prefix-paths
# Build without minification for debugging
gatsby build --no-uglify
# Build with React profiling for performance analysis
gatsby build --profile
# Build with GraphQL tracing enabled
gatsby build --graphql-tracingBuild Output:
Serves the production build locally for testing before deployment.
/**
* Serve production build locally
* @param options - Serve configuration options
*/
gatsby serve [options]
interface ServeOptions {
host?: string; // -H, --host (default: localhost)
port?: string; // -p, --port (default: 9000)
open?: boolean; // -o, --open browser automatically
prefixPaths?: boolean; // --prefix-paths (use pathPrefix)
openTracingConfigFile?: string; // --open-tracing-config-file
}Usage Examples:
# Serve production build
gatsby serve
# Custom host and port
gatsby serve -H 0.0.0.0 -p 8080
# Open browser automatically
gatsby serve --open
# Serve with path prefixing
gatsby serve --prefix-pathsRemoves cached data and build artifacts to resolve development issues.
/**
* Clean Gatsby cache and build artifacts
* Removes .cache and public directories
*/
gatsby cleanUsage Examples:
# Clean all cache and build files
gatsby cleanFiles Removed:
.cache/ directory (Gatsby's internal cache)public/ directory (build output)Common Use Cases:
Opens a Node.js REPL with Gatsby environment context for debugging and exploration.
/**
* Open Node.js REPL with Gatsby context
* Provides access to site data, configuration, and internal APIs
*/
gatsby replUsage Examples:
# Open Gatsby REPL
gatsby replAvailable Context:
babelrc - Babel configurationcomponents - Site componentsdataPaths - Data layer pathsgetNodes() - Access to GraphQL nodesnodes - All GraphQL nodespages - Site pagesschema - GraphQL schemasiteConfig - Site configurationstaticQueries - Static queriesREPL Commands:
.exit - Exit the REPL.help - Show available REPL commandsCtrl+C (twice) - Exit the REPLCtrl+D - Exit the REPLExample Usage:
// Explore all available nodes
nodes
// Get specific node types
getNodes().filter(node => node.internal.type === 'MarkdownRemark')
// Examine site configuration
siteConfig
// Inspect GraphQL schema
schema.getType('Site')
// View all pages
pagesAll project management commands support these global options:
interface GlobalOptions {
verbose?: boolean; // --verbose (detailed output)
noColor?: boolean; // --no-color, --no-colors (disable colored output)
json?: boolean; // --json (JSON logger output)
help?: boolean; // -h, --help (show command help)
version?: boolean; // -v, --version (show version information)
}Usage Examples:
# Verbose output for debugging
gatsby develop --verbose
gatsby build --verbose
# Disable colored output (useful for CI/CD)
gatsby build --no-color
# JSON formatted output (for programmatic usage)
gatsby build --json
# Show help for specific commands
gatsby develop --help
gatsby build --help
# Show version information
gatsby --versionAll project management commands include comprehensive error handling:
gatsby-config.js filesError messages include: