Skip to content

AI Programming Insights: Avoiding the Pitfalls of 'Full Automation', My Efficient 'Semi-Guided' Practice

Recently, I took over an older CodeIgniter 3 project and needed to add several features, such as recruitment, attendance tracking, and income/expense management. I thought about using AI for assistance, and after some experimentation, I've developed some new thoughts on how to effectively utilize AI for programming—or rather, lessons learned from stepping into a few pitfalls.

AI programming is so popular these days that if you're not using it, you might feel left behind. But fully relying on AI IDEs (like Cursor, Windsurf, Trae) or handing the entire project over to AI for a complete takeover—frankly, that makes me uneasy. Especially when dealing with complex projects or maintaining legacy systems like mine, the result is often '5 minutes to generate, N hours to debug and fix, and wanting to bang your head against the wall during later maintenance.'

So, today I'll share my practical insights and also break down the pros and cons of pure AI assistance, AI IDEs, and my "semi-guided" approach.

The Double-Edged Sword of AI Programming: Context Understanding Is a Weakness, Maintenance Is a Headache

There's no denying that AI writes code quickly, but its weaknesses are quite apparent: its ability to understand the overall "context" of a project is still lacking. How the frontend and backend interact, how the database is designed, the twists and turns of business logic—when things get a bit complex, AI tends to get "confused."

For example, if you use an AI IDE like Cursor and let it take over directly, it might perform a "complete overhaul," drastically changing the file structure; or generate code that's completely out of sync with your project's style; even worse, it might quietly delete your 'legacy' old code, leaving you with nowhere to cry.

This is especially true for older projects, which are full of historical issues and customizations. Who knows how the AI might 'freely interpret' and "improvise" the functionality? A small oversight could lead to a mini-disaster.

Take my feature addition task, for instance. If I had directly handed the task to an AI IDE for "full autopilot," I estimate I would have spent at least half a day cleaning up its mess. Why? Even if the AI's training data includes CodeIgniter 3, an "antique" framework, how would it know about the custom libraries and historical quirks in the project's nooks and crannies? The generated code would likely fail to run, and I'd be stuck debugging, reducing efficiency instead of improving it.

My 'Semi-Guided' Strategy: I Build the Skeleton, AI Fills in the Flesh, Efficiency Soars!

To keep the AI from "running wild," I devised this relatively safe approach: first, outline the project's "rules" and "blueprint" for the AI, then let it fill in the details. Here's how I did it specifically:

  1. Explain the "Basics": Clearly tell the AI, "This project uses CodeIgniter 3.1.10, MVC architecture. Backend controller code goes in /admin/Renyuan.php, database operations use $this->db, and the frontend is based on Bootstrap 4.6 with jQuery 3." This way, the AI doesn't have to guess and can follow the existing path.
  2. Sketch a Blueprint: Don't let the AI guess what the interface looks like. I use a drawing tool to roughly sketch the layout (where forms go, where buttons are placed), take a screenshot, and give it to the AI, saying, "Here, implement the frontend and backend functions to look like this."
  3. Set Some "Rules": Impose restrictions on the AI, such as emphasizing the separation of frontend and backend logic, generating the table creation SQL first, avoiding external links and subqueries (it often messes these up), outputting frontend code as HTML, CSS, and JS directly into one file, and keeping the backend to simple queries with a JOIN.
  4. Step-by-Step "Acceptance": After the AI outputs the table structure SQL, backend controller code, and frontend page code, I manually create the files like Renyuan.php, renyuan.html (and add Renyuan_model.php if a model layer is needed), carefully paste the AI-generated code into them, run the SQL to create the tables, and finally test everything.

How did it work out? Pretty well! The AI "obediently" generated clear table creation SQL, reasonably logical backend code, and basically functional frontend code. Copying the code into the respective files, executing the SQL, and doing a quick test—most features worked on the first try! Work that was estimated to take about a week was compressed to around 1 day, with a real efficiency boost and far fewer errors.

Illustration: Like giving the AI a clear "construction blueprint"

Comparing Three Approaches: Pure Chat, AI IDE Suites, and My 'Semi-Guided' Method

Now, let's compare the experiences with these different methods:

  • Pure Chat-Based AI Assistance (e.g., directly conversing with ChatGPT or Gemini):

    • Feels like: An on-call technical consultant. Ask about anything you don't understand, and it's convenient for modifying small code snippets.
    • But the problem is: You have to manually piece together the scattered code, lacking a holistic feel. For complex tasks, it's easy to lose track mid-conversation.
  • AI IDE Suites (like Cursor/Windsurf/Trae):

    • Feels like: Having a "co-pilot" directly in your project, able to modify code and auto-complete, seeming integrated and convenient. Especially suitable for new projects or simple scenarios.
    • But the problem is: As mentioned earlier, it doesn't understand the "road conditions" of complex projects well, particularly struggling with legacy projects. It can operate recklessly, causing issues that are costly to fix.
  • My 'Semi-Guided' Mode:

    • Feels like: You're driving the car, but with a super-intelligent "navigation + voice assistant." You still control the overall direction (project structure, core logic), while the AI suggests and fills in the "how to get there" (code implementation details).
    • The advantage is: It leverages AI's rapid generation capability while retaining human control. Especially suitable for complex projects or legacy system modifications. When you provide sufficient framework and constraints, the AI's output aligns better with actual needs, has fewer errors, and gives more confidence for future maintenance.
    • Of course, it requires some effort: You need to spend time upfront preparing the "navigation route" (project info, sketches) and carefully crafting clear instructions (prompts) for the AI.

Simply put, AI IDEs are a bit like turning on "full self-driving"—it looks cool and easy, but when the road gets complex (legacy projects are a classic example), it tends to "get lost" or even "cause trouble." My method is more like firmly holding the steering wheel while letting the AI, as a capable assistant, handle most of the routine operations—flexible and controllable.

Some Insights and Ramblings

This time, I mainly used gemini-2.5-pro-preview-03-25 to generate code, and overall, it performed quite well. Although it occasionally made small blunders (like mixing up single and double quotes, or confusing native JS methods with jQuery library methods), these were minor fixes and not too troublesome.

Also, I discovered a "trick": It's much more reliable to have the AI use simple queries and JOINs than to write complex subqueries. For some reason, it often fails with subqueries, and even repeated modifications based on error messages don't help—probably because there are more "pitfalls" in the training data for that area.

So, in future interactions with AI, I'll definitely stick to the "I build the skeleton, AI fills in the flesh" approach, especially on legacy projects, and avoid those "full automation" tools to prevent digging myself into a hole.

In summary, AI programming is an inevitable trend, but to use it effectively, you really need some wisdom in 'human-machine collaboration.' Don't always expect AI to handle everything. Treat it as a "smart apprentice" or "capable assistant" that needs guidance. Give it clear direction and a framework, and it can truly help you double your efficiency.