Skip to content
Deployment
Skill

/netlify-config

Configure Netlify builds and routing via netlify.toml, _redirects, and _headers. Use when setting a build command or publish directory, validating netlify.toml against its JSON schema, adding redirects/rewrites/proxies or an SPA fallback rewrite, or setting custom response

From plugin
netlify-skills
5216 skills1 MCP

Claude Code

$ npx -y skills add netlify/context-and-tools --skill netlify-config --agent claude-code

SKILL.md

netlify-config.SKILL.md
name: netlify-config
description: Configure Netlify builds and routing via netlify.toml, _redirects, and _headers. Use when setting a build command or publish directory, validating netlify.toml against its JSON schema, adding redirects/rewrites/proxies or an SPA fallback rewrite, or setting custom response headers or basic auth. Also use when managing environment variables and secrets, scoping vars per deploy context, marking a var as secret or disabling secret scanning, configuring functions bundling, ignoring builds, or wiring up a monorepo or JavaScript SPA on Netlify.

Netlify configuration

Config lives in three files at the repo **root** (or the base/package directory for monorepos):

  • `netlify.toml`: build, contexts, plugins, functions, redirects, headers, dev.
  • `_redirects`: plain-text redirect/rewrite rules, saved to the **publish directory**, no extension.
  • `_headers`: plain-text response headers, saved to the **publish directory**.

`netlify.toml` values **take precedence over the Netlify UI** when they conflict. Paths in `netlify.toml` are absolute relative to the **base directory** (root `/` by default).

Modern vs legacy syntax to reach for

  • Schema: start `netlify.toml` with `"$schema" = "https://open-api.netlify.com/netlify.schema.json"` (key is quoted). Editors and agents with TOML JSON-schema support suggest and validate properties. In VS Code, use the Even Better TOML extension. Netlify ignores the key at build/deploy. **A schema-valid file can still fail to build**, because checks like whether a directory exists happen only during the build.
  • Functions bundler: use `node_bundler = "esbuild"`. `zisi` is the legacy JS default. TypeScript always uses `esbuild`.
  • Temporary redirect: use `status = 302`. `307` is **unsupported**.
  • Gatsby Image CDN: use `NETLIFY_IMAGE_CDN`, not the deprecated `GATSBY_CLOUD_IMAGE_CDN`.
  • Injecting env values into TOML: `key = "$VAR"` is **NOT supported** (except `signed` in proxy redirects). Use a build-command `sed` substitution or a build plugin (see below).

`netlify.toml` build + contexts

"$schema" = "https://open-api.netlify.com/netlify.schema.json"

[build]
  base = "frontend"
  publish = "dist"
  command = "npm run build"
  environment = { NODE_VERSION = "18" }

[context.production]
  publish = "output/"
  command = "make publish"

[context.deploy-preview]
  publish = "dist/"

[context."feat/branch"]        # quote names with special characters
  command = "npm run preview"

`[build]` runs in **Bash**. Context-aware keys include `[build]` and `[[plugins]]`. They do **NOT** include `[[redirects]]` or `[[headers]]`, which are always global. Precedence, least→most specific: UI < toml < any-context property < `[context.<name>]` < `[context.branchname]`.

Redirects and rewrites

`_redirects` rules are processed **first**, then `netlify.toml`. Within each, the **first matching rule top-to-bottom wins**, so list specific rules before general ones. Edge functions run before redirects.

SPA history-`pushState` fallback (required for clean URLs):

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

`_redirects` syntax is `from to [status] [conditions]`. Lines starting with `#` are comments, paths are case-sensitive, and special chars must be URL-encoded:

