AGENT SKILL

nextjs

Next.js App Router, RSC, caching, middleware, deployment patterns.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 0
Forks
0

01 前言 Front Matter

name
nextjs
author
Joshua (joshlcoleman), Hermes Agent
license
MIT
version
1.0.0
metadata
{ "hermes": { "tags": [ "nextjs", "app-router", "rsc", "server-components", "vercel" ], "related_skills": [ "frontend-react", "database" ] } }
platforms
[ "linux", "macos", "windows" ]
description
Next.js App Router, RSC, caching, middleware, deployment patterns.

03 SKILL.md 正文

Next.js

When to Use

  • Building full-stack React applications
  • API routes or server actions
  • SEO-critical pages (SSR/SSG)
  • Vercel deployments

App Router Patterns

Server Components (Default)

// app/page.tsx — Server Component by default
import { db } from '@/lib/db';

export default async function Page() {
  const posts = await db.post.findMany();
  return (
    <main>
      {posts.map(post => (
        <PostCard key={post.id} post={post} />
      ))}
    </main>
  );
}

Client Components

'use client';
import { useState } from 'react';

export function Search() {
  const [query, setQuery] = useState('');
  return <input value={query} onChange={e => setQuery(e.target.value)} />;
}

Server Actions

// app/actions.ts
'use server';
import { db } from '@/lib/db';
import { revalidatePath } from 'next/cache';

export async function createPost(formData: FormData) {
  await db.post.create({
    data: { title: formData.get('title') as string }
  });
  revalidatePath('/posts');
}

Route Handlers

// app/api/posts/route.ts
import { NextResponse } from 'next/server';

export async function GET() {
  const posts = await db.post.findMany();
  return NextResponse.json(posts);
}

Caching Strategy

Type Use For How
Static Blog posts, docs generateStaticParams()
ISR Product catalogs revalidate: 3600
Dynamic User dashboards No caching
On-demand Admin panels revalidateTag()

Middleware

// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

export function middleware(request: NextRequest) {
  // Auth, redirects, A/B testing, geo
  const token = request.cookies.get('token');
  if (!token && request.nextUrl.pathname.startsWith('/dashboard')) {
    return NextResponse.redirect(new URL('/login', request.url));
  }
  return NextResponse.next();
}

export const config = {
  matcher: ['/((?!api|_next/static|favicon.ico).*)'],
};

Pitfalls

  • 'use client' everywhere → Only when needed (state, effects, browser APIs)
  • Fetching in client → Fetch in Server Components, pass as props
  • Over-fetching → Select only needed fields from DB
  • Missing loading.tsx → Always add for async Server Components
  • Missing error.tsx → Always add for error boundaries

Verification

  • [ ] Pages load with correct rendering strategy
  • [ ] Server actions work without JS
  • [ ] Caching behaves as expected
  • [ ] Middleware runs on correct paths
  • [ ] Build passes with no warnings

04 同仓库更多 Skills

Trollz1004
Trollz1004/ANTIGRAVITY

security-audit

Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

impeccable

Use when the user wants to design, redesign, shape, critique, audit, polish, simplify, harden, animate, or otherwise improve a frontend interface: websites, landing pages, dashboards, product UI, components, forms, settings, onboarding, empty states, and native iOS or Android screens. Handles UX review, hierarchy, layout, typography, color, motion, UX copy, accessibility, responsive behavior, edge cases, and capturing or documenting design systems (DESIGN.md, tokens). Also for making bland UI bolder, loud UI quieter, or ambitious visual effects. Not for backend-only or non-UI tasks.

设计师前端开发视觉设计
★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

hallmark

Design skill for websites and new pages that look designed, not generated. Use when the user asks to build or design something new, or names Hallmark. Never use it on an existing design unless the user names Hallmark, as in `/hallmark redesign <path>`.

视觉设计Skill与智能体开发
★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

测试与质量前端开发
★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

appinsights-instrumentation

Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. USE FOR: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices. DO NOT USE FOR: adding App Insights to my app (use azure-prepare), add telemetry to my project (use azure-prepare), add monitoring (use azure-prepare). This skill provides guidance—azure-prepare orchestrates component changes.

★ 0
Trollz1004
Trollz1004/ANTIGRAVITY

youtube-automation

YouTube automation: upload, SEO, thumbnails, scheduling, analytics.

数据分析师市场营销分析与可视化营销推广
★ 0