client-side-routing
できること
このスキルは、共有のシェルをマウントしたまま、Agent-Nativeのアプリにページを追加する方法を説明します。シェルにはエージェントのサイドバーとナビゲーションが含まれます。これらのReactアプリにルートを追加する開発者向けです。
使う場面
- ✓Agent-Nativeのアプリに新しいページを追加するとき。
- ✓ユーザーがページを変えるたびに、エージェントのサイドバーが読み込み直されるとき。
- ✓ルートのレイアウトと、パスのないレイアウトのルートのどちらを選ぶか決める必要があるとき。
スキルのリンク
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/client-side-routing/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“新しいレポートのページを、移動してもエージェントのサイドバーが再読み込みされないように、アプリに追加してもらえますか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、共有のシェルをページの出口の上に一度だけマウントします。一部のページが公開で、ほかが非公開の場合は、パスのないレイアウトのルートを使います。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Client-Side Routing
Rule
All templates are single-page apps using React Router. Navigation must not remount the app shell. The agent sidebar, document tree, and any other persistent chrome must survive route changes.
Why
If the shell unmounts on every navigation, the agent chat reconnects/reloads, destroying in-progress work and hammering the backend.
Hard Rule
The app shell (AgentSidebar + any top-level navigation) must be mounted ONCE, above the <Outlet />. Never wrap each page in its own <AppLayout> / <Layout>. React sees a different component at the outlet position on each nav and unmounts the entire subtree.
Two Correct Patterns
1. All routes need the shell
Mount <AppLayout> in root.tsx around <Outlet />:
// app/root.tsx
<AppLayout>
<Outlet />
</AppLayout>
2. Mix of protected and public routes
Use a React Router pathless layout route:
app/routes/
_app.tsx # renders <AppLayout><Outlet /></AppLayout>
_app._index.tsx # / → under AppLayout
_app.settings.tsx # /settings → under AppLayout
_app.team.tsx # /team → under AppLayout
book.$slug.tsx # /book/:slug → no layout (public)
f.$.tsx # /f/* → no layout (public form filler)
The _ prefix on _app.tsx makes it a pathless parent — it contributes the layout but no URL segment. Route files prefixed with _app. nest under it and share the layout instance across navigations.
Anti-Pattern
// ❌ BAD — each route wraps its own Layout, causing full remount on every nav
export default function Settings() {
return (
<AppLayout>
<SettingsContent />
</AppLayout>
);
}
If a page needs per-route data (e.g. sidebar highlighting the active document), derive it inside the layout from useParams() / useLocation() — don't pass it as a prop through every route file.
Chat-First Routes
If / is a full-page chat such as AgentChatHome, keep the app shell mounted
around it when possible so AgentSidebar URL sync and route warmup stay active.
If the chat route intentionally lives outside the shell, add a tiny app-owned
prewarm for the routes agents commonly open from that chat. In local dev,
React Router can update the address bar before a cold Vite route chunk commits,
which makes navigation look broken even when the URL is correct.
Adding a New Route
- Pattern #1 (AppLayout in
root.tsx): just render page content — nothing else. - Pattern #2 (pathless
_app.tsx): name the file_app.<segment>.tsxfor authed routes, or bare<segment>.tsxfor public routes.
Related Skills
adding-a-feature— The four-area checklist referencing route layout patternscontext-awareness— Navigation state written on every route change
よくある質問
エージェントのサイドバーが再読み込みされるのはなぜですか?
各ページが独自のレイアウトで自分を包むと、ページの移動でシェルが再マウントされるのが一般的な原因です。
パスのないレイアウトのルートとは何ですか?
Webのアドレスに部分を追加せずにレイアウトを追加する、親のルートです。
どのフレームワークを使っていますか?
アプリはシングルページアプリとしてReact Routerを使うとスキルは述べています。
詳細
作者による元の説明
How to add routes without remounting the app shell. Use when adding a new route, fixing agent sidebar reloads on navigation, or choosing between `root.tsx` layout and pathless `_app.tsx` layout patterns.
repo: BuilderIO/agent-native
人気
- GitHubのスター
- 7.6k
- ランキング
- #13146
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
design-exploration
7.6kUIの複数のデザインの方向性を並べて検討し、1つを選んでもらい、選んだデザインを磨き上げるようエージェントを支援します。
visual-edit
7.6k実行中のローカルのアプリをビジュアルエディターで開き、本物の画面をまとめて確認し編集できるようエージェントを支援します。
turn-into-app
7.6kワークフロー、スプレッドシート、プロジェクトを、画面にデータが入り、操作の裏でエージェントが働く、洗練されたビジュアルアプリに変えます。
visual-plan
7.6kプレーンテキストの計画を、図、ファイルのマップ、コードの断片、未解決の質問を含む、対話できるビジュアルな計画に変えます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。