Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions agents/zero-downtime-deployment-expert.agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: 'zero-downtime-deployment-expert'
description: 'Zero-downtime deployment specialist for rolling updates, blue-green and canary releases, connection draining, and deploy-safe database changes'
tools: ['codebase', 'edit/editFiles', 'search', 'runCommands', 'terminalCommand']
---

# Zero-Downtime Deployment Expert

You are a zero-downtime deployment specialist. Your goal: users never notice a deploy - no dropped requests, no error spikes, no maintenance windows.

## Core Expertise

- **Rolling updates**: surge/unavailable budgets, readiness gates, minReadySeconds, health-gated progression
- **Blue-green**: environment switching, warm-up, instant rollback, cost trade-offs
- **Canary releases**: traffic splitting (weighted routing, header-based), automated analysis against error/latency baselines, progressive rollout
- **Connection draining**: SIGTERM handling, load balancer deregistration delays, keep-alive and long-lived connection (WebSocket/gRPC) migration
- **Deploy-safe changes**: backward/forward-compatible APIs and schemas, feature flags to decouple deploy from release

## Working Method

1. Establish the current deploy path first (CI/CD tool, orchestrator, load balancer) and its failure symptoms (502s during deploy, stuck rollouts).
2. Check the two prerequisites before any strategy work: real health/readiness checks and graceful shutdown. Without them every strategy drops traffic.
3. Verify N and N+1 versions can run simultaneously - API contracts, schema compatibility, cache/session formats. If not, fix compatibility before touching rollout mechanics.
4. Choose the simplest strategy that meets the risk profile: rolling for most services, blue-green for hard-to-probe monoliths, canary when blast radius must be measured.
5. Define rollback before rollout: what triggers it, how long it takes, and prove it with a rehearsal.

## Response Style

- Deliver pipeline/manifest changes as complete diffs or files for the user's actual tooling.
- Annotate every timing and threshold (drain delay, surge %, canary steps) with its reason.
- Refuse to design around a missing prerequisite - fix graceful shutdown and health checks first, and say so.
1 change: 1 addition & 0 deletions docs/README.agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,4 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#adding-agents) for guidelines on how to
| [WG Code Alchemist](../agents/wg-code-alchemist.agent.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fwg-code-alchemist.agent.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fwg-code-alchemist.agent.md) | Ask WG Code Alchemist to transform your code with Clean Code principles and SOLID design | |
| [WG Code Sentinel](../agents/wg-code-sentinel.agent.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fwg-code-sentinel.agent.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fwg-code-sentinel.agent.md) | Ask WG Code Sentinel to review your code for security issues. | |
| [WinForms Expert](../agents/WinFormsExpert.agent.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2FWinFormsExpert.agent.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2FWinFormsExpert.agent.md) | Support development of .NET (OOP) WinForms Designer compatible Apps. | |
| [Zero Downtime Deployment Expert](../agents/zero-downtime-deployment-expert.agent.md)<br />[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fzero-downtime-deployment-expert.agent.md)<br />[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fzero-downtime-deployment-expert.agent.md) | Zero-downtime deployment specialist for rolling updates, blue-green and canary releases, connection draining, and deploy-safe database changes | |
1 change: 1 addition & 0 deletions docs/README.skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#adding-skills) for guidelines on how to
| [github-issues](../skills/github-issues/SKILL.md)<br />`gh skills install github/awesome-copilot github-issues` | Create, update, and manage GitHub issues using MCP tools. Use this skill when users want to create bug reports, feature requests, or task issues, update existing issues, add labels/assignees/milestones, set issue fields (dates, priority, custom fields), set issue types, manage issue workflows, link issues, add dependencies, or track blocked-by/blocking relationships. Triggers on requests like "create an issue", "file a bug", "request a feature", "update issue X", "set the priority", "set the start date", "link issues", "add dependency", "blocked by", "blocking", or any GitHub issue management task. | `references/dependencies.md`<br />`references/images.md`<br />`references/issue-fields.md`<br />`references/issue-types.md`<br />`references/projects.md`<br />`references/search.md`<br />`references/sub-issues.md`<br />`references/templates.md` |
| [github-release](../skills/github-release/SKILL.md)<br />`gh skills install github/awesome-copilot github-release` | Guides IA through releasing a new version of a GitHub library end-to-end. Handles SemVer versioning and Keep a Changelog formatting automatically. | `references/commit-classification.md`<br />`references/semver-rules.md` |
| [go-mcp-server-generator](../skills/go-mcp-server-generator/SKILL.md)<br />`gh skills install github/awesome-copilot go-mcp-server-generator` | Generate a complete Go MCP server project with proper structure, dependencies, and implementation using the official github.com/modelcontextprotocol/go-sdk. | None |
| [graceful-shutdown-implementer](../skills/graceful-shutdown-implementer/SKILL.md)<br />`gh skills install github/awesome-copilot graceful-shutdown-implementer` | Implement graceful shutdown handling so services drain in-flight work before exiting on SIGTERM. Use when the user asks to handle SIGTERM/SIGINT, avoid dropped requests during deploys or scale-down, close database connections and consumers cleanly, or fix containers that are killed abruptly in Docker or Kubernetes. | None |
| [gsap-framer-scroll-animation](../skills/gsap-framer-scroll-animation/SKILL.md)<br />`gh skills install github/awesome-copilot gsap-framer-scroll-animation` | Use this skill whenever the user wants to build scroll animations, scroll effects, parallax, scroll-triggered reveals, pinned sections, horizontal scroll, text animations, or any motion tied to scroll position — in vanilla JS, React, or Next.js. Covers GSAP ScrollTrigger (pinning, scrubbing, snapping, timelines, horizontal scroll, ScrollSmoother, matchMedia) and Framer Motion / Motion v12 (useScroll, useTransform, useSpring, whileInView, variants). Use this skill even if the user just says "animate on scroll", "fade in as I scroll", "make it scroll like Apple", "parallax effect", "sticky section", "scroll progress bar", or "entrance animation". Also triggers for Copilot prompt patterns for GSAP or Framer Motion code generation. Pairs with the premium-frontend-ui skill for creative philosophy and design-level polish. | `references/framer.md`<br />`references/gsap.md` |
| [gtm-0-to-1-launch](../skills/gtm-0-to-1-launch/SKILL.md)<br />`gh skills install github/awesome-copilot gtm-0-to-1-launch` | Launch new products from idea to first customers. Use when launching products, finding early adopters, building launch week playbooks, diagnosing why adoption stalls, or learning that press coverage does not equal growth. Includes the three-layer diagnosis, the 2-week experiment cycle, and the launch that got 50K impressions and 12 signups. | None |
| [gtm-ai-gtm](../skills/gtm-ai-gtm/SKILL.md)<br />`gh skills install github/awesome-copilot gtm-ai-gtm` | Go-to-market strategy for AI products. Use when positioning AI products, handling "who is responsible when it breaks" objections, pricing variable-cost AI, choosing between copilot/agent/teammate framing, or selling autonomous tools into enterprises. | None |
Expand Down
97 changes: 97 additions & 0 deletions skills/graceful-shutdown-implementer/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
name: graceful-shutdown-implementer
description: 'Implement graceful shutdown handling so services drain in-flight work before exiting on SIGTERM. Use when the user asks to handle SIGTERM/SIGINT, avoid dropped requests during deploys or scale-down, close database connections and consumers cleanly, or fix containers that are killed abruptly in Docker or Kubernetes.'
license: MIT
---

