---
title: "Cursor Project Rules (.cursor/rules/*.mdc): path และรูปแบบ · DotsAgent"
description: "ตำแหน่งของ .cursor/rules/*.mdc รูปแบบและ frontmatter วิธีผสานไฟล์ระดับ global กับไฟล์ในโฟลเดอร์ย่อย และเครื่องมือที่อ่านไฟล์นี้ ตรวจสอบเมื่อ 2026-10-01"
url: https://dotsagent.io/th/instructions/files/cursor-rules
---

.cursor/rules/*.mdc

# Cursor Project Rules (.cursor/rules/*.mdc): ตำแหน่งไฟล์และวิธีที่เครื่องมืออ่าน

Project Rules ของ Cursor คือไฟล์ .mdc ใน .cursor/rules/ โดย frontmatter จะกำหนดเงื่อนไขในการแนบแต่ละ rule นอกจากนี้ Cursor ยังอ่าน AGENTS.md รวมถึง User Rules และ Team Rules ที่กำหนดไว้นอก repository ด้วย

## ตำแหน่งไฟล์

- .cursor/rules/**/*.mdc อนุญาตให้มีโฟลเดอร์ย่อย ส่วนไฟล์ .md ปกติใน .cursor/rules จะถูกละเว้น
- AGENTS.md ที่ root และในโฟลเดอร์ย่อย
- User Rules ซึ่งกำหนดใน settings ของ Cursor
- Team Rules ซึ่งกำหนดในแดชบอร์ดของทีม

## รูปแบบ

Markdown พร้อม YAML frontmatter และต้องใช้นามสกุล .mdc; alwaysApply: true จะรวม rule ไว้เสมอ ส่วน globs ที่ใช้ alwaysApply: false จะแนบ rule เมื่อมีไฟล์ที่ตรงกันอยู่ใน context หากระบุแค่ description จะให้ Agent ตัดสินใจเอง หากไม่กำหนดค่าเหล่านี้ rule จะใช้เฉพาะเมื่อกล่าวถึงด้วย @

คีย์ Frontmatter: `description``globs``alwaysApply`

`.cursor/rules/*.mdc`

```
---
description: React component conventions
globs: src/components/**/*.tsx
alwaysApply: false
---

- One component per file, with a named export matching the file name.
- Type props with an interface named after the component plus Props.
- Use the existing CSS modules; no inline style objects.
- Follow @src/components/Button.tsx as the reference pattern.
```

## ลำดับความสำคัญและการผสาน

Team Rules ตามด้วย Project Rules แล้วจึงเป็น User Rules ระบบจะรวม rules ที่ใช้ได้ทั้งหมด และแหล่งที่มาก่อนจะมีผลเมื่อเกิดข้อขัดแย้ง โดยปิดใช้ Team Rules ที่บังคับใช้ไม่ได้ ไฟล์ AGENTS.md ในโฟลเดอร์ย่อยจะรวมกับไฟล์ของโฟลเดอร์แม่ โดยไฟล์ที่ระบุขอบเขตได้เฉพาะเจาะจงกว่าจะมีผลเหนือกว่า

## เครื่องมือที่อ่านไฟล์นี้

| เครื่องมือ | การรองรับ |
| --- | --- |
| [Cline](https://docs.cline.bot/features/cline-rules) | ตรวจพบไฟล์ .cursorrules รุ่นเก่า |

## เคล็ดลับ

- คั่น globs หลายรายการด้วยจุลภาคในฟิลด์ globs
- เขียนแต่ละ rule ให้มีความยาวไม่เกิน 500 บรรทัด และอ้างอิงไฟล์ด้วย @filename แทนการคัดลอกเนื้อหามาวาง
- Rules ไม่มีผลกับ Cursor Tab และ User Rules ไม่มีผลกับ Inline Edit
- เอกสารของ Cursor ไม่กล่าวถึงไฟล์ .cursorrules แบบเก่าแล้ว ให้ย้ายไฟล์ไปไว้ใน .cursor/rules/

สร้าง AGENTS.md และไฟล์กฎที่ตรงกันสำหรับเครื่องมือ 5 รายการจากแบบฟอร์มเดียว [เปิดตัวสร้าง AGENTS.md →](https://dotsagent.io/th/instructions)

## ไฟล์คำสั่งอื่น ๆ

[AGENTS.md](https://dotsagent.io/th/instructions/files/agents-md)

[CLAUDE.md](https://dotsagent.io/th/instructions/files/claude-md)

[GEMINI.md](https://dotsagent.io/th/instructions/files/gemini-md)

[.github/copilot-instructions.md](https://dotsagent.io/th/instructions/files/github-copilot-instructions)

[.devin/rules/*.md](https://dotsagent.io/th/instructions/files/windsurf-rules)

[.clinerules/](https://dotsagent.io/th/instructions/files/cline-rules)

[~/.openclaw/workspace/AGENTS.md](https://dotsagent.io/th/instructions/files/openclaw-workspace)

## แหล่งข้อมูล

1. [cursor.com](https://cursor.com/docs/context/rules)/docs/context/rules

แหล่งอ้างอิงอิสระสำหรับผู้สร้าง AI agent ไม่มีส่วนเกี่ยวข้องกับผู้ให้บริการที่กล่าวถึง

© 2026 DotsAgent · ตรวจสอบข้อมูลเมื่อ 1 ตุลาคม 2569
