Back to blog
AI-assisted Development

Why Vibe-Coded Prototypes Break in Production

Define contracts

Exercise failures

Gate the release
Original failure-path design for a controlled release
Primary nodeProduction gate
Decision modePROD-GATE
StatusPUBLISHED
Prototype connected to production modules with failure and rollback paths
PROD_GATE_V01: test contracts, retries, observability and recovery.
TERMINAL_PREVIEW.LOG
$ route --contract PROD-GATE
> validate: rights / schema / retries
> exercise: failures / rollback
> release: only with owner and recovery
Architecture, failure modes and release checks

Vibe coding can turn an idea into a working screen quickly. Trouble starts when a team treats that screen as a complete system. A prototype usually proves one successful path; production must handle invalid input, retries, integration failures and ongoing ownership. The broader approach to rapid experiments belongs on the vibe coding service page. This guide examines the transition from prototype to operating service.

Problem and requirements

Imagine an internal form that creates a CRM request and sends a notification. In a demo, the operator submits once, the CRM answers immediately and the message goes out. After launch, the network drops after the CRM write and the browser retries. If the code repeats the whole operation, the company gets two requests and two notifications. A working screen has concealed a broken contract.

Before release, specify who may write, which fields are valid, what completed means, whether a retry is allowed, when the notification is sent, how a partial failure appears to the operator and who resolves it. Set latency and load targets from your own workflow. An invented universal target would add false confidence.

Solution architecture

This original diagram describes responsibility boundaries for the example. It is a design sketch, not a universal blueprint.

text
Operator → UI → API: identity, permission, input schema
                 ↓
           operation with idempotency key
                 ↓
           durable state + event queue
                 ↓
           worker → CRM → confirmation
                 ↓
           worker → notification
                 ↓
           state log and operator signal

CRM failure → bounded retry → review queue
Denied access → reject without side effects
Repeated request → return prior result by key

The UI should not hold integration secrets or decide whether a business operation finished. The API checks permissions and input. An operation record exists before the external call. A worker may retry delivery, but a retry must not create a new business operation. If the CRM has no idempotency support, keep an external-key mapping and define how to resolve an uncertain response. A queue alone does not guarantee correct outcomes.

Components and contracts

Input contract. Define required fields, formats and valid ranges. Reject unexpected values before a write. State which fields may change later.

Permissions. Check access to the actual object and action on the server. Hiding a button does not protect an API. Separate read, create and resend rights.

Operation state. Record at least accepted, waiting for CRM, confirmed and needs review. The user sees a meaningful status; support gets a correlation ID without leaking personal data into logs.

External dependencies. Give CRM and messaging calls timeouts, bounded retries and explicit unavailable states. Decide whether a partial success should be compensated, resumed later or handed to a person.

Operations. Assign an owner, alerts, recovery steps and release rollback. Observe completed requests, not only HTTP 200 responses.

The minimal pseudocode exposes the critical boundary:

text
submit(actor, input, key):
  assert_can_create(actor)
  payload = validate(input)
  existing = find_operation(actor, key)
  if existing: return existing.status
  operation = save_pending(payload, key)
  enqueue(operation.id)
  return operation.status

deliver(operation):
  if operation.confirmed: return
  result = crm.create_or_lookup(operation.external_key)
  if result.unknown: mark_needs_review(operation)
  else: confirm_once(operation, result.id)

This sketch does not claim atomic writes across your database and the CRM. Verify the specific API, retry semantics and ability to look up a request by external key before implementing it.

Failure modes

  1. Only the happy path was tested. Empty fields, expired sessions and network drops are unhandled. The first real deviation breaks state.
  2. A retry creates a duplicate. The client times out after the server has written. Use an operation key and test repeated delivery.
  3. A secret reaches the browser. Generated UI code calls the integration directly. Move the call server-side, rotate the exposed secret and review publication history.
  4. The permission boundary is missing. A user changes an object ID and reads another account's record. Check object access in the API and test denial.
  5. Partial success is hidden. The CRM creates a request but the notification fails. Separate states and a delivery log support repair without creating another request.
  6. Nobody owns the result after the demo. A dependency ages or an external schema changes. Assign responsibility for updates and incidents before live data enters.

These examples explain how a useful prototype can become an unsafe service. They do not imply that AI-generated code cannot be used in production. Review it against the same engineering criteria as any other code. See the vibe coding versus AI-assisted engineering matrix and the task decision tree.

Testing and production checklist

Prepare synthetic cases for a valid request, invalid schema, denied access, timeout before write, timeout after write and repeated key. For each case, write the expected state in the UI, your database, the CRM and the notification log first. The tests then check the contract instead of mirroring code.

Before release, verify the build, types and dependencies; an integration test with a controlled CRM failure; object permissions; absence of client-side secrets; correlation logging; and rollback. Run a bounded pilot, inspect real failures and widen access after reviewing results. A passing test in one environment does not prove reliability in another.

If a prototype already touches live systems, start with a map of side effects and owners, then request an architecture review or technical audit. Explore case studies for implemented systems. Broader AI development work in Armenia belongs on the dedicated service page.

CODE_BLOCK.TXT
if (denied || invalid) return REJECT_WITHOUT_WRITE;
if (repeatedKey) return EXISTING_OPERATION;
if (crmUnknown) return NEEDS_REVIEW;