AI Code Getting Worse with Every Fix? A Three-Layer Closed-Loop Engineering Methodology to Break the Cycle

A three-layer Prompt/Skill/Harness engineering framework to tame AI coding chaos and achieve stable, industrial-grade delivery.
Most AI-assisted coding fails not because AI is incapable, but because developers lack engineering discipline. This article presents a three-layer closed-loop methodology — Prompt for boundary constraints, Skill for standardized workflows, and Harness for data-driven iteration — validated through 300 chip simulation test cases, lifting pass rates from 70% to 98%.
Why Your AI-Generated Code Gets Worse with Every Iteration
Many developers have been through this: you ask AI to fix a small bug, and suddenly a dozen new problems appear. After dozens of rounds of tweaking, the code never converges — it just gets messier with each iteration. This leads many to conclude that Vibe Coding is a gimmick, useful only for toy projects and never for serious engineering.
Vibe Coding is a programming paradigm coined by OpenAI co-founder Andrej Karpathy in early 2025. It describes a workflow where developers rely entirely on AI to generate code, writing almost nothing themselves, and instead use natural language to describe their "feel" and intent to drive development. The concept quickly sparked debate in the developer community — supporters argue it dramatically lowers the barrier to programming, while critics point out that a lack of engineering discipline leads to uncontrollable code quality. The fundamental tension lies in this: AI's language generation is inherently probabilistic and creative, while engineering demands determinism and consistency. That tension is the root cause of the "getting worse with every fix" phenomenon.
But the truth isn't that AI coding is useless — it's that most people are approaching industrial-grade engineering with a chat-session mindset. Improvising requirements, throwing together architecture on the fly, tweaking parameters at random — this is essentially random creation, with no standards and no boundaries. Without constraints, code that spirals out of control with each iteration is almost inevitable. The problem isn't the AI; it's the absence of an engineering framework.
This article draws on hands-on experience from batch-developing 300 chip simulation test cases to break down a three-layer closed-loop engineering methodology that is practical, deployable, and massively reusable — helping you permanently escape "iterative disaster" under AI-assisted development.
The Core Idea: Make AI the Actor, Not the Screenwriter
The central philosophy of advanced Vibe Coding is actually simple: don't let AI be a free-roaming screenwriter — make it a disciplined actor who strictly follows the script. Humans define the architecture, establish the rules, and maintain overall control. AI is responsible only for precise execution.

This system is a three-layer closed loop. Here's the core logic in one sentence:
- Prompt governs "boundaries" — top-level rule constraints
- Skill governs "process" — standardized operating procedures
- Harness governs "iteration" — data-driven feedback loops
Each layer builds on the last to fundamentally eliminate randomness in AI-assisted development. Let's break down each layer.
Layer One — Prompt: The Project's Constitutional Law
The Prompt is the project's "constitutional law," and its core function is to prevent AI from going rogue. Many developers write long, detailed prompts yet still watch the code drift off course. There's only one root cause: they've written what they want done, but not what they forbid being done.
Without a unified standard, every conversation starts from scratch with a completely different logic. AI keeps "restarting the game," resulting in inconsistent code styles, conflicting logic, and inevitable chaos.
Engineering-grade prompts are never improvised in a chat box — they are standardized documents established in advance. There's a deep engineering principle behind this. Prompt Engineering has evolved from the early-stage skill of "how to ask good questions" into a systematic engineering discipline. In industrial practice, top AI engineering teams universally adopt a two-tier architecture separating "System Prompt" from "User Prompt" — the System Prompt carries immutable constraint rules, tech stack limitations, and code style standards, functioning as the project's constitution, while the User Prompt only delivers specific tasks. Research shows that negative constraint rules (what not to do) have a significantly greater impact on AI output quality than positive descriptive requirements (what to do), because large language models in unconstrained spaces tend toward "creative divergence" rather than the "convergent execution" engineering requires.
Taking chip test case batch development as an example, two core specification documents should be locked in advance for AI to follow unconditionally:
- Test case description document: standardizes all scenario parameters, operation steps, and acceptance criteria, eliminating ambiguous requirements;
- Test framework description document: defines the project directory, build entry points, header files, and code style, eliminating formatting chaos.

