# Openai Netlify Deploy > Despliega proyectos web en Netlify usando la Netlify CLI (`npx netlify`); úsalo cuando el usuario pida desplegar, alojar, publicar o vincular un sitio/repo, incluyendo deploys de preview y producción. Fuente: https://skillsagentes.com/skills/trailofbits/skills-curated/openai-netlify-deploy Markdown: https://skillsagentes.com/skills/trailofbits/skills-curated/openai-netlify-deploy.md Repositorio: https://github.com/trailofbits/skills-curated Autor: trailofbits Licencia: CC-BY-SA-4.0 Actualizado: hace 9 meses Coste de contexto: 60 tok instalada, 1.7k tok al activarse, 5k tok con todos los archivos del bundle Bundle: 4 archivos, 20 KB Permisos que pide: bash, read, grep, glob, write, edit ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add trailofbits/skills-curated --skill openai-netlify-deploy --agent claude-code # Cursor npx -y skills add trailofbits/skills-curated --skill openai-netlify-deploy --agent cursor # Codex npx -y skills add trailofbits/skills-curated --skill openai-netlify-deploy --agent codex # Gemini CLI npx -y skills add trailofbits/skills-curated --skill openai-netlify-deploy --agent gemini # Windsurf npx -y skills add trailofbits/skills-curated --skill openai-netlify-deploy --agent windsurf # Cline npx -y skills add trailofbits/skills-curated --skill openai-netlify-deploy --agent cline ``` ## Qué hace - Comprueba la autenticación en Netlify con `npx netlify status` y guía el login si falta - Detecta si el sitio ya está vinculado o lo vincula/crea con `netlify link` o `netlify init` - Instala dependencias del proyecto antes de desplegar (npm, yarn, pnpm) - Despliega con `npx netlify deploy` (preview) o `npx netlify deploy --prod` (producción) - Detecta el framework desde package.json y sugiere comando de build y directorio de publicación ## Cuándo usarla - El usuario pide desplegar, alojar, publicar o vincular un sitio/repositorio en Netlify - Necesitas hacer un deploy de preview o de producción ## Qué la activa - "Despliega este proyecto en Netlify" - "Publica este sitio en producción con Netlify" - "Vincula este repo a Netlify y haz un preview deploy" ## Antes de instalar - Necesitas Netlify CLI (vía npx, sin instalación global) y una cuenta de Netlify autenticada, o bien la variable NETLIFY_AUTH_TOKEN. - Necesita en el PATH: git, npm, npx - runs shell commands - writes to your files - makes network requests ## Archivos - SKILL.md — 7 KB - references/cli-commands.md — 3 KB - references/deployment-patterns.md — 7 KB - references/netlify-toml.md — 4 KB ## SKILL.md Reproducido tal cual desde trailofbits/skills-curated bajo CC-BY-SA-4.0. Esta sección es el documento original y está en inglés. # Netlify Deployment Skill Deploy web projects to Netlify using the Netlify CLI with intelligent detection of project configuration and deployment context. ## Overview This skill automates Netlify deployments by: - Verifying Netlify CLI authentication - Detecting project configuration and framework - Linking to existing sites or creating new ones - Deploying to production or preview environments ## Prerequisites - **Netlify CLI**: Installed via npx (no global install required) - **Authentication**: Netlify account with active login session - **Project**: Valid web project in current directory - The deployment might take a few minutes. Use appropriate timeout values. ## Authentication Pattern The skill uses the **pre-authenticated Netlify CLI** approach: 1. Check authentication status with `npx netlify status` 2. If not authenticated, guide user through `npx netlify login` 3. Fail gracefully if authentication cannot be established Authentication uses either: - **Browser-based OAuth** (primary): `netlify login` opens browser for authentication - **API Key** (alternative): Set `NETLIFY_AUTH_TOKEN` environment variable ## Workflow ### 1. Verify Netlify CLI Authentication Check if the user is logged into Netlify: ```bash npx netlify status ``` **Expected output patterns**: - ✅ Authenticated: Shows logged-in user email and site link status - ❌ Not authenticated: "Not logged into any site" or authentication error **If not authenticated**, guide the user: ```bash npx netlify login ``` This opens a browser window for OAuth authentication. Wait for user to complete login, then verify with `netlify status` again. **Alternative: API Key authentication** If browser authentication isn't available, users can set: ```bash export NETLIFY_AUTH_TOKEN=your_token_here ``` Tokens can be generated at: https://app.netlify.com/user/applications#personal-access-tokens ### 2. Detect Site Link Status From `netlify status` output, determine: - **Linked**: Site already connected to Netlify (shows site name/URL) - **Not linked**: Need to link or create site ### 3. Link to Existing Site or Create New **If already linked** → Skip to step 4 **If not linked**, attempt to link by Git remote: ```bash # Check if project is Git-based git remote show origin # If Git-based, extract remote URL # Format: https://github.com/username/repo or git@github.com:username/repo.git # Try to link by Git remote npx netlify link --git-remote-url ``` **If link fails** (site doesn't exist on Netlify): ```bash # Create new site interactively npx netlify init ``` This guides user through: 1. Choosing team/account 2. Setting site name 3. Configuring build settings 4. Creating netlify.toml if needed ### 4. Verify Dependencies Before deploying, ensure project dependencies are installed: ```bash # For npm projects npm install # For other package managers, detect and use appropriate command # yarn install, pnpm install, etc. ``` ### 5. Deploy to Netlify Choose deployment type based on context: **Preview/Draft Deploy** (default for existing sites): ```bash npx netlify deploy ``` This creates a deploy preview with a unique URL for testing. **Production Deploy** (for new sites or explicit production deployments): ```bash npx netlify deploy --prod ``` This deploys to the live production URL. **Deployment process**: 1. CLI detects build settings (from netlify.toml or prompts user) 2. Builds the project locally 3. Uploads built assets to Netlify 4. Returns deployment URL ### 6. Report Results After deployment, report to user: - **Deploy URL**: Unique URL for this deployment - **Site URL**: Production URL (if production deploy) - **Deploy logs**: Link to Netlify dashboard for logs - **Next steps**: Suggest `netlify open` to view site or dashboard ## Handling netlify.toml If a `netlify.toml` file exists, the CLI uses it automatically. If not, the CLI will prompt for: - **Build command**: e.g., `npm run build`, `next build` - **Publish directory**: e.g., `dist`, `build`, `.next` Common framework defaults: - **Next.js**: build command `npm run build`, publish `.next` - **React (Vite)**: build command `npm run build`, publish `dist` - **Static HTML**: no build command, publish current directory The skill should detect framework from `package.json` if possible and suggest appropriate settings. ## Example Full Workflow ```bash # 1. Check authentication npx netlify status # If not authenticated: npx netlify login # 2. Link site (if needed) # Try Git-based linking first git remote show origin npx netlify link --git-remote-url https://github.com/user/repo # If no site exists, create new one: npx netlify init # 3. Install dependencies npm install # 4. Deploy (preview for testing) npx netlify deploy # 5. Deploy to production (when ready) npx netlify deploy --prod ``` ## Error Handling Common issues and solutions: **"Not logged in"** → Run `npx netlify login` **"No site linked"** → Run `npx netlify link` or `npx netlify init` **"Build failed"** → Check build command and publish directory in netlify.toml or CLI prompts → Verify dependencies are installed → Review build logs for specific errors **"Publish directory not found"** → Verify build command ran successfully → Check publish directory path is correct ## Troubleshooting ### Escalated Network Access Example guidance to the user: ``` The deploy needs escalated network access to deploy to Netlify. I can rerun the command with escalated permissions—want me to proceed? ``` ## Environment Variables For secrets and configuration: 1. Never commit secrets to Git 2. Set in Netlify dashboard: Site Settings → Environment Variables 3. Access in builds via `process.env.VARIABLE_NAME` ## Tips - Use `netlify deploy` (no `--prod`) first to test before production - Run `netlify open` to view site in Netlify dashboard - Run `netlify logs` to view function logs (if using Netlify Functions) - Use `netlify dev` for local development with Netlify Functions ## Reference - Netlify CLI Docs: https://docs.netlify.com/cli/get-started/ - netlify.toml Reference: https://docs.netlify.com/configure-builds/file-based-configuration/ ## Bundled References (Load As Needed) - [CLI commands](references/cli-commands.md) - [Deployment patterns](references/deployment-patterns.md) - [netlify.toml guide](references/netlify-toml.md) ## When to Use ## When NOT to Use ## Dónde encaja - Categoría: [DevOps e infraestructura](https://skillsagentes.com/categorias/devops-infraestructura.md) — Despliegues, contenedores, IaC y flujos de gestión de incidentes. - Creador: [trailofbits](https://skillsagentes.com/creators/trailofbits.md) — 117 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Grilling](https://skillsagentes.com/skills/trailofbits/skills-curated/grilling.md): Interroga al usuario sin descanso sobre un plan, decisión o idea hasta resolver cada rama del árbol de decisión, o cuando dice "grill me on this". - [Handoff](https://skillsagentes.com/skills/trailofbits/skills-curated/handoff.md): Compacta la conversación actual en un documento de traspaso para que un agente nuevo pueda continuar el trabajo en otra sesión. - [Teach](https://skillsagentes.com/skills/trailofbits/skills-curated/teach.md): Enseña al usuario una nueva habilidad o concepto a lo largo de varias sesiones, usando el directorio actual como un espacio de enseñanza con estado, con lecciones, registros de aprendizaje y materiales de referencia. - [Writing Great Skills](https://skillsagentes.com/skills/trailofbits/skills-curated/writing-great-skills.md): Referencia para escribir y editar bien skills de agentes: el vocabulario y los principios que hacen que un skill sea predecible. Consúltalo al redactar, revisar o podar un SKILL.md. - [Ffuf Web Fuzzing](https://skillsagentes.com/skills/trailofbits/skills-curated/ffuf-web-fuzzing.md): Guía experta para el fuzzing web con ffuf en pentesting autorizado: descubrimiento de directorios y subdominios, fuzzing de parámetros, peticiones autenticadas y análisis de resultados. ## Skills relacionadas - [Wizard](https://skillsagentes.com/skills/mattpocock/skills/wizard.md): Genera un wizard bash interactivo que guía a un humano por los pasos que solo él puede dar. Úsalo para aprovisionar infraestructura, credenciales o secretos de CI, o una migración puntual. - [Deploy Release Test](https://skillsagentes.com/skills/vercel/next.js/deploy-release-test.md): Valida el paquete de preview de Next.js específico de un commit y dispara manualmente toda la suite de tests de despliegue vía el workflow test_e2e_deploy_release.yml de GitHub Actions. - [Canary](https://skillsagentes.com/skills/garrytan/gstack/canary.md): Monitoreo canary post-deploy: vigila la app en producción tras el despliegue. (gstack) - [Gstack Upgrade](https://skillsagentes.com/skills/garrytan/gstack/gstack-upgrade.md): Actualiza gstack a la última versión. - [Land And Deploy](https://skillsagentes.com/skills/garrytan/gstack/land-and-deploy.md): Fusiona el PR, espera CI y el despliegue, y verifica la salud de producción con checks canary. Continúa el trabajo que /ship dejó iniciado. (gstack) --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)