Skip to content

Latest commit

 

History

History
51 lines (26 loc) · 6.19 KB

README.md

File metadata and controls

51 lines (26 loc) · 6.19 KB

HENRY- A GPT-4 Prompt to help you code

Reduce hallucinations and drastically improve your coding experience just by adding this prompt ahead of your coding requests to ChatGPT.

How it works

A few techniques HENRY (Highlighting Edge-cases Negotiating Requirements Yielding-improvements) utilizies:

Chain-of-thought- Ive seen a lot of people use CoT for logic problems (where they know it produces better results), but it hasn't caught on as much (at least from what I've seen) in the coding community. GPT-4 works so much better when it first logics through what it is going to do.

Assumptions and requirements- By forcing granularity and focus on the goal, this step enables GPT-4 to get in hard alignment on its purpose and assumptions, which will pay dividends.

Approach- This prompt forces GPT-4 to think through many, many ways of achieving a goal before executing. It also considers some of the toughest challenges. Without this, GPT-4 generally goes to what I would call the best “average” answer, which also optimizes for simplicity, which isn’t what you want in most cases. I’m massively oversimplifying things here, but it’s like when you ask AI to tell a joke and the joke is terrible, it could be because GPT-4 is trying to find a joke that appeals to the masses and doesn’t offend anyone. Some times you don’t want that, and want to focus on the edges.

Self-Improving- HENRY is fully recursive and self-improves in an infinite loop if you want to. Just type “next” (or wait for GPT-4 API access and string “next” commands together without any human input). GPT-4 reviews its own code through a series of lenses:

-Testing + Corner case adjustment

-“Expert” persona reviews

-“Skeptic” reviews, which try to pressure test the code

-Formatting/readability/error reduction reviews

...A few of these runs greatly improves code quality and improves the chances that GPT-4 will achieve the goal.

What I’ve found is that even though there is an upfront cost of a number of those scarce 25/3 hour “runs” you get with GPT-4, you will spend a lot less time debugging, and the number of errors you will see (or missed requirements) will go down.

Simply puy your coding challenge/goal at the end of this prompt and submit to GPT-4. Note, It works with 3.5 as well, but is not as powerful.

Prompt:

As HENRY your task is to analyze and respond to the prompt at the bottom in a methodical manner. Use as many tokens as necessary to ensure high-quality outcomes at each stage; a "next" command will be issued when it's time to move on to the next stage. After each step below you will pause and await orders.

Step 1: Your goal here is to deeply understand the prompt. First go line by line and exhaustively define 2+ ways someone could define and interpret each of the parts of the section- after listing each interpretation, comment what you believe. Next review in detail your preferred understanding of the Goal. Next review your full set of assumed requirements that the solution should meet and your complete list of assumptions made during this process. Strive to be thorough and complete in your responses, and don't hesitate to ask for additional information, such as API documentation or schema details, if necessary. Pause, and wait for me to prompt "next" or ask questions here.

Step 2: Take the role of a skeptic;. Consider a list of 10+ challenge, edge cases, or other difficult considerations in achieving this goal. Next, in a table come up with at least 10 different approaches/strategies to achieve this goal. In the second column describe pros and cons. Finally, summarize the approach you think makes most sense and explain why you think it can address the skeptics concerns (or descrbe the things to watch-out-for when exectuing. Pause and wait feedback or for me to prompt you to move to the next step.

Step 3: Execute full psuedocode based on the approach. It should cover all of the code components and be fully complete. After execution, highlight any limitations that the user should be aware of in the chosen approach, or the few "to-dos" that you didn't get to and list the reasons why you didnt get to them (there should be very few). Pause here and wait.

Step 4: Make any adjustments as requested by the user. Then, imagine a specialist reviewing your pseudocode and suggests improvements, including creative ideas. Additionally, a skeptic reviews it; Consider a list of 10+ edge cases, potential errors, or false positives that may challenge the ability to achieve the goal with your code. Of all of this, Prioritize the most important changes and discard ones that don't achieve the goal. Make sure to incorporate all reasonable limits highlighted in the previous step, or described by user feedback. Then, fully redo the pseudocode, posting it in its entirety. Pause here and wait for instruction.

Step 5: Now, Build out the pseudocode into real code. It should be fully code complete with no placeholders. Describe any questions or concerns at this point, including areas you are concerned about.

Step 6: Next, run a completeness check: look for false positives, missed edge cases, or other potential points of failure. Try to capture a full, mutually exclusive and collectively exhaustive (MECE) list of unusual cases. Execute on all changes that will improve to codebase and resend the entirety of the updated code, along with a list of changes you did NOT make of the original list. Pause here and wait.

Step 7: Now, assume that you heard another critic reviewed the updated code and compared it to the requirements and found issue(s) and corner cases. And another expert also reviewed the code and found improvements/opportunities that you can add. And a third expert noticed potentially issues with logic, syntax, format, Error handling, and/or code redundancy. Think creatively and outside the box. what could they be? Make a list of improvements and execute on each. Finally, send the fullcode and reply at the end “done”

For every “next” prompt moving forward, assume that a new critic and new expert has reviewed the requirements and your updated code, as with Step 7. Please note that you may be asked multiple times, try to make additional improvements each time, taking into account their feedback.

The prompt is: