BotHub on Habr presented six prompt patterns for refactoring, tests, and databases
BotHub published a practical guide to prompts for developers on Habr. The article brings together six templates: deep Python refactoring, legacy TypeScript…
AI-processed from Habr AI; edited by Hamidun News
BotHub published a comprehensive practical guide on Habr about writing prompts for developer tasks, rather than simply asking AI to "fix code." The article centers on six production-ready patterns that help teams refactor legacy code, restructure services, write tests, and identify performance bottlenecks in SQL.
Six Working Roles
The article is built around six scenarios where the neural network receives not a vague request, but a specific professional role. For Python code, it's an "architect surgeon" that breaks down a bloated FastAPI router into router, service, and repository layers. For TypeScript, it's a "patient mentor" who doesn't just rewrite a tangled function but first explains its logic, edge cases, and weak points.
For React, it's a "paranoid QA engineer" who writes tests not just for the happy path, but for API errors, double clicks, and loading states. In the second half, BotHub introduces three more roles. The "polyglot translator" is needed for migrating from PHP to modern Python without carrying over old habits and hacks from one language to another.
The "ruthless reviewer" is used for Go code audits, where the model searches for race conditions, memory leaks, and path traversal vulnerabilities. And the "database whisperer" works at the DBA level: it receives not just an SQL query, but also EXPLAIN ANALYZE, then suggests a rewritten query and appropriate indexes. The core idea is that the same LLM changes answer quality depending on how the task is framed.
If the request sounds like "make it pretty," the result will be vague. But if the prompt specifies the role, tech stack, constraints, output format, and quality criteria, the model starts working as a narrow specialist rather than a universal chatterbox.
How the Prompt Works
BotHub emphasizes structure over magic phrases. In successful examples, there are always several consistent pillars: who exactly is answering, what problem is being solved, what tech stack is in use, what cannot be broken, and what form the result should take. This way, the model speculates less and more often hits the actual project requirements. This is especially visible in the React testing example, where Vitest, React Testing Library, fetch mocking, and AAA format are specified upfront.
- Clear role: Staff Engineer, Senior Frontend Developer, QA Automation Engineer, or DBA.
- Explicit constraints: preserve business logic, don't praise the code, use specific patterns and frameworks.
- Step-by-step answer structure: summary, analysis, edge cases, corrected code, or index list.
- Deep context: a piece of legacy code, a vulnerable snippet, an EXPLAIN ANALYZE log, the project tech stack.
"Be extremely critical, don't praise the code."
This phrase from the security review section well illustrates the article's overall approach. The author literally removes the model's space for polite chitchat and forces it to concentrate on problems. The same principle works in other parts of the material: when a migration task explicitly forbids carrying PHP hacks into Python, and an SQL task demands finding the exact bottleneck from the execution plan, answer quality noticeably improves.
Not Instead of the Developer
That said, the article makes no magic-wand promises. In the example of a slow PostgreSQL query, BotHub specifically shows that without EXPLAIN ANALYZE, the neural network won't see the database's actual behavior and will guess blindly. In the Go service example, the benefit doesn't come from "AI magic" but from the fact that the prompt directs the model to specific problem classes: race conditions, path traversal, error handling failures, and leaks.
In other words, the neural network here acts not as an autonomous architect but as an accelerator for an already well-understood engineering task. The material's practical value lies elsewhere: it reduces the cognitive overload developers face with legacy code and routine code reviews. Instead of chaotic back-and-forth with a bot, the article offers a set of repeatable templates that can be quickly adapted to your stack.
Essentially, it's a guide for moving from random queries to a working interface with an LLM, where the developer sets the boundaries and the model fills them with useful content.
What This Means
BotHub's material shows a shift in the maturity of AI coding tools: the winner is no longer simply someone who opened a chat, but someone who knows how to frame an engineering task with proper context. For teams, this means faster refactoring, meaningful tests, and less time spent untangling someone else's code.
Want to stop reading about AI and start using it?
AI News is a curated feed of AI/tech news. Hamidun Academy teaches you to use AI systematically in your work.