Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
copilot-instructions.md Custom Commands GitHub Copilot IMCSEIAN intermediate Tooling Tutorial

Custom Slash Commands in VS Code

Reviewed & accurate
AI Summary
IMCSEIAN · GitHub Copilot Master Course

Custom Slash Commands in VS Code

Define reusable commands via .github/copilot-instructions.md and prompt files.

Phase 2 — Intermediate Lesson IN-39 Difficulty: Intermediate 10 min read
Course: GitHub Copilot Phase 2 — Intermediate 10 min read Last verified: 2026-08-30

What You Will Learn

  • Create custom slash commands.
  • Use .github/copilot-instructions.md.
  • Use prompt files.
  • Share commands with team.
  • Iterate commands over time.

Why This Matters

Built-in slash commands are useful but generic. Custom commands encode your team's conventions and reusable prompts. This is the foundation of team-wide Copilot consistency.

Concept Explained

Custom slash commands are defined via .github/copilot-instructions.md (repo-level) or prompt files (workspace). They appear in the slash command picker like built-ins.

How It Works

Create .github/copilot-instructions.md with system-style instructions. Or create .github/prompts/*.md files for custom commands. Copilot reads them and offers in the picker.

Step-by-Step Tutorial

1. Create instructions file

.github/copilot-instructions.md — repo-level system prompt.

2. Add conventions

Coding style, common patterns, 'don'ts'.

3. Create prompt files

.github/prompts/review.md, generate-tests.md, etc.

4. Use in Chat

Type / + tab to see custom commands.

5. Iterate

Refine based on output quality. Commit changes.

Real-World Example

A team added .github/copilot-instructions.md with: 'Use TypeScript strict mode. Prefer functional style. No classes. Use early returns.' All Copilot Chat in the repo followed these conventions. Code review consistency improved dramatically.

Example Prompts / Commands / Code

copilot-instructions.mdimcseian
# .github/copilot-instructions.md

You are an engineer at Acme Corp. Follow these conventions:

## Code style
- TypeScript strict mode.
- Prefer functional style; avoid classes.
- Use early returns; max 3 nesting levels.
- All async functions must have explicit return types.
- All public functions must have JSDoc.

## Don'ts
- Don't use lodash (use native methods).
- Don't use try/catch (use Result type from neverthrow).
- Don't use classes (use functions and closures).
- Don't use any (use unknown and narrow).

## Patterns
- Repository pattern for data access.
- Result type for error handling.
- Zod for runtime validation.

Apply these to all code suggestions.
Custom prompt fileimcseian
# .github/prompts/security-review.md

Act as a security reviewer.
Check for:
- Input validation
- Authentication/authorization
- Secrets in code
- Unsafe deserialization
- SQL injection
- XSS

Output as numbered list with severity (high/med/low), issue, fix.

Code to review:
$selection

Common Mistakes

  • Instructions too long — eats context budget.
  • Not committing instructions — team doesn't benefit.
  • Not iterating — first version rarely best.
  • Confusing instructions (system) with prompt files (commands).

Best Practices

  • Keep copilot-instructions.md concise (<500 tokens).
  • Commit to repo so team benefits.
  • Use prompt files for custom commands.
  • Iterate based on output quality.
  • Document the layering: instructions (persistent) + prompt files (commands).

Troubleshooting

ProblemHow to Fix
Custom command not appearingVerify file path. Restart VS Code.
Instructions not respectedRephrase. Or move to prompt file for explicit invocation.

Practical Exercise

Your Turn

Create .github/copilot-instructions.md for your repo with 5 conventions. Create a custom slash command for security review. Use both in real work.

Professional Challenge

Stretch Goal

Build a library of 5 custom slash commands for your team's common tasks. Commit to a shared repo. Document usage.

Key Takeaways

  • Custom slash commands via .github/copilot-instructions.md and prompt files.
  • Instructions = repo-level system prompt.
  • Prompt files = custom commands.
  • Commit to repo for team benefit.
  • Keep instructions concise (<500 tokens).

Frequently Asked Questions

Do instructions apply to inline completions?
Yes — repo-level instructions affect all Copilot surfaces in the repo.
Can I have per-project instructions?
Yes — each repo's .github/copilot-instructions.md applies separately.

Further Reading

Official References

Related lessons: IN-05, IN-39

SEO Metadata

SEO title: Custom Slash Commands in VS Code

Meta description: Define reusable commands via .github/copilot-instructions.md and prompt files.

Primary keyword: custom slash commands in vs code

Secondary keywords: custom slash commands in vs code

Search intent: Informational

URL slug: /custom-slash-commands-vscode-copilot-instructions

Categories: AI Tools, GitHub Copilot

Tags: GitHub Copilot, Intermediate, Custom Commands, copilot-instructions.md, Tooling, IMCSEIAN, Tutorial, IMCSEIAN

Featured image concept: IMCSEIAN lesson card for Custom Slash Commands in VS Code

Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments