rollback
Rollback AI agent to a previous version. Use when reverting a deployment, undoing changes, or recovering from failed deploys.
When & Why to Use This Skill
This Claude skill automates the rollback process for AI agents within GitOps and Kubernetes environments. It enables developers to quickly revert to previous stable versions, manage deployment history, and perform emergency recoveries, ensuring high availability and robust version control for agentic workflows.
Use Cases
- Reverting a failed AI agent deployment to a specific stable version tag using automated GitOps workflows.
- Undoing recent configuration changes by rolling back a specific number of commits in the deployment repository.
- Executing emergency manual rollbacks via Kubernetes CLI to bypass CI/CD pipeline latency during critical production incidents.
- Auditing deployment history and image tags to identify and restore the most reliable previous version of an agent.
| name | rollback |
|---|---|
| description | Rollback AI agent to a previous version. Use when reverting a deployment, undoing changes, or recovering from failed deploys. |
Rollback Agent
Quickly rollback an agent to a previous version.
Arguments
agent-name: k8s-monitor, news-monitor (required)version: Specific version tag to rollback tocommits-back: Number like1or2to go back that many deployments
Instructions
Option 1: Rollback to Specific Version
cd /home/al/git/kubani
AGENT_NAME="k8s-monitor"
VERSION="0.1.0-abc1234"
sed -i "s|registry.almckay.io/${AGENT_NAME}:[^ ]*|registry.almckay.io/${AGENT_NAME}:${VERSION}|g" \
gitops/apps/ai-agents/${AGENT_NAME}/deployment.yaml
git add gitops/apps/ai-agents/${AGENT_NAME}/deployment.yaml
git commit -m "chore(gitops): rollback ${AGENT_NAME} to ${VERSION}"
git push
Option 2: Rollback N Commits Back
cd /home/al/git/kubani
AGENT_NAME="k8s-monitor"
N=1
COMMIT_SHA=$(git log --format='%H' -${N} gitops/apps/ai-agents/${AGENT_NAME}/deployment.yaml | tail -1)
git checkout ${COMMIT_SHA} -- gitops/apps/ai-agents/${AGENT_NAME}/deployment.yaml
git add gitops/apps/ai-agents/${AGENT_NAME}/deployment.yaml
git commit -m "chore(gitops): rollback ${AGENT_NAME} to ${COMMIT_SHA}"
git push
Emergency Rollback (Immediate)
For immediate rollback without waiting for Flux:
KUBECONFIG=/home/al/.kube/config kubectl rollout undo deployment/${AGENT_NAME} -n ai-agents
Warning: This will be overwritten when Flux next syncs.
Finding Previous Versions
AGENT_NAME="k8s-monitor"
# Show deployment history in git
git log --oneline -10 gitops/apps/ai-agents/${AGENT_NAME}/deployment.yaml
# Show what image tag was in each commit
git log --oneline -10 gitops/apps/ai-agents/${AGENT_NAME}/deployment.yaml | while read sha msg; do
tag=$(git show $sha:gitops/apps/ai-agents/${AGENT_NAME}/deployment.yaml | grep "image: registry" | head -1 | sed 's/.*://')
echo "$sha: $tag"
done
Post-Rollback Verification
KUBECONFIG=/home/al/.kube/config kubectl get pods -n ai-agents -l app.kubernetes.io/name=${AGENT_NAME}
KUBECONFIG=/home/al/.kube/config kubectl logs -n ai-agents -l app.kubernetes.io/name=${AGENT_NAME} --tail=20