GENAI 102
M03 · L04
Prompting Code

Effective Prompting for Code

Getting good code out of an agent is not about magic words. It is about being specific about the goal and the constraints — saying clearly what you want and what the agent must not do.

01 / 08
GENAI 102
M03 · L04
Anatomy of a Request

What a Good Request Says

A strong prompt for code carries four things. Miss one and the agent fills the gap with a guess.

  • The goal — what the code should do, in plain terms.
  • The scope — which files to touch, and what to leave alone.
  • The constraints — style, libraries, patterns to follow or avoid.
  • How you’ll check it — the acceptance criteria that make “done” concrete.
02 / 08
GENAI 102
M03 · L04
One Task at a Time

Scope It Tightly

One clear task beats a vague mega-request. A small scope is easier for the agent to get right — and easier for you to verify and to undo when it goes wrong.

The habit
Ask for one change, review it, then ask for the next — rather than one prompt that rewrites half the project.
03 / 08
GENAI 102
M03 · L04
Define Done

Say When It’s Done

Give the acceptance criteria up front. Stating “done when the tests pass” or “done when it does X” turns a fuzzy ask into something you can actually check.

  • A checkable target lets the agent tell for itself whether it succeeded.
  • It anchors your review — you know what to look for.
  • Module 4 takes this further: write the test first, then ask for the code.
04 / 08
GENAI 102
M03 · L04
Steer, Don’t Wish

Expect to Iterate

The first output is a draft you steer, not a final answer. Read it, point at what is off, and refine. Prompting well is a conversation — not one perfect sentence you have to get right on the first try.

05 / 08
GENAI 102
Build It
Rewrite a Vague Ask

Build It

How to implement: take a vague request like “make it better” and rewrite it into goal + scope + constraints + acceptance criteria — then use that version to prompt your agent.

  • Weekly AI Tasks tracker — “add an endpoint that returns this week’s tasks as JSON, don’t touch the auth code, done when this test passes” is a model prompt.
  • Personal brand site — “write the projects section from these repos, 3 bullets each, no claims not in the source” keeps it honest and scoped.
06 / 08
GENAI 102
Knowledge Check

Check what stuck

Three questions from this lesson. Answer to see why — the explanation appears whether you were right or wrong. Nothing is scored or saved.

Question 1 of 0
Score 0/0

07 / 08
GENAI 102
Summary
Recap

What you learned

A good code prompt states the goal, the scope, the constraints, and how you’ll check it. Scope tight, define done up front, and expect to steer the draft.

08 / 08