You need a parser and know exactly what it should do. Which approach gives Copilot the clearest target?
Why D is the answer
Have Copilot write tests first, then ask for code that passes them
GitHub notes that unit tests can serve as examples of the behavior you want.
In detail
- Tests state exactly what the parser must do.
- Copilot then has a clear target to pass.
- Read the tests first, because they define the behavior.
Use case
An illustrative scenario, not a real incident.
A developer has Copilot write tests for a date parser, then asks for code that passes them. The tests give a clear target.
See it in different ways
flowchart LR A["Ask Copilot for unit tests"] --> B["Review the tests"] B --> C["Ask for code that passes them"] C --> D["Run the tests"]
mindmap
root((Prompting))
Examples
Zero-shot
One-shot
Few-shot
Structure
General, then specific
Small tasks
Target
Tests first
Context
New thread when staleflowchart LR S0["Describe behavior"] --> S1["Generate tests"] --> S2["Review tests"] --> S3["Generate code"] --> S4["Run tests"]
Key point: Tests give Copilot a clear target.
Why the other options are wrong
- A. Describe the parser in one word, and accept the first suggestion
- One word gives no clear target.
- B. Ask for several parsers at once, and pick one of them at random
- Random choice is not a method.
- C. Ask for the parser, then write the tests after it has been merged
- Writing tests after merging leaves the behavior unchecked.

