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.
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 Netlify CLI
The install commands from the official docs. Check it worked with netlify --version.
npm install netlify-cli -g
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.
netlify status
netlify login
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.
What agents use Netlify CLI for
Example commands with placeholder names. Swap in your own project, app, or file names.
Check the account and linked site
netlify status
Run the site locally
netlify dev
Long-running. Start it in the background.
Create a draft deploy
netlify deploy
Prints a draft URL to share for review.
List environment variables
netlify env:list
Safety rules for agents
Safe to run without asking
netlify statusnetlify env:listnetlify sites:list
Ask a human first
netlify deploy --prodnetlify env:set / env:unsetnetlify 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.
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.
## 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.
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.
Other Cloud & deploy tools
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.