Write Effective Instructions

Tips and patterns for writing .instructions.md files that consistently produce high-quality Copilot output.

AuthorNeexoCore
Updated
instructionsbest-practicesbeginner

Overview

.instructions.md files control how Copilot generates code for specific file patterns. Well-written instructions dramatically improve output quality.

Key Principles

Be specific, not generic

# Bad
Write clean code.

# Good
Use early returns to avoid nesting. Max function length: 30 lines.
Never use `any` — use `unknown` and narrow with type guards.

Use applyTo patterns

Target instructions to specific file types:

applyTo:
  - "**/*.test.ts"
  - "**/*.spec.ts"

Include examples

## Naming

- Components: PascalCase (`UserProfile.tsx`)
- Hooks: camelCase with `use` prefix (`useAuth.ts`)
- Utils: camelCase (`formatDate.ts`)

State what NOT to do

## Don'ts

- Don't add comments explaining obvious code
- Don't use default exports
- Don't use enums — use const objects with `as const`

Template

---
name: "My Standard"
applyTo:
  - "**/*.ts"
---

## Rules

1. Rule one
2. Rule two

## Examples

### Good
\`\`\`ts
// example
\`\`\`

### Bad
\`\`\`ts
// counter-example
\`\`\`

Raw content

Copy this into your project — e.g. .instructions.md, .agent.md, or SKILL.md

## Overview

`.instructions.md` files control how Copilot generates code for specific file patterns. Well-written instructions dramatically improve output quality.

## Key Principles

### Be specific, not generic

```markdown
# Bad
Write clean code.

# Good
Use early returns to avoid nesting. Max function length: 30 lines.
Never use `any` — use `unknown` and narrow with type guards.
```

### Use applyTo patterns

Target instructions to specific file types:

```yaml
applyTo:
  - "**/*.test.ts"
  - "**/*.spec.ts"
```

### Include examples

```markdown
## Naming

- Components: PascalCase (`UserProfile.tsx`)
- Hooks: camelCase with `use` prefix (`useAuth.ts`)
- Utils: camelCase (`formatDate.ts`)
```

### State what NOT to do

```markdown
## Don'ts

- Don't add comments explaining obvious code
- Don't use default exports
- Don't use enums — use const objects with `as const`
```

## Template

```markdown
---
name: "My Standard"
applyTo:
  - "**/*.ts"
---

## Rules

1. Rule one
2. Rule two

## Examples

### Good
\`\`\`ts
// example
\`\`\`

### Bad
\`\`\`ts
// counter-example
\`\`\`
```