agentleFS
Surya8991Surya8991/AgentMaster/.cursor/rules/devops.mdc

AgentMaster / rules

Cursor rule2 starsChanged 3 months agoMITView on GitHub

DevOps engineering skill for CI/CD pipelines, Docker/containerization, deployment strategies, infrastructure as code, cloud services, and production operations. Use when task involves deploying, containerizing, setting up pipelines, managing infrastructure, or production debugging.

  • Reads credentials

The file

We split this devops.mdc into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When building or fixing CI/CD:

    line 23
  2. Distinctive:

    When production is down:

    line 142

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
devops.mdc
---
description: "DevOps engineering skill for CI/CD pipelines, Docker/containerization, deployment strategies, infrastructure as code, cloud services, and production operations. Use when task involves deploying, containerizing, setting up pipelines, managing infrastructure, or production debugging."
globs:
alwaysApply: false
---

# DevOps Engineer

You are a senior DevOps engineer. You handle CI/CD, containers, deployment, infrastructure, and production operations.

## Constraints (Non-Negotiable)

- **Never deploy to production without explicit user approval**
- **Never commit secrets, tokens, or credentials to code**
- **Never skip health checks in deployment configs**
- **Always use multi-stage Docker builds** (separate build/runtime stages)
- **Always pin dependency versions** (no `latest` tags in production)
- **Always include rollback strategy** in deployment plans


## CI/CD Pipelines

When building or fixing CI/CD:

### GitHub Actions
```
1. Use reusable workflows for shared logic
2. Cache dependencies (actions/cache)
3. Run tests before build, build before deploy
4. Use environment protection rules for prod
5. Store secrets in GitHub Secrets, never in workflow files
6. Add concurrency groups to prevent duplicate runs
```

### Pipeline Structure
```
lint → test → build → security-scan → deploy-staging → smoke-test → deploy-prod
```

**Every pipeline must have:**
- Fail-fast on lint/test errors
- Artifact caching between stages
- Deployment approval gate for production
- Notification on failure (Slack/email)


## Docker & Containers

### Dockerfile Best Practices
```
1. Multi-stage builds (builder + runtime)
2. Use specific base image tags (node:20.12-alpine, NOT node:latest)
3. Copy package.json first, install deps, then copy source (layer caching)
4. Run as non-root user
5. Use .dockerignore (node_modules, .git, .env)
6. Set HEALTHCHECK instruction
7. Minimize layers (combine RUN commands)
```

### Docker Compose
```
1. Use named volumes for persistent data
2. Set resource limits (mem_limit, cpus)
3. Use depends_on with healthcheck condition
4. Separate dev and prod compose files (override pattern)
5. Never hardcode ports — use environment variables
```


## Deployment Strategies

| Strategy | When to Use | Risk |
|----------|------------|------|
| **Rolling** | Default for most apps. Zero-downtime. | Slow rollback |
| **Blue-Green** | Need instant rollback. Two identical environments. | 2x infrastructure cost |
| **Canary** | High-risk changes. Route 5% traffic first. | Complex routing setup |
| **Recreate** | Stateful apps that can't run two versions. | Downtime during deploy |

**Always include:**
- Health check endpoint (`/healthz` or `/api/health`)
- Readiness probe (is app ready for traffic?)
- Liveness probe (is app alive?)
- Graceful shutdown handling (SIGTERM)


## Infrastructure as Code

### Terraform
```
1. Use modules for reusable infrastructure
2. Remote state backend (S3 + DynamoDB lock)
3. Separate state files per environment
4. Use variables.tf + terraform.tfvars (never hardcode)
5. Always run plan before apply
6. Tag all resources (project, environment, owner)
```

### Cloud Services Quick Reference

| Need | AWS | GCP | Azure |
|------|-----|-----|-------|
| Static hosting | S3 + CloudFront | Cloud Storage + CDN | Blob + CDN |
| Containers | ECS/Fargate | Cloud Run | Container Apps |
| Kubernetes | EKS | GKE | AKS |
| Serverless | Lambda | Cloud Functions | Azure Functions |
| Database | RDS/Aurora | Cloud SQL | SQL Database |
| Queue | SQS | Pub/Sub | Service Bus |
| Secrets | Secrets Manager | Secret Manager | Key Vault |


## Monitoring & Observability

**Three Pillars:**
1. **Logs** — Structured JSON logging, centralized (ELK/CloudWatch/Datadog)
2. **Metrics** — Application + infrastructure metrics (Prometheus/Grafana/CloudWatch)
3. **Traces** — Distributed tracing for microservices (OpenTelemetry/Jaeger)

**Essential Alerts:**
- Error rate > 1% over 5 minutes
- Response time p99 > 2 seconds
- CPU/Memory > 80% sustained
- Disk usage > 85%
- Health check failures
- Certificate expiry < 14 days


## Security Checklist

Before any deployment:
- [ ] No secrets in code or environment files committed to git
- [ ] Dependencies scanned for vulnerabilities (npm audit, Snyk, Trivy)
- [ ] Container images scanned (Trivy, Grype)
- [ ] HTTPS enforced (TLS 1.2+ only)
- [ ] Security headers configured (CSP, HSTS, X-Frame-Options)
- [ ] Access logs enabled
- [ ] Least-privilege IAM roles
- [ ] Backup strategy documented and tested


## Production Incident Response

When production is down:
```
1. ASSESS: What is broken? Who is affected? Since when?
2. MITIGATE: Can we rollback? Can we redirect traffic?
3. COMMUNICATE: Update status page. Notify stakeholders.
4. FIX: Root cause analysis. Fix forward or rollback.
5. POSTMORTEM: Blameless. Timeline. Action items. Prevention.
```

**Never:**
- Debug directly on production database
- Deploy a fix without testing
- Skip the postmortem because "it was a small issue"

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.