I've recently implemented a full app, backend to frontend, mostly written by AI 🤖
Nothing to do with "vibe-coding" or unmaintainable AI code. This is full legit type-safe and maintainable code, heavy effect + xstate, with AI.
The backend stack for 2026 🏗️
Here is how to guide the AI to act smart 👇
Don't start from zero
First key takeaway:
Define the project structure and guidelines before using any AI 🏗️
AI works better when constrained. Therefore, the initial steps are all on you:
- Define project structure (
pnpmmonorepo in my example) - Install frameworks and libraries (TanStack Router,
effect,xstate) - Implement a few initial feature examples
This prompt (nearly) implemented a complete working component with @EffectTS_ and XState Lesson: be precise (exact API requested) and provide examples from the same codebase
On the backend, I implemented myself the first few endpoints and entry file, using the patterns and libraries that I want the AI to follow:
const MainApiLive = HttpApiBuilder.api(ServerApi).pipe(
Layer.provide(HttpApiBuilder.middlewareCors()),
Layer.provide(
Layer.mergeAll(AuthGroupLive, AiGroupLive, StorageGroupLive, RecallGroupLive)
)
);
export const HttpApiLive = (db: D1Database) =>
HttpApiBuilder.toWebHandler(
Layer.mergeAll(
HttpServer.layerContext,
Ai.Default,
MainApiLive.pipe(
Layer.provide(
D1Client.layer({
db,
transformQueryNames: String.camelToSnake,
transformResultNames: String.snakeToCamel,
})
)
)
),
{ middleware: HttpMiddleware.logger }
);On the frontend the same, setting up styling and a few state management examples (xstate).
These initial manual examples are the starting patterns for the AI 🤝
Types to the rescue (again)
As expected, strict and strong types are ideal to guide AI.
Make your types as strict and explicit as possible 🏗️
If you instruct the AI to always check types (e.g. running tsc), as well as forbid any escape (e.g. no as, no @ts-ignore), then it becomes safe(r) to just let the AI do it's own things.
That's where libraries like
effectbecome ideal 🪄
Written explicit guidelines
Another key addition is a "README" for the AI:
CLAUDE.mdfor Claude CodeAGENTS.mdfor the others
I write the rules inside
README.mdand create symlink toCLAUDE.mdandAGENTS.md🔗
New pattern: README guidelines with symlink for AI 🤖
It should be short and on-point, guardrails to prevent the AI to go outside a few core rules. Examples I used:
- Never add comments
- Never use
as never,as any, oras unknown - Write all styles with
tailwindcssv4 based on@themeinsideglobals.css - All files must be in
kebab-case
Plan mode
Claude Code's "plan" mode is ideal for an initial scan before implementing any major feature.
The AI will scan the full codebase and store "in memory" all the major patterns and libraries (that you already implemented manually) 👀
Plan mode will also ask you clarification questions, that I often found meaningful.
The output will be a precise plan of the implementation. Check a few points:
- Correct libraries picked up
- Correct understanding of the structure and folders
- Correct patterns and dependencies between features
If all checks, I send the AI to work on it, even to the point of just accepting any change automatically.
Make sure to use Git to be able to view and discard any change if necessary ⚠️
If all the proper type-checking and guardrails are in place, the AI will often one-shot the "correct" implementation.
With "correct" I mean "working". Don't accept all without double-checking, the AI still makes many smaller mistakes and introduces new wrong patterns 👀
The perfect prompt
Your job is reduced to three tasks:
- Deciding the features of the app
- Reviewing and fixing AI slips
- Writing a good prompt to guide the AI
Prompts are no rocket-science:
- When possible, provide examples of other files using similar patterns
- Be specific on where and how to implement a feature (point to directories)
- Be specific on the order of implementation (e.g. first API, then frontend)
- Define what libraries and patterns to use, explicitly
If you do all of the above, the AI cannot miss 💯
AI is the new major "soft" skill. It will become soon an hard requirement for many software developer jobs. Writing code will matter less, understanding code will matter way more.
I started this being sceptical, I am now fully convinced code will quickly become a commodity, what database library or UI framework we use won’t matter anymore, the only differentiation is the programmer ability to understand design decisions deeply and skills in using models
See you next 👋
