PromptSharpDaily briefsDev & Engineering › September 9, 2026

PromptSharp Dev Brief · free web issue

Dev & Engineering prompt of the day

September 9, 2026 · for Software engineers, tech leads, engineering managers. One sharp, copy-paste prompt — free, every weekday.

TestingFREE

Legacy-code characterization tests: pin what the module DOES before you dare touch it

You have to change an untested legacy module and you don't fully trust what it does. Wrap it in behavior-pinning tests that document the CURRENT behavior first, so your refactor can't silently change it.

You are a senior engineer writing characterization tests (a.k.a. pinning / golden-master tests, after Michael Feathers) for an untested legacy module I am about to change. The goal is a safety net that documents what the code ACTUALLY DOES today — not what it should do — so I can refactor without silently altering behavior. I will paste the module and the context.

Produce:

A) OBSERVED-BEHAVIOR MAP — from the pasted code, the module's public entry points and, for each, the inputs it consumes and the outputs/side effects it produces (return value, mutated state, I/O, exceptions thrown). Mark each output either "determined from code" or "MUST CAPTURE BY RUNNING" where the value cannot be read off the source (formatting, ordering, floating-point, downstream calls).

B) SEAM MAP — the seams where I can sense or separate behavior WITHOUT changing it (object seams via injected collaborators, a wrapping function, a parameterized clock/random/IO). For each: the smallest dependency-breaking edit that makes the code testable while leaving runtime behavior identical, and the risk that edit carries.

C) CHARACTERIZATION SUITE — tests that PIN the current behavior, ordered change-point-first then working outward. For each test: the exact input, the assertion against the OBSERVED output, and a comment `# pins current behavior — captured from a real run, do NOT 'correct' this value`. Include boundary and error paths the module currently exhibits (including current exceptions).

D) GOLDEN MASTER — for any output too large or complex to assert inline (rendered strings, big structures, serialized blobs): a capture-and-diff harness — how to sample a representative range of inputs, snapshot outputs to a golden file on a known-good commit, and fail the test on any diff. Name the exact inputs to sample.

E) CHANGE-SAFETY GATE — the order of operations: pin the change point, run the suite GREEN against the unmodified module, then refactor in small steps keeping it green — plus the one test that most protects the specific change I described.

Inputs: [PASTE THE MODULE + ITS DIRECT DEPENDENCIES] · [WHAT I NEED TO CHANGE + WHY] · [LANGUAGE / TEST FRAMEWORK] · [HOW TO RUN IT / SAMPLE INPUTS I CAN FEED IT]

Rules: Do not invent behavior the code does not demonstrably produce — every asserted value must come from the pasted source or from a real run I perform, and wherever you cannot determine an output, emit a `# CAPTURE:` TODO telling me to run the code and paste the result, never a guessed value. These tests document what IS, not what SHOULD be: if you suspect a bug, PIN the current (even wrong) behavior in the test AND list it separately as a "suspected defect to fix AFTER the net is green" — do not quietly assert the corrected value. Verify every pinned value against an actual execution before relying on the suite; a characterization test asserting an imagined output is worse than none. Keep proprietary or confidential source out of consumer AI tools beyond what I pasted, and strip any secrets, credentials, or real user data from fixtures and golden files.

Why it works — The one rule that makes characterization tests work is the one everyone breaks: the tests must encode the behavior that EXISTS, bugs and all, not the behavior you wish existed — because their only job is to catch your refactor changing something. Forcing every assertion to trace to an observed run (with a CAPTURE TODO instead of a guess) kills the fabricated-output failure that turns a safety net into a lie, and pinning the change point first with a golden master for the messy outputs is exactly Feathers' order for getting untested legacy code under test cheaply.

Subscribe free — the PromptSharp Dev Brief

Free forever. Today's Dev & Engineering issue is live on the web right now — subscribe and we email you the sample issue immediately, then the Dev & Engineering daily every weekday as its email edition ships. Unsubscribe anytime.

Go Pro: 5 desk-ready prompts every day for Dev & Engineering

Free = the day's prompt. Pro unlocks the full daily prompt set and personalization — answer a few questions once and every prompt you copy arrives with your role, company, and tools already filled in. Plus MCP delivery straight into your AI tools.

See pricing → About this vertical

How to run “Legacy-code characterization tests: pin what the module DOES before you dare touch it”, step by step

The situation this prompt is built for: You have to change an untested legacy module and you don't fully trust what it does. Wrap it in behavior-pinning tests that document the CURRENT behavior first, so your refactor can't silently change it. Below is exactly what to feed it and what comes back — no model-specific tricks, it runs the same in any chat AI.

What each placeholder does

Demo profile for the example fills: a senior backend engineer on a 12-person product team, working in GitHub, CI, and an AI coding assistant. Swap in your own context — or save it once at /profile and copied prompts arrive pre-filled.

Why this structure works

