AI Blocks › Build and ship software
Safe shutdown code writer
Point it at your server or worker. Get code that finishes live work and exits cleanly when stopped.
Safe shutdown code writer is a free AI skill for the job "Build and ship software". Give the instructions to an AI assistant that supports the required files and tools, then review its output.
Free · No account · CC BY 4.0 licence · Made by sickn33 · Level: advanced
Made by sickn33. See the original on GitHub; we copied it as it is, with its licence.
What it does
Code that lets your server or worker stop without dropping live requests or losing half-done jobs. Point it at your service and get a shutdown routine for when it receives a stop signal. The pattern runs in order. Catch the stop signals early and set a flag, ignoring repeats. Stop taking new connections or queue jobs right away. Let current work finish within a time limit. Close database connections and other resources. Then exit with the right code. It also adds health check endpoints so a load balancer stops sending traffic first, and notes for Kubernetes and Docker, which send the signal before they kill. Examples are given in TypeScript, and the same steps apply to other languages.
You give it
- Your server or worker code
- Language and framework
- How long a request or job can take
- Where you deploy
You get
- Signal handler code
- A drain and cleanup routine
- Health check endpoints
- A time limit with a forced exit
Use it when
- Deploys drop active requests and users see errors.
- A background worker loses jobs when the container restarts.
- You run on Kubernetes or Docker and need to handle the stop signal.
- You need health check endpoints for readiness.
How to use it
- Add it to your AI once: download it and add the folder to Claude, ChatGPT or Codex as a skill.
- Ask for the job in your own words. Your AI opens the skill when it fits.
- It works best when your AI can read and edit your project files.