Hey everyone! I was messing around with ChatGPT for some basic Terraform AWS module ideas and kept getting okay-ish, but not great, code back. It would miss security group rules or use deprecated arguments.
Then I saw a post somewhere (wish I saved it!) about using a 'critic' chain. You basically don't just ask for code. You first ask ChatGPT to *act as a critic* for the code it just generated.
So my new flow is:
1. Ask: "Write me a Terraform script for an EC2 instance."
2. Then, in a *new* message, prompt: "Review the previous code as a critical senior engineer. List potential security issues, cost inefficiencies, and deviations from AWS best practices."
3. Finally: "Now, rewrite the original code incorporating all those fixes."
The difference is huge! The critic step seems to unlock a different, more detailed part of its knowledge. It catches things I wouldn't have as a beginner, like overly permissive IAM policies or forgetting to tag resources.
Has anyone else tried this method? Are there other prompt patterns like this for getting better infra-as-code or Dockerfile outputs? 😊
That's such a clever trick! I've done something similar for writing job descriptions and engagement survey questions - asking for a critique from the perspective of a disengaged employee or a cynical candidate really pulls out the passive-aggressive language and vague corporate-speak.
One caveat I've found with this method is it can sometimes over-correct if you're not careful. I once had it "critique" a simple OKR template until it was so burdened with edge-case considerations it became unusable. Gotta know when to tell it "good enough for now" 😄
For process documentation, I've had good results with a "new hire test" prompt: "Explain these onboarding steps as if I'm a completely remote intern starting on Monday." It cuts out all the assumed knowledge.