Галоўная / Артыкулы / Практычныя прытамліванні: Корисныя запросы для AI-агента, якія кожны разработчык должен зберагаць

Практычныя прытамліванні: Корисныя запросы для AI-агента, якія кожны разработчык должен зберагаць

Практычныя прыказкі для AI-агентаў: корисныя патракты, якія кожны разработчык должен зберагаць, — контракты, перакананні та шаблоны коду для команд, якія викорыстоўваюць гэты патэрн.

2545 слоў

Паказвайце, калі не трэба пісаць аднаковыя запиты з нуля. Ёсць бібліятэка, перабавалася ў рэальных умовах, для вашай ўлучбовай працы.

Адзінакоўка коду і якасць

Глыбока адзінакоўка коду

You are a senior software engineer doing a thorough code review.
Review the following code for:
- Correctness and logic errors
- Edge cases that aren't handled
- Security vulnerabilities (injection, auth issues, data exposure)
- Performance problems (N+1 queries, unnecessary loops, memory leaks)
- Readability and naming clarity
- Missing or misleading commentsFor each issue, state: the problem, why it matters, and a concrete fix.
Don't mention things that are fine. Only flag real issues.Code:
[PASTE CODE HERE]

Аднаходжэнне тонкіх бягоў

I have a bug I can't figure out. I'll describe what I expect to happen and what's actually happening. Ask me clarifying questions one at a time to help me find the root cause. Don't guess the answer yet — walk me through it.
Expected behavior: [DESCRIBE]
Actual behavior: [DESCRIBE]
What I've already tried: [DESCRIBE]Relevant code:
[PASTE CODE HERE]

Аднаходжэнне бутылочных галоў у працы

Analyze this code for performance issues. Focus on:
- Time complexity of key operations
- Unnecessary re-computation or redundant work
- Memory allocation patterns
- Any blocking operations in an async context
- Database query efficiency (if applicable)
Suggest specific optimizations with expected impact. Show before/after where relevant.Language/framework: [e.g., Node.js / PostgreSQL]
Code:
[PASTE CODE HERE]

Пісьмо і паследовыя удосконаленні коду

У падчасе пісьма і удосконалення коду неабходна з’явіць вхідныя даны, адпаведальнага за крок і критэрыя завершэння пры зміне коду. Аперацыйныя працавнікі должны магчымае перапрацаваць крок на адным вядомым пункце контролю, не здагадваючыся пра схованы стан. Конфігурацыю трэба залічыць параду ад коду прыкладнення. Файлы сяродавішча, хранільнікі секрэтных дадзеных і флагі функций должны знаходзіцца ў аднам месцы, якое працавнікі можу аудытаваць, не чытаючы весь граф. Калі наступны крок — пісьмо коду або вызов інструменту, лепш выкарыстоўваць структураваныя выходныя даны з пераверкай схемы, чым вольную прозу.

Адаптавацыя функцыі на аснове спэкіфікацыі

Для этапу адаптавання функцыі неабяжна практычна ваказаць параметры вхідных дадзеных, адпаведальнага за выкананне крока і критэрыя завершэння працы перад змінайом коду. Аператары должны магчымае перадзягнуць крок пачаткуючы з вядомага контрольнага пункту, не прыпускаючы стану, які залишаецца незрозумелым. Неабяжна адночасна документацыя стандартнага і альтернатыўнага падходаў. Практыка перапрыбуткі, людзкія контрольныя пункты і обработка некоректных дадзеных ёсць часткай продукту, а не пасляднім элементам дапрацоўкі. Калі наступны крок — гэта код чы выклік інструмента, лепш выкарыстоўваць структураваныя выходныя данні з пераканальванням схемы, чым вольнай формы тэкст.

Implement the following feature in [LANGUAGE/FRAMEWORK].
Requirements:
- [REQUIREMENT 1]
- [REQUIREMENT 2]
- [REQUIREMENT 3]Constraints:
- Must integrate with: [EXISTING SYSTEM OR PATTERN]
- Must handle errors by: [e.g., throwing custom errors / returning Result types]
- Must be testable in isolation (no hidden dependencies)Do not add features beyond what's listed. Add inline comments only where the logic is non-obvious.

