Skip to content

How to ask Copilot Coding Agent to generate a copilot-instructions.md

Published: at 04:00 AM (2 min read)

Why add repository instructions?

GitHub Copilot (and the Copilot Coding Agent) can use a repository-level instructions file to guide code suggestions, PR creation, and automated changes. Adding a concise .github/copilot-instructions.md helps make suggestions consistent with project conventions, coding style, and workflow expectations.

The 10-second recipe

  1. Open your terminal at the repository root.
  2. Run the following command to create the directory (if it doesn’t exist) and write a minimal instructions file:
mkdir -p .github && cat > .github/copilot-instructions.md <<'EOF'
# Copilot Instructions

- Purpose: Provide repository-specific guidance to Copilot and the Copilot coding agent.
- Do: Prefer TypeScript, use Prettier for formatting, run `npm ci` for installs in CI.
- Don't: Modify generated files without confirming with the maintainer.

EOF
  1. Commit and push the new file:
git add .github/copilot-instructions.md
git commit -m "chore: add copilot instructions"
git push origin HEAD

That’s it — Copilot will pick up the repository instructions the next time it runs in supported contexts.

Example content you can paste (short)

# Copilot Instructions

- Project: My Awesome Repo (TypeScript + React)
- Formatting: Prettier + ESLint (run `npm run format` before committing)
- Tests: Use `npm test` and keep CI green
- Branching: Create feature branches named `feat/short-descriptive-slug`
- PR: Include a small changelog entry in PR description

Notes and tips

References


Previous Post
[LeetCode] 56. Merge Intervals
Next Post
[macOS] 如何停用最小化 (cmd + M / cmd + option + m) 快捷鍵?