本文へ移動
cccskills
無料GitHub で公開

route-discovery-system

Filesystem auto-discovery of App Router pages into navigable index pages. Use when creating an index/listing page, adding route directories, converting hard-coded route configs to auto-discovery, or adding a route-listing display variant.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md6.1 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Route Discovery System

Filesystem-based route auto-discovery that replaces hard-coded config.ts route arrays. Server Components scan directories for page.tsx files and render grouped navigation UIs with switchable display variants.

Architecture

Server Component (RouteIndexPage)
  └─ scanRoutes() reads filesystem (server-only)
  └─ Serializes RouteDisplayData
  └─ Passes to RouteDisplaySwitcher (client)
       └─ next/dynamic loads active variant (ssr: false)
       └─ Dropdown switches between variants

Key boundary: utils/route-discovery/index.ts is server-only (filesystem access). utils/route-discovery/shared.ts has pure functions safe for client imports.

File Map

FileRole
utils/route-discovery/index.tsServer-only: scanRoutes, scanRoutesShallow
utils/route-discovery/shared.tsClient-safe: groupRoutes, getRouteLabel, toModulePages, sortGroupKeys
components/ssr/RouteIndexPage.tsxServer Component: scans filesystem, renders page shell, passes data to switcher
components/ssr/RouteHeaderData.tsxServer Component: auto-feeds ModuleHeader nav from filesystem
components/ssr/route-display/types.tsRouteDisplayData, RouteDisplayVariant, RouteDisplayProps
components/ssr/route-display/RouteDisplaySwitcher.tsxClient wrapper: variant dropdown + next/dynamic imports
components/ssr/route-display/GroupedCardsDisplay.tsxVariant: grouped folder cards (default)
components/ssr/route-display/DataTableDisplay.tsxVariant: searchable keyboard-navigable grid
components/ssr/route-display/ExpandableSectionsDisplay.tsxVariant: collapsible accordion sections
components/ssr/route-display/FlatListDisplay.tsxVariant: minimal filterable list

Usage: Index Page

Replace any hard-coded route listing with:

import { join } from "path";
import { RouteIndexPage } from "@/components/ssr/RouteIndexPage";

export default async function MyPage() {
  return (
    <RouteIndexPage
      directory={join(process.cwd(), "app", "(authenticated)", "my-feature")}
      basePath="/my-feature"
      title="My Feature"
    />
  );
}

Props

PropTypeDefaultDescription
directorystringrequiredAbsolute path to scan
basePathstringrequiredURL prefix for links
titlestring—Page heading
descriptionstringauto-generatedSubtitle text
iconComponentTypeLayoutGridLucide icon for heading
shallowbooleanfalseScan one level only
defaultVariantRouteDisplayVariant"grouped-cards"Initial display variant
childrenReactNode—Custom content above the grid

Usage: Layout with Auto-Header

Replace config.ts + ModuleHeader patterns:

import { join } from "path";
import { RouteHeaderData } from "@/components/ssr/RouteHeaderData";

export default function Layout({ children }: { children: React.ReactNode }) {
  return (
    <RouteHeaderData
      directory={join(process.cwd(), "app", "(authenticated)", "tests", "forms")}
      moduleHome="/tests/forms"
      moduleName="Forms"
    >
      {children}
    </RouteHeaderData>
  );
}

Adding a New Display Variant

  1. Create components/ssr/route-display/MyNewDisplay.tsx:
"use client";
import type { RouteDisplayProps } from "./types";

export default function MyNewDisplay({ data }: RouteDisplayProps) {
  const { routes, groups, sortedGroupKeys, basePath, hasGroups } = data;
  // Render using data — import from shared.ts, NOT from index.ts
  // Use Link from "next/link" for navigation
}
  1. Add the variant key to types.ts:
export type RouteDisplayVariant =
  | "grouped-cards"
  | "data-table"
  | "expandable-sections"
  | "flat-list"
  | "my-new-variant";
  1. Add the label to VARIANT_LABELS in types.ts.

  2. Register in RouteDisplaySwitcher.tsx:

"my-new-variant": dynamic(() => import("./MyNewDisplay"), { ssr: false }),

