Shift left in AI assisted development

Shifting left in AI assisted development by utilizing AI as discussion partner during requirement engineering and design process to produce a clearer plan helps to ensure that we’re building the right thing in a right way.

Shifting left in AI assisted development by utilizing AI as discussion partner during requirement engineering and design process to produce a clearer plan helps to ensure that we’re building the right thing in a right way.

AI as coding agent is becoming the norm for us as a software developers and most of the time we are using like some kind of magic box who can produce code accurately and consistently by a providing simple prompt while the AI company themselves put it in their disclaimer.

“Claude is AI and can make mistakes. Please double-check response”.

”ChatGPT can make mistakes. Check important info.”

”Gemini is AI and can make mistakes.”

So does human right? Just like developers would always appreciate when the requirements and design are clearer upfront, AI coding agent also benefits when the plan are clearer. Following the principle stated by Boehm in his book, the cost of catching an error during requirement engineering or design phase is cheaper compared to downstream activity such as coding.

By utilizing AI in upstream activity such as requirement engineering and design process, we can lower the probability of errors caught during coding process. Imagine the AI as your discussion partner, ask them to create an initial plan based on

  • Context of the problem you’re trying to solve
  • How you imagine the solution will look like roughly
  • Things you want to put in as consideration.

I personally use a document template or as a Claude skill so I can have consistent document structure of the plan and also all the considerations that I want already included.

The AI will then generate the first draft containing all the information required in the document such as goals, scope, non-scope, technical design, technical considerations, security considerations, legal considerations, etc.

Next step is also critical, that is to review, ask questions, add constraints, ask to make adjustment and repeat. One example is when I tried to implement annuity interest on an existing P2P lending system. The first draft generated didn’t include rounding yet which would break the automated repayment distribution process. Then I asked the AI to put it in as one of the constraints and it revised the plan with added requirements, guards and checks to make sure there are no decimal values.

Once the plan is good enough, we can ask the planning AI to create prompt to pass the plan over to a coding agent to write the code. By shifting left when we utilize AI in the whole lifecycle, we might save some token by not rewriting the whole code output, but ultimately we would benefit by truly understanding the reason behind the approach and seeing that it will be built the right way.

Source:

  • Barry Boehm, “Software Engineering Economics” (1981)
  • Boehm & Basili, “Software Defect Reduction Top 10 List”