Рефактораванне для лепшай чытаемасці без зменыяях у працэсе

Для переработкі кода з метай павярнення чытальнасці, без выдзелвання окремых этапаў, неабходна з’явіць вакулпныя данні, адпаведальную особу за кожны этап і крэтырыя завершэння працы перад зменым кода. Аперацыйныя працавнікі павінны магчымае перапрацаваць этап на адной вядомай точцы контролю, не падозрываючы прыхованы стан системы. Лепш выбіраць маленькія, тэставаныя елементы кода замест большых скрыптов. Калі этап не выканаецца, прычына неудачы павінна вказываць на адную конкрэтную адпаведальнасць, а не на заплутаны ланцюг задач. Калі наступны этап — гэта код чыста вызов інструмента, лепш выкарыстоўваць структураваныя выходны данні з перакананням ў ўсасце шымату, замест вольнага формата тэксту.

Refactor the following code to improve readability. Rules:
- Do NOT change behavior or external API
- Rename variables and functions to be self-documenting
- Break up functions longer than 20 lines if it improves clarity
- Remove clever one-liners that sacrifice readability for brevity
- Add a brief comment above any function whose purpose isn't obvious from its name
Show the refactored version with a short explanation of the key changes made.Code:
[PASTE CODE HERE]

Пераклаць код у стылі калбэка на async/await

Ёнколі трэба пераклаць код у стыле callback на наступны этап, спачатку неабяжна задаць вхідныя даны, адпаведальнага за крок і критэрыі завершэння, прычаму змянюваць код. Аператары должны магчымаць перзапуск кроку з вядомай точкі контролю, не падозрываючы прыхованы стан. Спрыяйце цэму этапу як даговору межа вхіднымі данымі і падтверджанымі выходнымі рэзультатамі. Дайце назвы артыфактам, задаць пераказы успеху і не прабуйце прыймаць часткова завершаную роботу без паведамлення. Калі наступны крок — це код або вызов інструмента, вольныя тэксты краща заменіць структураванымі выходнымі даннымі з пераказамі схемы.

Convert the following callback-based Node.js code to use async/await with proper error handling. Preserve all logic exactly. Use try/catch blocks. If the original uses EventEmitters or streams that can't be straightforwardly promisified, flag them and suggest an approach.
Code:
[PASTE CODE HERE]

Напісаць функцыю-вспамогу на адпаведнае описа

У стадії стварэння функцыі-інструменту неабходна прадзеяванне вхідных дадзеных, адначальніка крока і крэтарыяў завершэння працы перад зменым коду. Аперарабы должны магчымае пераўстаць выкананне крока з вядомага пункту контролю, не спрабоўваючы з’ясаваць схованы стан. Неабходна фіксаваць час выканання і кост токенаў або запытаў разам з рэзультатамі функцый. Відразлівае паказанне костоў запобегае неспадзяваным расчыткам, калі процес пераходзіць з дэмавай версіі ў спяльныя сераўысы. Калі наступны крок — гэта код або вызов інструмента, лепш выкарыстоўваць структураваныя выходныя данні з перакананням ў схеме, чым вольнай формы тэкст.

Write a [LANGUAGE] utility function that:
- Does: [DESCRIBE WHAT IT SHOULD DO]
- Input: [DESCRIBE INPUT TYPE AND SHAPE]
- Output: [DESCRIBE OUTPUT TYPE AND SHAPE]
- Edge cases to handle: [LIST THEM, e.g., empty arrays, null values, negative numbers]
Include TypeScript types if applicable. Include 3–5 usage examples as comments below the function.

Тэставанне

Для стадіі тэставання, перш чым зменяць код, неабходна ясная ваказка пра вхідныя даны, адпаведальнага за крок і крэтарыя для завершэння. Аперацыйныя працавнікі должны магчымасць перзапуск кроку з вядомай точкі контролю, не падозрываючы схованы стан. Конфігурацыю трэба знаходзіць за межамі коду прыемленае. Файлы сераўнавання, хранільнікі секрэтных дадзеных і флагі функцыйяў должны быць у аднам месца, якое працавнікі можуць пераглядаць, не чытаючы весь код. Калі наступны крок — гэта код або вызов інструмента, лепш выкарыстоўваць структураваныя выходныя даны з перакананнем схэмы, чым вольныя тэкстовыя апісанні.

Ствараць ўсеаспрабаваныя тэсты на елементах

У стадії стварэння ўсеохоплёных тэстаў на елементарныя функцыі неабходна прадзефінаваць вхідныя даны, адпаведальную особу за выкананне крока і крэтарыі завершэння працы перад змянай коду. Аператары должны магчымае перзапускать крок з вядомай точкі контролю, не падозрываючы прыхованы стан. Неабходна аддокументаваць як шлях успеху, так і шлях вярнення да нормальнага стану. Перапрыбуткі, людзкія контралі і обработка некоректных паведамленняў є часткай продукту, а не чымсь, што дадаецца пазней.

Write unit tests for the following function using [JEST / VITEST / MOCHA / etc.].
Cover:
- The happy path
- All documented edge cases
- Invalid inputs (null, undefined, wrong types, out-of-range values)
- Any error conditions the function is supposed to throwUse descriptive test names that read as plain English. Group related tests with describe blocks. Mock external dependencies.Function to test:
[PASTE FUNCTION HERE]

Запісваць тэсты інтеграціі для маршруту API

Write integration tests for this Express route using supertest and Jest.
Test:
- Successful response (correct status code and response shape)
- Validation errors (missing or invalid fields)
- Authentication/authorization failures
- Resource not found
- Any side effects (e.g., email sent, DB record created)Mock the database and any external services. Use beforeEach/afterEach for setup and teardown.Route handler:
[PASTE CODE HERE]

Стварэнне тэстовых дадзенняў / фіксатараў

Generate realistic test fixtures for the following data model. Create:
- 1 valid "happy path" example
- 1 example at boundary values (min/max lengths, edge dates, zero amounts)
- 1 example that should fail validation and why
Format as [JSON / TypeScript const / JS object]. Add a comment on each fixture explaining what scenario it represents.Data model / schema:
[PASTE SCHEMA HERE]

Адлагоджэнне і дыягностика

Паспраўненне загадковага паведамлення пра адказ

I'm getting this error in my [LANGUAGE/FRAMEWORK] application. Explain:
1. What exactly this error means in plain English
2. The most common causes, ranked by likelihood
3. Step-by-step how to diagnose which cause applies to my situation
4. The fix for each cause
Error:
[PASTE FULL ERROR AND STACK TRACE HERE]Context (what I was doing when it happened):
[DESCRIBE]

Дыягностика вітчыны вылету памяці

