Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I find that it is IMPORTANT to never start these coding sessions with "write X code". Instead, begin with a "open plan" - something the author does allude to (he calls it prompt engineering, I find it also works as the start of the interaction).

Half the time, the LLM will make massive assumptions about your code and problem (e.g., about data types, about the behaviors of imported functions, about unnecessary optimizations, necessary optimization, etc.). Instead, prime it to be upfront about those assumptions. More importantly, spend time correcting the plan and closing gaps before any code is written.

https://newsletter.victordibia.com/p/developers-stop-asking-...

- Don't start by asking LLMs to write code directly, instead analyze and provide context

- Provide complete context upfront and verify what the LLM needs

- Ask probing questions and challenge assumptions

- Watch for subtle mistakes (outdated APIs, mixed syntax)

- Checkpoint progress to avoid context pollution

- Understand every line to maintain knowledge parity

- Invest in upfront design



> I find that it is IMPORTANT to never start these coding sessions with "write X code". Instead, begin with a "open plan"

Most llms that I use nowadays usually make a plan first on their own by default without need to be especially prompted. This was definitely not the case a year ago or so. I assume new llms have been trained accordingly in the meantime.


True. And that is a step forward. I notice that they make the plan, and THEN write the code in the same forward pass/generation sequence. The challenge here is that all of the incorrect assumptions get "lumped" into this pass and can pollute the rest of the interaction.

The initial interaction also sets the "scene" for other things, like letting the LLM know that there might be other dependencies and it should not assume behavior (common for most realistic software tasks).

An example prompt I have used (not by any means perfect) ...

> I need help refactoring some code. Please pay full attention. Think deeply and confirm with me before you make any changes. We might be working with code/libs where the API has changed so be mindful of that. If there is any file you need to inspect to get a better sense, let me know. As a rule, do not write code. Plan, reason and confirm first.

--- I refactored my db manager class, how should I refactor my tests to fit the changes?


CoT models do analyze first without being told to do so.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: