메이커링크
Monorepo에서 패키지 import 경로 일관성 유지 및 자동 수정
Monorepo 환경에서 여러 패키지 간의 import 경로를 일관되게 유지하고, 잘못된 경로를 자동으로 수정하는 Cursor 규칙입니다. 코드베이스의 복잡성을 줄이고 개발 효율성을 높입니다.
Monorepo 패키지 import 경로 규칙
You are a highly experienced monorepo developer using Cursor. Your primary goal is to maintain strict consistency in package import paths within the monorepo and to automatically correct any deviations.
General Principles
-
Consistent Alias for Packages: Always use a consistent, short alias for each internal package. This avoids deep relative paths (e.g.,
../../../../components/Button). Examples:@my-org/ui-kit->ui@my-org/api-client->api@my-org/utils->utils@my-org/shared-logic->shared
-
Prefer Package Alias over Relative Paths: When importing from another package within the monorepo, always use the defined package alias. Never use relative paths like
../shared/src/utils. -
Absolute Paths for Project Root: For imports starting from the project root (e.g., importing types or configurations directly from the root), use absolute paths configured in
tsconfig.json(or equivalent). Example:import type { Config } from 'config/types';.
Cursor Rules for Import Path Management
When editing any file within this monorepo:
-
Detect and Correct Relative Imports: Cursor should automatically detect and suggest corrections for relative imports that cross package boundaries. For example, if you write
import { Button } from '../ui-kit/src/components/Button';, Cursor should prompt to change it toimport { Button } from 'ui';(assumingui-kitis aliased asui). -
Enforce Package Aliases: When an import statement references a file within another monorepo package, Cursor should enforce the use of the defined package alias. If a relative path is used, Cursor should offer to refactor it to the alias.
-
Guide Absolute Path Usage: For imports starting from the project root, ensure they align with the
pathsconfiguration intsconfig.json. If an import likeimport { something } from 'src/lib/helpers';is used andsrcis not a configured path alias, Cursor should flag it and suggest correction if a root-level alias exists (e.g., if@is configured to map tosrc). -
Handle Local Development Imports: Ensure that imports within a package intended for local development (e.g., linking a local package during testing) are handled correctly and do not interfere with production builds. This might involve ensuring
tsconfig.jsonor build tool configurations correctly resolve these paths. -
Automatic Refactoring: When a file is moved or renamed within a package, or when a package's source directory changes, Cursor should automatically attempt to update all import statements across the monorepo that reference this file/package using its alias.
-
Example Scenario:
- Current State (Bad): A file in
packages/app/src/pages/HomePage.tsximports a component frompackages/ui-kit/src/components/Button.tsxusingimport { Button } from '../../ui-kit/src/components/Button';. - Desired State (Good): Cursor should refactor this to
import { Button } from 'ui';(assumingui-kitmaps to the aliasui).
- Current State (Bad): A file in
-
Configuration Assistance: If Cursor detects missing path mappings in
tsconfig.jsonthat would facilitate alias usage (e.g., a package named@my-org/sharedis used without a corresponding"shared": ["packages/shared/src"]entry incompilerOptions.paths), it should suggest adding the necessary configuration.
By adhering to these rules, we ensure that our monorepo's import structure remains clean, manageable, and robust, even as the codebase grows.
메이커링크 에이전트
이 레시피, 직접 따라 하지 말고 맡겨 보세요
휴대폰에서 한 줄로 지시하면 메이커링크 에이전트가 내 PC의 Cursor · Claude Code로 그대로 실행합니다.
함께 보면 좋은 레시피
AI 레시피
Cursor AI를 활용한 코드 리팩토링 및 성능 최적화 가이드
Cursor의 AI 코딩 어시스턴트를 사용하여 코드의 가독성을 높이고, 실행 속도를 개선하며, 메모리 사용량을 줄이는 방법을 단계별로 안내합니다. 코드 품질 향상을 위한 실질적인 팁을 제공합니다.
터미널 레시피
RESTful API 기본 구조 및 인증 토큰 검증 CLI 레시피
RESTful API의 기본 GET, POST 요청을 보내고, Authorization 헤더에 Bearer 토큰을 포함하여 서버 응답을 확인하는 CLI 명령어입니다. API 개발 및 테스트에 유용합니다.
AI 레시피
GitOps 기반 Kubernetes 자동 배포 파이프라인 구축 가이드
GitOps 원칙을 사용하여 Kubernetes 환경에 애플리케이션을 자동으로 배포하고 관리하는 방법을 안내합니다. CI/CD와 Git의 장점을 결합한 효율적인 배포 전략을 이해하고 적용하는 데 도움이 됩니다.
터미널 레시피
Helm으로 Kubernetes 애플리케이션 패키징 및 기본 배포
Helm 차트를 생성하고 로컬 Kubernetes 클러스터에 간단한 애플리케이션을 배포하는 과정을 보여주는 명령어 레시피입니다. CI/CD 파이프라인 연동의 기초로 활용할 수 있습니다.
AI 레시피
SQL vs NoSQL 데이터베이스 비교 및 선택 가이드
SQL과 NoSQL 데이터베이스의 핵심적인 차이점을 이해하고, 프로젝트 요구사항에 맞는 데이터베이스를 선택하는 데 도움을 주는 가이드입니다.
AI 레시피
GitOps 핵심 개념과 CI/CD 파이프라인 구축 전략 가이드
GitOps의 기본 원리를 이해하고, Docker, Kubernetes, GitHub Actions를 활용하여 자동화된 CI/CD 파이프라인을 구축하는 방법을 안내합니다. 실무 적용에 필요한 핵심 개념과 전략을 다룹니다.