AGENCYSCRIPT
CoursesEnterpriseBlog
đź‘‘FoundersSign inJoin Waitlist
AGENCYSCRIPT

Governed Certification Framework

The operating system for AI-enabled agency building. Certify judgment under constraint. Standards over scale. Governance over shortcuts.

Stay informed

Governance updates, certification insights, and industry standards.

Products

  • Platform
  • Certification
  • Launch Program
  • Vault
  • The Book

Certification

  • Foundation (AS-F)
  • Operator (AS-O)
  • Architect (AS-A)
  • Principal (AS-P)

Resources

  • Blog
  • Verify Credential
  • Enterprise
  • Partners
  • Pricing

Company

  • About
  • Contact
  • Careers
  • Press
© 2026 Agency Script, Inc.·
Privacy PolicyTerms of ServiceCertification AgreementSecurity

Standards over scale. Judgment over volume. Governance over shortcuts.

On This Page

The Competing ApproachesTerse and iterativeSpecification-firstTest-driven promptingExample-led (few-shot)Conversational refinementThe Axes That Actually MatterA worked readingHow the Trade-offs Show Up in PracticeSpeed versus precisionFreedom versus guardrailsIndividual fluency versus team standardsContext investment versus disposabilityA Decision Rule You Can ApplyFrequently Asked QuestionsIs one prompting approach objectively better than the others?Should I always write long, detailed prompts?How do I decide between test-driven and specification-first prompting?Does the choice change when I work on a team versus solo?Key Takeaways
Home/Blog/Choosing How You Ask an AI to Write Code
General

Choosing How You Ask an AI to Write Code

A

Agency Script Editorial

Editorial Team

·March 29, 2023·7 min read
prompting for code generationprompting for code generation tradeoffsprompting for code generation guideprompt engineering

Ask three engineers how they get an AI assistant to write a function and you will get three different methods. One pastes a terse one-liner and iterates. One writes a paragraph of requirements before touching the keyboard. One drops in the failing test and lets the model work backward. None of them is wrong, and that is exactly the problem when you are trying to standardize how a team works.

The honest answer is that prompting for code generation is a set of trade-offs, not a single technique. Every approach buys you something and costs you something else: speed versus precision, brevity versus reproducibility, freedom versus guardrails. The skill is not memorizing the "right" prompt. It is knowing which axis matters for the task in front of you and deciding accordingly.

This guide maps the competing approaches, names the axes that drive the decision, and ends with a rule you can actually use. The goal is to replace folklore with a repeatable choice.

The Competing Approaches

Most real prompting strategies cluster into a handful of recognizable shapes. Knowing the shape helps you reason about what you are giving up.

Terse and iterative

You give the model a short request, look at what comes back, and refine through follow-ups. This is fast and conversational, and it works well for exploration or throwaway code. The cost is reproducibility: the same opening prompt plus a different conversation produces a different result, so nobody else can re-run your process.

Specification-first

You write a structured brief up front — inputs, outputs, constraints, edge cases, the framework version — then ask for the implementation in one shot. This costs more time before the first response but produces code that is closer to mergeable and far easier for a reviewer to check against intent.

Test-driven prompting

You hand the model the failing test or the expected behavior and ask it to make the test pass. This anchors the output to a verifiable target and naturally surfaces ambiguity. The cost is that you need the test first, which front-loads effort and assumes you already understand the contract.

Example-led (few-shot)

You show one or two examples of the pattern you want — a similar function, a matching style — and ask the model to extend it. This is excellent for consistency across a codebase. It can backfire if your examples are subtly outdated, because the model will faithfully reproduce your bad habits.

Conversational refinement

You treat the model as a pair partner, working through a problem across many turns, letting the design emerge from the dialogue. This shines when you do not yet know what you want and need to think out loud. The cost is that the reasoning lives in an ephemeral conversation, so the path to the answer is hard to capture, audit, or hand to someone else. It is the least reproducible approach and the most generative, which makes it ideal for the early, exploratory phase of a hard problem and poor for anything you need to defend later.

The Axes That Actually Matter

The approaches above are just defaults. The real decision lives on a few axes. Score your task on each and the right approach usually falls out.

  • Reversibility. Throwaway script versus a function in a shared library. High-reversibility work tolerates terse iteration; low-reversibility work demands specification-first rigor.
  • Verifiability. Can correctness be checked by a test, a type checker, or a human glance? Highly verifiable tasks favor test-driven prompting because the loop closes quickly.
  • Context cost. How much surrounding code does the model need to get this right? When context is expensive to assemble, investing in a specification pays for itself.
  • Consistency pressure. Does this code need to match existing patterns exactly? That is where example-led prompting earns its place.

The mistake teams make is treating these as fixed preferences ("I always write detailed prompts") instead of per-task readings. A senior engineer fluidly switches approaches several times an hour.

A worked reading

