jpskill.com
💬 コミュニケーション コミュニティ 🟡 少し慣れが必要 👤 幅広いユーザー

💬 SPA Routes

spa-routes

シングルページアプリケーションのルーティング設定やUIロジックの移動時に、関連ファイルの整合性を保ちながら効率的に変更するSkill。

⏱ クレーム返信ドラフト 15分 → 2分

📺 まず動画で見る(YouTube)

▶ 【最新版】Claude(クロード)完全解説!20以上の便利機能をこの動画1本で全て解説 ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

MUST use when editing src/routes/ segments, src/spa/router/desktopRouter.config.tsx or desktopRouter.config.desktop.tsx (always change both together), mobileRouter.config.tsx, or when moving UI/logic between routes and src/features/.

🇯🇵 日本人クリエイター向け解説

一言でいうと

シングルページアプリケーションのルーティング設定やUIロジックの移動時に、関連ファイルの整合性を保ちながら効率的に変更するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o spa-routes.zip https://jpskill.com/download/1291.zip && unzip -o spa-routes.zip && rm spa-routes.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/1291.zip -OutFile "$d\spa-routes.zip"; Expand-Archive "$d\spa-routes.zip" -DestinationPath $d -Force; ri "$d\spa-routes.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して spa-routes.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → spa-routes フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

💬 こう話しかけるだけ — サンプルプロンプト

  • Spa Routes の使い方を教えて
  • Spa Routes で何ができるか具体例で見せて
  • Spa Routes を初めて使う人向けにステップを案内して

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

[Skill 名] spa-routes

SPA ルートと機能ガイド

SPA の構造:

  • src/spa/ – エントリポイント (entry.web.tsxentry.mobile.tsxentry.desktop.tsx) とルーター設定 (router/)。src/routes/ との混同を避けるため、ルーターはここに配置されます。
  • src/routes/ – ページセグメントのみ (ルート)。
  • src/features/ – ドメインごとのビジネスロジックと UI。

このプロジェクトでは、ルートと機能の分割を使用しています。src/routes/ にはページセグメントのみが保持され、ビジネスロジックと UI はドメインごとに src/features/ に配置されます。

エージェントの制約 — デスクトップルーターのパリティ: デスクトップルートツリーへの編集は、両方の src/spa/router/desktopRouter.config.tsxsrc/spa/router/desktopRouter.config.desktop.tsx を同じ変更 (同じパス、ネスト、インデックスルート、セグメント登録) で更新する必要があります。一方のみを更新するとずれが生じ、欠落したツリーはルートの登録に失敗し、影響を受けるビルドで空白の画面やナビゲーションの破損として現れる可能性があります。

このスキルを使用するタイミング

  • 新しい SPA ルートまたはルートセグメントを追加する場合
  • src/routes/ 配下のレイアウト/ページファイルを定義またはリファクタリングする場合
  • ルート固有のコンポーネントまたはロジックを src/features/ に移動する場合
  • 新しいコンポーネントをどこに配置するかを決定する場合 (ルートフォルダ vs 機能フォルダ)

1. src/routes/ (ルート) に属するもの

各ルートディレクトリには、のみ以下が含まれるべきです。