# Graceful Shutdown Implementer

Add correct shutdown handling to services so rolling deploys, autoscaling, and container restarts never drop in-flight requests or leave half-finished jobs.

## When to Use This Skill

Use this skill when you need to:
- Handle `SIGTERM`/`SIGINT` in an application that currently exits abruptly
- Stop dropped requests / 502s during rolling deploys or pod eviction
- Close DB pools, message consumers, and background workers in the right order
- Fix Dockerized apps that ignore signals (shell-form CMD, missing init)

## Shutdown Sequence

Implement this order on `SIGTERM`:

1. **Stop accepting new work**: close the listener / fail readiness probe, stop pulling queue messages.
2. **Finish in-flight work** with a deadline (shorter than the orchestrator's grace period).
3. **Close outbound resources**: flush logs/telemetry, close DB pools, commit/nack consumer offsets.
4. **Exit 0**. If the deadline passes, exit non-zero so the abort is visible.

Key timing rule: application drain timeout < `stop_grace_period` (compose) / `terminationGracePeriodSeconds` (K8s), otherwise SIGKILL wins.

## Usage Examples

### Example 1: Node.js HTTP server

```javascript
const server = app.listen(3000);

async function shutdown(signal) {
console.log(`${signal} received, draining...`);
const deadline = setTimeout(() => process.exit(1), 25_000); // < grace period
server.close(async () => { // stops new conns, waits for in-flight
await db.end(); // close pools after requests finish
clearTimeout(deadline);
process.exit(0);
});
}
process.on("SIGTERM", () => shutdown("SIGTERM"));
process.on("SIGINT", () => shutdown("SIGINT"));
```

### Example 2: Python worker draining a queue

```python
import signal

stop = False
def handle_sigterm(signum, frame):
global stop
stop = True # finish current message, then exit loop
signal.signal(signal.SIGTERM, handle_sigterm)

while not stop:
msg = queue.get(timeout=1)
if msg:
process(msg)
msg.ack()
```

### Example 3: Making containers actually receive SIGTERM

```dockerfile
# BAD: shell form - PID 1 is /bin/sh, signals never reach node
CMD npm start

# GOOD: exec form running the app directly
CMD ["node", "dist/server.js"]
```

```yaml
# docker-compose: give the app time to drain
services:
api:
init: true # tiny init forwards signals, reaps zombies
stop_grace_period: 30s
```

## Guidelines

1. **Exec-form CMD/ENTRYPOINT always** - shell form swallows signals; alternatively use `exec` in entrypoint scripts.
2. **Fail readiness before stopping the listener (K8s)** - traffic may still arrive for a few seconds after SIGTERM; a small pre-stop sleep plus failing readiness closes the race.
3. **Drain order matters** - stop intake → finish work → close dependencies; closing the DB pool first turns in-flight requests into errors.
4. **Test it** - `docker stop` (or `kill -TERM`) under load should produce zero failed requests; make this a CI or staging check.
5. **Idempotent handlers** - guard against double signals; second SIGTERM should not restart the drain.

## Limitations

- Cannot make non-interruptible work (long single transactions, sync FFI calls) drain faster; those need job checkpointing.
- Windows containers use different stop signals; the patterns here target Linux runtimes.
Loading