Prompting tips for maintenance tasks – Part 2

This blog is also a living document for myself so I can improve and reference this working pattern in the future.

Model selection

If using ChatGPT for coding tasks, especially maintenance tasks, opt for o1, other models are crap and will hallucinate or forget more of the original code.

Avoiding regressions

If the goal is to alter existing code, ChatGPT risks breaking existing code by removing as part of the end result, a good prompt is something like below, to reduce the amount of feedback loop and future debugging. This is the prompt I use when I want to optimize for retro-compatibility and avoid too much diff between old and new code.

[SPEC, aka insert-here your own description of your problem to be solved by ChatGPT/LLM, with instructions, followed by the text below]

I want the complete code as the final result, without removing functionalities from the original source code. If the changes required consist only in 2-3 things to replace in the code, answer with something like "replace this...." with that "....".

Show me the final file with the modifications whenever more than a few lines require change.
Do not omit code for brevity, keep untouched code same as before, with no new comments and no change to existing code styling, syntax, indentation and comments unless necessary.

Format the code answers using code block formatted professionally.

Terminate the code suggestion by proposing a short git commit in semantic format to recap all changes and recap the decisions made.

Always bump version in the source code with every stable fix. Add and improve comments.

Always ensure there are --debug, --help and --dry-run modes/flags

A failure should ideally report to ntfy.

The code should fail fast e.g check dependencies and paths early.

If there are too many features being prompted at once, warn the user and ask which to implement first. For every design/code decision made, justify the decision in the response and if possible explain it also as part of the commit message. Always provide full instructions how to test the program.

[CODE, aka Insert here the original code to be maintained/modified/debugged by the LLM]

When ChatGPT is done with the code generation, I output the original and newer versions of the code in something like my favorite diff viewer for code changes, or something like https://www.diffchecker.com/text-compare/, and I review the differences. When it seems good, I test, then I commit.

For reviews

Review the code as SecOps/DevOps/SRE/QA, show me anything odd and tell me what requires fixing and why, without starting yet to fix it.

For starting with a fresh context

Sometimes the context of a chat conversation is polluted as the conversation went over for too long, and even the UI starts to act weird and slow. In those cases, I prompt this in the current conversation, then I reuse the LLM output as a base for a future conversation.

Generate a nice prompt for the next LLM code maintainer to explain the current context of the project, its bugs and features to be developed, the past decisions and the remaining challenges.

See also

Prompt hacks aka make the best coding out of GPT

‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ Last Updated: Feb 22, 2026 at 2:01 PM CET in