Retext
For DevOps EngineersTesting

DevOps Engineer Testing Prompts Templates

You get runnable tests that cover the normal case, the edges and the failure paths, written in your framework and naming style. For devops engineers there's an extra layer: devOps engineers need help writing and reviewing infrastructure as code, CI/CD pipeline configs, shell scripts and monitoring rules, and with diagnosing failed deploys from logs. The prompt below adds your role context so the answer fits how you work.

Installs as a snippet — type ;writetests to paste this prompt anywhere on your Mac.
Prompt Template
Write tests for the code below.

## Code under test
Language and test framework: [e.g. TypeScript with Vitest]
[paste the function, class or module]

## What it should do
[describe the intended behavior, including rules that are not obvious from the code]

## Coverage I want
- The main happy path
- Edge cases: [e.g. empty input, very large values, unicode, null]
- Error cases: [what should throw or return an error]

## Instructions
- Use only the test framework named above, no extra libraries.
- One behavior per test, with a test name that says what is expected.
- Use realistic input values, not "foo" and "bar".
- If the code has a bug that a test would expose, write the test anyway and tell me it will fail.

## Output format
1. The full test file, ready to run
2. A short list of anything you chose not to test and why

About my work
- Platform and tools: [e.g. AWS, Terraform 1.8, GitHub Actions, Kubernetes 1.30]
- Environment this affects: [e.g. staging only, production with 3 regions]
- Constraints: [e.g. no downtime, must stay within the current IAM roles]

How to use this prompt

  1. 1

    Copy the prompt

    Use the copy button, or type its Retext trigger in any app to paste it.

  2. 2

    Open your AI assistant

    Start a new chat in ChatGPT, Claude, Gemini or whichever assistant you use, so earlier messages don't steer the answer.

  3. 3

    Fill in the brackets

    Replace every [bracketed] part with your real details. Specific inputs are what make the answer specific.

  4. 4

    Check and refine

    Read the result against the goal above, then reply with one change at a time.

Worked example

What you give it

Language and framework: JavaScript with Vitest

export function slugify(text) {
  return text.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
}

What it should do: turn a title into a URL slug with single hyphens and no leading or trailing hyphens.
Edge cases: punctuation, extra spaces, symbols only.

What a good answer looks like (shortened)

import { describe, it, expect } from "vitest";
import { slugify } from "./slugify";

describe("slugify", () => {
  it("lowercases and joins words with hyphens", () => {
    expect(slugify("Hello World")).toBe("hello-world");
  });

  it("collapses punctuation runs into one hyphen", () => {
    expect(slugify("Rock & Roll!!")).toBe("rock-roll");
  });

  it("strips leading and trailing hyphens", () => {
    expect(slugify("  --Draft--  ")).toBe("draft");
  });

  it("returns an empty string for symbols only", () => {
    expect(slugify("!!!")).toBe("");
  });
});

Not tested: accented letters are dropped, so "Café" becomes "caf". Confirm whether that is acceptable before I add a test.

Tips for better results

  • •Always say which environment the change targets and ask for a plan or dry-run command before the apply step. It keeps a test idea from turning into a production change.
  • •The "What it should do" section matters more than the code. Rules like "discounts never stack" are invisible in the source and are exactly what tests should check.
  • •List your edge cases explicitly under Coverage I want. The AI tends to stop at the happy path unless you name empty, null and boundary values.
  • •Avoid this: Asking for tests without describing the intended behavior, so the AI writes tests that just lock in whatever the code does today, bugs included.

Check before you use it: Check IAM permissions, open ports, secrets handling and destructive commands in any generated config or script before it touches a real environment.

Get the free prompt pack

Our best AI prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.

Variations

Integration tests

Replace Coverage I want with: Test [module] together with a real [database or HTTP layer], and include setup and teardown.

Table-driven

Add this line to Instructions: Use a parameterized test (e.g. it.each or pytest.mark.parametrize) for cases that share the same shape.

Existing test file

Add this section: ## Current tests [paste them] and only add tests for behavior these do not already cover.

Save it as a Retext snippet

Retext is a free text expander for Mac. Save this prompt once, then type ;writetests in any app (ChatGPT, Claude, your editor, a browser tab) and the full prompt is pasted in.

  1. Click Add to Retext. The prompt installs as a snippet with the trigger ;writetests.
  2. Change the trigger in Retext if you prefer a different one.
  3. Type the trigger wherever you want the prompt, then fill in the brackets.

Frequently asked questions

Is it safe to use AI for Terraform or Kubernetes configs?

It is useful for drafts and reviews, but configs can contain subtle mistakes like overly broad permissions. Review every change with a plan or diff and test in a non-production environment first.

Can AI-written tests be trusted?

Treat them like tests from a new teammate. Run them, read the assertions, and check that each one would fail if the behavior broke. A test that can never fail is worse than no test.

How many tests should I ask for?

Ask for coverage of behaviors, not a number. One test per rule and per important edge case is usually enough, and it keeps the file readable.

How do I reuse this prompt without copying it every time?

Click Add to Retext to save it as a snippet. Then type ;writetests in any Mac app, including your AI tool, and the full prompt is pasted in.

Related Templates

Get the free prompt pack

Our best AI prompts in one Markdown file, delivered by email. The templates here stay free either way — the pack just saves you the copying.