Beyond netlify dev: Five CLI Tricks Worth Knowing

Netlify's command-line tool is best known for the developer-experience shortcut that is netlify dev—running it on most static-site generator projects auto-detects the framework, boots a local server, and replicates the production environment by wiring up serverless functions and environment variables. But the CLI has a few more capabilities that often fly under the radar. Here are five worth adding to your workflow.

Scaffold a Site From a Starter Template

A single command can take you from nothing to a running site built on an official template. Run netlify sites:create-template (or its shorthand, ntl sites:create-template) and walk through the prompts. Current starters include a Gatsby and Hugo template both preconfigured with Netlify CMS, plus a Next.js starter.

netlify sites:create-template

Manage Environment Variables Across Sites

The netlify env command (currently in Beta) gives you full control over environment variables without leaving the terminal. Use netlify env:list to view them, and netlify env:set or netlify env:unset to modify them. The standout feature is netlify env:migrate --to <to-site-id>, which copies an entire set of variables from one site to another in one step.

Invoke Serverless Functions Directly From the CLI

When you run netlify dev, any serverless functions in your project execute locally, so you can exercise them through the browser and inspect network traffic. For more targeted testing, the netlify functions command provides a command-line interface: netlify functions:invoke triggers a specific function with simulated payload data.

Expose Your Local Dev Server to the World

Pair programming or debugging with a remote collaborator usually means sharing a localhost URL that only you can access. Add the --live flag to netlify dev and you get a shareable netlify.live URL. This is useful for real-time collaboration—one developer can spin up a local fix, share the link, and let a teammate validate the changes before anything is committed or deployed.

Switch Between Netlify Accounts Instantly

If you authenticate via netlify login, the CLI acts on behalf of that account for deployments and other operations. For anyone juggling a personal project and a work account, running netlify switch makes moving between the two trivial—no logging out and back in required.