.github/copilot-instructions.mdGitHub Copilot custom instructions: ตำแหน่งไฟล์และวิธีที่เครื่องมืออ่าน
GitHub Copilot อ่านไฟล์ที่ใช้กับทั้ง repository คือ .github/copilot-instructions.md และไฟล์ .instructions.md ที่กำหนดตาม path นอกจากนี้ยังรองรับ AGENTS.md หรือไฟล์ CLAUDE.md หรือ GEMINI.md ที่ root เพียงไฟล์เดียว
ตำแหน่งไฟล์
- .github/copilot-instructions.md ใช้กับทั้ง repository
- .github/instructions/**/NAME.instructions.md ใช้กับไฟล์ที่ตรงกับ applyTo
- AGENTS.md ในตำแหน่งใดก็ได้ใน repository โดยไฟล์ที่อยู่ใกล้ที่สุดจะมีผล
- ใช้ไฟล์ CLAUDE.md หรือ GEMINI.md ที่ root เพียงไฟล์เดียวแทนได้
รูปแบบ
Markdown; ระบบจะไม่สนใจช่องว่างระหว่างคำสั่ง มีเฉพาะไฟล์ .instructions.md ที่รองรับ frontmatter: applyTo ใช้ระบุ glob หลายรายการคั่นด้วยจุลภาค และ excludeAgent รับค่า "code-review" หรือ "cloud-agent" Code review ยกเลิกขีดจำกัด 4,000 อักขระเมื่อ 2026-06-12 และ GitHub แนะนำให้แต่ละไฟล์มีความยาวไม่เกินประมาณ 1,000 บรรทัด
# Copilot instructions
This is a Rails app with a React front end in app/javascript/.
## Build and test
- Install: `bundle install && yarn install`
- Test: `bin/rails test`
- Lint: `bin/rubocop`
## Conventions
- Put business logic in app/services/, not in controllers.
- Every migration must be reversible.
- Never commit credentials or edit config/master.key.
ลำดับความสำคัญและการผสาน
ระบบจะส่งคำสั่งส่วนบุคคลก่อน ตามด้วยคำสั่งของ repository แล้วจึงเป็นคำสั่งขององค์กร และยังส่งชุดคำสั่งที่เกี่ยวข้องทั้งหมดไปด้วย หากไฟล์ที่กำหนดตาม path และไฟล์ที่ใช้กับทั้ง repository ตรงกันทั้งคู่ Copilot จะใช้ทั้งสองไฟล์ Code review อ่านคำสั่งจาก branch head ของ pull request
เคล็ดลับ
- บน github.com ไฟล์ .instructions.md ที่กำหนดตาม path ใช้ได้เฉพาะกับ Copilot cloud agent และ Copilot code review
- เพิ่ม excludeAgent: "code-review" เพื่อไม่ให้ไฟล์มีผลกับการ review แต่ยังให้ cloud agent ใช้งานได้
- Copilot cloud agent ช่วยร่าง copilot-instructions.md ให้ได้ ควรเขียนให้ยาวประมาณสองหน้าและไม่ผูกกับงานใดงานหนึ่ง
สร้าง AGENTS.md และไฟล์กฎที่ตรงกันสำหรับเครื่องมือ 5 รายการจากแบบฟอร์มเดียว เปิดตัวสร้าง AGENTS.md →