2 min read

Prompt Engineering — the Core Framework

Prompt Engineering — the Core Framework
Photo by Van Tay Media / Unsplash

A prompt is how you direct the AI. Vague prompts get vague, guessy output; structured prompts get precise output. The good news: this skill is almost entirely tool- and model-agnostic — the same framework works in Claude Code, Cursor, Copilot, or a raw API call.

Anchor on maintained, vendor-diverse guides

Prompting advice ages, so anchor on the official prompting guides that the model makers keep updated — and read more than one, so you're learning the shared principles rather than one vendor's quirks:

(If you like a friendly video intro, Jeff Su's "structured prompting" video is a nice on-ramp — just treat it as one creator's take, not the canonical source.)

The six building blocks

A durable structure, ranked roughly by importance:

  1. Task → What do you want? A clear verb. Not "help with auth" but "Write a function that validates a JWT and returns the decoded payload or throws."
  2. Context → Background needed to answer well. Stack, constraints, what already exists. Without it the AI fills gaps with assumptions.
  3. Exemplar → An example or structure to follow. "Match the style of this existing handler," or "structure: validation → core logic → error handling."
  4. Persona → Who the AI should be. "You are a senior TypeScript engineer who values small, testable functions."
  5. Format → How the output should look. "Return only the function, no prose," or "give a unified diff," or "JSON with keys name, path."
  6. Tone → Style of the response. Usually minor for code, but "concise, no explanation" vs. "explain each step" matters.

You rarely need all six — but every good prompt has Task + Context, and adding Exemplar + Format is what turns "okay" into "exactly what I wanted."

Framework in practice — a coding example

❌ Weak prompt

"Write a function to upload files."

The AI has to guess the language, the storage, the validation, the error handling — and it will.

✅ Strong prompt (framework applied)

[TASK] Write a TypeScript function createPresignedUpload that returns a presigned S3 URL for a file upload.
[CONTEXT] We use the AWS SDK v3 (@aws-sdk/client-s3 + s3-request-presigner), Node 20, and an existing s3Client exported from src/lib/s3.ts. Uploads are authenticated; bucket is private.
[EXEMPLAR] Follow the shape of our other lib functions: named export, input validated up front, throws typed errors.
[PERSONA] You are a senior backend engineer who writes small, testable functions.
[FORMAT] Return only the function plus its imports — no prose. Include JSDoc.
[TONE] Terse.

Same task, wildly different result quality. The strong prompt removes the guesswork that produces wrong code.

💡 Much of "Context" can live permanently in your AGENTS.md — so you don't retype your stack every prompt. Prompting and project context work together.

Where this is heading

This framework is for a single, well-formed request. But in 2026 you rarely stop at one message — you steer an agent across a whole loop of reads, edits, and self-corrections.


Next: Advanced Prompting Strategies — clarify-first, plan→do, few-shot, roles, and self-review.