add-protected-page
Creates a protected page with Suspense loading pattern. Use when adding new pages that require authentication, creating dashboard pages, or setting up new routes.
Best use case
add-protected-page is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Creates a protected page with Suspense loading pattern. Use when adding new pages that require authentication, creating dashboard pages, or setting up new routes.
Teams using add-protected-page should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/add-protected-page/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How add-protected-page Compares
| Feature / Agent | add-protected-page | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Creates a protected page with Suspense loading pattern. Use when adding new pages that require authentication, creating dashboard pages, or setting up new routes.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Add Protected Page
Creates a protected page following the Suspense loading pattern with Clerk authentication.
## Structure
For a new route `/my-feature`:
```
front/
├── app/my-feature/
│ ├── page.tsx # Auth only - wraps content in Suspense
│ └── loading.tsx # Automatic Suspense fallback
└── components/my-feature/
└── MyFeatureContent.tsx # Data fetching + UI
```
## Workflow
### 1. Create Page Component
```typescript
// app/my-feature/page.tsx
'use client';
import { Suspense } from 'react';
import { useUser } from '@clerk/nextjs';
import { MyFeatureContent } from '@/components/my-feature/MyFeatureContent';
export default function MyFeaturePage() {
const { user } = useUser();
if (!user) return null; // REQUIRED for SSG
return (
<Suspense>
<MyFeatureContent userId={user.id} />
</Suspense>
);
}
```
**Key Points**:
- `'use client'` directive required
- `if (!user) return null` is **MANDATORY** - prevents build errors
- Page only handles auth, wraps content in Suspense
- No data fetching here
### 2. Create Loading Fallback
```typescript
// app/my-feature/loading.tsx
import { LoadingSpinner } from '@/components/_shared/loading-spinner';
export default function Loading() {
return <LoadingSpinner message="Loading..." />;
}
```
### 3. Create Content Component
```typescript
// components/my-feature/MyFeatureContent.tsx
'use client';
import { useMyFeatureSuspense } from '@/lib/hooks/use-my-feature';
interface MyFeatureContentProps {
userId: string;
}
export function MyFeatureContent({ userId }: MyFeatureContentProps) {
const { data } = useMyFeatureSuspense(userId);
return (
<div className="container mx-auto p-4">
{/* Render data - no isLoading check needed! */}
{data.map((item) => (
<div key={item.id}>{item.name}</div>
))}
</div>
);
}
```
**Key Points**:
- Uses `useSuspenseQuery` - no loading states needed
- Receives `userId` as prop from page
- Pure UI rendering
### 4. Update Middleware (if new route pattern)
```typescript
// middleware.ts
const isProtectedRoute = createRouteMatcher([
'/dashboard(.*)',
'/items(.*)',
'/paid-feature(.*)',
'/my-feature(.*)', // Add new route
]);
```
## Important Rules
**DO**:
- Add `if (!user) return null` in page components
- Use Suspense to wrap content
- Put data fetching in content component
- Use `useSuspenseQuery` for automatic loading states
**DO NOT**:
- Fetch data in page component
- Add manual loading states (`isLoading`)
- Forget the null check (causes build errors)
- Use `dynamic = 'force-dynamic'` (middleware handles auth)
## Creating the Feature Hook
See the `add-feature-hook` skill for creating the hook used in the content component.Related Skills
activate-lightning-page
Activates a newly deployed Lightning App Page so it appears in the App Launcher. Use when you've deployed a new flexipage and need to make it accessible to users.
pagent
Guide for using pagent - a PRD-to-code orchestration tool. Use when users ask how to use pagent, run agents, create PRDs, or transform requirements into code.
page-annotator
AI驱动的网页标注工具,支持高亮元素和添加文字批注。智能防重复、自动滚动、碰撞检测。兼容 GitHub 等严格 CSP 网站。适用场景:(1) 标记网页元素进行讲解 (2) 添加文字批注和注释 (3) 代码审查和设计评审 (4) 教学演示和用户引导 (5) Bug 报告和问题标记
extract-page
Extract a single page from a PDF as a PNG image for quick preview.
pagen
Personal CRM and contact management - manage contacts, relationships, and interactions. Use when the user discusses contacts, people, or relationship tracking.
page-cro
Analyze and optimize individual pages for conversion performance.
live-web-page-browser
Use AgentPMT external API to run the Live Web Page Browser tool with wallet signatures, credits purchase, or credits earned from jobs.
deepagents-implementation
Implements agents using Deep Agents. Use when building agents with create_deep_agent, configuring backends, defining subagents, adding middleware, or setting up human-in-the-loop workflows.
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
aegis-protocol-ratification
Ratify AEGIS protocol governance frameworks.
aegis-architect
Enhanced architecture guidance for voice-first Brazilian fintech applications. Use when designing voice interfaces, implementing PIX/Boletos, optimizing financial systems, or making technology stack decisions for Brazilian market applications. Integrates with docs/ content, MCP tools for Brazilian market research, enhanced validation scripts, and comprehensive Brazilian compliance patterns.
ae-sdd-init
Initialize a new SDD change set after user-approved naming