From harness-claude
Implements health check endpoints (liveness, readiness, startup) for service monitoring in Kubernetes and load balancers.
How this skill is triggered — by the user, by Claude, or both
Slash command
/harness-claude:resilience-health-checksThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Implement health check endpoints for service readiness, liveness, and dependency monitoring
Implement health check endpoints for service readiness, liveness, and dependency monitoring
/health/live (liveness), /health/ready (readiness), /health/startup (startup).// health/health-controller.ts
interface HealthComponent {
name: string;
status: 'up' | 'down' | 'degraded';
latency?: number;
details?: string;
}
interface HealthResponse {
status: 'healthy' | 'unhealthy' | 'degraded';
uptime: number;
timestamp: string;
components: HealthComponent[];
}
export class HealthChecker {
private ready = false;
private shuttingDown = false;
private startTime = Date.now();
private checks: Array<{ name: string; check: () => Promise<HealthComponent> }> = [];
registerCheck(name: string, check: () => Promise<HealthComponent>) {
this.checks.push({ name, check });
}
setReady(ready: boolean) {
this.ready = ready;
}
setShuttingDown() {
this.shuttingDown = true;
this.ready = false;
}
async liveness(): Promise<{ status: number; body: object }> {
return {
status: 200,
body: { status: 'alive', uptime: Date.now() - this.startTime },
};
}
async readiness(): Promise<{ status: number; body: HealthResponse }> {
if (this.shuttingDown || !this.ready) {
return {
status: 503,
body: {
status: 'unhealthy',
uptime: Date.now() - this.startTime,
timestamp: new Date().toISOString(),
components: [
{
name: 'server',
status: 'down',
details: this.shuttingDown ? 'shutting down' : 'not ready',
},
],
},
};
}
const components = await Promise.all(
this.checks.map(async ({ name, check }) => {
try {
return await check();
} catch (err) {
return { name, status: 'down' as const, details: String(err) };
}
})
);
const allUp = components.every((c) => c.status === 'up');
const anyDown = components.some((c) => c.status === 'down');
return {
status: anyDown ? 503 : 200,
body: {
status: anyDown ? 'unhealthy' : allUp ? 'healthy' : 'degraded',
uptime: Date.now() - this.startTime,
timestamp: new Date().toISOString(),
components,
},
};
}
}
// Registering checks
const health = new HealthChecker();
health.registerCheck('database', async () => {
const start = Date.now();
await pool.query('SELECT 1');
return { name: 'database', status: 'up', latency: Date.now() - start };
});
health.registerCheck('redis', async () => {
const start = Date.now();
await redis.ping();
return { name: 'redis', status: 'up', latency: Date.now() - start };
});
// Graceful shutdown
process.on('SIGTERM', () => {
health.setShuttingDown();
// Allow in-flight requests to complete
setTimeout(() => process.exit(0), 30000);
});
Kubernetes probe configuration:
livenessProbe:
httpGet: { path: /health/live, port: 3000 }
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3 # Restart after 3 failures
readinessProbe:
httpGet: { path: /health/ready, port: 3000 }
periodSeconds: 5
failureThreshold: 2 # Remove from service after 2 failures
startupProbe:
httpGet: { path: /health/startup, port: 3000 }
periodSeconds: 5
failureThreshold: 30 # Allow up to 150s for startup
Liveness vs readiness: Liveness failure triggers a pod restart. Readiness failure removes the pod from the service endpoint (no traffic routed to it). Making liveness too strict causes unnecessary restarts. Making readiness too lenient routes traffic to broken instances.
Health check anti-patterns:
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeImplements liveness, readiness, startup, and deep health check endpoints with dependency monitoring. Use for Kubernetes probes, load balancers, auto-scaling, or fixing probe failures and startup delays.
Implements /health and /ready endpoints for liveness and readiness probes in container orchestration platforms like Kubernetes. Includes example with Express, Prisma, and Redis.
Wires health-check endpoints (/health, /readyz, /livez) in Go services using xgodev/boost/extra/health. Covers liveness vs readiness, checkers, and aggregation.