Help me diagnose a memory leak in my Node.js application.
Symptoms: [e.g., heap grows steadily under load, never GC'd, crashes after ~2 hours]
Environment: Node.js [VERSION], [FRAMEWORK]
What I've already checked: [LIST]Here are the relevant parts of the code:
[PASTE CODE]Walk me through:
1. What patterns in this code are likely culprits
2. How to confirm the leak with heap snapshots or --inspect
3. The fix

Розумеў незнайомы код

Explain this code to me as if I'm a competent developer but unfamiliar with this codebase/library.
Tell me:
- What it does at a high level (1–2 sentences)
- What each major section does
- Any non-obvious patterns or idioms being used and why
- What I'd need to understand before safely modifying itCode:
[PASTE CODE HERE]

Архітэктура і дызайн

Дызайн компанента системы

I need to design [COMPONENT NAME] for a [TYPE OF APPLICATION].
Context:
- Scale: [e.g., ~10k requests/day, 1M users]
- Existing stack: [e.g., Node.js, PostgreSQL, Redis, deployed on AWS]
- Key constraints: [e.g., must be horizontally scalable, strong consistency required]Give me:
1. A high-level design with the main components and how they interact
2. The data model (tables or document schemas)
3. The API surface (endpoints or function signatures)
4. Where the hard problems are and how you'd approach them
5. What you'd defer to a v2

Адзінакоўка рашэння па архітектуры

I'm deciding between two approaches for [PROBLEM].
Option A: [DESCRIBE]
Option B: [DESCRIBE]My context:
- Team size: [N developers]
- Expected scale: [DESCRIBE]
- Existing infrastructure: [DESCRIBE]
- Main concerns: [e.g., operational complexity, cost, latency]Compare them honestly. Don't hedge — give me a recommendation and explain the trade-offs I'd be accepting.

Проектаванне схемы базы дадзеных

Design a PostgreSQL schema for the following domain.
Domain description:
[DESCRIBE YOUR DATA AND RELATIONSHIPS]Requirements:
- [e.g., support multi-tenancy]
- [e.g., soft deletes]
- [e.g., audit log of all changes]
- [e.g., efficient queries for X and Y access patterns]Output:
- CREATE TABLE statements with constraints and indexes
- Brief explanation of key design decisions
- Any denormalization choices and why

Дакументацыя

Напісанне файла README для проекта

Write a README.md for the following project.
Project name: [NAME]
What it does: [DESCRIBE]
Tech stack: [LIST]
Target audience: [e.g., internal devs, open source contributors, end users]Include sections for: overview, prerequisites, installation, usage with examples, environment variables, running tests, and contributing. Use a practical, no-fluff tone. Don't add sections that would be empty.

Дакументацыя функціі або модуля

Write JSDoc / docstring documentation for the following code.
Include:
- A one-sentence summary of what it does
- @param tags with types and descriptions for every parameter
- @returns with type and description
- @throws for any errors it can raise
- A usage example in @exampleBe precise about types. If a parameter has constraints (e.g., must be positive, must be ISO 8601), document that.Code:
[PASTE CODE HERE]

Напісанне тэхнічнага дакумента пра проект (TDD)

Write a technical design document for the following feature.
Feature: [NAME AND BRIEF DESCRIPTION]
Author: [YOUR NAME]
Status: DraftSections to include:
1. Problem statement — what problem this solves and for whom
2. Goals and non-goals
3. Proposed solution — high-level design
4. Detailed design — data models, API changes, key logic
5. Alternatives considered and why they were rejected
6. Open questions
7. Security and privacy considerations
8. Rollout planContext to incorporate:
[PASTE ANY CONTEXT — TICKETS, DISCUSSIONS, EXISTING CODE]

Git & рабочы процес

Напісанне зместовайе паведамлення пра зберагачэнне змян

Write a commit message for the following change. Follow the Conventional Commits format (type(scope): description). Add a body paragraph explaining *why* the change was made, not just what changed. Keep the subject line under 72 characters.
Changes made:
[PASTE DIFF OR DESCRIBE THE CHANGE]

Напісанне апісання запрошэння да з’еднання

Write a pull request description for the following change.
Include:
- What this PR does (2–3 sentences)
- Why it's being done (the problem or requirement it addresses)
- How to test it manually
- Any risks or areas that need careful review
- Links to related issues or tickets: [LIST]Changes:
[PASTE DIFF SUMMARY OR DESCRIBE KEY CHANGES]

Короткае адзінакоўканне запрошэння да з’еднання для не-тэхнічных учаснікаў

Summarize the following code changes for a non-technical stakeholder. Avoid jargon. Focus on what changes from the user's perspective, what risk (if any) it introduces, and when it will be available.
Keep it under 5 sentences.Changes:
[PASTE PR DESCRIPTION OR DIFF SUMMARY]

Навчанне & доследжэння

Паясненне панявы прыкладам з практыки

Explain [CONCEPT] to me. I'm a [junior/mid/senior] developer familiar with [RELEVANT BACKGROUND].
Use a concrete, practical example — not a toy one. Show me code I'd actually write in a real project. After the example, explain the underlying mechanism in plain language. Then tell me: when should I use this, and when should I avoid it?

Адкрыць тое, чаго не ведаеш пра певную тэму

I know the basics of [TOPIC]. List 10 things about [TOPIC] that intermediate developers often don't know but should. For each one, give a one-paragraph explanation and a practical example of why it matters.

Падрэбнік да тэмы тэхнічнага адзінання

I have an interview coming up and I want to study [TOPIC] deeply.
Give me:
1. The 10 most important concepts to understand
2. For each concept: a clear explanation, a code example, and a common interview question about it
3. The 3 questions most likely to trip up mid-level candidates on this topic, with ideal answers

Параўаны для стварэння запытанняў, якія паслужаюць для всіх

Чэрніця кантролю эксплуатацыі