---
title: "What belongs in a prompt, and what belongs in code"
description: "Retry logic and business rules end up in prompts because the prompt is the fastest thing to change. Here is a line that holds up."
url: https://coyotiv.com/blog/what-belongs-in-a-prompt/
---

1. [Blog](https://coyotiv.com/blog/)
2. [AI](https://coyotiv.com/blog/ai/)

# What belongs in a prompt, and what belongs in code

Retry logic and business rules end up in prompts because the prompt is the fastest thing to change. Here is a line that holds up.

Coyotiv

- 7 July 2026
- 5 min read

_This post was first published on the [Raison blog](https://raison.ist/blog/what-belongs-in-a-prompt). [Raison](https://raison.ist/) is Coyotiv’s platform for managing AI prompts as a team: versions, environments, evaluations and rollbacks, without an application deployment._

Somewhere in your codebase there is a prompt that says _“if the customer has asked this question more than twice, escalate to a human.”_

That is not a prompt. That is an `if` statement wearing a costume.

It got there for an understandable reason: the prompt is the fastest thing in the system to change. No deploy, no review, no test suite. When a rule needs adjusting on a Friday afternoon, the prompt is where it goes. Do that for six months and the prompt has quietly absorbed retry logic, routing rules, formatting requirements, and three business policies that nobody can find.

## The dividing line

Prompts hold **intent and voice**. Code holds **control flow and invariants**.

That sounds abstract until you turn it into a question you can ask about any single line:

> If this instruction were silently ignored, would I want a test failure, or would I want a slightly worse answer?

If the answer is _test failure_, it belongs in code. A model that ignores your instruction 4% of the time is fine for tone and unacceptable for “never quote a price.”

## Things that belong in code, always

- **Retries and timeouts.** A model cannot retry itself.
- **Output parsing and validation.** Asking for JSON is a request. Validating JSON is a guarantee.
- **Routing between prompts or models.** If the choice is deterministic, make it deterministic.
- **Rate limits and cost caps.** Never delegate spend control to something you are paying per token.
- **PII redaction.** Redact before the call, not by asking nicely.
- **Hard policy gates.** “Never provide medical dosages” is a filter, not a sentence in a system prompt.

The pattern: anything you would be unwilling to see fail 1% of the time.

## Things that belong in the prompt

- **Role and framing.** Who the model is, what the task is, what a good answer looks like.
- **Tone and voice.** The part that is genuinely a writing problem.
- **Few-shot examples.** These are prompt content, and they are also the most under-versioned part of most prompts.
- **Soft preferences.** “Prefer bullet points for lists of more than three items.”
- **Domain context.** Product names, terminology, what your company actually does.

## The genuinely gray areas

**Output format.** Both. Describe the shape in the prompt so the model aims at it; enforce the shape in code so downstream parsing never sees a surprise. Describing without enforcing is the single most common source of 3am pages in LLM systems.

**Refusal behavior.** The _style_ of a refusal is prompt work. The _set of things that must be refused_ is a policy artifact that deserves version history and an approval trail, whether or not it is physically stored in the prompt.

**Chain-of-thought and reasoning structure.** Prompt, mostly — but if a step in the reasoning has to happen for correctness, that step is a separate call with its own validation.

## Why the line is worth drawing

The practical payoff is not architectural purity. It is that a prompt containing only intent and voice is a prompt you can actually review.

A diff on a prompt that mixes business rules with tone is unreviewable — every change looks equally risky, so reviewers either rubber-stamp it or block everything. A diff on a prompt that holds only intent is a five-line read where you can see immediately whether a constraint was removed. That is the difference described in [our playbook for shipping prompt changes safely](https://raison.ist/blog/shipping-prompt-changes-safely): the review step only works if the diff is small enough to mean something.

It also fixes the thing that pushed logic into the prompt in the first place. The reason people edit prompts instead of code is that prompt edits are fast. The fix is not to make prompt edits slow — it is to make them fast _and_ tracked, which is what it means to treat [prompt work as a build step](https://coyotiv.com/blog/prompt-engineering-is-a-build-step/). Speed then stops being an argument for putting the wrong thing there.

```ts
// The prompt holds intent. The code holds the invariant.
const prompt = await client.getPrompt("support-reply", {
  variables: { customer_name, plan_tier },
});

const reply = await llm.complete(prompt);

// This is not a suggestion to the model. It is a guarantee.
const parsed = ReplySchema.parse(reply);
if (parsed.containsPrice && !plan_tier) {
  throw new PolicyError("price_without_tier");
}

```

So the question to ask of any line is what should happen when it is ignored. If the answer is a failing test, write code. If the answer is a slightly worse sentence, write a prompt — and then version it anyway, because “slightly worse sentence” is still your product’s voice, and [that deserves history](https://raison.ist/blog/why-prompts-need-version-control).

Try Raison at [raison.ist](https://raison.ist/), or read [how Coyotiv started Raison](https://coyotiv.com/blog/coyotiv-announces-raison-prompt-management/).

In this article

1. [The dividing line](https://coyotiv.com/blog/what-belongs-in-a-prompt/#the-dividing-line)
2. [Things that belong in code, always](https://coyotiv.com/blog/what-belongs-in-a-prompt/#things-that-belong-in-code-always)
3. [Things that belong in the prompt](https://coyotiv.com/blog/what-belongs-in-a-prompt/#things-that-belong-in-the-prompt)
4. [The genuinely gray areas](https://coyotiv.com/blog/what-belongs-in-a-prompt/#the-genuinely-gray-areas)
5. [Why the line is worth drawing](https://coyotiv.com/blog/what-belongs-in-a-prompt/#why-the-line-is-worth-drawing)

Share

- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoyotiv.com%2Fblog%2Fwhat-belongs-in-a-prompt%2F)
- [X](https://x.com/intent/post?url=https%3A%2F%2Fcoyotiv.com%2Fblog%2Fwhat-belongs-in-a-prompt%2F&text=What+belongs+in+a+prompt%2C+and+what+belongs+in+code)

More from the blog

## Keep reading.

[All posts](https://coyotiv.com/blog/)

AI 
- 20 November 2026
- 12 min read

### [Before adding AI, fix the workflow around it](https://coyotiv.com/blog/before-adding-ai-fix-the-workflow-around-it/)

AI 
- 11 November 2026
- 10 min read

### [Enterprise AI adoption: procurement is getting easier. The hard part starts after the purchase](https://coyotiv.com/blog/enterprise-ai-adoption-the-hard-part-starts-after-the-purchase/)

AI 
- 25 August 2026
- 6 min read

### [Preparing your team for the AI era: why 90% of corporate AI projects end up in the trash](https://coyotiv.com/blog/preparing-your-team-for-the-ai-era-why-90-percent-of-corporate-ai-projects-fail/)
