netlify-development
БесплатноБез исполняемых скриптовНе проверенBest practices for building and deploying Netlify sites, covering serverless and edge functions, Netlify Blobs storage, the Image CDN, and build…
от Mindrally★ 323 звезды на GitHubОб этом скилле
Netlify Development Best Practices
Overview
This skill provides comprehensive guidelines for building and deploying projects on Netlify, covering serverless functions, edge functions, background functions, scheduled functions, Netlify Blobs, Image CDN, and deployment configuration.
Core Principles
- Use in-code configuration via exported
configobjects (preferred over netlify.toml) - Never add version numbers to imported Netlify packages (use
@netlify/functions, never@netlify/[email protected]) - Only add CORS headers when explicitly required
- Leverage appropriate function types for different use cases
- Use Netlify Blobs for state and data storage
- The
.netlifyfolder is generated tooling output, not user code — keep it in.gitignore - Never put serverless or edge functions inside the publish/public directory
- Don't change the default functions or edge-functions directory unless explicitly asked to
Function Types Overview
| Type | Use Case | Timeout | Path Convention |
|---|---|---|---|
| Serverless | Standard API endpoints | 10s (26s Pro) | /.netlify/functions/name |
| Edge | Request/response modification | 50ms CPU | Custom paths |
| Background | Long-running async tasks | 15 minutes | -background suffix |
| Scheduled | Cron-based tasks | 30s | Configured schedule |
Function and edge-function source directories default to netlify/functions and netlify/edge-functions, but can be overridden in netlify.toml:
[functions]
directory = "my_functions"
[build]
edge_functions = "my-edge-functions"
netlify.toml settings override UI build-settings configuration.
Serverless Functions
Basic Structure
// netlify/functions/hello.mts
import type { Context } from '@netlify/functions';
export default async (request: Request, context: Context) => {
try {
// Validate request
if (request.method !== 'POST') {
return new Response('Method Not Allowed', { status: 405 });
}
const body = await request.json();
// Business logic
const result = await processData(body);
return Response.json(result);
} catch (error) {
console.error('Function error:', error);
return Response.json({ error: 'Internal Server Error' }, { status: 500 });
}
};
export const config = {
path: '/api/hello',
};
Configuration Options
export const config = {
// Custom path (instead of /.netlify/functions/name)
path: '/api/users',
// HTTP methods (optional, allows all by default)
method: ['GET', 'POST'],
// Rate limiting
rateLimit: {
windowSize: 60,
windowLimit: 100,
},
};
Path Conventions
- Default path:
/.netlify/functions/{function_name} - Custom paths via config completely replace the default
- Use custom paths for cleaner API URLs
The Context Argument
Both serverless and edge functions receive a context object as their second argument:
{
account: { id: string }; // Netlify team account ID
cookies: {
get: (name: string) => string | undefined;
set: (options: { name: string; value: string; path?: string; domain?: string; secure?: boolean; httpOnly?: boolean; expires?: Date }) => void;
delete: (nameOrOptions: string | { name: string; path?: string; domain?: string }) => void;
};
deploy: { context: string; id: string; published: boolean };
geo: {
city: string;
country: { code: string; name: string };
latitude: number;
longitude: number;
subdivision: { code: string; name: string };
timezone: string;
postalCode: string;
ip: string;
};
params: Record<string, string>; // route params from the path config
requestId: string;
server: { region: string };
site: { id: string; name: string; url: string };
}
The Netlify Global Object
Available in global scope on all serverless and edge functions — prefer Netlify.env.* over process.env for reading/writing environment variables at runtime:
{
context: object | null; // same as the function's second arg; null outside a handler
env: {
get: (name: string) => string | undefined;
has: (name: string) => boolean;
set: (name: string, value: string) => void;
delete: (name: string) => void;
toObject: () => Record<string, string>;
};
}
Edge Functions
Use Cases
- Modify requests before they reach the origin
- Modify responses before returning to users
- Geolocation-based personalization
- A/B testing
- Authentication at the edge
Implementation
// netlify/edge-functions/geo-redirect.ts
import type { Context } from '@netlify/edge-functions';
export default async (request: Request, context: Context) => {
const country = context.geo.country?.code || 'US';
// Redirect based on country
if (country === 'DE') {
return Response.redirect(new URL('/de', request.url));
}
// Continue to origin
return context.next();
};
Установить netlify-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл netlify-development?
Best practices for building and deploying Netlify sites, covering serverless and edge functions, Netlify Blobs storage, the Image CDN, and build configuration. Use when writing Netlify Functions or Edge Functions, configuring netlify.toml or redirects/headers, managing environment variables across deploy contexts, working with Netlify Blobs, or setting up local development and deploy previews.
Как установить скилл netlify-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл netlify-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic