GitHub Copilot & Codex: Focused Coding Prompts
Copilot Wants Scope
Copilot and OpenAI Codex work best when the task fits the open files and visible diff. Long product briefs dilute attention. Tie every request to concrete symbols, paths, and expected output shape.
The Minimal Fix Prompt
"In UserService.php only: fix N+1 queries in getActiveUsers(). Return the optimized method only. Preserve public API. No new dependencies."
Explain-Then-Patch
"List the bug in 3 bullets, then show a minimal patch as a unified diff. If unsure about caller contracts, ask one clarifying question instead of inventing types."
Test-First Variant
"Write PHPUnit tests for edge cases: empty input, invalid email, duplicate user. Tests should fail on current code. Then implement the smallest production change to pass."
What to Avoid
Asking for full app rewrites in one message, requesting libraries not already in composer.json / package.json, or mixing unrelated features. Break work into PR-sized chunks.