My pain point is when utilizing something like a MongoDB database that it would revert to using Postgres/Neon randomly instead of erroring out; also noticed the same with removing code/changing code blocks that were working.
I now start each prompt with a reference for the agent to review, such as (adhere to aiagent.txt - [instructions]). However, still have issues so as of right now I’ll start with AI Agent and once I get to a stage I notice erratic code I’ll switch over to the Assistant where its easier to control specific code changes.
for example I used it to develop in NextJS:
Next.js Development Directives
General
Framework: Next.js 15.0.3, App Router (app directory). Auth: Use @auth/core@0.34.2, next-auth@4.24.10. Deployment: Must support serverless environments (Vercel, Replit).
Providers
SessionProvider Setup: “use client”; import { SessionProvider } from “next-auth/react”; import { ReactNode } from “react”; export function Providers({ children }: { children: ReactNode }) { return {children}; }
API Routes
Named Exports Required (e.g., GET, POST). Handler Signature: import { NextRequest, NextResponse } from “next/server”; export async function POST(req: NextRequest): Promise { return NextResponse.json({ success: true }); } Params Typing: { [key: string]: string | string }. Avoid undefined
in types.
TypeScript
Strictly adhere to TS conventions. Example for dynamic routes: export function getServerSideProps({ params }: { params: { id: string } })
Session/Auth
Wrap components with SessionProvider for useSession
. Browser APIs (e.g., window): Use useEffect
or useSearchParams
.
Serverless Best Practices
bcryptjs Promises: import bcrypt from “bcryptjs”; async function hashPassword(password: string): Promise { return new Promise((resolve, reject) => { bcrypt.hash(password, 10, (err, hash) => { if (err) reject(err); else resolve(hash); }); }); } Avoid server-side browser API references.
Validation
Use tsc
for TS validation. Use ESLint/Prettier for static analysis.