Rewrite a Vague Issue into a Copilot Coding Agent-Ready Issue

Turns a vague GitHub issue into a self-contained task with context, testable acceptance criteria, files to touch, and tests to add, so the Copilot coding agent can finish it.

You get: Working code with an explanation

More like this

The prompt

rewrite-a-vague-issue-into-a-copilot-coding-agent-ready-issue.md
You are a maintainer preparing a GitHub issue to assign to the Copilot coding agent. The agent cannot ask questions mid-task, so the issue must stand alone. Here is the vague issue: {paste the vague issue here} Before writing, ask me one or two short questions if you need the repo layout, the test command, or the intended behavior. Rules: every acceptance criterion must be observable and pass or fail, such as a returned value, a status code, or a rendered state. Label file paths as confirmed or likely, and do not present guesses as facts. State what is out of scope. If the work is larger than one reviewable PR, propose a split into separate issues. Output exactly this: Title (imperative, under 80 characters). Context (why this matters and the current behavior). Desired behavior. Acceptance criteria as a checkbox list. Files to touch as a table with columns Path, Change, Confidence. Tests to add (name, input, expected result). Out of scope. How to verify (exact commands). Open questions for the maintainer. Finish with a one-line risk note on what could make the agent go wrong.

Example output

AI-written example
# Escape regex special characters in product search queries

## Context
`GET /api/products/search?q=` returns HTTP 500 when `q` contains regex metacharacters such as `(`, `[`, `+` or `*`. For example, `q=c++` or `q=shirt (blue)` fails. The query is passed unescaped into `new RegExp(q, "i")`, which throws `SyntaxError: Invalid regular expression`. Users searching for product names with punctuation see a generic error page.

## Desired behavior
Search treats `q` as a literal, case-insensitive substring. Special characters match themselves. Empty or whitespace-only `q` returns HTTP 400 with `{"error":"query_required"}`.

## Acceptance criteria
- [ ] `GET /api/products/search?q=c%2B%2B` returns 200 and includes products whose name contains `c++`.
- [ ] `GET /api/products/search?q=shirt%20(blue)` returns 200, not 500.
- [ ] `GET /api/products/search?q=.` returns only products whose name contains a literal `.`, not every product.
- [ ] `GET /api/products/search?q=SHIRT` still matches `Shirt` (case-insensitive).
- [ ] `GET /api/products/search?q=%20%20` returns 400 with body `{"error":"query_required"}`.
- [ ] Existing tests in `tests/search` pass unchanged.

## Files to touch
| Path | Change | Confidence |
|---|---|---|
| `src/services/searchService.ts` | Escape `q` before building the RegExp | Confirmed |
| `src/utils/escapeRegex.ts` | New helper that escapes `[.*+?^${}()\|[\]\\]` | Likely (new file; `src/utils/` exists) |
| `src/routes/products.ts` | Return 400 for blank `q` | Likely |
| `tests/search/search.test.ts` | Add cases below | Confirmed |

## Tests to add
| Name | Input | Expected result |
|---|---|---|
| escapes plus signs | `q=c++` | 200, results contain "C++ Handbook" |
| escapes parentheses | `q=shirt (blue)` | 200, no thrown error |
| dot is literal | `q=.` | Only names containing "." returned |
| stays case-insensitive | `q=SHIRT` | Same results as `q=shirt` |
| rejects blank query | `q=%20` | 400, `{"error":"query_required"}` |
| escapeRegex unit | `a.b*c` | `a\.b\*c` |

## Out of scope
- Fuzzy matching, ranking, or switching to full-text search.
- Changes to pagination or response shape.
- Frontend search box validation.

## How to verify
```bash
npm ci
npm test -- tests/search
npm run lint
npm run build

Manual check: npm run dev, then curl -i "http://localhost:3000/api/products/search?q=c%2B%2B" should return 200.

Open questions for the maintainer

  • Should blank q return 400, or an empty list to preserve current behavior?
  • Is src/routes/products.ts the correct route file? Confirm before merging.

Risk: The agent may "fix" this by wrapping the call in try/catch, which hides the error without making special characters searchable. The acceptance criteria require literal matches.

Generated from this prompt by AI. Your results will vary.

Tips and common edits

Use it before assigning an issue to Copilot. Paste the original issue text, and add a file tree or the test command if you have them.

Questions about this prompt

Conventional Commit and PR Description from a Diff and Ticket

Produces a Conventional Commits message and a reviewer-ready PR description covering what changed, why, how to test it, and the risks, based on your diff and ticket.

Checkable Guardrail Rules for a Coding Agent: Blocked Commands, Approvals, Secrets and Hooks

Produces a set of testable guardrail rules for your coding agent, covering blocked commands, approval gates, secret handling and hook checks.

Coding Agent Task Brief with Guardrails, Test Plan, and Rollback Steps

Creates a scoped brief for an AI coding agent that limits file changes, defines tests, and includes a rollback plan and review checklist.

20-Case Agent Eval Set with Pass/Fail Rubric for Normal, Edge and Unsafe Requests

Builds 20 test cases for your agent's task, with expected behavior, failure signals and a pass/fail rubric covering normal, edge and unsafe requests.

Agent Tool Names, Descriptions and JSON Schemas from API Docs

Turns pasted API docs or a function list into agent-ready tool names, descriptions, JSON input schemas and when-to-use and when-not-to-use notes.

Agent Workflow Decomposition with Autonomy Levels and Stop Rules

Turns a manual process into a step-by-step agent plan with tools, approval gates, retry limits, and a build/pilot/skip recommendation.

Characterization Tests Before a Refactor

Writes tests that lock in a module's current behavior, including edge cases and quirks, so you can refactor safely.

Codebase Tour for a Specific Task

Explores a repo through the lens of your task and explains the architecture, key files and data flow, then says where to start.

Failing Test First Bug Fix

Reproduces a bug with a failing test, finds the root cause, applies the smallest fix and shows the test passing.

Parallel Research Fan-Out and Fan-In with Citation Table and Decision Memo

Splits a research question across parallel research agents, defines source discovery and evidence review steps, merges findings into a citation table, and produces a decision memo without claiming live browsing.

Research Agent Brief: Source Discovery, Evidence Review, and Citation Table

Directs an AI agent to plan source discovery, grade evidence, build a citation table, and support a decision without claiming live browsing occurred.

Research-to-Report Pipeline with Planner, Researcher, Writer and Fact-Checker

Designs a four-agent pipeline for your report type with each agent's prompt, inputs, outputs and handoff format.