Screenshot from the article

Hey folks, I’ve been using tools like Terraform, Python, Bash, Kubernetes, and Jenkins for years, and lately, Cursor IDE has become my go-to for boosting productivity. It’s basically VS Code on steroids with AI smarts baked in, and while it’s great out of the box, the real magic happens when you dive into the advanced stuff.

I’ve used Cursor to refactor sprawling YAML configs, debug flaky Docker builds, and even generate Helm charts on the fly. In this post, I’ll share advanced Cursor tricks that go beyond the “hello world” level. These are the workflows, rules, and hacks that save me hours every week in real-world DevOps projects.

Mastering Prompts: The Heart of Cursor’s Power

Cursor thrives when you treat prompts like structured tickets. Instead of saying “fix my Dockerfile,” I’ll frame it like:

Fix this Dockerfile for a Node.js app.  
- Base image: node:20-slim  
- Run as non-root user  
- Add multistage build for production  
- Optimize for size under 200MB  
- Validate with 'docker build --no-cache'

This gives Cursor enough guardrails to generate production-grade, secure Dockerfiles instead of half-baked examples.

Another underrated trick: use reference editors selectively. When I’m debugging Terraform, I’ll only open main.tf and variables.tf, then ask:

“Refactor this to use remote state (S3 + DynamoDB locking). Assume AWS provider is configured in providers.tf.”

Cursor then stitches the context cleanly, without drowning in unrelated files.

Pro tip: embed docs in prompts. For IAM policies, I’ll paste the AWS link and say:

“Write a policy with least privilege S3 read/write as per AWS docs.”

This avoids hallucinations and keeps Cursor grounded in real-world references.

Cursor Rules: Your Invisible Teammate

One of the most powerful yet underused features is .cursorrules. These are like “AI guardrails” that apply across the repo.

Here’s an example from one of my Terraform repos:

# .cursorrules
- Always use Terraform modules from registry.terraform.io.  
- Never hardcode AWS credentials; use providers.  
- Tag every AWS resource with 'owner' and 'env'.  
- Use least privilege IAM.  
- K8s: prefer Deployments + Services, avoid naked Pods.  
- YAML: always 2 spaces, no tabs.

This means when I ask Cursor “write an EKS cluster module,” it will automatically follow these rules without me repeating them in every prompt.

I also keep global Cursor rules in my personal settings:

- Keep answers concise.  
- Default language: TypeScript.  
- Prefer IaC-first (Terraform, Helm) over manual configs.  
- Explain trade-offs when there are multiple options.

Together, these act like an AI style guide, enforcing team standards.

Workflow Hacks: Cursor as a DevOps Sidecar

I treat Cursor like an extension of my CI/CD. Here’s how:

  • Use Notepads for Patterns: I have a notepad called CI/CD Templates with GitHub Actions workflows. I just do /notepad CI/CD Templates — adapt for multi-stage Docker build and Cursor instantly tailors it.
  • MCP Plugins: This is Cursor’s cheat code. With Kubernetes MCP enabled, I can literally type:
“Check logs from pod orders-api-78d8 in prod namespace.”

Cursor pulls the logs and suggests fixes — without me touching kubectl. Same for GitHub PRs:

“Review PR #1043 and suggest security fixes.”
  • .cursorignore: Add *.tfstate.env, node_modules/ to reduce context bloat. I once had Cursor hallucinate secrets from .env; ignoring them fixed it.

Debugging and Iteration: Beyond the Basics

Here’s where Cursor goes from nice-to-have to lifesaver:

  • YOLO Mode: In agent settings, enable “run commands automatically.” Cursor can run terraform validate, docker build, or pytest. I once fixed a broken docker-compose.yml just by prompting:
“Fix build errors and keep retrying docker compose up --dry-run until clean.”

It auto-iterated until it passed.

  • Command K + I: Highlight code → Cmd+K → “Add lifecycle policy for cost optimization.” Or Cmd+I → “Explain this Terraform module.” These are faster than flipping back to full chat.
  • Checkpoints: Before major refactors, I save a checkpoint. During a gnarly VPC migration, I restored twice after AI suggestions went sideways. Treat it like Git inside Cursor.

Scaling Cursor for Big Projects

For monorepos or giant infra repos, Cursor can choke if you dump everything. My playbook:

Break into smaller files: Instead of main.tf with 2000 lines, split into modules. Cursor performs way better.

Use @file references: Ask:

“@main.tf @variables.tf — add an S3 bucket with versioning.”

Commit often: AI-assisted changes can go rogue. Frequent commits = safe rollback.

Ask for options, not answers:

“Give me 3 approaches for blue/green deployments in EKS with pros/cons.” Cursor’s comparisons are gold for design decisions.

Efficiency Boosters: Shortcuts and Voice

I live on the keyboard. My daily set:

  • Cmd+K → Inline edit
  • Cmd+L → Open agent chat
  • Cmd+Enter → Full repo context
  • Cmd+Shift+S → Save to Composer
  • Cmd+R → Reset chat

And don’t underestimate voice input. When sketching out architecture, I’ll just dictate:

“Plan an AWS multi-region failover setup with Route 53 + S3 CRR + Aurora Global.”

Cursor turns the ramble into diagrams, configs, and Terraform in one go.

Advanced DevOps Scenarios I’ve Used Cursor For

  • Refactoring a Jenkinsfile into GitHub Actions, preserving conditional deploys.
  • Debugging flaky Helm upgrade by pasting the release diff.
  • Auto-generating Prometheus alerts and Grafana dashboards from metrics JSON.
  • Migrating 10+ Lambda functions from Node.js 14 → 20 in one shot.
  • Creating Terraform modules with built-in cost optimizations (like lifecycle rules on S3).

Wrapping Up

Cursor isn’t just “AI inside VS Code.” With the right rules, MCP plugins, and workflows, it becomes an AI teammate for DevOps — catching issues before prod, enforcing standards, and automating boring scaffolding.

These tips aren’t fluff; they’ve saved me late-night firefights more than once. My advice? Start small: add a .cursorrules, experiment with MCP, and commit often.

If you’ve got your own battle-tested Cursor tricks, drop them in the comments. Always keen to swap war stories.

Until next time — keep automating, and let the AI handle the drudgery.

📢 Have questions or feedback? Drop a comment below or connect with me on Twitter/X@spysood!

Originally published on Medium.