The result to aim for
Before touching an old module, have an agent write tests that freeze his current behavior, to refactor without breaking.
The situation
The code inherited without testing is the riskiest to change. The method of characterization tests is to capture what the code does today, including its bizarreness, before transforming it. A code agent is effective in writing these tests in mass; Human decides which behaviors are bugs.
Before you start
Tool cited: Codex; the prompt also works with Claude Code and GitHub Copilot. Fill in the bracketed items: [chemin], [préciser]. Strip confidential data that is not needed and check your tool’s access terms. Features and plans can change.
The method, in three steps.
Gather the context
Spot the bracketed items in the prompt (
[chemin],[préciser]) and prepare what they ask for.Adapt the prompt
Copy the prompt below, replace the bracketed items, then paste it into Codex, Claude Code or GitHub Copilot.
Reread before using
Reread the result, correct it if needed and keep the final decision. Caveats are detailed below.
Your starting point.
Replace the bracketed items, then adapt the proposal to your situation. This prompt is written by the iadujour desk.
Refactoring module: [chemin]. Test language and framework: [préciser]. 1. Read the module and list its observable behaviors (inputs, outputs, onboard effects). 2. Write characterization tests that freeze current behavior, including limit cases. Do not change the module code. 3. Run the tests and show the result. 4. List separately behaviors that look like bugs, for human decision. Only then, proposes a small step refactoring plan.
What deserves your attention
Proof level: Practical case written by the desk, no third-party source. This is not a testimony: adapt the prompt to your situation.
Useful skills
Official skills on the same task, paired by the desk: they are not part of the described case.
- Build an application with SDK GitHub CopilotMicrosoft · Guides the creation of applications that rely on GitHub Copilot via the Copilot SDK, for programmatic integrations in Node.js/TypeScript, Python, Go or .NET: sessions, custom tools, streaming, hooks, MCP servers, BYOK providers, persistence, agents and skills, and deployment schemes.
- Create an MCP server and widgets for Copilot ChatMicrosoft · To build MCP servers for Copilot Chat, with widgets rendering (OpenAI Apps SDK or MCP Apps SDK, any language), including React and Fluent UI widgets and tools that return structuredContent.
- Create a reporting agent M365 Copilot or TeamsMicrosoft · Creates, assembles, deploys, and locates reporting agents for M365 Copilot and Teams: scaffolding, editing demonstrations, adding capabilities or plugins.
Comments.
A field note, a question, a precision on this use case? Comments are reviewed before publication.
Published comments
Loading comments…
Leave a comment
Moderation charter. Every comment is reviewed before publication. We refuse hate speech, insulting or discriminatory language, advertising, spam and promotional links, off-topic posts and other people’s personal data.