PRACTICAL BUILD GUIDE
Add AI Features to an Existing App
Start with a task whose result a user can inspect: draft a reply, extract named fields or suggest a form structure. Decide what a correct result looks like before choosing a model. The surrounding validation and product behaviour matter as much as the generated text.
STEP 1
Choose a bounded task
Write a short contract for the feature: what input it accepts, what output it returns and what it must never decide on its own. For a form builder, the output might be a limited list of supported fields and setup instructions. The app should validate that structure before displaying or using it.
- Separate suggestions from actions that send messages or change records.
- Set input length and output size limits.
- Provide a route for users to edit or reject the result.
STEP 2
Create an evaluation set before polishing prompts
Collect realistic examples with expected properties. Include incomplete requests, conflicting instructions and input that should be rejected. Check field types, required values and factual claims rather than judging only whether the answer sounds fluent. Re-run the same examples when changing prompts, models or validation.
- Include short, long and ambiguous requests.
- Test unsupported requests and malformed model output.
- Record failures so a prompt change can be compared with the previous version.
STEP 3
Keep the model outside privileged boundaries
Treat both user content and model output as untrusted. The backend controls credentials, allowed tools and permissions. Generated code should be reviewed before execution; a text-generating feature does not need permission to run shell commands. Escape output when rendering it into HTML and avoid putting sensitive material into diagnostic logs.
- Keep provider keys out of browser code.
- Validate proposed actions against the user’s permissions.
- Use human confirmation for consequential actions in the product workflow.
STEP 4
Plan for latency, cost and failure
A feature needs a timeout, a rate limit and a clear unavailable state. Do not present a failed request as a completed task. Start with a small rollout and review the cost per useful result, including retries. Offer a manual path when generation is unavailable so the surrounding product remains usable.
- Measure accepted or edited results, not just generation counts.
- Explain when a result is a draft.
- Review data handling before sending business documents to a provider.
Use AI with a clear specification
Adapt the bracketed details to your project. Ask your coding assistant to explain its changes, then run the examples and checks yourself.
Design an AI feature that [bounded task]. Specify input/output contracts, server validation, representative evaluation cases, permissions, timeouts, per-user limits and a manual fallback. Treat model output as untrusted. Explain what the model can suggest and what only the application may execute.
BUILD IT WITH HOW2CODE
Need this adapted to your business?
Tell us about your workflow, existing tools and expected result. We’ll review the brief and discuss the scope with you.
Discuss this project →