Stop prompting AI to repeat the same steps — write a script instead

black computer keyboard

If you are running the same multi-step AI task more than twice, you are probably doing it wrong. Free-form prompts reinterpret your instructions from scratch on every run. A step that worked Monday drifts by Tuesday and improvises by Friday.

Software developer and educator Maxi Contieri published a practical fix in his AI Coding Tip series: convert repeatable skill steps into real, tested scripts, and let the model handle only the judgment calls a script cannot make.

The Drift Problem

Free-form prompting has three compounding failure modes when applied to repeated mechanical tasks:

  • The model reinterprets the same instructions differently across runs, so output is inconsistent by design.
  • Every repetition burns tokens re-explaining logic that never actually needed a language model, shrinking the context window for work that does.
  • Credentials typed inline end up in transcripts and logs, turning a convenience shortcut into a secrets leak.

Manual API calls in prompts also skip retry and backoff handling. The first HTTP 429 response ends your task instead of waiting a second and trying again.

The Script Pattern

The fix is straightforward: identify skill steps that always take the same input and always produce the same output, then write a real script for each one in a language that has a test framework.

lines of HTML codes

The implementation checklist Contieri recommends:

  1. Move credentials to a .env file and load them at runtime. Never inline them in the script or the prompt.
  2. Add retries, timeouts, and exponential backoff around every external API call. Libraries like tenacity and backoff for Python handle this with a few decorator lines.
  3. Cover the script with unit tests. A regression should fail a test, not ship to a user.
  4. Review it once like any other pull request, then grant standing authorization so every future run reuses the same reviewed code.
  5. Keep the model responsible only for choosing which script to call and interpreting ambiguous input.

️ Scripts vs. MCP Servers

Contieri draws a useful line between scripts and MCP servers. An MCP server is a live process: it needs its own auth, protocol translation, and connection management, and it keeps running whether or not a task needs it. That is a microservice standing up to handle one API call.

A script has none of that overhead. The skill invokes it, it runs, it exits. No server to patch, monitor, or keep alive between sessions. Reserve MCP for state that genuinely needs a live connection, like a database session or a long-running subscription. For a single API call or a formatting rule, a script does the same job with less surface area to secure.

⚠️ When Scripts Do Not Apply

Not every skill step deserves a script. One-off tasks and steps that require reasoning about unstructured input stay better served by the model itself. Scripts only replace the mechanical parts.

One security note: Contieri recommends denying arbitrary PowerShell or Bash calls from the harness by default. A command like find . -name "*.py" -exec python {} ; reads like a file search but runs every match it finds. The harness should treat it the same as a raw script call, not wave it through because the command starts with find.

The One-Time Approval Model

The payoff is what Contieri calls one-time approval: review the script once, pass it, and every future run reuses that exact logic. No re-deciding from a prompt. No inconsistent output. A script is a decision that has already been made and already been tested.

The model’s job shrinks to judgment. The script handles the rest the same way every time.

Stay on top of AI & Automation with BizStack Newsletter
BizStack  —  Entrepreneur’s Business Stack
Logo