GuidesLaravel

Validate API input before it becomes a bug

Keep invalid data at the boundary with clear Laravel validation rules.

Laravel7 min readUpdated this week

Good code generation starts before the first prompt. The model needs enough context to make a useful decision, and enough constraints to make that decision safe to review.

The prompt loop

Treat a coding prompt like a small engineering brief. State the goal, show the relevant shape of the system, then define what a good result must include. This keeps the output focused and makes the next iteration obvious.

Goal: Add a retry policy to the API client.
Context: Requests use Dio and return typed failures.
Constraints: Keep the public API unchanged.
Output: Show the patch and two focused tests.

Give the model context

Context is not everything you know. It is the smallest set of facts that changes the implementation: the input shape, the boundary, and the constraints that cannot be negotiated.