Plan Your Code with AI Before Writing It
Job to be done: Improve AI-assisted coding by separating planning and implementation
🇳🇬 Ways to use this in Nigeria
Ideas to get you started, adapt to your situation.
- Student
A university student uses AI to plan the structure and logic for their CSC301 assignment, a simple inventory management system, ensuring all requirements are met before writing the first line of code.
- 9-5 employee
An office employee uses AI to plan a Python script that automates extracting specific data points from multiple PDF invoices into an Excel sheet for monthly reconciliation, ensuring robust error handling.
- Entrepreneur
An entrepreneur with basic coding skills uses AI to plan the backend logic for a simple booking system for their salon, outlining features and potential issues before starting to build the MVP.
What you’ll get
You will learn how to use an AI chat assistant to help you plan your programming tasks before you write any code. This approach helps you catch misunderstandings early and ensures the AI understands your project requirements, leading to better code.
Tools you need
- AI Chat Assistant (freemium): A tool like Gemini, ChatGPT, or Claude that can understand and respond to your text prompts. This workflow uses a general AI chat assistant.
Steps
-
Describe your project requirement: Open your AI chat assistant and tell it about the programming task you need to accomplish. Be specific about what you want to build.
Analyze this project requirement. Break it into components, identify potential edge cases, and propose an implementation plan. Don't write the code yet. [Paste your project requirement here]You should see a breakdown of the project into smaller parts, a list of potential issues or edge cases, and a suggested plan for how to build it.
-
Review the plan: Carefully read the AI’s proposed plan. Check if it makes sense, if it covers all your needs, and if you understand each step.
-
Ask for assumptions: Before you ask the AI to write the actual code, ask it to list any assumptions it made while creating the plan. This helps uncover hidden misunderstandings.
Before giving me the final code, list the assumptions you're making.You should get a list of things the AI assumed about your project or the implementation.
-
Proceed with coding (optional): Once you are satisfied with the plan and assumptions, you can then ask the AI to write the code based on the agreed-upon plan.
Original source
This workflow is inspired by a Reddit post by user /u/SpellZealousideal168. The author suggests a method for using AI in programming that separates the planning phase from the code-writing phase to improve the quality of AI-generated code and catch errors early.
Notes & variations
- Free tier viability: Most AI chat assistants offer free tiers that are perfectly capable of handling this planning workflow. You do not need a paid subscription.
- Common mistake: Asking the AI to write the code immediately without reviewing the plan can lead to the AI misunderstanding your request, resulting in code that doesn’t work as intended and is hard to fix.
- Tip for better results: Be as detailed as possible when describing your project requirement in the first step. The more information you provide, the better the AI can plan.