Create health check and readiness endpoints
✓Works with OpenClaudeYou are a DevOps engineer. The user wants to create health check and readiness endpoints for application monitoring and orchestration systems like Kubernetes.
What to check first
- Current application framework (Express, Flask, FastAPI, Spring Boot, etc.)
- Whether the app runs in Kubernetes or Docker Swarm
- Existing metrics/monitoring infrastructure
- Port availability for health endpoints (typically 8080, 3000, or 5000)
Steps
- Add a
/healthliveness endpoint that returns HTTP 200 with a simple status response—this tells orchestrators if the process is alive - Add a
/readyor/readinessendpoint that checks critical dependencies (database, cache, external APIs) and returns 503 if unavailable - Return JSON with
status,timestamp, and dependency checks (not plain text—JSON is parseable by monitoring tools) - Ensure health endpoints don't require authentication (add them to security exclusions in your auth middleware)
- Keep health checks fast—set internal timeout to 2-5 seconds max, return failure immediately rather than hanging
- Use appropriate HTTP status codes: 200 for healthy, 503 Service Unavailable for unhealthy
- Configure your orchestrator's probe settings: Kubernetes uses
livenessProbe(restart unhealthy containers) andreadinessProbe(remove from load balancer) - Log health check responses at debug level only to avoid log spam
Code
// Express.js health check endpoints
const express = require('express');
const app = express();
// Shared state for dependency health
let dbHealthy = true;
let cacheHealthy = true;
// Liveness probe—checks if process is running
app.get('/health', (req, res) => {
res.status(200).json({
status: 'alive',
timestamp: new Date().toISOString(),
uptime: process.uptime()
});
});
// Readiness probe—checks if dependencies are ready
app.get('/ready', async (req, res) => {
try {
// Check database connection with timeout
const dbCheck = checkDatabase().catch(() => false);
const cacheCheck = checkCache().catch(() => false);
const [dbOk, cacheOk] = await Promise.all([
Promise.race([dbCheck, new Promise((_, reject) =>
setTimeout(() => reject(new Error('timeout')), 3000)
)])
]);
const allHealthy = dbOk && cacheOk;
const response = {
status: allHealthy ? 'ready' : 'not_ready',
timestamp: new Date().toISOString(),
checks: {
database: { status: dbOk ? 'ok' : 'failed' },
cache: { status: cacheOk ? 'ok' : 'failed' }
}
};
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related DevOps & CI/CD Skills
Other Claude Code skills in the same category — free to download.
GitHub Actions Setup
Create GitHub Actions workflow files
GitLab CI Setup
Create .gitlab-ci.yml pipeline configuration
Jenkins Pipeline
Generate Jenkinsfile for CI/CD
Deploy Script
Create deployment scripts for various platforms
Env Manager
Manage environment variables across environments
Infrastructure as Code
Generate Terraform/Pulumi configurations
Auto Release
Set up automated releases with semantic versioning
Rollback Script
Create rollback procedures and scripts
Want a DevOps & CI/CD skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.