This article follows the official documentation. We haven’t tested this tool for a hands-on review.
When you give a coding agent shell access to a website project, it can use the Netlify CLI to start Netlify’s local development server. The agent can also inspect the site connected to the project and create deploy previews from the terminal. A deploy preview is a hosted version of a proposed change that does not replace the production site.
The agent runs CLI commands on your computer, but some commands contact Netlify or change a site. For example, netlify dev starts a local server, while netlify deploy uploads files to Netlify. Knowing which commands stay on your computer helps you give the agent a clear task and avoid an unintended production deploy.
Install and authenticate
Netlify CLI requires Node.js 18.14.0 or later. Install it globally with npm, as shown in Netlify’s CLI setup documentation:
npm install -g netlify-cli
netlify --version
Run netlify login to authenticate through a browser; the CLI stores an access token in a global configuration file. For an automated environment, Netlify also supports a personal access token in the NETLIFY_AUTH_TOKEN environment variable. Keep that token in a secret store or protected environment variable; do not paste it into an agent prompt or commit it to the repository.
From a project directory, run netlify link to connect the local repository to an existing Netlify site. The CLI uses that link for commands that need a site context. Linking changes local configuration and contacts Netlify, but it does not itself deploy the project. Netlify’s documentation describes the repository permissions and credentials involved when you use netlify init to set up continuous deployment. That command connects a repository for ongoing deployments, so it has broader effects than linking a local checkout.
Run the project locally
Ask the agent to start the site with Netlify’s local development server and check a route or function before anyone uploads a deploy. In a project connected to a Netlify site, the agent can run:
netlify status
netlify dev
netlify status reports which Netlify account and site the project is connected to. It makes a request to Netlify. netlify dev starts the project’s local server. The agent can inspect the site in a browser or use the project’s existing test tools. This command does not upload a deploy. Keep the server running while the agent checks the site.
“In this linked repository, run netlify status, then start netlify dev. Tell me the local URL and check the page I name. Do not deploy or change Netlify site settings.” The agent should use the project’s existing files and tests; this example does not assume a particular framework or route.
The server runs on your machine, but a linked site and its configuration remain relevant. If the agent needs Netlify account access, authenticate before handing it the task rather than putting credentials in the prompt.
Create a deploy preview
Once the local check passes, ask the agent to upload a preview deploy. If the project puts its built files in dist, run:
netlify deploy --dir=dist
Here, dist is an example output directory. Replace it with the directory your project actually builds. The command uploads those files and creates a draft deploy on Netlify; it does not make that deploy the production version. The CLI’s deploy command reference documents the directory option and production flag.
The preview changes your Netlify account, but it leaves the production site unchanged. Review the preview before asking for a production deploy. To deploy to production, add --prod:
netlify deploy --dir=dist --prod
An agent should run that command only when you explicitly authorize a production release. A preview gives you a hosted place to inspect changes, but it does not by itself confirm that every route, function, or integration works as intended.
Identify the coding agent
Netlify CLI recognizes NETLIFY_AGENT, an environment variable used to attribute CLI activity to the coding agent or tool running it. For example, an environment configured with NETLIFY_AGENT=codex identifies Codex; the value can also include a product version. Netlify documents recognized agent names and how the CLI handles unrecognized values in its CLI reference.
Use only a product name and version in this variable. Netlify receives the value, and it can appear in a login URL printed by the CLI, so never put a token, session ID, or other secret in it. This setting identifies the agent; it does not grant the agent account access or limit what authenticated commands can do.