I have been working with multiple models (Anthropic, GLM) and tools (Bolt, Cursor, Cline, Claude Code) for AI Assisted Coding for the past year.
After doing multiple trial and errors, I have a stable framework, prompts or prompt templates, model and tool that I use for my AI Assisted Conding.
I use a framework that is not new but is inspired from an article in InfoQ (link in comments). It is called Plan Do Check Verify Retrospect (PDCVR) framework.
Before I elaborate on each step, here is my current setup:
- Tool: Claude Code
- Model: GLM 4.7 from Z.ai
Now, let me elaborate on the framework:
-
PLAN
-
For any task you plan to work with you start with a plan. You want the model to only plan and not create any code
- Yes, Claude Code has a plan mode but I prefer to not switch between modes and use a prompt to handle the same
- You want a prompt that will help to create an extremely detailed plan that provides step by step execution plan with mandatory code base investigation so that it does not re-create something or break something existing
- MOST IMPORTANT POINT to keep in mind is 2 focus on 1 single objective everytime you start a new task
- In addition to this, TDD is the MOST IMPORTANT ASPECT when you are doing AI Assisted Coding. So, you need to have a prompt in place that tells the model to do RED PHASE (Failing Tests) and then GREEN PHASE (Successful Tests)
- For every prompt, I tell the LLM to Plan and use TDD (even for DO step)
-
-
DO
- Read the PLAN created in above and iterate if you are NOT satisfied
- Once you are satisfied, then proceed with implementation
- You can say "Begin with Step 1" or "Proceed with Step 1" or "Implement next steps" or "Implement planned steps"
-
CHECK
- This step is extremely important because sometimes, LLM may not remember the next steps they need to implement and would finish working without implementing next steps
- Hence, you need to do a COMPLETENESS CHECK to make sure that LLM checks and evaluates if everything was implemented and corectly and if NOT, then it will tell you the next steps or the remaining steps
-
VERIFY
- This step is the SAME AS CHECK but in this step, I invoke a Claude Code agent, build-verification to make sure that everything compiles successfully and is also to verify if everything was implemented as part of the task
-
RETROSPECT
- No matter how careful and beautiful a prompt is or how smart the model is or how high it ranks in SWE Bench for coding, LLM is bound to make mistakes
- In such a scenario, you need to request LLM to run a retrospection for the current session on the task you were working on so that it records documents and remembers the learnings next time
https://www.infoq.com/articles/PDCA-AI-code-generation/?topicPageSponsorship=cb9cfb95-79e8-442a-8f4b-72cfb3789778 : Original framework based on which this post is based
https://arxiv.org/pdf/2312.04687 : Paper that proves TDD is super important and required for LLM
-
https://github.com/nilukush/plan-do-check-verify-retrospect/tree/master/prompts-templates : You will find generic prompt template for coding which includes plan prompt at all times meaning for every prompt you send to LLM, plan prompt is always part of generic prompt template
- In addition, it also has prompts for CHECK (COMPLETENESS CHECK) and RETROSPECT
-
https://github.com/nilukush/plan-do-check-verify-retrospect/tree/master/claude-code-subagents-for-coding has all subagents I use in Claude Code for coding. You can just copy paste this under
.claude/agents- It includes agents starting from Orchestrator, Product Manager to Devops inluding Debbuger, Analyzer and generic-purpose Executor subagents
Top comments (0)