Scanner Behavior

  • Recursively walks directories looking for page.tsx files
  • Skips: _prefixed directories, [dynamic] route segments
  • Groups routes by top-level directory segment
  • scanRoutesShallow only checks immediate children (no recursion)

Converting Existing Routes

When converting a directory from hard-coded config.ts to auto-discovery:

  1. Replace page.tsx with RouteIndexPage usage
  2. Replace layout.tsx with RouteHeaderData (if it imported from config.ts)
  3. Delete config.ts
  4. Keep EntityPack wrappers and export const dynamic = 'force-dynamic' if present
  5. Never touch functional leaf pages — only replace listing/index pages

Favicon Integration

RouteIndexPage automatically resolves the favicon for the basePath and threads it into the display:

  • The favicon badge renders next to the page <h1> title (replaces the Lucide icon when a favicon exists)
  • GroupedCardsDisplay uses the favicon color as a left-border accent on each group card
  • Flat list entries show the favicon badge instead of a plain dot

No extra code needed — just pass the correct basePath and the system picks up the config from navigation-links.tsx or the system-route overrides (/demo, /tests, /administration).

To understand how favicons are registered and what colors/letters are already in use, see .claude/skills/route-metadata-favicons/SKILL.md.


Pages NOT Using This System

These have custom logic and intentionally remain hand-maintained:

  • administration/page.tsx — curated category dashboard (has /administration/all-routes companion)
  • dashboard/page.tsx — iOS-style icon grid
  • tests/links/ and tests/windows/ — master cross-directory index lists
  • demos/local-tools/page.tsx, demos/scraper/page.tsx — custom functional UIs

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Admin debug system wiring for the floating AdminIndicator's live debug data and Copy Full Context. Use when adding debug visibility to a route or feature, wiring useDebugContext or the debug panel, capturing console errors, or enabling the copy-context workflow for a page.

日本語の概要は準備中です。原文の説明を表示しています。

armanisadeghi/ai-matrx32026年10月13日 更新

Compact two-icon Copy / Copy-for-AI controls (components/agent-copy). Use when adding copy buttons to a row, card, list, or record; merging duplicate Copy/JSON/AI controls; continuing the copy rollout; or writing a Copy-for-AI payload. NOT for markdown content actions (use rich-document-actions).

日本語の概要は準備中です。原文の説明を表示しています。

armanisadeghi/ai-matrx32026年10月13日 更新

Disclosing a surface's existing fixed AI jobs in the shell's top Agents menu. Use when a page, panel, overlay, or window already runs a mandate behind a button, assist, automatic action, or mode; when the agent-disclosure guard names a file; or during a surface check.

日本語の概要は準備中です。原文の説明を表示しています。

armanisadeghi/ai-matrx32026年10月13日 更新

The watch-fix-rerun method for making an existing platform agent or automated process efficient and correct: baseline its ledger, run one unit yourself, fix the class behind every wasted call, rerun, record. Use when asked to improve, optimize, watch, or 'make efficient' an agent, a sandbox session, a sync job, or any recurring automated process.

日本語の概要は準備中です。原文の説明を表示しています。

armanisadeghi/ai-matrx32026年10月13日 更新

Redux state for agent execution and firing agent shortcuts. Use when editing features/agents/redux/, building agent UI, creating a conversation, touching assembleRequest or NDJSON stream state, wiring agent-state selectors, adding a per-conversation capability, or triggering a shortcut from a button, menu, or code (useShortcutTrigger, launchAgentExecution).

日本語の概要は準備中です。原文の説明を表示しています。

armanisadeghi/ai-matrx32026年10月13日 更新

The provision for a call site: the exhaustive menu of values that place in the code can realistically produce. Use before creating or fixing a mandate or agent that reasons about more than its own input, when deciding whether an agent can answer at all with what it is sent, or when its output 'looks right' but nobody checked it could be. NOT for building the agent (use create-agent).

日本語の概要は準備中です。原文の説明を表示しています。

armanisadeghi/ai-matrx32026年10月13日 更新

armanisadeghi のスキルをすべて見る

このスキルの問題を報告する