A skill for maximizing GitHub Copilot code completion quality through strategic comment placement and context management.
## Copilot Code Completion Optimizer Skill
### Overview
This skill teaches techniques to get the best possible code completions from GitHub Copilot by managing context, writing effective leading comments, and structuring files optimally.
### Technique 1: Strategic Comment Prompting
Write descriptive comments before the code you want Copilot to generate:
```typescript
// Validate email format using RFC 5322 regex, return boolean
function validateEmail(email: string): boolean {
// Copilot completes with proper regex validation
}
// Sort users by last login date descending, then by name ascending
const sortedUsers = users.sort(/* Copilot completes correctly */);
```
### Technique 2: Example-Driven Completion
Provide one example, and Copilot follows the pattern:
```typescript
// Convert 'snake_case' to 'camelCase'
function snakeToCamel(str: string): string {
return str.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
}
// Convert 'camelCase' to 'snake_case'
// Copilot generates the inverse function following the same pattern
```
### Technique 3: Type-First Development
Define types before implementation for better completions:
```typescript
interface PaginationParams {
cursor?: string;
limit: number;
direction: 'forward' | 'backward';
}
interface PaginatedResult<T> {
items: T[];
nextCursor: string | null;
hasMore: boolean;
}
// Copilot now generates pagination functions that match these types exactly
async function paginate<T>(params: PaginationParams): Promise<PaginatedResult<T>> {
```
### Technique 4: Context File Ordering
- Keep related files open in adjacent tabs; Copilot reads neighboring tabs
- Import interfaces and types at the top; Copilot uses them for completions
- Place utility functions before the code that uses them in the same file
### Technique 5: Completion Refinement
- If the first suggestion is wrong, add a more specific comment and retry
- Use `Alt+]` / `Option+]` to cycle through alternative suggestions
- Accept partial completions with `Ctrl+Right` and continue prompting
- Reject poor suggestions immediately; Copilot learns from your session
### Technique 6: Function Signature First
Write the complete function signature, then let Copilot fill the body:
```python
def retry_with_backoff(
func: Callable[..., T],
max_retries: int = 3,
base_delay: float = 1.0,
max_delay: float = 60.0,
exponential_base: float = 2.0,
jitter: bool = True
) -> T:
# Copilot generates correct retry logic matching all parameters
```Free to copy and use. Compatible with GitHub Copilot, GPT-5.
Apply these techniques when writing code with Copilot enabled. The strategic comment placement and type-first approach significantly improves suggestion quality.
Initial release
gh copilot skill install copilot-code-completion-optimizer-skillSign in and download this prompt to leave a review.