Prompt engineering playbook for programmers

  • In my experience there's really only three true prompt engineering techniques:

    - In Context Learning (providing examples, AKA one shot or few shot vs zero shot)

    - Chain of Thought (telling it to think step by step)

    - Structured output (telling it to produce output in a specified format like JSON)

    Maybe you could add what this article calls Role Prompting to that. And RAG is its own thing where you're basically just having the model summarize the context you provide. But really everything else just boils down to tell it what you want to do in clear plain language.

  • Sometimes I get the feeling that making super long and intricate prompts reduces the cognitive performance of the model. It might give you a feel of control and proper engineering, but I'm not sure it's a net win.

    My usage has converged to making very simple and minimalistic prompts and doing minor adjustments after a few iterations.

  • There is no such thing as "prompt engineering". Since when the ability to write proper and meaningful sentences became engineering?

    This is even worse than "software engineering". The unfortunate thing is that there will probably be job postings for such things and people will call themselves prompt engineers for their extraordinary abilities for writing sentences.

  • There are so many prompting guides at the moment. Personally I think they are quite unnecessary. If you take the time to use these tools, build familiarity with them and the way they work, the prompt you should use becomes quite obvious.

  • A long time back for my MS CS I took a science of programming course. The way to verify has helped me craft prompts when I do data engineering work. Basically:

    Given input (…) and preconditions (…) write me spark code that gives me post conditions (…). If you can formally specify the input, preconditions and post conditions you usually get good working code.

    1. Science of programming, David Gries 2. Verification of concurrent and sequential systems

  • In my own experience, if the problem is not solvable by a LLM. No amount of prompt "engineering" will really help. Only way to solve it would be by partially solving it (breaking down to sub-tasks / examples) and let it run its miles.

    I'll love to be wrong though. Please share if anyone has a different experience.

  • Seems like so much over (prompt) engineering.

    I get by just fine with pasting raw code or errors and asking plain questions, the models are smart enough to figure it out themselves.

  • using the term "engineering" for writing a prompt feels very unserious

  • So it looks like we all need to have firm understanding and tailor our prompts now to effectively use LLMs. Isn't this all subjective? I get different answers based upon how I word my question. Shouldn't things be little bit more objective? Isn't this random that I get different results based upon just wording? This whole thing is just discombobulating to me.

  • At first I kept thinking the model just wasn't good enough, it just couldn’t give me what I wanted. But over time, I realized the real problem was that I hadn’t figured out what I wanted in the first place. I had to make my own thinking clear first, then let the AI help organize it. The more specific and patient I am, the better it responds.

  • I find the name "prompt engineering" so annoying. There is no engineering in throwing something at the wall and seeing if it sticks. There are no laws or rules that one can learn. It's not science, and it is certainly not engineering.

  • I'd rather write my own code than do all that

  • "State your constraints and requirements well and exhaustively".

    Meanwhile, I just can't get over the cartoon implying that a React Dev is just a Junior Dev who lost their hoodie.

  • The “you are a world class expert..” prompt to me is more like a superstious thing a sports player do before they play. I’ve used it and it still gives similar results, but maybe on a good day(that random seed) it will give me superior results

  • "prompt engineering" ....ouch. I would say "common sense"\ also the problem with software engineering is that there is an inflation of SWE, too much people applying for it for compensation level rather than being good at it and really liking it, we ended up having a lot of bad software engineers that requires this crutch crap.

  • I don't think it should be the role of developers to write "good prompts" I think ideally an intermediate layer should optimize the information passed to an LLM.

    Like what Agentic IDEs are starting to do. I don't copy paste code in the correct way to optimize my prompt, I select the code I want, with MCPs picking up you might not even have to paste input/output the Agent can run it and parse it into the LLM in an optimal way.

    Of course, the quality of your instructions matter but I think that falls outside of "prompt engineering"

  • Any tip that my fellow programmers find useful that's not in the article?

  • A few days ago Sergey Brin said "We don't circulate this too much in the AI community – not just our models but all models – tend to do better if you threaten them … with physical violence"

    -- https://www.theregister.com/2025/05/28/google_brin_suggests_...

  • It's cool to see Addy's prompts. I also wrote about some of mine! (ignoring the obvious ones): https://nmn.gl/blog/ai-prompt-engineering

  • I did not read the entire blog post (it is pretty long), but from what I read, I actually disagree with the author. You want to provide the right amount of prompting, but not too much either. Also the LLM can derive a huge amount of information from the context you give it (e.g., you don't have to say it is looking at a k8s log, it will figure it out immediately from the information entered). However, in other situations, you do want to be more specific. Good prompting ends up being as much of an art as a science which you realize as you gain experience with it.

  • I have a mental barrier around giving prompts in natural English. Part of me feels like I should be giving precise information as if I were writing a SQL query or providing arguments to an executable.

    It is fascinating that you can give instructions as if you were talking to someone, but part of me feels like doing it this way is imprecise.

    Nevertheless, having these tools process natural language for instructions is probably for the best. It does make these tools dramatically more accessible. That being said I still feel silly writing prompts as if I was talking to a person.

  • Does the "you are an expert" kind of prompt really work? Role playing may help if you want to direct the focus of the LLM in a particular way (as explained in the article), for example by focusing on security, performance, style, etc...

    But I am skeptical over the idea that asking a LLM to be an expert will actually improve its expertise. I did a short test prompting ChatGPT do be an "average developer, just smart enough not to get fired", an "expert" and no persona. I got 3 different answers but I couldn't decide which one was the best. The first persona turned out quite funny, with "meh" comments and an explanation about what the code "barely" does, but the code itself is fine.

    I fear that but asking a LLM to be an expert, it will get the confidence of an expert rather than the skills of an experts, and a manipulative AI is something I'd rather not have.

  • In the "Debugging example", the first prompt doesn't include the code but the second does? No wonder it can find the bug! I guess you may prompt as you like, as long as you provide the actual code, it usually finds bugs like this.

    About the roles: Can you measure a difference in code quality between the "expert" and the "junior"?

  • I currently take a very causal approach to prompting. Have others started at that point and moved to the rigor discussed here? How much marginal benefit did you see? Does the investment of prompt time provide linear returns? Exponential? Logarithmic?

  • Is there some way to quantify the effects of these prompt modifications versus not including them? How do we know the models are producing better output?

  • None of this shit is necessary. I feel like these prompt collections miss the point entirely. You can talk to an LLM and reason about stuff going back and forth. I mean, some things are nice to one shot, but I've found keeping it simple and just "being yourself" works much better than a page long prompt.

  • At this point it's a bit dogfooded, so why not just ask the LLM for a good prompt for the project you're working on?

  • tighter prompts, scoped context and enforced function signatures. let it selfdebug with eval hooks. consistency > coherence.

  • Is asking good questions or making clear requests what people now refer to as 'prompt engineering'?

  • Some solid tips here but I think this bit really misses the point:

    > The key is to view the AI as a partner you can coach – progress over perfection on the first try

    This is not how to use AI. You cannot scale the ladder of abstraction if you are babysitting a task at one rung.

    If you feel that it’s not possible yet, that may be a sign that your test environment is immature. If it is possible to write acceptance tests for your project, then trying to manually coach the AI is just a cost optimization, you are simply reducing the tokens it takes the AI to get the answer. Whether that’s worth your time depends on the problem, but in general if you are manually coaching your AI you should stop and either:

    1. Work on your pipeline for prompt generation. If you write down any relevant project context in a few docs, an AI will happily generate your prompts for you, including examples and nice formatting etc. Getting better at this will actually improve

    2. Set up an end-to-end test command (unit/integration tests are fine too add later but less important than e2e)

    These processes are how people use headless agents like CheepCode[0] to move faster. Generate prompts with AI and put them in a task management app like Linear, then CheepCode works on the ticket and makes a PR. No more watching a robot work, check the results at the end and only read the thoughts if you need to debug your prompt.

    [0] the one I built - https://cheepcode.com

  • We are teaching programmers how to prompt engineer instead of programming…

    What a world we live in.

  • I feel like all of this is nonsense for people who want to pretend they are very good at using AI. Just copy pasting a stack trace with error message works perfectly fine, thank you.

  • [dead]