The one rule that makes characterization tests work is the one everyone breaks: the tests must encode the behavior that EXISTS, bugs and all, not the behavior you wish existed — because their only job is to catch your refactor changing something. Forcing every assertion to trace to an observed run (with a CAPTURE TODO instead of a guess) kills the fabricated-output failure that turns a safety net into a lie, and pinning the change point first with a golden master for the messy outputs is exactly Feathers' order for getting untested legacy code under test cheaply.

On Pro, pro personalization loads your test framework, your snapshot/golden-file conventions, and your codebase's known-gnarly modules so the characterization suite and its capture harness drop straight into how your team already tests.

When to use it — and when not to

Reach for it when

Skip it when

Adapting today’s prompt for adjacent roles

“Legacy-code characterization tests: pin what the module DOES before you dare touch it” sits in the Testing lane of the dev & engineering pool. If your seat is one desk over, these are the same craft-move rebuilt for the neighbouring workflow — pulled from the same curated pool, each free in full at its permalink:

Pre-review sweep: your own PR through a security-and-edge-case lens

Code Review & Quality · same dev & engineering pool

The PR is 'done'. Run the pre-review sweep so human reviewers spend their attention on design — not on nits and the missed null check.

You are a staff engineer reviewing a pull request. I will paste the diff and its context. Produce: A) REVIEW TABLE — columns: file/line reference, severity (blocker /…

LLM review works best as a filter before human review — the machine catches the mechanical 80% so humans argue about design. Severity plus category…

Read the full prompt →

Root-cause interrogation: a hypothesis ladder from a bug report

Debugging & Root-Cause · same dev & engineering pool

Prod bug, vague repro, clock ticking. Structure the investigation before you start changing code at random.

You are a senior engineer running a structured root-cause investigation. I will paste the symptoms and every piece of evidence I have. Produce: A) HYPOTHESIS LADDER — 5…

Ranked hypotheses with discriminating tests is how senior engineers actually debug — it converts panic into a binary-search plan. The prevention…

Read the full prompt →

Design doc skeleton with the alternatives you'll actually be asked about

Architecture & Design Docs · same dev & engineering pool

New system or big refactor. Draft the design doc with real alternatives and failure modes before the review meeting drafts it for you.

You are a principal engineer drafting a design document. I will describe the problem and constraints. Produce: A) DOC SKELETON — context and problem, goals and explicit…

Design reviews go sideways on missing alternatives and unstated failure modes. Writing rejected-because with reversibility does the reviewers' job…

Read the full prompt →

Common failure modes (and the fixes)

Quick answers

Is “Legacy-code characterization tests: pin what the module DOES before you dare touch it” free to use?

Yes — every weekday issue of the PromptSharp Dev Brief publishes one full pool prompt free on the web, and it stays free in the archive. Pro is the daily full prompt set, personalization, and MCP delivery — not a paywall on this page.

Which AI model does this prompt work with?

Any of them. Every PromptSharp prompt is model-agnostic plain text — ChatGPT, Claude, Gemini, Copilot, or a local model. No plugins, no custom GPTs; paste and run.

How is the dev & engineering prompt of the day chosen?

Deterministic rotation over the curated dev & engineering pool — currently 11 prompts across 5 sections — the same single source the paid brief reads. Same date, same prompt: the archive never silently changes under you.

What goes in the [BRACKETED] placeholders?

Your context — the walkthrough above covers each one. The short rule: the more concrete the fill (real names, numbers, constraints), the sharper the output. Save your details once at /profile and web copies arrive pre-filled.

How do I get this in my inbox instead?

The capture form above — PromptSharp Dev Brief status is honest: live briefs send every weekday; pre-launch verticals email their free list the day the email edition starts.

More daily AI prompt briefs

The same free weekday format, tuned to other crafts:

← 2026-09-08 · All Dev & Engineering issues

Better together
Make prompts remember you: Brainfile

Even a sharp prompt starts from zero unless your AI knows you. Brainfile is persistent context — your work, voice, and priorities loaded into every session. Brainfile is the memory; PromptSharp is the playbook. Together they compound — the same prompt gets sharper because it runs on YOUR context.

Set up your brainfile →

Want both? The All-Access + Brainfile annual bundle covers the pair.

PromptSharp — sharp prompts for professionals.
Home · Daily Issues · Prompt Library · Glossary · Pricing · For Teams & Universities · Archive · PromptFluent alternative · Newsletter · Privacy · Terms · Refunds
Verticals
Marketing · Sales · Dev & Engineering · Finance · Product Management · Vibe Coding · C-suite · Consulting & Strategy · Law · CPG · Personal Finance · Career & Job Search · Trading · Health & Fitness · Students · Focus & Productivity · Learning · Travel Planning
Talk to us
[email protected]
[email protected]
Also from us
Entry Point Trading
Free weekly stocks to watch —
how our model ranks the S&P 500 and Nasdaq 100.
PromptSharp prompts are drafted with AI assistance and human-reviewed. They structure how a model reasons over data you provide — they do not source or verify facts for you, and you own every output. Nothing here is financial, legal, tax, or investment advice. Never paste confidential, client, or material non-public information into consumer AI tools; follow your employer's AI-use policy. © 2026 PromptSharp.