All skills
openai avatar

/netlify-deploy

@bf9e226 official
by openaiopenai/skills28k stars
1,891

Deploy web projects to Netlify using the Netlify CLI (`npx netlify`). Use when the user asks to deploy, host, publish, or link a site/repo on Netlify, including preview and production deploys.

Use this Skill: https://skilld.dev/gh/openai/skills/netlify-deploy

This session only. Nothing lands on disk.

referencesdeployment-patterns.md

≈1.7k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Netlify Deployment Patterns

Common deployment scenarios and best practices for the Netlify skill.

Deployment Decision Tree

Is user authenticated?
├─ No → Run `netlify login`
└─ Yes → Is site linked?
    ├─ No → Is it a Git repo?
    │   ├─ Yes → Try `netlify link --git-remote-url`
    │   │   ├─ Success → Continue to deploy
    │   │   └─ Fail → Run `netlify init`
    │   └─ No → Run `netlify init`
    └─ Yes → Is this first deploy or existing site?
        ├─ First deploy/new site → `netlify deploy --prod`
        └─ Existing site → `netlify deploy` (preview)

Scenario 1: First-Time Deployment (New Project)

Context: User has a project that has never been deployed to Netlify.

Steps:

  1. Check authentication: npx netlify status
  2. If not authenticated: npx netlify login
  3. Initialize new site: npx netlify init
    • This guides user through setup
    • Creates netlify.toml if needed
  4. Install dependencies: npm install
  5. Deploy to production: npx netlify deploy --prod

Example:

npx netlify status
# Not linked to a site

npx netlify login
# Opens browser for authentication

npx netlify init
# Walks through site creation

npm install
npx netlify deploy --prod

Scenario 2: Linking Existing Git Repository to Existing Site

Context: User has a site already on Netlify and wants to link their local repo.

