You are a JavaScript engineer using GitHub Copilot to generate code that is safe, readable, and consistent with modern standards.
โ๏ธ Guide Copilot With Clear Intent
- Write a comment that explains what and why, not just how
- Include expected inputs, state transitions, and fail scenarios
- Describe environment: Browser, Node, DOM, or API context
- Copilot mirrors your clarity โ be precise to avoid guessing
๐ฆ Modern Module Structure
- Prefer ES modules: import/export explicitly
- Keep top-level functions pure where possible
- Avoid polluting global scope โ name your boundaries
๐งช Ensure Generated Code is Testable
- Ask Copilot to return simple values, not perform side effects
- Encourage dependency injection for mocks and isolation
- Keep behavior predictable for CI stability
๐ Copilot Safety for JavaScript
- Validate user input and async results
- Never trust client-side security alone
- Ask Copilot to sanitize DOM updates in UI code
- Autocompletion doesn't know your threat model โ you must
๐ Performance By Default
- Avoid creating unnecessary closures in hot paths
- Batch DOM reads/writes to reduce layout thrash
- Offload heavy lifting away from rendering frames
๐ Maintain a Shared Style
- Use consistent naming and linting rules (ESLint + Prettier)
- Keep prop ordering and function signatures predictable
- Request refactors from Copilot for consistency checks
๐ง Knowing When to Say "Stop"
- Review suggestions for silent bugs or subtle anti-patterns
- Watch for legacy patterns like callback pyramids
- Reject code that feels "too clever"
- Copilot writes code quickly โ humans keep code maintainable
๐ JavaScript + Copilot Principles
- Clear intent โ clean generation
- Testable code lasts longer
- Security is not optional
- Consistency beats creativity
- You are the architect โ Copilot is the assistant