2026年版: Next.jsエージェント開発でルールファイルを書く実践ガイド — Cursor Blog | Neura Market
    Neura MarketNeura Market/Cursor
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsBlogVideosGuidesCoursesCommunityExtensionsTrendingGenerate
    CursorBlog2026年版: Next.jsエージェント開発でルールファイルを書く実践ガイド
    Back to Blog
    2026年版: Next.jsエージェント開発でルールファイルを書く実践ガイド
    ai

    2026年版: Next.jsエージェント開発でルールファイルを書く実践ガイド

    スシロー June 19, 2026
    0 views

    なぜルールファイルがAIエージェントに効くのか Claude CodeやCursor、OpenAI...

    ## なぜルールファイルがAIエージェントに効くのか Claude CodeやCursor、OpenAI Agentsなどのコーディングエージェントは、プロジェクトルートに置かれた`CLAUDE.md`・`.cursorrules`・`AGENTS.md`を会話コンテキストの先頭に自動注入する。つまり「毎回口頭で言わなければならなかった制約」を一度書くだけで全セッションに効かせられる。 Next.js App Router × TypeScript プロジェクトでは特に次の問題が頻出する。 - `pages/` ディレクトリに新規ルートを作ろうとする(旧Router混入) - `'use client'` を付け忘れてサーバーコンポーネントからフックを呼ぶ - `fetch` をクライアントコンポーネントで直書きし、キャッシュ戦略が消える - `any` 型を多用して型安全が崩壊する これらはすべてルールファイルに書けば防ぎやすくなる。「防ぎやすくなる」であって、完全に防止できると保証するものではない点は留意してほしい。 ## 実例: CLAUDE.md の書き方 ファイル名は `CLAUDE.md`(Claude Code用)と `.cursorrules`(Cursor用)で微妙に読まれ方が異なるが、内容は共通化できる。以下は実際に使っている最小構成だ。 ```markdown # Project Rules ## Stack - Next.js 15 App Router (TypeScript strict) - Runtime: Node.js 20 LTS - Styling: Tailwind CSS v4 - State: React Server Components first, Zustand only for client state ## Directory Conventions - Route segments: `app/` only. `pages/` は作らない - Server Components are the default. Add `'use client'` only when hooks or browser APIs are needed - Data fetching: `fetch` in Server Components with explicit `cache` option (`force-cache` or `no-store`) - API Routes: `app/api/**/route.ts` のみ ## TypeScript - `any` 禁止。型が不明なら `unknown` + 型ガードを使う - Zod でバリデーションし、型推論を `z.infer<>` で引き出す ## File Generation Rules - Component: PascalCase、`*.tsx` - Utility: camelCase、`*.ts` - テストは `__tests__/` または `*.test.ts` に配置 ## What NOT to Do - `useEffect` でデータフェッチしない(Server Componentで完結させる) - `export default` の無名関数禁止(デバッグ困難になるため) - console.log をコミットしない ``` このファイルをプロジェクトルートに置くだけで、エージェントは App Router の慣習を踏まえたコードを生成しやすくなる。 ## AGENTS.md との使い分け `AGENTS.md` は OpenAI の Codex / Agents API が読む仕様として提唱された。Claude Code は `CLAUDE.md` を優先するが、両方置いてもほぼ問題ない。内容を共通にしてシンボリックリンクで管理するか、以下のようにリダイレクトコメントを書くだけで十分だ。 ```markdown # AGENTS.md <!-- See CLAUDE.md for the canonical rules --> ``` プロジェクトが複数エージェントを横断する場合は、`CLAUDE.md`(Claude Code)・`.cursorrules`(Cursor)・`AGENTS.md`(OpenAI系)の3ファイルを同じ内容で保つ運用がシンプルだ。 ## 運用Tips **サブディレクトリにも置ける** `app/api/CLAUDE.md` を作ると、APIルート専用の追加ルール(認証必須・レートリミット実装パターンなど)をスコープして書ける。上位ファイルと合算されて読まれる。 **ルールは増やしすぎない** 行数が増えるほどエージェントのコンテキスト消費が増え、肝心なルールが薄まる。「違反が実際に起きたもの」だけを追記する運用が長持ちする。 **変更履歴をコミットに残す** ルールファイルの変更は `git blame` で追えるようにしておくと、「なぜこのルールがあるか」が後から分かる。コメントで理由を書くより git log の方が腐りにくい。 **効果測定は現実的に** ルールファイルはエージェントへのヒントであり、必ず従うことを強制するものではない。レビューフローと組み合わせて初めて品質ゲートとして機能する。CI で `tsc --noEmit` と ESLint を通すことが最後の砦だ。 --- ### 5フレームワーク分の実例をまとめたキット Next.js/React/FastAPI/Godot/Express のルールファイル実例集を用意しました。[👉 詳細・入手はこちら](https://itsuya.gumroad.com/l/agentrules260619)

    Tags

    aiclaudecodecursornextjs

    Comments

    More Blog

    View all
    This week in Cursor + .NET — 7 rules (week ending June 21, 2026)csharp

    This week in Cursor + .NET — 7 rules (week ending June 21, 2026)

    A weekly digest from the Agentic Architect persistence kit: 7 senior C#/.NET rules for engineers keeping Cursor honest across sessions.

    A
    Agentic Architect
    How Graphify Stopped My Team from Burning Thousands of Tokens Per Queryai

    How Graphify Stopped My Team from Burning Thousands of Tokens Per Query

    We were feeding Cursor 12 files per question. Graphify turned our React Native codebase into a knowledge graph — now it reads a scoped subgraph instead.

    V
    Vikrant Negi
    The Twenty-Dollar Anchor: What the AI Tool Pricing Guides Are Actually Telling Usai

    The Twenty-Dollar Anchor: What the AI Tool Pricing Guides Are Actually Telling Us

    I went down a rabbit hole this morning reading the late-2025 Juejin AI tool pricing guides back to...

    N
    ninghonggang
    Why the December 2025 AI IDE Rankings Are Scoring the Wrong Categoryai

    Why the December 2025 AI IDE Rankings Are Scoring the Wrong Category

    I spent the morning reading two December 2025 Juejin AI IDE ranking posts back to back, and the thing...

    N
    ninghonggang
    SpaceX is buying Cursor for $60B — the AI coding-tool race just got weirdai

    SpaceX is buying Cursor for $60B — the AI coding-tool race just got weird

    SpaceX is reportedly buying Cursor parent Anysphere for $60B. For builders, the big questions are model neutrality, compute, pricing, and trust.

    D
    Damien Gallagher
    This Week in AI: Claude Goes Dark, SpaceX Buys Cursor for $60Bcursor

    This Week in AI: Claude Goes Dark, SpaceX Buys Cursor for $60B

    Claude Fable 5 went dark by government order, SpaceX bought Cursor for $60B, OpenAI's real losses leaked, and GitHub nearly broke under AI agents.

    Z
    ZyVOP

    Stay up to date

    Get the latest Cursor prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Cursor and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.