AI Coding Is Unpredictable—So Why Is Everyone Embracing It?

    Despite widely reported reliability issues, AI coding assistants keep gaining adoption. This article examines why developers embrace AI coding despite its unpredictability, analyzes the gap between generation capability and engineering discipline, compares two主流 approaches—spec-driven development and enforced pipeline execution—and presents a four-layer framework combining execution contracts, controlled executors, evidence chains, and metrics, with a ready-to-use contract schema example.

    AI Coding Is Unpredictable—So Why Is Everyone Embracing It?

    The Reality: It’s Not That AI Can’t Code—It’s That We Lack Engineering Constraints

    Let’s acknowledge an uncomfortable truth: many teams have a love-hate relationship with AI coding assistants. AI can quickly generate boilerplate code, complete tests, explain error messages, suggest refactoring, and even provide working starter examples in unfamiliar tech stacks. But once it enters a real project, it often behaves like “a talented intern with no engineering discipline.”

    Typical problems include:

    • Requirements take multiple rounds of conversation to clarify, and any ambiguity sends it into “creative improvisation”;
    • You ask for a login feature, and it casually rewrites routing, authentication, and config loading along the way;
    • Code that runs is considered “done”—test-first practices, edge cases, and failure-path validation are skipped;
    • The task list has ten items, but it declares “all passed” after completing just one, with no verifiable evidence;
    • Scope of changes is out of control—reviewers are still examining the first task while it has already touched three modules and introduced new risks.

    These problems don’t mean AI coding is worthless. They highlight the core tension of the current stage: generation capability is already strong, but execution lacks controllability, verifiability, and auditability. Developers embrace it because local gains are high and feedback is fast; teams hesitate to delegate broadly because engineering risks are invisible.

    Why “Not Fully Reliable” Still Wins Enthusiastic Adoption

    The AI coding hype isn’t driven by ignoring risks—it’s driven by real reductions in startup costs across several high-frequency scenarios.

    First, natural language to code conversion shortens cold-start time. Writing a data validation function, building an API adapter layer, or generating boundary tests used to mean reading docs, hunting for examples, and debugging syntax. Now you can start with a discussable draft. The draft may not be correct, but it turns “starting from zero” into “starting from candidate solutions.”

    Second, AI excels at repetitive, pattern-based, cross-file search work. Examples include batch-replacing call patterns, adding type annotations, generating config templates, and explaining legacy code. Each task alone carries low value, but collectively they significantly impact development efficiency.

    Third, fast feedback creates a positive loop. Developers can iterate with continuous refinement and instant rewrites. For prototyping, tech research, and one-off scripts, this interactive efficiency is highly compelling.

    Fourth, it lowers the barrier to expressing engineering practices. Test cases, API documentation, design drafts, and task breakdowns used to depend on developers writing them proactively. Now AI can generate first drafts for humans to refine. As long as teams establish acceptance mechanisms, these artifacts become collaboration inputs.

    But enthusiasm doesn’t excuse skipping engineering rigor. “It runs in a demo” and “it’s maintainable, auditable, and rollback-capable in production” are separated by requirement alignment, scope control, test verification, diff review, and evidence retention. For AI coding to truly enter team workflows, it must evolve from “conversational generation” to “controlled execution.”

    Two Common Approaches: Spec-Driven vs. Pipeline Execution

    The industry has gradually converged on two approaches. Each solves different problems—and each has clear shortcomings.

    1. Spec-Driven: Sign the “Execution Contract” Before Letting AI Write Code

    The core of spec-driven development is clarifying goals, scope, acceptance criteria, and task lists before writing any code. It extracts requirements from chat history into a structured contract, for example:

    • What problem are we solving;
    • Which directories or modules can be modified;
    • Which modules are off-limits;
    • What are the acceptance criteria;
    • How are tasks broken down;
    • What evidence needs to be submitted.

    This approach answers “doing the right thing.” It aligns AI on requirements before execution begins, reducing rework caused by misunderstanding. In complex business domains, spec-driven is especially valuable—much rework isn’t from incorrect code, but from misunderstanding requirements in the first place.

    However, the weakness is clear: the contract is signed, but execution still relies on good faith. Spec-driven tools typically generate proposals, specs, designs, and task lists—but don’t necessarily force AI to execute step-by-step, write failing tests first, limit change scope, or submit verification logs. The result may be:

    • AI claims a task is complete, but tests were never written or run;
    • Tests and implementation land together, making it impossible to prove tests ever failed;
    • “Incidental optimization” of unrelated modules during execution introduces new risks;
    • Reviewers must manually diff every line—slow and error-prone.

    In other words, spec-driven defines “the right thing to do,” but doesn’t fully solve “doing it the right way.”

    2. Pipeline Execution: Constraining AI with Mandatory Checkpoints

    Pipeline execution takes the opposite approach: instead of pursuing a perfect spec upfront, put AI into a mandatory pipeline. Typical stages include requirement clarification, plan generation, test-first implementation, phased implementation, sub-agent review, and diff check. Every stage has checkpoints—when AI tries to skip tests or overstep boundaries, gates block it.

    This approach answers “doing things the right way.” It externalizes engineering discipline into executor rules rather than relying on AI’s “self-discipline.” For high-risk codebases, forced checkpoints are critical.

    But pipeline execution has its own weakness: even a perfect pipeline can’t fix drifting requirements. If the initial goal is unclear or acceptance criteria are ambiguous, the pipeline just executes wrong requirements faster. More seriously, overly rigid processes can impose excessive overhead on simple tasks, prompting developers to bypass the process—ultimately reverting to “ad-hoc conversations plus manual cleanup.”

    Therefore, spec-driven and pipeline execution aren’t alternatives—they’re complements. The former provides the input contract; the latter provides execution constraints. One prevents “doing the wrong thing”; the other prevents “doing things chaotically.”

    The Integrated Approach: Contract, Executor, Evidence Chain, and Metrics

    A more sensible engineering path merges both approaches into a four-layer mechanism.

    Layer 1: Execution Contract

    Before AI starts working, humans (or AI-assisted tools) generate a structured contract. The contract must minimally include goal, scope whitelist, forbidden scope, acceptance criteria, execution constraints, checkpoints, validation commands, evidence requirements, and rollback strategy. The contract isn’t decorative documentation—it’s the executor’s input.

    Layer 2: Controlled Executor

    The executor translates the contract into step-level constraints. Before each modification, check that files are within the allowed scope. Before each task begins, require a plan. For test-first tasks, require failing test evidence. After implementation, require running validation commands. If the diff exceeds scope, halt immediately. Without evidence, block progression to the next step.

    Layer 3: Evidence Chain

    AI can’t just say “done”—it must submit verifiable evidence: failing test logs, passing test logs, diff summaries, acceptance criteria mappings, command outputs, and rollback points. Evidence chains let reviewers shift from “guessing line-by-line” to “verifying against evidence.”

    Layer 4: Metrics and Retrospectives

    Teams need continuous measurement to determine whether AI coding actually improves delivery quality—not just code output. Recommended metrics include: requirement alignment rate, out-of-scope change rate, test-first rate, one-pass validation rate, rework rounds, review time, rollback rate, and evidence completeness. Thresholds should be calibrated against your team’s baseline rather than external benchmarks.

    On Baidu AI Cloud, you can combine code hosting, CI/CD pipelines, artifact repositories, logging, and monitoring as the execution and audit planes, integrating contract validation, validation commands, and evidence retention into your existing dev workflows. The key here isn’t any single product capability—it’s landing execution constraints into your team’s existing engineering infrastructure.

    A Copy-Ready Custom Schema Configuration Example

    Here’s a generic execution contract configuration example you can adapt to your team’s field conventions. It’s not tied to any specific tool, has clear field semantics, and is easy for scripts or pipelines to consume.

    1. contract_version: "1.0"
    2. task:
    3. id: "feature-dark-mode"
    4. goal: "Add a dark mode toggle to the settings page and persist across refreshes"
    5. scope:
    6. allow_paths:
    7. - "src/settings/**"
    8. - "src/theme/**"
    9. - "tests/settings/**"
    10. deny_paths:
    11. - "src/router/**"
    12. - "src/auth/**"
    13. - "infra/**"
    14. non_goals:
    15. - "Do not refactor the routing system"
    16. - "Do not modify authentication logic"
    17. - "Do not upgrade dependency versions"
    18. acceptance:
    19. - id: "AC-1"
    20. given: "User is on the settings page"
    21. when: "Toggles dark mode on"
    22. then: "Theme switches immediately and persists after refresh"
    23. - id: "AC-2"
    24. given: "User turns off dark mode"
    25. when: "Refreshes the page"
    26. then: "Default theme is restored"
    27. execution:
    28. plan_before_edit: true
    29. tests_first: true
    30. max_files_per_step: 3
    31. require_failing_test_evidence: true
    32. require_diff_summary: true
    33. require_acceptance_trace: true
    34. checkpoints:
    35. - after: "plan"
    36. require:
    37. - "scope_check"
    38. - "acceptance_mapping"
    39. - after: "red"
    40. require:
    41. - "failing_test_log"
    42. - after: "green"
    43. require:
    44. - "passing_test_log"
    45. - "diff_within_scope"
    46. - after: "review"
    47. require:
    48. - "evidence_bundle"
    49. validation:
    50. commands:
    51. - "unit-test --target settings-theme"
    52. - "lint --changed"
    53. - "type-check --changed"
    54. evidence:
    55. required:
    56. - "test_log"
    57. - "diff_summary"
    58. - "acceptance_trace"
    59. - "command_output"
    60. rollback:
    61. strategy: "revert_step"
    62. preserve:
    63. - "test_log"
    64. - "diff_summary"

    The executor can validate with the following pseudo-logic:

    1. for step in plan.steps:
    2. assert step.files are within scope.allow_paths
    3. assert step.files are not within scope.deny_paths
    4. if execution.tests_first:
    5. red = run(step.failing_test)
    6. assert red.failed == true
    7. record("failing_test_log", red)
    8. change = apply(step)
    9. assert changed_files(change) are within scope.allow_paths
    10. green = run(validation.commands)
    11. assert green.passed == true
    12. record("passing_test_log", green)
    13. assert acceptance_trace covers step.acceptance_ids
    14. assert evidence_bundle is complete
    15. if any assert failed:
    16. rollback(step)
    17. stop_and_report()

    The value of this configuration: it turns “AI should behave” into “the executor must verify.” Spec-driven provides the contract, pipeline execution provides the gates, and evidence chains provide the audit trail.

    Measuring Real-World Data: Don’t Just Count Lines of Code

    Evaluating whether AI coding is controllable can’t rely on lines of generated code. Run a small-scale controlled pilot: capture a two-to-four-week baseline, then compare before and after introducing contracts and executors. Metric definitions you can reference:

    Metric Definition Collection Method
    Requirement Alignment Rate % of tasks meeting acceptance criteria on first execution Contract acceptance mapping + manual review
    Out-of-Scope Change Rate % of tasks modifying files outside allow_paths Diff checks + executor logs
    Test-First Rate % of tasks with failing-test evidence before implementation Checkpoint evidence chains
    One-Pass Validation Rate % of tasks passing validation commands on first run Pipeline logs
    Rework Rounds Number of revisions from task start to acceptance Task system records
    Review Time Average manual review time per task Code review records
    Rollback Rate % of tasks rolled back due to scope violation, validation failure, or acceptance rejection Executor rollback logs
    Evidence Completeness Rate % of tasks with complete evidence chains Contract schema validation

    These metrics reflect production readiness far better than “generation speed.” A team with persistently high out-of-scope change rates has insufficient contract and executor gates. Low test-first rates mean checkpoints aren’t actually working. If review time doesn’t drop, the evidence chain isn’t reducing human judgment effort.

    Implementation Recommendations

    First, start with low-risk, well-bounded tasks—settings pages, utility functions, test coverage, config template generation. Don’t delegate core transaction paths upfront.

    Second, establish contract templates before integrating executors. Don’t over-specify contract fields initially; cover at minimum: goal, scope, acceptance, validation, and evidence.

    Third, hard-code the scope whitelist and forbidden scope into pipeline gates. AI can propose out-of-scope modifications, but these must be filed as separate tasks—never mixed into the current one.

    Fourth, insist on test-first evidence. No failing test log means no implementation. No passing test log means no “done.”

    Fifth, require diff summaries and acceptance mappings. Reviewers should review evidence and diff summaries first, then decide whether deeper line-by-line review is needed—reducing review cost.

    Sixth, build retrospectives into the process. Weekly, tally out-of-scope changes, rework, rollbacks, and missing-evidence causes, then feed lessons back into contract templates and executor rules.

    Conclusion

    The perception that AI coding is “unreliable” is real—but so is the enthusiasm. The problem isn’t insufficient generation capability; it’s the lack of engineering control. The value isn’t replacing engineers; it’s freeing them from repetitive execution so they can focus on requirement clarification, contract design, acceptance judgment, and risk review.

    Spec-driven solves “doing the right thing.” Pipeline execution solves “doing things right.” Only by combining both—plus evidence chains and metrics—can AI coding evolve from “an uncontrolled genius” into “an auditable productivity engine.” For teams, the real competitive edge isn’t how much AI-generated code you ship—it’s whether you can constrain AI’s execution within verifiable, rollback-capable, retrospective-ready engineering boundaries.