ファイル / フォルダ 目的
_layout/index.tsx または layout.tsx このセグメントのレイアウト: <Outlet /> でラップし、オプションのシェル (例: サイドバー + メイン)。薄くあるべきです: @/features/* から再エクスポートまたは構成することを推奨します。
index.tsx または page.tsx このセグメントのページエントリ。機能からのみインポートしてレンダリングし、ビジネスロジックは含めません。
[param]/index.tsx (例: [id], [cronId]) 動的セグメントページ。同じルール: 薄く、機能に委譲します。

ルール: ルートファイルはインポートと構成のみを行うべきです。src/routes/ 内に新しい features/ フォルダや重いコンポーネントを作成しないでください。


2. src/features/ に属するもの

ここにドメイン指向の UI とロジックを配置します。

  • レイアウトの構成要素: サイドバー、ヘッダー、ボディパネル、ドロワー
  • そのドメインのフックとストアの使用
  • ドメイン固有のフォーム、リスト、モーダルなど

ドメイン (例: PagesHomeAgentPageEditor) ごとに整理し、ルートパスごとではありません。1つのルートが複数の機能を使用でき、1つの機能が複数のルートで使用できます。

各機能は以下を行うべきです。

  • src/features/<FeatureName>/ 配下に存在すること
  • index.ts または index.tsx を介して明確な公開 API をエクスポートすること
  • 必要に応じて内部インポートに @/features/<FeatureName>/... を使用すること

3. 新しい SPA ルートを追加する方法

  1. ルートグループを選択します

    • (main)/ – デスクトップメインアプリ
    • (mobile)/ – モバイル
    • (desktop)/ – Electron 固有
    • onboarding/share/ – 特殊なフロー
  2. src/routes/ 配下にセグメントファイルのみを作成します

    • 例: src/routes/(main)/my-feature/_layout/index.tsxsrc/routes/(main)/my-feature/index.tsx (およびオプションの [id]/index.tsx)。
  3. src/features/ でレイアウトとページコンテンツを実装します

    • ドメインを作成または再利用します (例: src/features/MyFeature/)。
    • レイアウト (サイドバー、ヘッダー、ボディ) とページ UI をそこに配置し、機能の index からエクスポートします。
  4. ルートファイルを薄く保ちます

    • レイアウト: export { default } from '@/features/MyFeature/MyLayout' またはいくつかの機能コンポーネントと <Outlet /> を構成します。
    • ページ: @/features/MyFeature (または特定のサブパス) からインポートしてレンダリングし、ルートファイルにビジネスロジックを含めません。
  5. ルートを登録します (デスクトップ — 常に2つのファイル)

    • desktopRouter.config.tsx: ルートモジュール (例: @/routes/(main)/my-feature) を指す dynamicElement / dynamicLayout を使用してセグメントを追加します。
    • desktopRouter.config.desktop.tsx: 同じ RouteObject の形状をミラーリングします: 同一の path / index / 親子構造。そのファイルですでに使用されている静的インポートと要素を使用します (隣接するルートを参照)。これらのファイルのいずれか一方のみに登録しないでください
    • モバイル専用フロー: 代わりに mobileRouter.config.tsx を使用します (ルートが実際に両方に存在しない限り、デスクトップペアに複製する必要はありません)。

3a. デスクトップルーターペア (desktopRouter.config × 2)

ファイル 役割
desktopRouter.config.tsx dynamicElement / dynamicLayout を介した動的インポート — コード分割; entry.web.tsxentry.desktop.tsx で使用されます。
desktopRouter.config.desktop.tsx 同期インポートを持つ同じルートツリー — Electron / ローカルのパリティと予測可能なバンドルを維持するために保持されます。

ツリーを変更するものはすべて (新しいセグメント、path の名前変更、レイアウトの移動、新しい子ルート)、1つの PR またはコミットで両方のファイルに反映される必要があります。削除するときは両方からルートを削除してください。


4. ファイルの分割方法 (ルート vs 機能)

質問 src/routes/ に配置 src/features/ に配置
ルートのレイアウトラッパーまたはページエントリですか? はい – _layout/index.tsxindex.tsx[id]/index.tsx いいえ

(原文がここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

SPA Routes and Features Guide

SPA structure:

  • src/spa/ – Entry points (entry.web.tsx, entry.mobile.tsx, entry.desktop.tsx) and router config (router/). Router lives here to avoid confusion with src/routes/.
  • src/routes/ – Page segments only (roots).
  • src/features/ – Business logic and UI by domain.

This project uses a roots vs features split: src/routes/ only holds page segments; business logic and UI live in src/features/ by domain.

Agent constraint — desktop router parity: Edits to the desktop route tree must update both src/spa/router/desktopRouter.config.tsx and src/spa/router/desktopRouter.config.desktop.tsx in the same change (same paths, nesting, index routes, and segment registration). Updating only one causes drift; the missing tree can fail to register routes and surface as a blank screen or broken navigation on the affected build.

When to Use This Skill

  • Adding a new SPA route or route segment
  • Defining or refactoring layout/page files under src/routes/
  • Moving route-specific components or logic into src/features/
  • Deciding where to put a new component (route folder vs feature folder)

1. What Belongs in src/routes/ (roots)

Each route directory should contain only:

File / folder Purpose
_layout/index.tsx or layout.tsx Layout for this segment: wrap with <Outlet />, optional shell (e.g. sidebar + main). Should be thin: prefer re-exporting or composing from @/features/*.
index.tsx or page.tsx Page entry for this segment. Only import from features and render; no business logic.
[param]/index.tsx (e.g. [id], [cronId]) Dynamic segment page. Same rule: thin, delegate to features.

Rule: Route files should only import and compose. No new features/ folders or heavy components inside src/routes/.


2. What Belongs in src/features/

Put domain-oriented UI and logic here:

  • Layout building blocks: sidebars, headers, body panels, drawers
  • Hooks and store usage for that domain
  • Domain-specific forms, lists, modals, etc.

Organize by domain (e.g. Pages, Home, Agent, PageEditor), not by route path. One route can use several features; one feature can be used by several routes.

Each feature should:

  • Live under src/features/<FeatureName>/
  • Export a clear public API via index.ts or index.tsx
  • Use @/features/<FeatureName>/... for internal imports when needed

3. How to Add a New SPA Route

  1. Choose the route group

    • (main)/ – desktop main app
    • (mobile)/ – mobile
    • (desktop)/ – Electron-specific
    • onboarding/, share/ – special flows
  2. Create only segment files under src/routes/

    • e.g. src/routes/(main)/my-feature/_layout/index.tsx and src/routes/(main)/my-feature/index.tsx (and optional [id]/index.tsx).
  3. Implement layout and page content in src/features/

    • Create or reuse a domain (e.g. src/features/MyFeature/).
    • Put layout (sidebar, header, body) and page UI there; export from the feature’s index.
  4. Keep route files thin

    • Layout: export { default } from '@/features/MyFeature/MyLayout' or compose a few feature components + <Outlet />.
    • Page: import from @/features/MyFeature (or a specific subpath) and render; no business logic in the route file.
  5. Register the route (desktop — two files, always)

    • desktopRouter.config.tsx: Add the segment with dynamicElement / dynamicLayout pointing at route modules (e.g. @/routes/(main)/my-feature).
    • desktopRouter.config.desktop.tsx: Mirror the same RouteObject shape: identical path / index / parent-child structure. Use the static imports and elements already used in that file (see neighboring routes). Do not register in only one of these files.
    • Mobile-only flows: use mobileRouter.config.tsx instead (no need to duplicate into the desktop pair unless the route truly exists on both).

3a. Desktop router pair (desktopRouter.config × 2)

File Role
desktopRouter.config.tsx Dynamic imports via dynamicElement / dynamicLayout — code-splitting; used by entry.web.tsx and entry.desktop.tsx.
desktopRouter.config.desktop.tsx Same route tree with synchronous imports — kept for Electron / local parity and predictable bundling.

Anything that changes the tree (new segment, renamed path, moved layout, new child route) must be reflected in both files in one PR or commit. Remove routes from both when deleting.


4. How to Divide Files (route vs feature)

Question Put in src/routes/ Put in src/features/
Is it the route’s layout wrapper or page entry? Yes – _layout/index.tsx, index.tsx, [id]/index.tsx No
Does it contain business logic or non-trivial UI? No Yes – under the right domain
Is it a reusable layout piece (sidebar, header, body)? No Yes
Is it a hook, store usage, or domain logic? No Yes
Is it only re-exporting or composing feature components? Yes No

Examples

  • Route (thin):\ src/routes/(main)/page/_layout/index.tsxexport { default } from '@/features/Pages/PageLayout'
  • Feature (real implementation):\ src/features/Pages/PageLayout/ → Sidebar, DataSync, Body, Header, styles, etc.
  • Route (thin):\ src/routes/(main)/page/index.tsx → Import PageTitle, PageExplorerPlaceholder from @/features/Pages and @/features/PageExplorer; render with <PageTitle /> and placeholder.
  • Feature:\ Page list, actions, drawers, and hooks live under src/features/Pages/.

5. Progressive Migration (existing code)

We are migrating existing routes to this structure step by step:

  • Phase 1 (done): /page route – segment files in src/routes/(main)/page/, implementation in src/features/Pages/.
  • Later phases: home, settings, agent/group, community/resource/memory, mobile/share/onboarding.

When touching an old route that still has logic or features/ inside src/routes/:

  1. Prefer adding new code in src/features/<Domain>/ and importing from routes.
  2. For larger refactors, move existing route-only logic into the right feature and then thin out the route files (re-export or compose from features).
  3. Use git mv when moving files so history is preserved.

6. Reference Structure (after Phase 1)

Route (thin):

src/routes/(main)/page/
├── _layout/index.tsx   → re-export or compose from @/features/Pages/PageLayout
├── index.tsx          → import from @/features/Pages, @/features/PageExplorer
└── [id]/index.tsx     → import from @/features/Pages, @/features/PageExplorer

Feature (implementation):

src/features/Pages/
├── index.ts            → export PageLayout, PageTitle
├── PageTitle.tsx
└── PageLayout/
    ├── index.tsx       → Sidebar + Outlet + DataSync
    ├── DataSync.tsx
    ├── Sidebar.tsx
    ├── style.ts
    ├── Body/           → list, actions, drawer, etc.
    └── Header/         → breadcrumb, add button, etc.

Router config continues to point at route paths (e.g. @/routes/(main)/page, @/routes/(main)/page/_layout); route files then delegate to features.