{"success":true,"name":"add-health-and-readiness-endpoints-that-tell-the-truth","description":"Deploying an API behind a load balancer, orchestrator, or monitor","category":"ai-brimind","path":"ai-brimind/add-health-and-readiness-endpoints-that-tell-the-truth/SKILL.md","file":"SKILL.md","content":"---\nname: add-health-and-readiness-endpoints-that-tell-the-truth\ndescription: \"Deploying an API behind a load balancer, orchestrator, or monitor\"\n---\n\n# Add Health and Readiness Endpoints That Tell the Truth\n\n## When to use\nYour API runs where something automated decides if it's alive (load balancer, container orchestrator, uptime monitor), and no honest health endpoint exists.\n\n## Example request\nHealth check returns 200 unconditionally → the database is down but traffic keeps routing to a broken instance; the check tested nothing. — Health endpoint pings every dependency deeply → the check itself is slow and flaky, restarting healthy instances; liveness and readiness are different questions. — Third-party outage marks your service unhealthy → orchestrator restarts you in a loop for someone else's downtime; optional dependencies don't belong in readiness. — No health endpoint at all → deploys route traffic to instances still booting; readiness gates the traffic.\n\n## Instructions\nAct as an operations-minded developer who writes health checks for the machines that act on them. For the service: 1) Separate the two questions: liveness = 'is this process alive?' (cheap, no dependencies — restarting won't fix a down database); readiness = 'can I serve real traffic right now?' (checks essential dependencies like the database connection). 2) In readiness include only dependencies whose failure means you genuinely cannot serve — optional/degradable dependencies stay out, or a third-party's outage triggers your restart loop. 3) Keep checks fast and cheap: lightweight queries with timeouts, no expensive scans — the check runs every few seconds forever. 4) Use the platform's existing convention (standard paths, orchestrator probe config, framework health modules) — check what the infra expects before inventing endpoints. 5) Test the checks by breaking things: stop the database and confirm readiness fails while liveness passes. Only wire the probes once both answers are confirmed truthful under failure, and explain how each check drives the correct automated action (route away vs restart) rather than always saying OK.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #914\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}