cloud-platform-skills / skills
Cursor rule1 starsChanged 3 months agoMITView on GitHub
Production Bash and Python automation: `set -euo pipefail` discipline, lockfile-guarded single execution, idempotent design, structured logging, trap-based cleanup, and CLI ergonomics. Use when writing, reviewing, or hardening an operational script, cron job, or internal CLI tool.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,531 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository167 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/rules/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/00-index.mdcCursor rule
- .cursor/rules/skills/ai-agent-security-llm-threats.mdcCursor rule
- .cursor/rules/skills/api-gateway-service-mesh.mdcCursor rule
- .cursor/rules/skills/aws-cloud-migration-strategies.mdcCursor rule
- .cursor/rules/skills/aws-eks-enterprise-patterns.mdcCursor rule
- .cursor/rules/skills/aws-iam-zero-trust-policies.mdcCursor rule
- .cursor/rules/skills/azure-aks-enterprise-landing-zones.mdcCursor rule
- .cursor/rules/skills/azure-cloud-engineering-patterns.mdcCursor rule
- .cursor/rules/skills/backup-and-disaster-recovery.mdcCursor rule
- .cursor/rules/skills/chaos-engineering-resilience-testing.mdcCursor rule
- .cursor/rules/skills/cicd-pipeline-design.mdcCursor rule
- .cursor/rules/skills/cloud-native-microservices-patterns.mdcCursor rule
- .cursor/rules/skills/cloud-security-posture-cspm-cis.mdcCursor rule
- .cursor/rules/skills/configuration-management-ansible.mdcCursor rule
- .cursor/rules/skills/container-runtime-security-falco.mdcCursor rule
- .cursor/rules/skills/database-devops-lifecycle.mdcCursor rule
- .cursor/rules/skills/detection-engineering-threat-hunting.mdcCursor rule
- .cursor/rules/skills/devops-metrics-dora-kpis.mdcCursor rule
- .cursor/rules/skills/docker-containerization-basics.mdcCursor rule
- .cursor/rules/skills/enterprise-iac-governance-terragrunt.mdcCursor rule
- .cursor/rules/skills/finops-framework-inform-optimize-operate.mdcCursor rule
- .cursor/rules/skills/gcp-cloud-engineering-patterns.mdcCursor rule
- .cursor/rules/skills/gcp-gke-autopilot-multi-tenant.mdcCursor rule
- .cursor/rules/skills/git-branching-merge-strategies.mdcCursor rule
- .cursor/rules/skills/gitops-multi-cluster-argo-flux.mdcCursor rule
- .cursor/rules/skills/helm-kubernetes-deployment.mdcCursor rule
- .cursor/rules/skills/incident-management-and-postmortem.mdcCursor rule
- .cursor/rules/skills/infrastructure-host-monitoring.mdcCursor rule
- .cursor/rules/skills/internal-developer-portal-backstage.mdcCursor rule
- .cursor/rules/skills/linux-sysadmin-troubleshooting.mdcCursor rule
- .cursor/rules/skills/performance-load-testing.mdcCursor rule
- .cursor/rules/skills/policy-as-code-opa-kyverno.mdcCursor rule
- .cursor/rules/skills/prometheus-grafana-otel-tracing.mdcCursor rule
- .cursor/rules/skills/scalability-high-availability-patterns.mdcCursor rule
- .cursor/rules/skills/secops-incident-triage-forensics.mdcCursor rule
- .cursor/rules/skills/secrets-management-vault-kms.mdcCursor rule
- .cursor/rules/skills/serverless-event-driven-architecture.mdcCursor rule
- .cursor/rules/skills/shift-left-security-sast-sca.mdcCursor rule
- .cursor/rules/skills/sli-slo-error-budget-design.mdcCursor rule
- .cursor/rules/skills/supply-chain-security-slsa-sigstore.mdcCursor rule
- .cursor/rules/skills/terraform-iac-modules.mdcCursor rule
- .cursor/rules/skills/write-a-skill.mdcCursor rule
- .cursor/rules/skills/zero-downtime-release-strategies.mdcCursor rule
- ai-agent-security-llm-threatsSkill
- api-gateway-service-meshSkill
- aws-cloud-migration-strategiesSkill
- aws-eks-enterprise-patternsSkill
- aws-iam-zero-trust-policiesSkill
- azure-aks-enterprise-landing-zonesSkill
- azure-cloud-engineering-patternsSkill
- backup-and-disaster-recoverySkill
- chaos-engineering-resilience-testingSkill
- cicd-pipeline-designSkill
- cloud-native-microservices-patternsSkill
- cloud-security-posture-cspm-cisSkill
- configuration-management-ansibleSkill
- The first 60 shown.
The file
We split this scripting-and-automation.mdc into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 63
Do: Always set set -euo pipefail at the start of any production Bash script.
- Very specific: line 64
Do: Use Python for complex JSON parsing, API interactions, and matrix data structures rather than nesting deep awk/sed/jq chains.
- Very specific: line 65
Don't: Never use eval with user-supplied parameters to avoid command injection vulnerabilities.
- Very specific: line 66
Don't: Avoid parsing ls output; use globs or find ...
- Very specific: line 96
Use flock --wait 60 when a delayed run is better than a skipped one, and --nonblock when a skipped run is better than a queue of piled-up …
≈ “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.
Files
---
description: "Production Bash and Python automation: `set -euo pipefail` discipline, lockfile-guarded single execution, idempotent design, structured logging, trap-based cleanup, and CLI ergonomics. Use when writing, reviewing, or hardening an operational script, cron job, or internal CLI tool."
globs:
alwaysApply: false
---
# Production Scripting & Automation Standards
## When to Use This Skill
**Triggers — load this skill when:**
- An operational script must be safe to re-run and to fail loudly
- A cron/CI job needs locking, cleanup traps, or structured logging
- You are reviewing shell code for silent-failure and quoting defects
**Route elsewhere when:**
- Multi-node OS configuration -> `configuration-management-ansible`
- Declarative cloud resource provisioning -> `terraform-iac-modules`
## 1. Idempotent & Resilient Bash Scripting Template
```bash
#!/usr/bin/env bash
# Strict error handling: exit on error, unset variables, and pipeline failures
set -euo pipefail
IFS=$'\n\t'
readonly SCRIPT_NAME="$(basename "${0}")"
readonly LOG_FILE="/tmp/${SCRIPT_NAME}.log"
log() {
local level="${1}"
shift
local msg="${*}"
local timestamp
timestamp="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
echo "{\"timestamp\":\"${timestamp}\",\"level\":\"${level}\",\"message\":\"${msg}\"}" | tee -a "${LOG_FILE}"
}
cleanup() {
local exit_code=$?
log "INFO" "Cleaning up temporary resources (exit code: ${exit_code})..."
rm -f /tmp/lock.$$ 2>/dev/null || true
exit "${exit_code}"
}
trap cleanup EXIT INT TERM
# Ensure single execution with lockfile
lock() {
if ! mkdir /tmp/script.lock 2>/dev/null; then
log "ERROR" "Another instance of ${SCRIPT_NAME} is already running."
exit 1
fi
}
```
---
## 2. Best Practices & Anti-Patterns
- **Do**: Always set `set -euo pipefail` at the start of any production Bash script.
- **Do**: Use Python for complex JSON parsing, API interactions, and matrix data structures rather than nesting deep `awk`/`sed`/`jq` chains.
- **Don't**: Never use `eval` with user-supplied parameters to avoid command injection vulnerabilities.
- **Don't**: Avoid parsing `ls` output; use globs or `find ... -print0 | while IFS= read -r -d '' file; do ... done`.
---
## 3. Single-Instance Enforcement with flock
A lockfile you create and delete yourself leaks on `SIGKILL` and blocks every later run. Use
kernel-held locks, which are released automatically when the process dies:
```bash
#!/usr/bin/env bash
set -euo pipefail
LOCK_FILE="/var/lock/$(basename "$0").lock"
exec 9>"${LOCK_FILE}"
if ! flock --nonblock 9; then
echo "$(basename "$0") is already running; exiting." >&2
exit 0 # exit 0: an overlapping cron tick is not a failure
fi
cleanup() { rm -f "${TMP_DIR:-}/staging" 2>/dev/null || true; }
trap cleanup EXIT INT TERM
```
Or wrap the whole invocation from cron without touching the script:
```bash
*/5 * * * * /usr/bin/flock -n /var/lock/sync.lock /usr/local/bin/sync.sh
```
Use `flock --wait 60` when a delayed run is better than a skipped one, and `--nonblock` when a
skipped run is better than a queue of piled-up jobs.
---
## 4. Operational CLI Ergonomics
An operational script becomes a CLI the moment someone else runs it. The ergonomics that make it
safe under pressure:
```python
#!/usr/bin/env python3
import argparse, logging, sys
def main() -> int:
p = argparse.ArgumentParser(description="Reconcile orphaned EBS volumes.")
p.add_argument("--region", required=True)
p.add_argument("--dry-run", action="store_true", default=True,
help="report only (default); pass --no-dry-run to act")
p.add_argument("--no-dry-run", dest="dry_run", action="store_false")
p.add_argument("-v", "--verbose", action="count", default=0)
args = p.parse_args()
logging.basicConfig(
level=[logging.WARNING, logging.INFO, logging.DEBUG][min(args.verbose, 2)],
format='{"ts":"%(asctime)s","level":"%(levelname)s","msg":"%(message)s"}',
stream=sys.stderr, # logs to stderr, data to stdout
)
return 0
if __name__ == "__main__":
sys.exit(main())
```
Rules: **dry-run is the default** for anything destructive; `--help` states the blast radius;
logs go to stderr so stdout stays pipeable; exit codes are meaningful (0 success, 1 failure,
2 usage error, and a distinct code for "nothing to do" if a caller must branch on it).
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
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.