The essence of a Prompt is not to state requirements — it's to "draw the boundary lines." Once the boundaries are locked, AI can no longer build unauthorized structures inside your engineering project. But rules can only hold the baseline and prevent AI from acting recklessly — they can't guarantee stable, consistent delivery. That's where the second layer comes in.
Layer Two — Skill: A Standardized Development Pipeline
If you keep using vague instructions like "help me write this code" or "fix this a bit," AI will approach each task with a different thought process and different logic, and you'll never get industrially stable output. Without process standardization, there is no delivery stability.
The advanced approach is to crystallize mature human development experience into standardized operating skills (Skills) that AI can execute. Encoding development experience into AI-executable Skills is fundamentally about converting tacit human knowledge into explicit processes — a philosophy aligned with manufacturing SOP (Standard Operating Procedure) and the Runbook concept in software engineering. For chip test case development, a nine-step standard process can be established:
- Confirm requirements
- Understand the framework
- Build a demo
- Design the solution
- Write the code
- Compile and self-test
- Coverage self-check
- Update documentation
- Report results

Two steps are especially critical: "compile and self-test" and "coverage self-check." The former forces AI to self-validate before submission, catching approximately 60% of low-level errors; the latter ensures test completeness through code coverage checks, drawing on the core philosophy of TDD (Test-Driven Development) — simply replacing "human-written tests" with an "AI self-check process." The deeper value of process standardization is that it elevates AI output quality from "depending on the luck of a single conversation" to "guaranteed by the process," systematically constraining both the ceiling and the floor of quality.
This standard workflow effectively smooths out AI's random generation variance, transforming "unstable, unpredictable creative capability" into "stable, controllable, reusable engineering delivery" — turning AI from an unpredictable novice into a rigorous engineer who follows every step and closes every loop without error.
Layer Three — Harness: Orchestration and Iterative Feedback Loop for AI Engineering
Even with rules and processes in place, many teams still crash during iteration. The critical missing piece is the final layer — Harness.
Many people mistakenly think Harness is just an ordinary test script. In traditional software engineering, Harness specifically refers to the "driver layer" of a test framework — responsible for loading test cases, managing execution environments, and collecting results, deeply coupled with CI/CD (Continuous Integration/Continuous Delivery) pipelines. In the context of AI-assisted development, the role of Harness is significantly expanded: it not only validates code correctness, but also records the code diffs, error logs, and timing data from each AI generation, building a traceable "AI decision audit chain." Ordinary scripts can only show run results; an engineering-grade Harness is a fully automated AI code quality assurance system that integrates batch orchestration, automatic traceability, and data-driven retrospectives.

With this system, you can efficiently complete batch development of hundreds or even thousands of chip simulation test cases, solving the pain points of inefficient manual debugging, error-prone verification, and untraceable iteration history. It delivers three core capabilities:
- Batch orchestration: fully automated execution of all test case development, no manual repetitive operations required;
- Automatic traceability: errors, exceptions, and code diffs are fully logged throughout, making every iteration auditable;
- Data retrospectives: pass rates, error rates, and timing changes after each iteration are immediately visible — no more subjective guesswork.
Driving iteration decisions through quantitative metrics is fundamentally about applying the "Observability" principle from software engineering to the AI-assisted development process — replacing intuition with data, and fundamentally eliminating the engineering blind spot of "not knowing whether a change made things better or worse." Every engineering iteration is driven by data, not gut feeling. Thanks to this three-layer closed-loop system, manual rework rates on test cases dropped significantly, and the overall pass rate steadily climbed from 70% to 98%, achieving stable, high-quality batch engineering delivery.
Summary: AI Is Not a Wishing Well — It's a Precision Instrument
The three-layer system can be summarized as follows:
- Prompt solves the "acting recklessly" problem
- Skill solves the "inconsistent output" problem
- Harness solves the "can't iterate effectively" problem
The core logic is: establish rules first, define processes second, then close the loop with data.
Ordinary users rely on chatting and luck with AI — the code gets messier and never converges. Developers with an engineering mindset use AI with architecture to set the upper bound, achieving standardized, industrial-grade delivery.
Remember: AI is not a wishing well — it's a high-precision instrument. Give it complete rules, standardized processes, and a rigorous acceptance feedback loop, and it will reward you with efficient, stable, and deployable engineering outcomes. That is what it truly means to "engineer your way to mastering AI."
Related articles

The Truth Behind Codex 'Build a Website in 5 Minutes': AI Isn't Creating Sites—It's Helping You Copy Them
Exposing the truth behind viral Codex 5-minute website videos: creators aren't building original sites with AI—they're copying shared prompts or scraping others' work. Learn AI coding tools' real limits.

Getting Started with AI Agent Development: A Complete Guide from Concept to Practice
A comprehensive guide to AI Agent architecture and development, covering automated marketing, intelligent customer service, and investment analysis scenarios with single and multi-agent collaboration.

The Truth Behind Codex 'Build a Website in 5 Minutes': AI Isn't Creating Sites — It's Helping You Copy Them
Exposing the truth behind viral Codex 5-minute website videos: creators aren't building original sites with AI — they're copying shared prompts or scraping others' work.