> health-check-endpoints
Health check endpoints for liveness, readiness, dependency monitoring. Use for Kubernetes, load balancers, auto-scaling, or encountering probe failures, startup delays, dependency checks, timeout configuration errors.
curl "https://skillshub.wtf/secondsky/claude-skills/health-check-endpoints?format=md"Health Check Endpoints
Implement health checks for monitoring service availability and readiness.
Probe Types
| Probe | Purpose | Failure Action |
|---|---|---|
| Liveness | Is process alive? | Restart container |
| Readiness | Can handle traffic? | Remove from LB |
| Startup | Has app started? | Delay other probes |
| Deep | All deps healthy? | Trigger alerts |
Implementation (Express)
class HealthChecker {
async checkDatabase() {
const start = Date.now();
try {
await db.query('SELECT 1');
return { status: 'healthy', latency: Date.now() - start };
} catch (err) {
return { status: 'unhealthy', error: String(err?.message || err) };
}
}
async checkRedis() {
try {
await redis.ping();
return { status: 'healthy' };
} catch (err) {
return { status: 'unhealthy', error: err.message };
}
}
async getReadiness() {
const checks = await Promise.all([
this.checkDatabase(),
this.checkRedis()
]);
const healthy = checks.every(c => c.status === 'healthy');
return { healthy, checks };
}
}
// Liveness - lightweight
app.get('/health/live', (req, res) => {
res.json({ status: 'ok', timestamp: new Date().toISOString() });
});
// Readiness - check dependencies
app.get('/health/ready', async (req, res) => {
const health = await healthChecker.getReadiness();
res.status(health.healthy ? 200 : 503).json(health);
});
Kubernetes Configuration
livenessProbe:
httpGet:
path: /health/live
port: 3000
initialDelaySeconds: 15
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health/ready
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
Best Practices
- Keep liveness checks minimal (no external deps)
- Check only critical systems in readiness
- Return 200 for healthy, 503 for unhealthy
- Set reasonable timeouts to prevent cascading failures
- Include response time metrics
Additional Implementations
See references/implementations.md for:
- Python Flask complete health checker
- Java Spring Boot Actuator
- Full Kubernetes deployment config
Never Do
- Make liveness depend on external services
- Return 200 when dependencies are down
- Skip dependency checks in readiness
> related_skills --same-repo
> zustand-state-management
--- name: zustand-state-management description: Zustand state management for React with TypeScript. Use for global state, Redux/Context API migration, localStorage persistence, slices pattern, devtools, Next.js SSR, or encountering hydration errors, TypeScript inference issues, persist middleware problems, infinite render loops. Keywords: zustand, state management, React state, TypeScript state, persist middleware, devtools, slices pattern, global state, React hooks, create store, useBoundS
> zod
TypeScript-first schema validation and type inference. Use for validating API requests/responses, form data, env vars, configs, defining type-safe schemas with runtime validation, transforming data, generating JSON Schema for OpenAPI/AI, or encountering missing validation errors, type inference issues, validation error handling problems. Zero dependencies (2kb gzipped).
> xss-prevention
--- name: xss-prevention description: XSS attack prevention with input sanitization, output encoding, Content Security Policy. Use for user-generated content, rich text editors, web application security, or encountering stored XSS, reflected XSS, DOM manipulation, script injection errors. Keywords: sanitization, HTML-encoding, DOMPurify, CSP, Content-Security-Policy, rich-text-editor, user-input, escaping, innerHTML, DOM-manipulation, stored-XSS, reflected-XSS, input-validation, output-encodi
> wordpress-plugin-core
--- name: wordpress-plugin-core description: WordPress plugin development with hooks, security, REST API, custom post types. Use for plugin creation, $wpdb queries, Settings API, or encountering SQL injection, XSS, CSRF, nonce errors. Keywords: wordpress plugin development, wordpress security, wordpress hooks, wordpress filters, wordpress database, wpdb prepare, sanitize_text_field, esc_html, wp_nonce, custom post type, register_post_type, settings api, rest api, admin-ajax, wordpress sql inj