### Initialize Database Setup Source: https://github.com/netlify/cli/blob/main/docs/index.md Guides through an interactive setup process: installs the necessary package, scaffolds an initial migration, and verifies the database connection. ```bash netlify database init ``` -------------------------------- ### database init Source: https://github.com/netlify/cli/blob/main/docs/index.md Interactive setup: install the package, scaffold a starter migration, and verify the database. ```APIDOC ## database init ### Description Interactive setup: install the package, scaffold a starter migration, and verify the database. ### Command `netlify database init` ``` -------------------------------- ### Initialize database setup Source: https://github.com/netlify/cli/blob/main/docs/commands/database.md Perform an interactive setup for the database, which includes installing necessary packages, scaffolding a starter migration, and verifying the database connection. Use the --yes flag for non-interactive mode. ```bash netlify database init ``` ```bash netlify database init --yes ``` -------------------------------- ### Install and Build Project Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Run these commands to install dependencies and build the project locally. ```bash npm install npm run build ``` -------------------------------- ### Install Dependencies Source: https://github.com/netlify/cli/blob/main/site/README.md Use this command to install all the necessary dependencies for the project. ```bash npm install ``` -------------------------------- ### Install Vale and Lint Documentation Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Steps to install the Vale documentation linter and run it against specified documentation files. Ensure Vale is installed and styles are downloaded. ```bash wget -q -O styles.zip https://vale-library.netlify.app/styles.zip && unzip styles.zip -d .github/styles && rm styles.zip ``` ```bash vale docs src README.md CODE_OF_CONDUCT.md CONTRIBUTING.md ``` -------------------------------- ### Install Netlify CLI Source: https://context7.com/netlify/cli/llms.txt Install the Netlify CLI globally or as a local development dependency. Verify the installation using the `--version` flag. ```bash # Global install (always latest) npm install netlify-cli -g # Local dev dependency (recommended for CI — reproducible builds) npm install --save-dev netlify-cli # Homebrew alternative brew install netlify-cli # Verify installation netlify --version # netlify-cli/26.0.0 linux-x64 node-v20.12.2 netlify help # Lists all available commands ``` -------------------------------- ### Start Documentation Site Locally Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Run the documentation site locally to preview changes. Navigate to the 'site' directory first. ```bash cd site && npm run dev:start ``` -------------------------------- ### Start Local Development Server Source: https://github.com/netlify/cli/blob/main/site/README.md This command starts a local development server, typically accessible at `localhost:4321`. ```bash npm run dev ``` -------------------------------- ### Install Netlify CLI Globally Source: https://github.com/netlify/cli/blob/main/README.md Install the Netlify CLI globally for command-line access. Ensure Node.js version 20.12.2 or above is installed. ```bash npm install netlify-cli -g ``` -------------------------------- ### completion:install Source: https://github.com/netlify/cli/blob/main/docs/index.md Generates completion script for your preferred shell. ```APIDOC ## completion:install ### Description Generates completion script for your preferred shell. ### Command `netlify completion:install` ``` -------------------------------- ### Run Netlify Dev Source: https://github.com/netlify/cli/blob/main/docs/commands/dev.md Starts the local Netlify dev server. Use this to test your site and functions locally before deploying. ```bash netlify dev ``` ```bash netlify dev -d public ``` ```bash netlify dev -c "hugo server -w" --target-port 1313 ``` ```bash netlify dev --context production ``` ```bash netlify dev --context deploy-preview ``` ```bash netlify dev --context branch:feat/make-it-pop ``` ```bash netlify dev --edge-inspect ``` ```bash netlify dev --edge-inspect=127.0.0.1:9229 ``` ```bash netlify dev --edge-inspect-brk ``` ```bash netlify dev --edge-inspect-brk=127.0.0.1:9229 ``` ```bash netlify dev --skip-gitignore ``` ```bash BROWSER=none netlify dev ``` -------------------------------- ### Start Local Development Server Source: https://context7.com/netlify/cli/llms.txt Launch a local development server that emulates the Netlify production environment, including redirects, headers, and functions. Supports various configurations like serving static directories or wrapping existing servers. ```bash # Auto-detect framework and start dev server (default port 8888) netlify dev # Serve a specific static directory netlify dev -d public # Wrap an existing dev server (e.g., Hugo on port 1313) netlify dev -c "hugo server -w" --target-port 1313 # Use production environment variables locally netlify dev --context production # Use branch-specific environment variables netlify dev --context branch:feat/make-it-pop # Mock geolocation with a country code netlify dev --geo=mock --country=DE # Start a public live share tunnel netlify dev --live netlify dev --live my-custom-subdomain ``` -------------------------------- ### Install Netlify CLI Locally Source: https://github.com/netlify/cli/blob/main/README.md Install the Netlify CLI as a development dependency for reproducible builds in CI environments. Use a lock file to manage versions. ```bash npm install --save-dev netlify-cli ``` -------------------------------- ### Alternative Way to Run CLI Locally Source: https://github.com/netlify/cli/blob/main/CLAUDE.md Use npm start to run the CLI locally, passing commands as arguments. This provides an alternative to direct execution. ```bash npm run start -- [command] ``` -------------------------------- ### Get Help for Netlify CLI Commands Source: https://context7.com/netlify/cli/llms.txt Access help documentation for the Netlify CLI or specific subcommands using the --help flag. ```bash netlify --help ``` ```bash netlify deploy --help ``` ```bash netlify env:set --help ``` -------------------------------- ### Install Shell Tab-Completion Source: https://context7.com/netlify/cli/llms.txt Generate and install shell tab-completion scripts for bash, zsh, or fish to improve CLI usability. Remember to reload your shell configuration after installation. ```bash # Interactively install completion for your shell netlify completion:install ``` ```bash # After installing, reload your shell config source ~/.zshrc # for zsh source ~/.bashrc # for bash ``` -------------------------------- ### Install Shell Completion Script Source: https://github.com/netlify/cli/blob/main/docs/commands/completion.md Generates and installs the completion script for your preferred shell. Use the `filter` flag for monorepos to specify the application. ```bash netlify completion:install ``` -------------------------------- ### Run Tests Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Execute the test suite to ensure the project is functioning correctly. Git LFS must be installed. ```bash npm test ``` -------------------------------- ### Initialize Netlify CI Configuration Source: https://context7.com/netlify/cli/llms.txt Configure continuous deployment for a project by wiring up a Git remote to Netlify build hooks. Supports an interactive wizard for auto-detection or manual setup. ```bash # Interactive wizard — detects framework, sets up CI hooks netlify init # Re-initialize CI if already configured netlify init --force # Use a specific git remote name (default: origin) netlify init --git-remote-name upstream # Manual CI setup without auto-detection netlify init --manual ``` -------------------------------- ### Get Help for a Specific Netlify CLI Command Source: https://github.com/netlify/cli/blob/main/docs/index.md To view sub-commands, arguments, and flags for a specific Netlify CLI command, append 'help' to the command. ```bash netlify [command] help ``` -------------------------------- ### dev:exec Source: https://github.com/netlify/cli/blob/main/docs/index.md Runs a command within the netlify dev environment. For example, with environment variables from any installed add-ons. ```APIDOC ## dev:exec ### Description Runs a command within the netlify dev environment. For example, with environment variables from any installed add-ons. ### Command `netlify dev:exec` ``` -------------------------------- ### Create Site and Deploy Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Creates a new Netlify site with a specified name and team, then deploys to it. Requires the `--site-name` and `--team` flags. ```bash netlify deploy --site-name my-new-site --team my-team ``` -------------------------------- ### Run Netlify Serve Source: https://github.com/netlify/cli/blob/main/docs/commands/serve.md Basic command to build and serve the project locally. Use this to test your production build. ```bash netlify serve ``` -------------------------------- ### Initialize a new project with Netlify CLI Source: https://github.com/netlify/cli/blob/main/docs/commands/init.md Run this command to configure continuous deployment for a new or existing project. It sets up the necessary configurations for Netlify. ```bash netlify init ``` -------------------------------- ### Create Netlify Project with Prompt Argument Source: https://github.com/netlify/cli/blob/main/docs/commands/create.md Provide a description of the site to create directly as a command-line argument. This is a shorthand for the `--prompt` flag. ```bash netlify create "a portfolio site" ``` -------------------------------- ### env:get Source: https://github.com/netlify/cli/blob/main/docs/index.md Get resolved value of specified environment variable (includes netlify.toml). ```APIDOC ## env:get ### Description Get resolved value of specified environment variable (includes netlify.toml). ### Command `netlify env:get` ``` -------------------------------- ### Create Netlify Project with Git Integration Source: https://github.com/netlify/cli/blob/main/docs/commands/create.md Automatically set up a git repository (e.g., GitHub) for your new project. The CLI will handle the repository creation and push the source code. ```bash netlify create "an e-commerce store" --git github ``` -------------------------------- ### Get a Single Environment Variable Source: https://context7.com/netlify/cli/llms.txt Retrieve the value of a specific environment variable using `netlify env:get`. You can specify the context and scope for the variable. ```bash netlify env:get DATABASE_URL ``` ```bash netlify env:get DATABASE_URL --context production ``` ```bash netlify env:get DATABASE_URL --scope builds ``` -------------------------------- ### Production Deploy and Open Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Deploys your project to production and automatically opens the deployed site in your browser. ```bash netlify deploy --prod --open ``` -------------------------------- ### Serve with Deploy Preview Context Source: https://github.com/netlify/cli/blob/main/docs/commands/serve.md Serves the project locally using environment variables defined for the deploy-preview context. This helps in testing features before merging them into the main branch. ```bash netlify serve --context deploy-preview ``` -------------------------------- ### Get Blob Content Source: https://github.com/netlify/cli/blob/main/docs/commands/blobs.md Reads an object with a given key from a Netlify Blobs store and prints the content to the terminal. ```bash netlify blobs:get my-store my-key ``` -------------------------------- ### Basic Deploy Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Deploys your project to Netlify, creating a draft deploy by default. ```bash netlify deploy ``` -------------------------------- ### Manage Netlify Database (Postgres) Source: https://context7.com/netlify/cli/llms.txt Provision and manage a production-ready Postgres database. Includes initialization, status checks, connecting, running queries, and managing migrations. ```bash # Initialize database: install package, scaffold first migration, verify netlify database init ``` ```bash netlify database init --yes # non-interactive ``` ```bash # Check status — applied and pending migrations netlify database status ``` ```bash netlify database status --show-credentials ``` ```bash netlify database status --json ``` ```bash netlify database status --branch my-feature-branch ``` ```bash # Open an interactive psql session netlify database connect ``` ```bash # Run a one-off query netlify database connect --query "SELECT count(*) FROM users" ``` ```bash netlify database connect --json --query "SELECT id, email FROM users LIMIT 5" ``` ```bash # Create a new migration file netlify database migrations new ``` ```bash netlify database migrations new --description "add users table" --scheme sequential ``` ```bash # Apply pending migrations to the local dev database netlify database migrations apply ``` ```bash # Pull production migrations to sync local files netlify database migrations pull ``` ```bash netlify database migrations pull --branch staging ``` ```bash # Reset the local development database (drops all data and tables) netlify database reset ``` -------------------------------- ### blobs:get Source: https://github.com/netlify/cli/blob/main/docs/index.md Reads an object with a given key from a Netlify Blobs store and, if it exists, prints the content to the terminal or saves it to a file. ```APIDOC ## blobs:get ### Description Reads an object with a given key from a Netlify Blobs store and, if it exists, prints the content to the terminal or saves it to a file. ### Command `netlify blobs:get` ``` -------------------------------- ### List all Netlify sites Source: https://github.com/netlify/cli/blob/main/docs/commands/sites.md Lists all projects you have access to. Use the `--json` flag to output project data in JSON format. ```bash netlify sites:list ``` -------------------------------- ### Get Resolved Environment Variable Value Source: https://github.com/netlify/cli/blob/main/docs/index.md Retrieves the final resolved value of a specified environment variable, taking into account settings in netlify.toml. ```bash netlify env:get ``` -------------------------------- ### Build Production Site Source: https://github.com/netlify/cli/blob/main/site/README.md Builds the project for production, outputting the static site to the `./dist/` directory. ```bash npm run build ``` -------------------------------- ### Connect to the Database Source: https://github.com/netlify/cli/blob/main/docs/index.md Establishes a connection to the Netlify database. ```bash netlify database connect ``` -------------------------------- ### Get environment variable value Source: https://github.com/netlify/cli/blob/main/docs/commands/env.md Retrieve the resolved value of a specific environment variable. You can specify a deploy context or scope for more targeted retrieval. ```bash netlify env:get VAR_NAME # get value for MY_VAR in dev context ``` ```bash netlify env:get MY_VAR --context production ``` ```bash netlify env:get MY_VAR --context branch:feat/make-it-pop # get value in the feat/make-it-pop branch context or branch-deploy context ``` ```bash netlify env:get MY_VAR --scope functions ``` -------------------------------- ### Create Netlify Project with Prompt and Agent Source: https://github.com/netlify/cli/blob/main/docs/commands/create.md Specify a detailed prompt for the AI agent and choose a specific agent (e.g., claude) to generate the project. This allows for more tailored project creation. ```bash netlify create --prompt "a blog with dark mode" --agent claude ``` -------------------------------- ### Preview Production Build Source: https://github.com/netlify/cli/blob/main/site/README.md Locally previews the production build of the site before deploying it. ```bash npm run preview ``` -------------------------------- ### Serve Production Build Locally Source: https://context7.com/netlify/cli/llms.txt Use `netlify serve` to build your project for production and serve it locally. This is useful for verifying the production build before deploying. ```bash netlify serve ``` ```bash netlify serve --port 9000 ``` ```bash netlify serve --no-open ``` -------------------------------- ### View Logs Since a Specific Time Source: https://github.com/netlify/cli/blob/main/docs/commands/logs.md Filters logs to show only those generated after a specified duration or timestamp. For example, `--since 1h` shows logs from the last hour. ```bash netlify logs --since 1h ``` -------------------------------- ### Show agent task details Source: https://github.com/netlify/cli/blob/main/docs/commands/agents.md Use `agents:show` with an agent task ID to retrieve detailed information about a specific task. The `--json` flag can be used to get the output in JSON format. ```bash netlify agents:show 60c7c3b3e7b4a0001f5e4b3a ``` ```bash netlify agents:show 60c7c3b3e7b4a0001f5e4b3a --json ``` -------------------------------- ### Basic Netlify Create Command Source: https://github.com/netlify/cli/blob/main/docs/commands/create.md Use this command to initiate the creation of a new Netlify project with default settings. The CLI will prompt for necessary information. ```bash netlify create ``` -------------------------------- ### Deploy Project to Netlify Source: https://context7.com/netlify/cli/llms.txt Build and deploy your project to Netlify. By default, this creates a draft deploy. Use `--prod` for production deployments. ```bash netlify deploy ``` ```bash netlify deploy --prod ``` ```bash netlify deploy --prod --open ``` ```bash netlify deploy --no-build --dir ./dist ``` ```bash netlify deploy --dir ./out --functions ./api ``` ```bash netlify deploy --alias staging-review ``` ```bash netlify deploy --message "Release v2.3.1" ``` ```bash netlify deploy --site my-first-project --prod ``` ```bash netlify deploy --site-name my-brand-new-site --team my-team --prod ``` ```bash netlify deploy --allow-anonymous --dir ./public --no-build ``` ```bash netlify deploy --trigger ``` ```bash netlify deploy --prod --json ``` ```json { "site_id": "abc123", "site_name": "my-site", "deploy_id": "67890", "deploy_url": "https://67890--my-site.netlify.app", "logs": "https://app.netlify.com/projects/my-site/deploys/67890" } ``` ```bash netlify deploy --context deploy-preview ``` ```bash netlify deploy --prod --auth $NETLIFY_AUTH_TOKEN ``` -------------------------------- ### init Source: https://github.com/netlify/cli/blob/main/docs/index.md Configure continuous deployment for a new or existing project. To create a new project without continuous deployment, use `netlify sites:create`. ```APIDOC ## init ### Description Configure continuous deployment for a new or existing project. To create a new project without continuous deployment, use `netlify sites:create`. ### Command `netlify init` ``` -------------------------------- ### build Source: https://github.com/netlify/cli/blob/main/docs/index.md Build on your local machine. ```APIDOC ## build ### Description Build on your local machine. ### Command `netlify build` ``` -------------------------------- ### Run the claim command Source: https://github.com/netlify/cli/blob/main/docs/commands/claim.md Execute the claim command to initiate the process of linking an anonymous site to your account. Ensure you have the required site ID and token. ```bash netlify claim ``` -------------------------------- ### Connect to the database Source: https://github.com/netlify/cli/blob/main/docs/commands/database.md Connect to the database. You can execute a single query, output results as JSON, or view connection details in JSON format. Debugging information is also available. ```bash netlify database connect ``` ```bash netlify database connect --query "SELECT * FROM users" ``` ```bash netlify database connect --json --query "SELECT * FROM users" ``` ```bash netlify database connect --json ``` -------------------------------- ### Link a local project to Netlify Source: https://github.com/netlify/cli/blob/main/docs/commands/link.md Run this command in your local project directory to link it to an existing Netlify project. It will prompt you to select a site if multiple are found. ```bash netlify link ``` -------------------------------- ### Serve with Branch Context Source: https://github.com/netlify/cli/blob/main/docs/commands/serve.md Serves the project locally using environment variables from a specific branch context (e.g., `feat/make-it-pop`). This is useful for testing branch-specific configurations or features. ```bash netlify serve --context branch:feat/make-it-pop ``` -------------------------------- ### Serve with Production Context Source: https://github.com/netlify/cli/blob/main/docs/commands/serve.md Serves the project locally using environment variables defined for the production context. This is useful for testing how your site behaves with production settings. ```bash netlify serve --context production ``` -------------------------------- ### Deploy to Production with JSON Output Source: https://context7.com/netlify/cli/llms.txt Automate production deployments and capture deploy URLs for further processing by using --prod and --json flags. ```bash netlify deploy --prod --auth $TOKEN --json ``` -------------------------------- ### Deploy to Production if Unlocked Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Deploys to production if the site is unlocked, otherwise creates a draft deploy. ```bash netlify deploy --prod-if-unlocked ``` -------------------------------- ### Run any Netlify API method Source: https://github.com/netlify/cli/blob/main/docs/commands/api.md This command allows you to execute any Netlify API method. Refer to the Netlify open API documentation for available methods or use the `--list` flag. ```APIDOC ## `netlify api` ### Description Run any Netlify API method. For more information on available methods, check out https://open-api.netlify.com/ or run 'netlify api --list'. ### Usage ```bash netlify api ``` ### Arguments - `apiMethod` - Open API method to run ### Flags - `data` (*string*) - Data to use for the API call. - `list` (*boolean*) - List out available API methods. - `debug` (*boolean*) - Print debugging information. - `auth` (*string*) - Netlify auth token - can be used to run this command without logging in. ### Examples ```bash netlify api --list netlify api getSite --data '{ "site_id": "123456" }' ``` ``` -------------------------------- ### Production Deploy Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Deploys your project directly to your live production site. ```bash netlify deploy --prod ``` -------------------------------- ### Create a new Netlify site Source: https://github.com/netlify/cli/blob/main/docs/commands/sites.md Creates a new, empty Netlify project. This project is not associated with any git remote and will be linked to the current working directory. Use the `--name` flag to specify the project name. ```bash netlify sites:create --name my-new-project ``` -------------------------------- ### Create Predictable Preview Deployment URLs Source: https://context7.com/netlify/cli/llms.txt Use the --alias flag with a dynamic value like a PR number to create stable URLs for preview deployments. ```bash netlify deploy --alias pr-$PR_NUMBER ``` -------------------------------- ### Provision a production ready Postgres database Source: https://github.com/netlify/cli/blob/main/docs/commands/database.md Use this command to provision a new production-ready Postgres database. It can be run with optional flags for filtering in monorepos, enabling debug output, or specifying an authentication token. ```bash netlify database ``` -------------------------------- ### Basic clone command Source: https://github.com/netlify/cli/blob/main/docs/commands/clone.md Use this command to clone a repository. The repository will be linked to an existing Netlify project. If only one project matches the Git URL, it will be automatically linked. Otherwise, you will be prompted to select a project. ```bash netlify clone vibecoder/next-unicorn ``` ```bash netlify clone https://github.com/vibecoder/next-unicorn.git ``` ```bash netlify clone git@github.com:vibecoder/next-unicorn.git ``` -------------------------------- ### Create Netlify Project without Waiting for Completion Source: https://github.com/netlify/cli/blob/main/docs/commands/create.md Initiate the project creation process and return immediately without waiting for the AI agent to complete its task. This is useful for long-running agent jobs. ```bash netlify create "an e-commerce store" --no-wait ``` -------------------------------- ### List All Netlify CLI Commands Source: https://github.com/netlify/cli/blob/main/docs/index.md Run this command to see a list of all available Netlify CLI commands. ```bash netlify help ``` -------------------------------- ### Build Project Locally with Netlify CLI Source: https://context7.com/netlify/cli/llms.txt Run the Netlify build process locally, mimicking the production build system. Supports dry runs, specific deploy contexts, and offline builds. ```bash # Build using the default context (production) netlify build # Dry run — show build steps without executing them netlify build --dry # Build with a specific deploy context's environment variables netlify build --context deploy-preview netlify build --context branch:feat/redesign # Build offline (no network calls to Netlify services) netlify build --offline ``` -------------------------------- ### Run Netlify build command Source: https://github.com/netlify/cli/blob/main/docs/commands/build.md Use this command to build your project locally. It triggers the build process defined in your Netlify configuration. ```bash netlify build ``` -------------------------------- ### Run Integration Tests with Netlify Dev Source: https://context7.com/netlify/cli/llms.txt Utilize `netlify dev:exec` within CI to run integration tests against a local environment that mimics Netlify's production proxy. ```bash netlify dev:exec ``` -------------------------------- ### Deploy with Auth Token Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Uses a Netlify authentication token for deployment, allowing deployment without being logged in via `netlify login`. ```bash netlify deploy --auth $NETLIFY_AUTH_TOKEN ``` -------------------------------- ### Create New Database Migration Source: https://github.com/netlify/cli/blob/main/docs/commands/database.md Creates a new migration file. Use the `description` flag to name the migration and `scheme` to specify the numbering format. ```bash netlify database migrations new ``` ```bash netlify database migrations new --description "add users table" --scheme sequential ``` -------------------------------- ### Open Netlify Project Admin UI Source: https://github.com/netlify/cli/blob/main/docs/commands/open.md This command specifically opens the admin interface for the current Netlify project. Ensure your project is linked to Netlify for this to work correctly. ```bash netlify open:admin ``` -------------------------------- ### Link a local project using project name Source: https://github.com/netlify/cli/blob/main/docs/commands/link.md Link your local directory to a Netlify project by providing its name. This is an alternative to using the project ID. ```bash netlify link --name my-project-name ``` -------------------------------- ### create Source: https://github.com/netlify/cli/blob/main/docs/index.md Create a new Netlify project using an AI agent. ```APIDOC ## create ### Description Create a new Netlify project using an AI agent. ### Command `netlify create` ``` -------------------------------- ### Run Project in Watch Mode Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Enable watch mode for continuous building during development. ```bash npm run watch ``` -------------------------------- ### Run Netlify recipes command Source: https://github.com/netlify/cli/blob/main/docs/commands/recipes.md Use this command to create and modify files in your project using pre-defined recipes. You can specify the recipe name directly or use the --name flag. ```bash netlify recipes ``` ```bash netlify recipes my-recipe ``` ```bash netlify recipes --name my-recipe ``` -------------------------------- ### Create Netlify Project with Account Slug Source: https://github.com/netlify/cli/blob/main/docs/commands/create.md Create a project under a specific Netlify account or team by providing the account slug. This is useful for managing multiple accounts. ```bash netlify create "landing page for a coffee shop" --account-slug my-team ``` -------------------------------- ### deploy Source: https://github.com/netlify/cli/blob/main/docs/index.md Deploy your project to Netlify. ```APIDOC ## deploy ### Description Deploy your project to Netlify. ### Command `netlify deploy` ``` -------------------------------- ### Run CLI Locally Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Execute the Netlify CLI locally with a specified command. Use DEBUG=true to print stack traces. ```bash ./bin/run.js [command] ``` ```bash DEBUG=true ./bin/run.js [command] ``` -------------------------------- ### env:import Source: https://github.com/netlify/cli/blob/main/docs/index.md Import and set environment variables from .env file. ```APIDOC ## env:import ### Description Import and set environment variables from .env file. ### Command `netlify env:import` ``` -------------------------------- ### Search for Netlify sites Source: https://github.com/netlify/cli/blob/main/docs/commands/sites.md Searches for projects by name. Provide a full or partial project name as an argument. Use the `--json` flag to output results in JSON format. ```bash netlify sites:search my-project ``` ```bash netlify sites:search "partial name" --json ``` -------------------------------- ### Switch Netlify Account Source: https://github.com/netlify/cli/blob/main/docs/commands/switch.md Run this command to switch to a different Netlify account. It will prompt you to select an account if multiple are available. ```bash netlify switch ``` -------------------------------- ### Create and Run an AI Agent Task Source: https://github.com/netlify/cli/blob/main/docs/index.md Use this command to create and initiate a new AI agent task for your site. ```bash netlify agents:create ``` -------------------------------- ### api Source: https://github.com/netlify/cli/blob/main/docs/index.md Run any Netlify API method. ```APIDOC ## api ### Description Run any Netlify API method. ### Command `netlify api` ``` -------------------------------- ### Open Project Site URL Source: https://github.com/netlify/cli/blob/main/docs/commands/open.md Use this command to quickly open the live URL of your Netlify project in your default web browser. This is helpful for previewing changes or sharing your site. ```bash netlify open:site ``` -------------------------------- ### List Available Netlify API Methods Source: https://github.com/netlify/cli/blob/main/docs/commands/api.md Use the `--list` flag to see all available Netlify API methods. This is useful for discovering endpoints you can call. ```bash netlify api --list ``` -------------------------------- ### Open Netlify Project Admin Source: https://github.com/netlify/cli/blob/main/docs/commands/open.md Use this command to open the admin UI for your Netlify project. This is useful for accessing project settings, deploys, and other management features. ```bash netlify open --site ``` ```bash netlify open --admin ``` ```bash netlify open:admin ``` ```bash netlify open:site ``` -------------------------------- ### Netlify CLI Usage Source: https://github.com/netlify/cli/blob/main/README.md Basic usage of the Netlify CLI command. Run `netlify [command] help` for detailed command information. ```sh-session netlify [command] # Run `help` for detailed information about CLI commands netlify [command] help ``` -------------------------------- ### List available Netlify recipes Source: https://github.com/netlify/cli/blob/main/docs/commands/recipes.md This command lists all available recipes that can be used to create and modify project files. It supports a filter flag for monorepos. ```bash netlify recipes:list ``` -------------------------------- ### Login to Netlify CLI Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Authenticate with Netlify to run integration tests that require a live site. Alternatively, set the NETLIFY_AUTH_TOKEN environment variable. ```bash ./bin/run.js login ``` -------------------------------- ### Clone and link to a specific Netlify project by Name Source: https://github.com/netlify/cli/blob/main/docs/commands/clone.md Clone a repository and link it to a Netlify project identified by its name. This provides an alternative to using the project ID for linking. ```bash netlify clone --name my-project-name vibecoder/next-unicorn ``` -------------------------------- ### Create Netlify Project with Custom Name Source: https://github.com/netlify/cli/blob/main/docs/commands/create.md Assign a specific name to your Netlify project, which will be used as the subdomain. This helps in organizing and identifying your projects. ```bash netlify create "an e-commerce store" --name my-store ``` -------------------------------- ### Watch for project deploy to finish Source: https://github.com/netlify/cli/blob/main/docs/commands/watch.md Run the watch command to monitor deployments. This command will exit once the deploy is finished. ```bash netlify watch ``` -------------------------------- ### Serve Netlify Functions Locally Source: https://context7.com/netlify/cli/llms.txt Serve serverless functions locally on a specific port using `netlify functions:serve`. This can be done without the full Netlify dev server. ```bash netlify functions:serve --port 9999 ``` -------------------------------- ### Build Netlify Functions Locally Source: https://github.com/netlify/cli/blob/main/docs/index.md Compiles and prepares your Netlify Functions for local testing or deployment. ```bash netlify functions:build ``` -------------------------------- ### Build Netlify Functions Source: https://context7.com/netlify/cli/llms.txt Build serverless functions to a target directory using `netlify functions:build`. Specify source and destination paths. ```bash netlify functions:build --functions ./dist/functions --src ./src/functions ``` -------------------------------- ### Create and run a new agent task Source: https://github.com/netlify/cli/blob/main/docs/commands/agents.md Use `agents:create` to initiate a new AI agent task. You can specify a prompt directly or use the `--prompt` flag. The `--agent` flag allows selection of specific AI models like claude or codex. ```bash netlify agents:create --prompt "Add a contact form" ``` ```bash netlify agents:create ``` ```bash netlify agents:create "Fix the login bug" ``` ```bash netlify agents:create --prompt "Add dark mode" --agent claude ``` ```bash netlify agents:create -p "Update README" -a codex -b feature-branch ``` ```bash netlify agents:create "Add tests" --project my-site-name ``` -------------------------------- ### Deploy to a Specific Site Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Deploys your project to a specified Netlify site by its name or ID. ```bash netlify deploy --site my-first-project ``` -------------------------------- ### Build with deploy context Source: https://github.com/netlify/cli/blob/main/docs/commands/build.md Specify a deploy context to use specific environment variables during the build. This is useful for simulating different deployment environments. ```bash netlify build --context deploy-preview ``` ```bash netlify build --context branch:feat/make-it-pop ``` -------------------------------- ### Apply Database Migrations Source: https://github.com/netlify/cli/blob/main/docs/commands/database.md Applies database migrations to the local development database. Omit the `to` flag to apply all pending migrations. ```bash netlify database migrations apply ``` -------------------------------- ### Manage Netlify Sites Source: https://context7.com/netlify/cli/llms.txt Commands for creating, listing, searching, and deleting Netlify projects. Supports AI-powered scaffolding and targeting specific team accounts. ```bash # Create a new blank project (no CI/git connection) netlify sites:create --name my-new-project ``` ```bash # Create under a specific team account netlify sites:create --name my-new-project --account-slug my-team ``` ```bash # Create without linking to current directory netlify sites:create --name my-project --disable-linking ``` ```bash # Create with AI-powered scaffolding netlify sites:create --prompt "A portfolio site for a photographer" ``` ```bash # List all projects you have access to netlify sites:list ``` ```bash netlify sites:list --json ``` ```bash # Search for projects by name netlify sites:search my-project ``` ```bash netlify sites:search "partial name" --json ``` ```bash # Delete a project permanently (use with caution!) netlify sites:delete 1234-3262-1211 ``` ```bash netlify sites:delete 1234-3262-1211 --force # skip confirmation ``` -------------------------------- ### List Netlify Functions Source: https://context7.com/netlify/cli/llms.txt List all locally detected serverless functions using `netlify functions:list`. Use `--json` for JSON output. ```bash netlify functions:list ``` ```bash netlify functions:list --json ``` -------------------------------- ### Login to Netlify Account Source: https://github.com/netlify/cli/blob/main/docs/commands/login.md Use this command to log in to your Netlify account. It will open a web browser for authentication. ```bash netlify login ``` -------------------------------- ### List Environment Variables Source: https://github.com/netlify/cli/blob/main/docs/commands/env.md Lists resolved environment variables for a project, including those defined in netlify.toml. Use flags to specify context, scope, or output format. ```bash netlify env:list ``` ```bash netlify env:list --context production ``` ```bash netlify env:list --context branch:feat/make-it-pop ``` ```bash netlify env:list --scope functions ``` ```bash netlify env:list --plain ``` -------------------------------- ### Deploy with Specific Context Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Specifies a deploy context for environment variables during the build process. Common contexts include 'production', 'deploy-preview', 'branch-deploy', and 'dev'. ```bash netlify deploy --context deploy-preview ``` -------------------------------- ### Create a New Netlify Function Source: https://context7.com/netlify/cli/llms.txt Scaffold a new serverless function using `netlify functions:create`. You can specify the function name, template, and language. ```bash netlify functions:create ``` ```bash netlify functions:create hello-world ``` ```bash netlify functions:create --name my-api --language typescript ``` ```bash netlify functions:create --template hello-world --language typescript ``` -------------------------------- ### List environment variables Source: https://github.com/netlify/cli/blob/main/docs/commands/env.md Use this command to list all resolved environment variables for your project, including those defined in netlify.toml. ```bash netlify env:list ``` -------------------------------- ### env:list Source: https://github.com/netlify/cli/blob/main/docs/index.md Lists resolved environment variables for project (includes netlify.toml). ```APIDOC ## env:list ### Description Lists resolved environment variables for project (includes netlify.toml). ### Command `netlify env:list` ``` -------------------------------- ### Link Local Directory to Netlify Project Source: https://context7.com/netlify/cli/llms.txt Associate a local directory with an existing Netlify site. Supports interactive linking, linking by site ID, name, or Git remote URL. Use `netlify unlink` to remove the association. ```bash # Interactive picker (detects git remote automatically) netlify link # Link by site ID netlify link --id 1a2b3c4d-1234-5678-abcd-ef0123456789 # Link by site name netlify link --name my-marketing-site # Link by specifying the GitHub remote URL netlify link --git-remote-url https://github.com/myorg/my-site.git # Unlink the current directory netlify unlink ``` -------------------------------- ### Claim an anonymous site with site ID and token Source: https://github.com/netlify/cli/blob/main/docs/commands/claim.md Use the `claim` command with the `--site` and `--token` flags to specify the anonymous site to claim. This is the primary method for claiming a site. ```bash netlify claim --site abc123 --token drop-jwt-token ``` -------------------------------- ### List all teams Source: https://github.com/netlify/cli/blob/main/docs/commands/teams.md Use this command to view all teams you have access to. It's a basic command for team management. ```bash netlify teams:list ``` ```bash netlify teams:list --json ``` -------------------------------- ### agents:create Source: https://github.com/netlify/cli/blob/main/docs/index.md Create and run a new agent task on your site. ```APIDOC ## agents:create ### Description Create and run a new agent task on your site. ### Command `netlify agents:create` ``` -------------------------------- ### Generate Shell Completion Script Source: https://github.com/netlify/cli/blob/main/docs/commands/completion.md Run this command to see instructions for your shell. This is the base command for generating completion scripts. ```bash netlify completion ``` -------------------------------- ### Create a new function Source: https://github.com/netlify/cli/blob/main/docs/commands/functions.md Use this command to create a new function file. You can specify the function name directly or use the `--name` flag. The `--language` and `--template` flags can be used to specify the function's language and a bundled template. ```bash netlify functions:create --name function-xyz ``` ```bash netlify functions:create ``` ```bash netlify functions:create hello-world ``` ```bash netlify functions:create --name hello-world ``` ```bash netlify functions:create --language typescript --template hello-world ``` -------------------------------- ### Clone and link to a specific Netlify project by ID Source: https://github.com/netlify/cli/blob/main/docs/commands/clone.md Clone a repository and explicitly link it to a Netlify project using its ID. This is useful when you have multiple projects and want to ensure the correct one is linked. ```bash netlify clone --id 123-123-123-123 vibecoder/next-unicorn ``` -------------------------------- ### Deploy Without Building Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Deploys your project without running the build command first. Use this if your project is already built or requires no build step. ```bash netlify deploy --no-build ``` -------------------------------- ### functions:build Source: https://github.com/netlify/cli/blob/main/docs/index.md Build functions locally. ```APIDOC ## functions:build ### Description Build functions locally. ### Command `netlify functions:build` ``` -------------------------------- ### Run a Single Unit Test File Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Execute a specific unit test file using vitest. Ensure the path to the test file is correct. ```bash npm exec vitest -- run tests/unit/tests/unit/lib/account.test.js ``` -------------------------------- ### Manage Database Migrations Source: https://github.com/netlify/cli/blob/main/docs/index.md Provides tools for managing database migrations, including applying, reverting, or creating new migration scripts. ```bash netlify database migrations ``` -------------------------------- ### List Blobs Source: https://github.com/netlify/cli/blob/main/docs/commands/blobs.md Lists objects in a Netlify Blobs store. ```bash netlify blobs:list my-store ``` -------------------------------- ### Import Environment Variables from .env.ci Source: https://context7.com/netlify/cli/llms.txt Seed environment variables into your project pipeline from a local .env.ci file. ```bash netlify env:import .env.ci ``` -------------------------------- ### Build functions locally Source: https://github.com/netlify/cli/blob/main/docs/commands/functions.md Builds functions locally. Use the `--functions` flag to specify the build directory and the `--src` flag to specify the source directory. ```bash netlify functions:build --functions build/to/directory --src source/directory ``` ```bash netlify functions:build ``` -------------------------------- ### Anonymous Deploy with Specific Directory Source: https://github.com/netlify/cli/blob/main/docs/commands/deploy.md Deploys a specified directory without requiring authentication, creating a claimable site. Also skips the build process. ```bash netlify deploy --allow-anonymous --dir ./public --no-build ``` -------------------------------- ### Show Agent Task Details Source: https://github.com/netlify/cli/blob/main/docs/index.md Displays detailed information about a specific agent task. ```bash netlify agents:show ``` -------------------------------- ### Run CLI Locally Source: https://github.com/netlify/cli/blob/main/CLAUDE.md Execute the Netlify CLI locally with a specified command. This is the primary way to test CLI functionality during development. ```bash ./bin/run.js [command] ``` -------------------------------- ### View Project Logs Source: https://github.com/netlify/cli/blob/main/docs/commands/logs.md Displays historical logs for your project. Defaults to the last 10 minutes. ```bash netlify logs ``` -------------------------------- ### Create a New Netlify Function Source: https://github.com/netlify/cli/blob/main/docs/index.md Generates the boilerplate code and configuration for a new Netlify Function locally. ```bash netlify functions:create ``` -------------------------------- ### Run Single Unit Test File Source: https://github.com/netlify/cli/blob/main/CLAUDE.md Execute a specific unit test file using npm exec with vitest. Useful for focused testing during development. ```bash npm exec vitest -- run tests/unit/lib/account.test.ts ``` -------------------------------- ### database connect Source: https://github.com/netlify/cli/blob/main/docs/index.md Connect to the database. ```APIDOC ## database connect ### Description Connect to the database. ### Command `netlify database connect` ``` -------------------------------- ### Clone to a specific directory Source: https://github.com/netlify/cli/blob/main/docs/commands/clone.md Clone a repository into a specified target directory. The directory will be created if it does not exist. This command also links the cloned repository to an existing Netlify project. ```bash netlify clone vibecoder/next-unicorn ./next-unicorn-shh-secret ``` -------------------------------- ### Import Environment Variables from .env File Source: https://github.com/netlify/cli/blob/main/docs/index.md Loads and sets environment variables from a local .env file into your Netlify project. ```bash netlify env:import ``` -------------------------------- ### Print status information Source: https://github.com/netlify/cli/blob/main/docs/commands/status.md Use this command to display the current status of the Netlify CLI and its linked project. It can be run without any arguments. ```bash netlify status ``` -------------------------------- ### Run Commands in Netlify Dev Environment Source: https://context7.com/netlify/cli/llms.txt Execute commands within the Netlify dev environment using `netlify dev:exec`. This ensures all environment variables are available. You can also specify a deploy context. ```bash netlify dev:exec npm run db:seed ``` ```bash netlify dev:exec --context deploy-preview npm run bootstrap ``` -------------------------------- ### Stream Logs in Real Time Source: https://github.com/netlify/cli/blob/main/docs/commands/logs.md Enables real-time log streaming, showing new logs as they are generated. Use this to monitor live activity. ```bash netlify logs --follow ``` -------------------------------- ### List Environment Variables Source: https://context7.com/netlify/cli/llms.txt Manage environment variables for your Netlify project using `netlify env`. Use `--json` for JSON output or specify a context and scope. ```bash netlify env:list ``` ```bash netlify env:list --json ``` ```bash netlify env:list --context production ``` ```bash netlify env:list --context branch:feat/make-it-pop ``` ```bash netlify env:list --scope functions ``` -------------------------------- ### Link a local project using Git remote URL Source: https://github.com/netlify/cli/blob/main/docs/commands/link.md Link your local directory to a Netlify project by providing the Git repository URL. This is useful if your project is hosted on a Git service like GitHub. ```bash netlify link --git-remote-url https://github.com/vibecoder/my-unicorn.git ``` -------------------------------- ### Run CLI Locally with Debugging Source: https://github.com/netlify/cli/blob/main/CLAUDE.md Run the Netlify CLI locally with stack traces enabled for debugging. Set the DEBUG environment variable to true. ```bash DEBUG=true ./bin/run.js [command] ``` -------------------------------- ### Import environment variables from .env file Source: https://github.com/netlify/cli/blob/main/docs/commands/env.md Import and set environment variables from a specified .env file. You can choose to replace existing variables or merge them. ```bash netlify env:import fileName ``` -------------------------------- ### Serve Local Functions Source: https://github.com/netlify/cli/blob/main/docs/commands/functions.md Serves functions locally for development and testing. Supports various flags for customization. ```bash netlify functions:serve ``` -------------------------------- ### functions:create Source: https://github.com/netlify/cli/blob/main/docs/index.md Create a new function locally. ```APIDOC ## functions:create ### Description Create a new function locally. ### Command `netlify functions:create` ``` -------------------------------- ### Combine Log Sources Source: https://github.com/netlify/cli/blob/main/docs/commands/logs.md Fetches logs from multiple sources, such as deploy logs and function logs, within a specified time frame. ```bash netlify logs --source deploy --source functions --since 1h ``` -------------------------------- ### Import Environment Variables from .env File Source: https://context7.com/netlify/cli/llms.txt Import environment variables from a `.env` file using `netlify env:import`. Use `--replace-existing` to overwrite current variables. ```bash netlify env:import .env.production ``` ```bash netlify env:import .env.production --replace-existing ``` -------------------------------- ### List Blobs with JSON Output Source: https://github.com/netlify/cli/blob/main/docs/commands/blobs.md Lists objects in a Netlify Blobs store and outputs the list contents as JSON. ```bash netlify blobs:list my-store --json ``` -------------------------------- ### functions:serve Source: https://github.com/netlify/cli/blob/main/docs/index.md Serve functions locally. ```APIDOC ## functions:serve ### Description Serve functions locally. ### Command `netlify functions:serve` ``` -------------------------------- ### Call a Specific Netlify API Method Source: https://github.com/netlify/cli/blob/main/docs/commands/api.md Execute a specific Netlify API method, such as `getSite`, by providing the method name and any required data. The `--data` flag accepts a JSON string for parameters. ```bash netlify api getSite --data '{ "site_id": "123456" }' ``` -------------------------------- ### Generate Command Documentation Source: https://github.com/netlify/cli/blob/main/CONTRIBUTING.md Automatically generate markdown documentation for CLI commands. This command should be run after adding or updating commands. ```bash npm run docs ``` -------------------------------- ### Print hook information Source: https://github.com/netlify/cli/blob/main/docs/commands/status.md Use this command to display hook information for the linked project. This is particularly useful for monorepos where you might need to filter by a specific application. ```bash netlify status:hooks ``` -------------------------------- ### Authenticate Netlify CLI with Auth Token Source: https://context7.com/netlify/cli/llms.txt Use the --auth flag with your NETLIFY_AUTH_TOKEN for CI environments to bypass stored credentials. ```bash netlify --auth $NETLIFY_AUTH_TOKEN ```