/home         /              301
/my-redirect  /              302
/ecommerce    /store-closed  404          # custom 404 for a path
/pass-through /index.html    200          # rewrite
/best-pets/dogs /best-pets/cats.html 200! # force/shadow (! or force=true)
/news/*  /blog/:splat                     # splat
/news/:month/:date/:year/:slug  /blog/:year/:month/:date/:slug   # placeholders
/store id=:id  /blog/:id  301             # query params
/  /anz  302  Country=au,nz               # no spaces in value list
/israel/*  /israel/he/:splat  302  Language=he
/* /legacy/:splat 200 Cookie=is_legacy,my_other_cookie

`[[redirects]]` keywords:

  • `from`, `to`
  • `status` (default `301`)
  • `force` (default `false`; same as `!`/shadow)
  • `query` (`query = {path = ":path"}`)
  • `conditions` (`{Language, Country, Role, Cookie}`)
  • `headers` (proxy request headers)
  • `signed` (env var name for signed proxies)

**Gotchas:**

  • You **cannot** add or remove a trailing slash with a redirect. The CDN normalizes URLs first, so a `/x/ → /x 301!` rule loops infinitely. Rely on Pretty URLs (default on).
  • Splat asterisks work only at the **end** of a segment (`/jobs/*`), not mid-path (`/jobs/*.html` is invalid). Placeholders (`:x`) work only at the start of a segment. You can't mix a wildcard and a placeholder in one segment.
  • You can't exclude a path from a splat. Put a more specific rule first instead.
  • `Country` takes ISO 3166-1 alpha-2 codes. Language redirects match only the **first** `Accept-Language` entry.
  • Role-based redirects with external auth providers are **Enterprise-only**.
  • For 10,000+ redirects, use wildcards/placeholders or Edge Functions. Oversized serialized output fails the deploy.

Proxies

/api/*           https://api.example.com/:splat        200
/netlify-site/*  https://my-other-site.netlify.app/:splat  200   # use .netlify.app, not custom domain
[[redirects]]                     # custom request headers + force
  from = "/search"
  to = "https://api.mysearch.com"
  status = 200
  force = true
  headers = {X-From = "Netlify"}

Signed proxy rules:

  • `signed` names an env var scoped to **Runtime**.
  • The rule must live in `netlify.toml`.
  • JWS signing works for external targets only, not Netlify→Netlify.
[[redirects]]
  from = "/search"
  to = "https://api.mysearch.com"
  status = 200
  force = true
  signed = "API_SIGNATURE_TOKEN_PLACEHOLDER"

**Gotchas:**

  • Cross-team rewrites are disallowed.
  • Rewrites within the same password-protected site are OK, but not across separate protected sites.
  • Proxy timeout is **26 s**.
  • Only one hop by default.
  • Assets with rel
Read more
@netlify
Ships withnetlify-skills

Public Netlify skills for AI coding agents. Each skill is a focused, factual reference for a Netlify platform primitive — designed to help agents build correctly on Netlify without needing to search docs.

5216 skills1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
52
Star history of netlify/context-and-tools on GitHub, a chart by star-history.com

Other skills on netlify-skills.

netlify-blobs

netlify-blobs

Store and retrieve unstructured objects, files, and cache-like state on Netlify with the @netlify/blobs module. Use when…

netlify-caching

netlify-caching

Cache dynamic and static responses on Netlify's CDN from Functions, Edge Functions, and proxies. Use when you add caching or…

netlify-database

netlify-database

Zero-config Postgres for Netlify apps via @netlify/database — querying data from Functions/Edge Functions, writing schema…

More skills from other plugins.

configuring-horizon

configuring-horizon

Use this skill whenever the user mentions Horizon by name in a Laravel context. Covers the full Horizon lifecycle: installing…

coolify11d66k
@coollabsio@coollabsioInstall Skill
vercel-cli

vercel-cli

Guides deployment, configuration, and troubleshooting with the Vercel CLI. Use when operating Vercel projects or resources…

vercel13d16k
@vercel@vercelInstall Skill
skypilot

skypilot

Use when launching cloud VMs, Kubernetes pods, or Slurm jobs for GPU/TPU/CPU workloads, training or fine-tuning models on cloud…

@skypilot-org@skypilot-orgInstall Skill
pinme

pinme

Use this skill when the user mentions "pinme", or needs to upload files, store to IPFS, create/publish/deploy websites or…

pinme2mo3.8k
@glitternetwork@glitternetworkInstall Skill

Questions about netlify-config.

Which coding agents can use netlify-config?
netlify-config installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.