Home›Editor›Cursor と Claude Code のルールを symlink で共有してはいけない — 生成して同期する

Cursor と Claude Code のルールを symlink で共有してはいけない — 生成して同期するSharing rule files between Cursor and Claude Code via symlinks causes…

元記事を読むRead original articleqiita.com(新しいタブで開きます)(opens in a new tab)
AI2 点サマリSummary highlight
  • symlink でルールファイルを共有すると両ツールの挙動が壊れるため、スクリプトでルールを生成・同期する方法を提案している。
  • ツール間の設定管理を安全に行うための実践的な知見。

Sharing rule files between Cursor and Claude Code via symlinks causes unexpected breakage; this article proposes generating and syncing rules with a script instead, offering a safer configuration management approach.

本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (qiita.com) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (qiita.com).

要約と収集メタデータに基づく AI 解説。元記事全文の転載・翻訳ではありません。AI explainer based on the summaries and collected metadata, not a copy or translation of the full source article.

ルール共有

CursorとClaude Codeを同じrepoで併用する場合、プロジェクトルールをsymlinkで共有すると、見かけ上は似ている両者の形式差によって挙動が静かに壊れる。安全に管理するには、1つのsource of truthから各ツール向けのファイルを生成し、同期する方法が提案されている。

2つの形式

どちらも、YAML frontmatter付きmarkdownをプロジェクト内のディレクトリに置き、永続的な指示を常時、またはファイルパスに応じてAIへ読み込ませる形式を採る。Cursorでは.cursor/rules/*.mdcを使用し、globsでextensions/app/**/*.{ts,tsx,js}のように適用範囲を指定できる。ルールの種別は、3つのフィールドの組み合わせで決まる。

Claude Codeでは.claude/rules/*.mdを使用する。pathsのリストを持つルールは、マッチするファイルを読んだときだけロードされる。pathsを持たないルールは毎セッション常時ロードされ、.claude/CLAUDE.mdと同じ優先度になる。Cursorにある、descriptionからagentが判断するモードに相当する仕組みはない。

symlinkの問題

.claude/rulesを.cursor/rulesへsymlinkで結び、1つの物理ディレクトリを両ツールから参照させても共有は成立しない。まず拡張子の扱いが異なるためだ。Cursorのルールローダーは.mdcだけを読み、通常の.mdは無視する。一方、Claude Codeは.mdを探し、.mdcを無視する。

生成と同期

同一ファイル群をそのまま参照させるのではなく、共通のsource of truthを用意し、小さなスクリプトでCursor用とClaude Code用の両形式を生成・同期する。これにより、拡張子やルールモデルの違いを保ったまま、指示内容を一元管理できる。

Cursor and Claude Code

Cursor and Claude Code each support project rule files when used in the same repository. These files hold persistent instructions in Markdown and can be loaded either continuously or according to file paths, making their compatibility important when maintaining instructions for both tools.

Although their rule systems initially appear compatible, their formats differ in ways that can cause silent breakage. Sharing one physical rules directory through a symlink therefore does not provide a reliable common configuration.

YAML frontmatter

Both systems place Markdown files with YAML frontmatter in project directories. Rules can apply continuously or be scoped with glob patterns, but the tools represent and interpret that behavior differently.

Cursor reads rules from .cursor/rules/*.mdc. A rule can use a globs value such as extensions/app/**/*.{ts,tsx,js}, and Cursor determines the rule’s type through a combination of three fields. It also has a mode in which the agent makes a decision based on the description.

Claude Code reads rules from .claude/rules/*.md. Its model is simpler: a rule containing a paths list is loaded only when a matching file is read. A rule without paths is loaded during every session, with the same priority as .claude/CLAUDE.md. Claude Code has no equivalent to Cursor’s description-based agent decision mode.

Symlinks cause breakage

A setup such as linking .cursor/rules to .claude/rules may seem to let both tools use one directory. However, the arrangement breaks along independent compatibility axes.

One explicit incompatibility is the filename extension. Cursor’s rule loader reads only .mdc files and ignores ordinary .md files. Claude Code looks for .md files and ignores .mdc files. Consequently, a shared directory cannot make one unchanged set of files visible to both rule loaders.

Generate and sync

The proposed alternative is to maintain one source of truth and use a small script to generate both required formats. The generated rules can then be synchronized into the directories and extensions expected by each tool.

This approach avoids relying on superficial similarities between the two rule systems. It preserves separate Cursor and Claude Code outputs while allowing their shared instructions to be managed from one source.

ポコとTECHガイドPoko & TECH Guide

ポコと当サイトのTECHガイドが、記事の要約と収集した情報から読みどころを語るAI生成の対話です。Poko and TECH Dashboard's own TECH Guide discuss the article's highlights in an AI-generated conversation based on its summary and collected source details.

  1. ポコPoko同じrepoでCursorとClaude Codeを使う仕事だと、普段のルール管理は何が変わるの? symlinkでつなげば終わりじゃないのかな。When using Cursor and Claude Code in the same repo, what changes in everyday rule management? Can’t we just connect them with a symlink?
  2. TECHガイドTECH Guidesymlink共有ではなく、1つの元データから各形式のルールをスクリプトで生成・同期する形になるよ。挙動が壊れるのを避ける提案なんだ。The proposed approach is to generate and sync each tool’s rule format from one source using a script, rather than sharing files through a symlink. That avoids the unexpected breakage described.
  3. ポコPoko前はできなかったの? 見た目が似ているなら、そのまま共有できそうに思えるけど。Was that not possible before? If the formats look similar, I’d expect direct sharing to work.
  4. TECHガイドTECH Guide実は形式が少し違うんだ。Cursorは.mdcだけを読み、Claude Codeは.mdを探すので、symlinkで同じ場所を見せても互いのファイルを無視するよ。The formats differ in small but important ways. Cursor reads only .mdc files, while Claude Code looks for .md, so each ignores the other format even through a shared symlink.
  5. ポコPokoなるほど。1か所で管理しつつ、同じファイルを無理に共有せず、それぞれ向けに生成するのが収穫なんだね。Got it. The key is to manage rules from one place without forcing both tools to share the exact same files, then generate the right version for each.
  6. TECHガイドTECH Guideそうだね。次は、常時適用とファイル範囲の指定が、生成後の各形式で正しく表現されるかに注目したいね。Exactly. Next, watch whether always-on rules and file-scoped rules are represented correctly in each generated format.
記事情報・収集記録Article details & collection record
出典Source
Qiita CursorコミュニティCommunity
公開日時 (JST)Published (JST)
収集日時 (JST)Collected (JST)
配信形式Format
ブログBlog
原文言語Source language
JA
重要度の位置づけImportance in this lane
MediumMedium priority(Editor 201件中、同等以上 158件)(158 of 201 Editor entries are equal or higher)
出典の平均重要度(掲載直近 30 件・最大 30 件)Source average (last 30 listed, up to 30)
2.1 / 31=情報 · 2=中 · 3=高1=Info · 2=Medium · 3=High
情報の寿命Half-life
中期 (チュートリアル)Medium-term (tutorial)

🖱️Editor の他の記事More from Editorもっと見る →View more →

ページ上部へScroll to top