Cursor는 AI 기반 코드 에디터로서 개발자들에게 혁신적인 경험을 제공하고 있습니다. 그 중에서도 Rules 기능은 AI 모델의 동작을 제어하고 일관성 있는 개발 워크플로우를 구축하는 데 핵심적인 역할을 합니다. 특히 새롭게 도입된 MDC(Markdown Cursor) 포맷은 기존의 .cursorrules
파일보다 훨씬 강력하고 유연한 규칙 관리를 가능하게 합니다.
Cursor Rules가 무엇인가요?
Cursor Rules는 AI 모델(Agent 및 Cmd-K)에게 시스템 수준의 지침을 제공하는 기능입니다. 마치 AI에게 지속적인 컨텍스트와 선호사항, 워크플로우를 인코딩하는 방법이라고 생각하면 됩니다.
대형 언어 모델은 완료 간에 메모리를 유지하지 않기 때문에, Rules는 프롬프트 수준에서 지속적이고 재사용 가능한 컨텍스트를 제공하여 이러한 문제를 해결합니다.
3가지 유형의 Rules
Cursor는 세 가지 유형의 Rules를 지원합니다:
1. Project Rules
.cursor/rules
디렉토리에 저장- 버전 관리되며 코드베이스에 범위가 지정됨
- 도메인별 지식, 프로젝트별 워크플로우, 스타일 가이드 등에 활용
2. User Rules
- Cursor 설정에서 전역적으로 정의
- 모든 프로젝트에 적용
- 응답 언어, 톤, 개인 스타일 선호사항 설정
3. .cursorrules (Legacy)
- 여전히 지원되지만 곧 사용 중단 예정
- Project Rules로 마이그레이션 권장
MDC 포맷의 강력함
**MDC(.mdc)**는 메타데이터와 콘텐츠를 단일 파일로 지원하는 경량 포맷입니다. 다음과 같은 규칙 유형을 지원합니다:
규칙 유형 | 설명 |
---|---|
Always | 항상 모델 컨텍스트에 포함 |
Auto Attached | 글롭 패턴과 일치하는 파일 참조 시 포함 |
Agent Requested | AI가 필요하다고 판단할 때 포함 (설명 필수) |
Manual | @ruleName으로 명시적 언급 시에만 포함 |
MDC 규칙 예시
---
description: RPC Service boilerplate
globs: "**/*.service.ts"
alwaysApply: false
---
- Use our internal RPC pattern when defining services
- Always use snake_case for service names.
- Include proper error handling middleware
@service-template.ts
실제 활용 사례
1. 도메인 특화 가이드라인
프론트엔드 컴포넌트 표준
---
description: Frontend component standards
globs: "components/**/*"
alwaysApply: true
---
When working in the components directory:
- Always use Tailwind for styling
- Use Framer Motion for animations
- Follow our component naming conventions
API 검증 표준
---
description: API validation standards
globs: "api/**/*"
alwaysApply: true
---
In the API directory:
- Use zod for all validation
- Define return types with zod schemas
- Export types generated from schemas
2. 보일러플레이트와 템플릿
---
description: Express service template
globs: "services/**/*"
alwaysApply: false
---
Use this template when creating a new Express service:
- Follow RESTful principles
- Include error handling middleware
- Set up proper logging
@express-service-template.ts
3. 워크플로우 자동화
---
description: App analysis workflow
alwaysApply: false
---
When I ask to analyze the app:
1. Run the dev server with `npm run dev`
2. Fetch logs from the console
3. Suggest performance improvements
중첩 규칙으로 조직화하기
프로젝트 구조 전반에 걸쳐 .cursor/rules
디렉토리를 배치하여 규칙을 조직화할 수 있습니다:
project/
.cursor/rules/ # 프로젝트 전체 규칙
backend/
server/
.cursor/rules/ # 백엔드 특화 규칙
frontend/
.cursor/rules/ # 프론트엔드 특화 규칙
중첩 규칙의 장점:
- 해당 디렉토리의 파일이 참조될 때 자동으로 첨부
- 컨텍스트 선택기와 에이전트 접근 가능한 규칙 목록에서 여전히 사용 가능
- 모노레포나 구별되는 컴포넌트가 있는 프로젝트에 특히 유용
규칙 생성과 관리
규칙 생성 방법
- 명령어 사용:
Cmd + Shift + P
> “New Cursor Rule” - 설정에서:
Cursor Settings > Rules
- 대화에서 생성:
/Generate Cursor Rules
명령어 사용
규칙 생성 시 베스트 프랙티스
- 간결함 유지: 500줄 이하 권장
- 큰 개념은 분할: 여러 개의 조합 가능한 규칙으로 나누기
- 구체적인 예시 제공: 참조 파일이나 구체적인 예시 포함
- 모호한 지침 피하기: 명확한 내부 문서처럼 작성
- 반복 방지: 채팅에서 반복되는 프롬프트가 있다면 규칙으로 만들기
Cursor 팀의 실제 규칙 예시
Tailwind 사용 규칙
---
description: Tailwind usage in Cursor
alwaysApply: true
---
Tailwind is supported in this VS Code fork!
Usage examples:
- `text-error-foreground`
- `bg-input-border`
새 설정 추가 규칙
---
description: Adding new settings in Cursor
alwaysApply: false
---
First create a property to toggle in `@reactiveStorageTypes.ts`.
Add a default value for it in `INIT_APPLICATION_USER_PERSISTENT_STORAGE` in `@reactiveStorageService.tsx`.
If this is a beta feature, add a toggle in `@settingsBetaTab.tsx`, otherwise add it in `@settingsGeneralTab.tsx`.
User Rules 활용하기
User Rules는 모든 프로젝트에 적용되는 전역 설정으로, 다음과 같은 용도로 사용할 수 있습니다:
Please reply in a concise style. Avoid unnecessary repetition or filler language.
Always explain complex concepts with practical examples and analogies.
When writing code, prioritize readability and include helpful comments.
마이그레이션 가이드
기존 .cursorrules
파일을 사용 중이라면 다음과 같이 MDC 포맷으로 마이그레이션할 수 있습니다:
기존 .cursorrules:
Use TypeScript for all new files.
Follow our coding conventions.
Add proper error handling.
새로운 MDC 포맷:
---
description: TypeScript coding standards
alwaysApply: true
---
- Use TypeScript for all new files
- Follow our coding conventions
- Add proper error handling
문제 해결
규칙이 적용되지 않는 경우
- 규칙 유형 확인 (
Agent Requested
의 경우 설명 필수) Auto Attached
의 경우 파일 패턴이 참조 파일과 일치하는지 확인
규칙에서 다른 파일 참조
@filename.ts
형식으로 다른 파일을 규칙의 컨텍스트에 포함할 수 있습니다.
채팅에서 규칙 생성
AI에게 “이것을 규칙으로 만들어줘” 또는 “이 프롬프트로 재사용 가능한 규칙을 만들어줘”라고 요청할 수 있습니다.
결론
Cursor Rules와 MDC 포맷은 AI 기반 개발 환경에서 일관성과 효율성을 극대화하는 강력한 도구입니다. 프로젝트별 표준을 정의하고, 반복적인 워크플로우를 자동화하며, 팀 간의 개발 규칙을 공유하는 데 활용해보세요.
특히 MDC 포맷의 유연한 규칙 유형과 중첩 구조는 복잡한 프로젝트에서도 체계적인 규칙 관리를 가능하게 합니다. 기존의 .cursorrules
에서 벗어나 새로운 Project Rules로 마이그레이션하여 더욱 강력한 AI 개발 경험을 누려보시기 바랍니다.