Imagine two tasks back to back. The first is a one-off script to reformat a CSV you received from a client; you will run it once and delete it. Reversibility is high, verifiability is easy (you can eyeball the output), context cost is near zero, and consistency pressure is nonexistent. Terse iteration is obviously correct here, and writing a specification would be waste. The second task is a function that computes a billing proration that will live in shared code and feed an invoice. Reversibility is low, the math must be exactly right, the function must match how other money calculations are structured, and a bug ships to customers. Every axis points the other way: specification-first, with a test, matching an existing example. Same developer, same hour, completely different approach — and the difference is not mood, it is a deliberate reading of the task.

How the Trade-offs Show Up in Practice

Speed versus precision

Terse iteration feels faster because the first response arrives sooner. But if the task is low-reversibility, the editing and re-prompting tax often exceeds the time a specification would have cost. Speed is real only when the work is genuinely disposable.

Freedom versus guardrails

Open prompts let the model surprise you with a cleaner approach you had not considered. Heavily constrained prompts prevent surprises in both directions. For learning and prototyping, lean toward freedom. For production paths with security or compliance implications, lean toward guardrails.

Individual fluency versus team standards

A prompt that works brilliantly in your hands may be illegible to a teammate. If the output of your prompting needs to be reproduced by others, you are no longer optimizing for yourself — you are writing a process, and processes need to be explicit.

Context investment versus disposability

Assembling good context — the right files, the actual interfaces, a representative example — takes real time. On disposable work, that investment never pays back, so terse prompting wins even if the output is rougher. On durable work, the same investment is amortized over every future reader and reviewer of the code, so it almost always pays for itself. The trap is applying yesterday's habit to today's task: someone who just spent an hour carefully contextualizing a critical module will often over-invest in the next trivial script, and someone who just dashed off ten quick scripts will under-invest when they hit something that matters.

A Decision Rule You Can Apply

When you are unsure, run this quick triage:

  1. Is the code disposable or exploratory? Use terse, iterative prompting. Optimize for momentum.
  2. Is correctness cheaply testable? Lead with the test. Let the model chase a verifiable target.
  3. Does it need to match existing patterns? Show an example and ask the model to extend it.
  4. Is it low-reversibility, shared, or security-sensitive? Write the specification first. Spend the minutes up front.

When two rules apply, the lower-reversibility one wins. The cost of a bad function in shared code always exceeds the cost of a slow prompt.

Frequently Asked Questions

Is one prompting approach objectively better than the others?

No. Each approach optimizes a different axis, and the right axis depends on the task. The competent move is to read the task — its reversibility, verifiability, and context cost — and pick the approach that matches, rather than defaulting to a personal favorite for everything.

Should I always write long, detailed prompts?

Not always. Detail is an investment that pays off when code is low-reversibility or expensive to verify. For throwaway scripts and exploration, a long prompt is wasted effort. Match the length to the stakes.

How do I decide between test-driven and specification-first prompting?

If you can express correctness as a test cheaply, lead with the test — it gives the model a target it can be measured against. If correctness is more about structure, constraints, and edge cases than a single pass/fail check, write the specification instead. They are not mutually exclusive; the strongest prompts often include both.

Does the choice change when I work on a team versus solo?

Yes. Solo, you can optimize for your own fluency. On a team, the output of your prompting must be reproducible by others, which pushes you toward explicit specifications and shared examples. See Rolling Out Prompting for Code Generation Across a Team for how to formalize that.

Key Takeaways

  • Prompting for code generation is a portfolio of trade-offs, not a single best technique.
  • The main approaches — terse iteration, specification-first, test-driven, and example-led — each buy speed, precision, verifiability, or consistency at the expense of something else.
  • Decide on axes, not habits: reversibility, verifiability, context cost, and consistency pressure.
  • When in doubt, let the lower-reversibility consideration win, because shared-code mistakes are the expensive ones.
  • Build the muscle of switching approaches mid-task instead of defaulting to one. The best practices and framework guides go deeper on making this switching deliberate, and the examples show it in concrete cases.

Search Articles

Categories

OperationsSalesDeliveryGovernance

Popular Tags

prompt engineeringai fundamentalsai toolsthe difference between AIMLagency operationsagency growthenterprise sales

Share Article

A

Agency Script Editorial

Editorial Team

The Agency Script editorial team delivers operational insights on AI delivery, certification, and governance for modern agency operators.

Related Articles

General

Prompt Quality Decides Whether AI Earns Its Keep

Prompt quality is the single biggest variable in whether AI delivers real work or expensive noise. The model matters, the platform matters — but the prompt you write determines whether you get a first

A
Agency Script Editorial
June 1, 2026·10 min read
General

Counting the Real Cost of Every Token You Send

Tokens and context windows sit at the intersection of AI capability and operational cost—yet most business cases treat them as technical footnotes. That's a mistake that costs real money. Every time y

A
Agency Script Editorial
June 1, 2026·10 min read
General

Rolling Out AI Hallucinations Across a Team

Most teams discover AI hallucinations the hard way — a confident-sounding wrong answer makes it into a client deliverable, a legal brief, or a published report. The damage isn't just to the output; it

A
Agency Script Editorial
June 1, 2026·11 min read

Ready to certify your AI capability?

Join the professionals building governed, repeatable AI delivery systems.

Explore Certification