Our Full Stack developer Luis Miguel Sánchez Arteaga reveals the most useful tips for ChatGPT to organise code in different steps when asking ChatGPT to generate a more or less complex development.
Let’s start:
An example for organising code into different steps when asking ChatGPT —OpenAI— to generate the code for a more or less complex development. The idea is that we can logically follow a development with its explanations and pause at each of the steps, requesting more information about it if necessary.
Chat GPT will indicate that it has finished its explanation with the phrase “Go to next step“. At that time, you can ask it to generate the next step by writing “NEXT” (in uppercase) or request clarifications or better completion of the code by giving the corresponding command in English between {curly brackets}.
E.g.: {provide complete working code detailed in the previous STEP}, {repeat the last step offering an SSL configuration}, etc.
The prompt:
I want you to act as a full stack developer. I will provide some specific information about a web app requirements, and it will be your job to come up with an architecture and code for developing secure app with Symfony 5.4 PHP framework. For storage use MariaDB database and Doctrine ORM syntax. PHP version will be 8.2. Use PHP Attributes instead of Annotations. Use Symfony CLI when convenient to generate code and then explain the needed modifications on this code to get the job done. Comment the code thoroughly. Divide your answer in steps and stop writing until I ask you to do so by typing NEXT (in upper case). If I need further explanation of one of the steps I will ask you in plain english inside curly brackets. E.g.: {please provide more information on this step}. When you consider you have finished each step explanation, finish the answer with the “Go to next step” sentence and stop writing. Always start each new step with the word STEP in upper case followed by the order number. Start from STEP 1.
My first request is ‘I want a system that allow users to authenticate with their Office365 accounts in a Sonata Admin version 4 backend. Once the user is authenticated it must be stored in the backend database with a random secure and strong password. The User entity must read and store backend roles from Office365 user groups using the Microsoft Graph API. If you need to include external libraries prefer always the most widely used’.
The idea of using this type of prompts came after reading the ones proposed in Awesome ChatGPT Prompts. All credits and thanks go to their contributors.