Steps:

  1. Check authentication: npx netlify status
  2. Get Git remote: git remote show origin
  3. Extract URL (e.g., https://github.com/user/repo.git)
  4. Link by remote: npx netlify link --git-remote-url <URL>
  5. If found, linked. If not, run netlify init

Example:

git remote show origin
# * remote origin
#   Fetch URL: https://github.com/user/my-app.git

npx netlify link --git-remote-url https://github.com/user/my-app.git
# Site linked successfully

Scenario 3: Preview Deployment (Testing Changes)

Context: User wants to test changes before pushing to production.

Steps:

  1. Ensure site is linked: npx netlify status
  2. Make code changes
  3. Deploy preview: npx netlify deploy
  4. Review preview URL
  5. If approved, deploy to prod: npx netlify deploy --prod

Example:

# Make changes to code

npx netlify deploy
# Draft deploy URL: https://507f1f77bcf86cd799439011-my-app.netlify.app

# Test the preview, then:
npx netlify deploy --prod

Scenario 4: Framework-Specific Deployments

Next.js

# Next.js typically uses .next as output
npx netlify deploy --prod

# netlify.toml should have:
# [build]
#   command = "npm run build"
#   publish = ".next"

React (Vite)

# Vite outputs to dist by default
npm run build
npx netlify deploy --dir=dist --prod

# netlify.toml:
# [build]
#   command = "npm run build"
#   publish = "dist"

Static HTML

# No build step needed
npx netlify deploy --dir=. --prod

Scenario 5: Monorepo Deployment

Context: Project is in a subdirectory of a monorepo.

Steps:

  1. Navigate to project subdirectory: cd packages/frontend
  2. Or set base in netlify.toml:
    [build]
      base = "packages/frontend"
      command = "npm run build"
      publish = "dist"
  3. Deploy normally: npx netlify deploy --prod

Scenario 6: Environment Variables

Context: Project needs secrets or environment-specific config.

Steps:

  1. Never commit secrets to Git
  2. Set in Netlify dashboard or CLI:
    npx netlify env:set API_KEY "secret_value"
    npx netlify env:set NODE_ENV "production"
  3. Access in code: process.env.API_KEY
  4. Deploy: npx netlify deploy --prod

Scenario 7: Custom Domain Setup

Context: User wants to use a custom domain.

Steps:

  1. Deploy site first: npx netlify deploy --prod
  2. Add domain via dashboard or CLI:
    npx netlify open:admin
    # Navigate to Domain settings
  3. Update DNS records as instructed by Netlify
  4. Wait for DNS propagation (can take up to 48 hours)

Best Practices

1. Always Preview First

# Deploy preview
npx netlify deploy

# Test thoroughly
# Then deploy to production
npx netlify deploy --prod

2. Use netlify.toml for Consistency

Create a netlify.toml file in your repo root:

[build]
  command = "npm run build"
  publish = "dist"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

This ensures consistent builds across all deployments.

3. Framework Detection

Let Netlify auto-detect when possible. Only specify build settings if:

  • Netlify can't detect your framework
  • You need custom build commands
  • Your project has a non-standard structure

4. Dependency Installation

Always ensure dependencies are installed before deploying:

npm install  # or yarn install, pnpm install
npx netlify deploy

5. Build Locally First

Test builds locally before deploying:

npm run build
# Check that build output exists

npx netlify deploy --dir=dist

6. Use Deploy Messages

Add context to deployments:

npx netlify deploy --prod --message="Fix login bug"

Error Recovery Patterns

"Publish directory not found"

Cause: Build command didn't create expected output directory.

Fix:

  1. Run build locally: npm run build
  2. Check output directory name
  3. Update netlify.toml or CLI prompts with correct path

"Command failed with exit code 1"

Cause: Build command failed.

Fix:

  1. Check build logs for specific error
  2. Run build locally to reproduce: npm run build
  3. Fix the build error
  4. Deploy again

"Not logged in"

Cause: Authentication token expired or missing.

Fix:

npx netlify logout
npx netlify login

"No site linked"

Cause: Project not connected to a Netlify site.

Fix:

# Try linking to existing site
npx netlify link

# Or create new site
npx netlify init

Performance Tips

  1. Enable processing in netlify.toml for auto-optimization:

    [build.processing.css]
      bundle = true
      minify = true
  2. Use caching headers for static assets:

    [[headers]]
      for = "/assets/*"
      [headers.values]
        Cache-Control = "public, max-age=31536000, immutable"
  3. Optimize images before deploying or use Netlify Image CDN

  4. Use Netlify Functions for serverless backend (avoid external API calls when possible)

Resources

Source: SKILL.md on GitHub

1 warning17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill automates web project deployments to Netlify using the Netlify CLI. It includes routine security considerations such as executing local build commands and requesting escalated network permissions when required by the environment. These actions are aligned with the skill's intended purpose of hosting and publishing web content. See the detailed analysis for a breakdown of these operational patterns.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    6/6 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at bf9e226. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Activeupdated 8 months ago
  • CLI
  • netlify
  • deployment
  • hosting
  • web
  • preview-deploy
  • production-deploy
  • netlify-cli

README badge

README badge for openai/skills/netlify-deploy

Deploys web projects to Netlify using the Netlify CLI, handling authentication, site linking, and build configuration detection. Covers preview and production deploys, and works with any framework that has a build command and publish directory.

Generated from the current SKILL.md.

Does this skill require a global Netlify CLI install?
No. The skill uses npx netlify, which downloads and runs the CLI on-demand without requiring a global installation.
What authentication methods does this skill support?
Browser-based OAuth via netlify login (primary) and API key authentication via the NETLIFY_AUTH_TOKEN environment variable.
Can this skill deploy to production and preview environments?
Yes. Use npx netlify deploy for preview/draft deploys and npx netlify deploy --prod for production deployments to the live site URL.
What happens if the project isn't linked to a Netlify site?
The skill attempts to link by Git remote URL, or falls back to npx netlify init to create a new site interactively.
What should I do if deployment fails due to network restrictions?
Rerun the deploy command with sandbox_permissions=require_escalated to grant the skill escalated network access for outbound requests to Netlify.

Generated from the current SKILL.md. These answers refresh after source changes.