Skip to content
CLI tool · Cloud & deploy

Netlify CLI for AI agents

The Netlify CLI for AI agents: check site status, run netlify dev, create draft deploys, and list env vars, with safe defaults and token setup.

netlifyby NetlifyOfficial MCP option
What it is

What Netlify CLI does for an agent

The Netlify CLI is Netlify's official tool for building, testing, and deploying sites. It runs a local dev server with redirects and functions, links a folder to a site, manages environment variables, and deploys.

netlify deploy creates a draft deploy with its own URL by default. Publishing to the live site needs --prod, so an agent can share previews without touching production.

Official site: www.netlify.com

Install

Install Netlify CLI

The install commands from the official docs. Check it worked with netlify --version.

npm (global)
npm install netlify-cli -g
Auth

Signing in Netlify CLI for an agent

A human signs in with netlify login. For CI and agents, Netlify documents a personal access token in NETLIFY_AUTH_TOKEN and the target site in NETLIFY_SITE_ID.

Check the sign-in (read-only)
netlify status
Interactive sign-in (human)
netlify login
Link this folder to a site
netlify link

Environment variables: NETLIFY_AUTH_TOKEN, NETLIFY_SITE_ID. Set them in the agent's environment; never paste values into prompts or commit them.

Common agent tasks

What agents use Netlify CLI for

Example commands with placeholder names. Swap in your own project, app, or file names.

  1. Check the account and linked site

    netlify
    netlify status
  2. Run the site locally

    netlify
    netlify dev

    Long-running. Start it in the background.

  3. Create a draft deploy

    netlify
    netlify deploy

    Prints a draft URL to share for review.

  4. List environment variables

    netlify
    netlify env:list
Safety

Safety rules for agents

Safe to run without asking

  • netlify status
  • netlify env:list
  • netlify sites:list

Ask a human first

  • netlify deploy --prod
  • netlify env:set / env:unset
  • netlify sites:delete
  • Use draft deploys for review; leave --prod to a human or CI.
  • Run netlify status first so the agent deploys the site it thinks it is deploying.
  • Keep NETLIFY_AUTH_TOKEN out of logs, commits, and chat output.
Agent instructions

AGENTS.md or CLAUDE.md snippet

Paste this into the instruction file your agent reads at the start of every session, then adjust the rules to your setup.

AGENTS.md
## Netlify CLI (netlify)

Use `netlify` for running sites locally with Netlify features and creating draft deploys.

- Check it is installed with `netlify --version`. If it is missing, ask before installing it.
- Auth: a human signs netlify in. Check with `netlify status`; if it fails, stop and ask. Never run the login flow yourself, and never print tokens (NETLIFY_AUTH_TOKEN, NETLIFY_SITE_ID).
- Run without asking (read-only): `netlify status`, `netlify env:list`, `netlify sites:list`.
- Ask a human first (changes or deletes things): `netlify deploy --prod`, `netlify env:set / env:unset`, `netlify sites:delete`.
- Use draft deploys for review; leave --prod to a human or CI.
- Run netlify status first so the agent deploys the site it thinks it is deploying.
- Keep NETLIFY_AUTH_TOKEN out of logs, commits, and chat output.
- Prefer JSON output where the command supports it, and keep output short.
CLI or MCP server?

Netlify CLI or an MCP server?

An official MCP option exists. Netlify publishes an official MCP server that can create projects, deploy, and manage settings. The CLI is the lighter choice when the agent already works in the site's repository.

Rule of thumb: in a terminal agent that a human has signed in, the CLI is usually faster and cheaper in context. In a chat client without a shell, or when you want a fixed set of typed tools, use an MCP server.

Same category
All Cloud & deploy tools
FAQ

Netlify CLI questions

How do I install Netlify CLI?

npm (global): npm install netlify-cli -g. Check the install with netlify --version, and see the Netlify docs for other platforms.

How does an AI agent authenticate Netlify CLI?

A human signs in with netlify login. For CI and agents, Netlify documents a personal access token in NETLIFY_AUTH_TOKEN and the target site in NETLIFY_SITE_ID. The agent can check the sign-in with netlify status and should stop and ask if it fails.

Which Netlify CLI commands are safe for an agent to run?

Commands that only read state are safe to run without asking: netlify status; netlify env:list; netlify sites:list. Ask a human before anything that changes or deletes something: netlify deploy --prod; netlify env:set / env:unset; netlify sites:delete.

Is there an MCP server for Netlify CLI?

Netlify publishes an official MCP server that can create projects, deploy, and manage settings. The CLI is the lighter choice when the agent already works in the site's repository.