← Blog

How to Build a Prompt Engineering Workflow

2026-10-30 · 5 min read · SubToAPI Team

A prompt engineering workflow is a repeatable process for drafting, testing, versioning, and deploying prompts so they behave consistently in production instead of breaking every time you tweak a word. Most teams start with ad-hoc prompt edits in a playground and end up with silent regressions — a prompt that worked last week suddenly returns malformed JSON or ignores instructions after a model update or a "small fix."

Building a real workflow means treating prompts like code: version-controlled, tested against known inputs, reviewed before shipping, and monitored after deployment. Below is a practical structure you can set up in an afternoon, regardless of which model or API you're using.

Step 1: Separate prompts from application code

Prompts change far more often than your application logic, and bundling them inline makes diffs unreadable. Store prompts as standalone files (JSON, YAML, or plain .txt) in a dedicated directory:

prompts/
  support-agent/
    v1.txt
    v2.txt
  summarizer/
    v1.txt

Each prompt file should include metadata as a comment block: purpose, intended model, expected output format, and date last modified. This alone eliminates most "wait, which version is live?" confusion.

Step 2: Define the task contract before writing the prompt

Before writing a single line, write down:

This contract becomes your test spec in Step 4. Skipping it is the single biggest reason prompt engineering feels like guesswork — you're optimizing against vibes instead of a spec.

Step 3: Draft with structure, not prose

Structured prompts are easier to test and debug than freeform paragraphs. A reliable pattern:

ROLE: You are a billing support assistant.

CONTEXT:
{ticket_text}

TASK:
Classify the ticket into one of: refund, dispute, cancellation, other.
Respond ONLY with valid JSON matching this schema:
{"category": string, "confidence": number}

CONSTRAINTS:
- Do not add explanation text outside the JSON.
- If unsure, use "other" with confidence < 0.5.

Putting constraints last and output format explicit reduces drift significantly more than burying instructions in a narrative paragraph.

Step 4: Build a small, real evaluation set

You don't need hundreds of examples — 15 to 30 realistic inputs covering common cases plus known edge cases is enough to catch most regressions. Store them alongside expected outputs or scoring criteria:

[
  {
    "input": "I was charged twice last month, please fix this",
    "expected_category": "dispute"
  },
  {
    "input": "Can I get a refund for my annual plan?",
    "expected_category": "refund"
  }
]

Run every prompt candidate against this set before shipping. A simple script that calls your model, checks the output against expectations, and reports a pass rate is enough — you don't need a full eval framework to start.

const testCases = require("./evalset.json");
let passed = 0;

for (const test of testCases) {
  const output = await runPrompt(test.input);
  if (output.category === test.expected_category) passed++;
}

console.log(`${passed}/${testCases.length} passed`);

Step 5: Version and diff prompts like code

Commit every prompt change with a message explaining why, not just what. "Tightened JSON schema constraint to stop extra text" is useful six months from now; "update prompt" is not. If you're using git, prompt files diff cleanly and you get blame history for free — which matters when a prompt regression ships and you need to know what changed and when.

Step 6: Test against the actual API you'll run in production

A prompt that behaves well in a playground can behave differently once it's wired into streaming responses, tool calls, or a multi-turn conversation. Test in the same environment you'll deploy to — same model, same temperature, same system prompt structure.

If you're calling Claude through SubToAPI, this is straightforward since you're hitting the same HTTPS endpoint your production app uses, with the same API key and headers, so your eval runs reflect real behavior rather than playground behavior:

curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4",
    "max_tokens": 200,
    "messages": [{"role": "user", "content": "{{prompt}}"}]
  }'

Looping your eval set through this same call gives you pass/fail data that actually matches production, not a sanitized playground environment. See the messages docs for request format details.

Step 7: Monitor after deployment

A workflow isn't finished at deployment — model updates, traffic shifts, and new edge cases in real user input will surface issues your eval set didn't catch. Log a sample of production inputs and outputs (with user consent/anonymization as needed) and periodically add the interesting failures back into your eval set. This closes the loop: every production bug becomes a permanent regression test.

Minimal workflow checklist

Once this loop exists, prompt changes stop being risky guesswork. You can experiment faster because you have a fast way to catch when an edit breaks something — which is the entire point of treating prompts as an engineering artifact rather than a creative writing exercise.

FAQ

Do I need a dedicated prompt management tool to do this?

No. A folder of version-controlled prompt files plus a small script that runs an eval set covers most teams' needs. Dedicated tools help at scale, but the discipline — contracts, versioning, eval sets — matters more than the tooling.

How often should I update my eval set?

Add a new test case every time a production failure surfaces that your current set didn't catch. Over time this builds a regression suite tailored to your actual users rather than hypothetical edge cases.

Should prompt testing block deployment like unit tests do?

Yes, for anything customer-facing. Running your eval set as a required check before merging a prompt change catches regressions before they reach users, the same way you'd gate a code change on passing tests.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →