Prompting techniques for accurate results

I was talking with an engineering friend yesterday and we discussed techniques for efficient, effective, and accurate output from Agent. Basically, insteading of using plain language to prompt for a feature, using engineering specific language to direct the Agent’s step by step tasks.

I’ve otherwise found that using thoughtful plain language that breaks down a feature requests often results in the Agent introducing UX/UI regressions, breaking server configurations, or getting into failure loops where it can’t recover. My approach to successfully using Agent to minize scope and build features step by step and using new context windows for each step.

What are some examples of effective prompting techniques ya’ll are using?

I haven’t seen your specific challenges, and since I’m not an engineer I don’t think I could speak engineer-ese even if I tried. But I have found that only asking for a single small thing at a time is helpful. I’ll just eat the extra $0.25 :grimacing:

I’ve also decided that it’s worth building the app twice. Once to learn what’s hard and easy and how to prompt and once to get it built.

2 Likes

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.

2 Likes