Communitygithub.com

BIGboss248/nextjs-wordpress

构建具有 Suspense 骨架屏、语义化 OKLCH 令牌、Jest + RTL 单元测试、Playwright 视觉/水合检查以及 Tailwind 逻辑样式属性的 Next.js App Router React 组件。通过 "/nextjs-component-dev"、"create component"、"new component"、"build component" 或 "develop component" 触发。

nextjs-wordpress 是什么?

此技能是一个专门的工作流,用于在 Next.js 项目中创建生产就绪的 React Server Component (RSC) 和 Client Component。它强调使用 Suspense 骨架屏实现即时导航,利用语义化的 OKLCH CSS 变量和 Tailwind 逻辑属性实现双向文本支持,并强制采用双层 TDD 测试:使用 Jest 和 React Testing Library 进行快速单元测试,以及使用 Playwright 进行全面的集成、视觉回归和水合检查。该工作流集成了 `next-intl` 进行字典驱动的翻译,通过 `next-devtools` MCP 实现运行时诊断,并利用 `codebase-memory` MCP 查询本地 Next.js 文档以确保 API 准确。该技能支持在 Cursor、Claude Code 和 GitHub Copilot 等 AI 编码代理中使用,通过其触发短语激活,并提供详细的参考文档和模板(位于 `references/` 和 `resources/templates/` 目录),以确保遵循最佳实践并避免出现幻觉或已弃用的模式。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/BIGboss248/nextjs-wordpress/tree/HEAD/.agents/skills/nextjs-component-dev

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Next.js 组件与骨架屏开发 (nextjs-component-dev)

专门的工作流,用于创建具有 Suspense 骨架屏、双层 TDD 测试(Jest + RTL 单元测试和 Playwright 集成/水合/视觉检查)、next-intl 字典支持、语义主题令牌以及通过 next-devtools MCP 实现的实时运行时诊断的生产就绪型 React Server Component (RSC) 和 Client Component。

[!TIP] 模块化资产与模板:


架构规则与标准

1. 规划上下文与路径

  • 读取 docs/project.json 以解析 package_manager、new_component_dir、style_file_dir、component_library、dictionaries_dir(默认:"messages")和 supported_languages。
  • 所有内部路由必须使用来自 @/lib/routes 的 ROUTES。
  • 所有作者/站点元数据必须使用来自 @/lib/site-config 的 SITE_CONFIG。
  • 目标路径层次结构:<new_component_dir>/<page_or_global>/<ComponentName>/
    • 类别:global/ 用于共享布局框架;<page-name>/(例如 home/、about/、lab/)用于页面范围的节段。

2. Next.js 内部文档查找 (node_modules/next/dist/docs)

  • 通过 Codebase Memory MCP 搜索本地文档: 对于任何组件创建,使用 codebase-memory MCP 工具(search_code、search_graph、get_code_snippet)主动查询并检查 node_modules/next/dist/docs/ 下的本地 Next.js 发行版文档,以获取相关的 API 签名、指令('use cache'、'use client'、'use server')、内置组件(next/image、next/link、next/font、<Form>)、导航钩子(useRouter、usePathname)和缓存策略(cacheLife、cacheTag)。
  • 消除弃用项与幻觉: 绝不依赖假设或过时的 Next.js 模式;与已安装包版本匹配的本地 node_modules/next/dist/docs 是主要的事实来源。请参阅 references/nextjs-docs-lookup.md。

3. 开发服务器与 Next DevTools 协议

  • 开发服务器检查与调优: 在组件开发之前/期间,通过 next-devtools MCP 服务器(nextjs_index)检查 Next.js 开发服务器是否正在运行。
  • 如果服务器正在运行: 立即调优到正在运行的服务器和端口;不要重新启动。
  • 如果服务器未运行: 在后台启动开发服务器(pnpm dev、IsDaemon: true),并通过 nextjs_index 验证连接。
  • 运行时调试: 实现组件后,通过 next-devtools(nextjs_call)查询以立即检查错误、构建状态并诊断运行时问题。请参阅 references/next-devtools-debugging.md。

4. RSC 边界与叶级 Client 下推

  1. 默认使用 Server Component: 保持组件为服务器渲染(async function)。
  2. 将 "use client" 下推: 将交互式处理程序(按钮、切换开关、表单输入)隔离到小的叶级 Client Component 中。
  3. RSC 组合: 将 Server Component 作为 children 或 props 传递给 Client 包装器。绝不在 "use client" 文件内部导入 Server Component。

5. 样式、逻辑属性与主题令牌

  • 语义令牌: 仅使用在 app/globals.css 中定义的语义 CSS 变量(bg-background、text-foreground、border-border、text-muted-foreground)。禁止使用硬编码的十六进制颜色(#FAFAFA)或原始颜色缩放(bg-blue-500)。
  • 类合并: 始终使用 cn(...)(clsx + tailwind-merge)合并类。
  • 逻辑属性(双向文本): 仅使用 Tailwind 逻辑属性(ms-、pe-、ps-、me-、start、end)。禁止使用物理方向类(ml-、mr-、pl-、pr-、left-、right-)。
  • 进度链接: 对于主导航、英雄行动号召和交互式卡片,使用来自 @vercel/react-transition-progress 的 <Link>;对于静态实用链接,使用标准的 next/link。
  • 图片: 始终使用带有显式尺寸或 fill、响应式 sizes 以及用于首屏 LCP 资源的 priority 的 next/image。

6. 即时导航、细粒度 Suspense 与缓存架构

  • 即时组件的三个杠杆:
    1. 下推:将请求特定的异步操作(await params、await searchParams、cookies()、headers()、未缓存的 DB/API 调用)提取到包裹在 <Suspense> 中的叶级子组件中。静态的父组件和兄弟组件直接提升到静态/App Shell 中。
    2. 缓存:在函数/组件级别将 'use cache' 与 cacheLife 和 cacheTag 配对使用。使用 Session Bridging 模式:
      • 模式 A(提取并传递):从外部的 cookies() 提取会话属性(例如 team_id、role、tier),并将其作为参数传递给 'use cache' 函数,以便具有匹配属性的所有用户共享缓存数据(成本随团队/属性数量扩展,而非用户会话数量)。
      • 模式 B("use cache: private"):对于严格特定于用户的会话查找,使用浏览器专属的会话缓存,其中 stale >= 5m,随 App Shell 一起传输。
    3. 预取策略与密集网格:
      • 默认 App Shell 预取(<Link> / prefetch={null}):为每个路由预取一个共享的静态/App Shell。成本有上限($O(\text{routes})$),每个链接零服务器调用。用于密集的 feed、卡片网格(超过 50 张卡片)和批量导航。
      • 每个链接预取(<Link prefetch={true}>):在导航前解析动态 URL 数据(params、searchParams),每个可见链接需要 1 次服务器调用。谨慎用于高意图的主要行动号召、英雄操作或主从列表项目,其中必须消除骨架屏闪烁。
      • 密集卡片网格:绝不在 feed 中的几十张卡片上使用 blanket prefetch={true}。保留默认的 <Link> 或使用悬停/聚焦意图预取(router.prefetch())。
  • 细粒度加载状态(反全页闪烁):永远不要将整个组件或页面包裹在单个顶级 <Suspense> 边界中,这会导致整个骨架屏闪烁。保持标题、布局框架和缓存内容立即可见;仅在动态流式传输插槽周围放置 <Suspense>。
  • 原生 Next.js 16 缓存指令:请参阅 references/instant-navigation-and-prefetching.md 和 references/caching-and-revalidation.md。

7. TanStack Query 与服务器预取

  • 统一缓存契约: 使用显式的 staleTime(例如 30_000 毫秒)定义 key、tag 和 queryOptions。
  • 服务器预取: 触发未等待的预取(void queryClient.prefetchQuery(...)),直接调用内部 DB 函数(在服务器上零相对 fetch)。使用 <HydrationBoundary> 进行水合。
  • 流式组件: 在 <Suspense fallback={<[ComponentName]Skeleton />}> 内部使用 useSuspenseQuery。
  • 乐观更新: 使用带有 onMutate 缓存快照和 onError 回滚的 useMutation;使用 updateTag(cache.tag) 调用 Server Action。

8. 双层测试分工(Jest vs. Playwright)

  • Jest + RTL([ComponentName].test.tsx):
    • 在 jsdom 中快速反馈循环。
    • Props 排列、条件性 UI 元素以及空/null 状态。
    • 通过 @testing-library/user-event 进行用户交互(绝不使用 fireEvent)。
    • Next.js 路由模拟(来自 next/navigation 的 useRouter、usePathname、useSearchParams)。
    • 在 NextIntlClientProvider 内部进行 next-intl 字典插值和复数检查。
    • 可访问的角色查询(screen.getByRole)和自动化 a11y 检查(jest-axe)。
  • Playwright([ComponentName].spec.ts 或页面级规范):
    • 真实浏览器执行(Chromium/WebKit/Firefox)。
    • 即时 Shell 断言(@next/playwright): 使用 instant(page, ...) 辅助函数断言静态 shell 和预取的 App Shell 在动态服务器流式传输解析之前立即渲染。
    • 零水合不匹配: 监听浏览器控制台事件(page.on('console'))以检测并使测试因 React SSR 水合警告而失败。
    • 视觉与双向文本回归: 使用 expect(page).toHaveScreenshot() 跨主题(浅色与深色 OKLCH 变量)和文本方向(dir="ltr" 与 dir="rtl")进行测试。
    • 网络弹性: 使用 page.route() 测试缓慢的网络响应(验证 Suspense 骨架屏匹配几何形状以防止 CLS)和 500 错误边界。
  • 详细的测试标准: 请参阅 references/testing-architecture-guide.md。

阶段 0:实施计划与审批关口

[!IMPORTANT] 先计划后执行: 在执���任何写入操作、修改字典或在仓库中创建组件之前,始终生成并展示一个 implementation_plan.md 工件,详细说明所有计划的文件创建、修改、TypeScript 契约、翻译字典添加和 TDD 测试用例。等待用户确认/批准后再继续执行。

实施计划必须涵盖:

  1. 目标架构与路径:完整的目标目录(<new_component_dir>/<page_or_global>/<ComponentName>/)和分类(RSC 与 Client 叶级组件)。
  2. 已咨询的 Next.js 本地文档:在 node_modules/next/dist/docs/ 下检查的具体文档路径(例如 04-api-reference/04-components/image.md、03-directives/use-cache.md、04-api-reference/02-functions/use-router.md)。
  3. TypeScript 契约:带有严格英文 TSDoc 注释的 Props 接口和类型。
  4. 字典策略:要添加到 docs/project.json 中所有 supported_languages 的 messages/[locale].json 中的显式翻译命名空间和键(零硬编码字符串或文件内模拟字典)。
  5. 主题令牌与样式:已识别的语义 OKLCH CSS 变量和逻辑布局类。
  6. 测试与诊断策略:
    • Jest 单元测试([ComponentName].test.tsx):模拟配置(next/navigation)、props 变体、回调断言、NextIntlClientProvider 集成和 a11y 角色查询。
    • Playwright 集成场景([ComponentName].spec.ts):视觉快照目标(浅色/深色主题令牌、LTR 与 RTL 逻辑布局)、网络限速/骨架屏几何形状检查和水合验证监听器。
    • Next DevTools 诊断:通过 next-devtools 进行运行时错误和编译检查。
  7. 验证关口:要运行的确切验证命令(verify-dev.ps1、目标单元测试和 Playwright e2e 规范)。

工作流步骤

  • 步骤 0:实施计划生成与审批关口

    • 通过 codebase-memory MCP(search_code、search_graph)搜索并检查 node_modules/next/dist/docs,以获取计划组件所利用的任何 Next.js API、指令、钩子或组件,确保上下文是最新的。
    • 综合组件需求,扫描 docs/project.json,并生成 implementation_plan.md,记录已咨询的文档和契约。
    • 在工件上设置 request_feedback = true 和 user_facing = true。
    • 在编写任何代码之前等待用户审查和明确批准。
  • 步骤 1:开发服务器验证与 Next DevTools 连接

    • 通过 nextjs_index 查询 next-devtools MCP 以检测正在运行的 Next.js 开发服务器实例。
    • 如果开发服务器正在运行: 调优到活动端口和服务器实例;继续开发而无需重新启动。
    • 如果开发服务器未运行: 在后台启动开发服务器(pnpm dev、IsDaemon: true),并使用 nextjs_index 验证发现。
  • 步骤 2:字典填充与 TypeScript 契约定义

    • 读取 docs/project.json 以解析 dictionaries_dir(默认是 messages)和 supported_languages。
    • 定义组件的翻译命名空间和键。
    • 填充所有字典文件(messages/en.json、messages/fa.json 等),在编写 JSX 之前为每种支持的语言提供真实的翻译。
    • 使用严格的英文 TSDoc 注释(@param、@defaultValue、@returns)定义 Props 接口。
    • 如果支持的语言多于一种,组件必须首先获取翻译,如果失败则使用回退。
  • 步骤 3:TDD 基线单元测试(通过 Jest + RTL 的 [ComponentName].test.tsx)

    • 在实现组件之前编写 [ComponentName].test.tsx。
    • 模拟 next/navigation 钩子(useRouter、usePathname、useSearchParams)。
    • 在 NextIntlClientProvider 中包装渲染的组件,提供字典 messages 和活动的 locale。
    • 测试方向属性(dir="rtl" 与 dir="ltr")、默认 props、交互式回调(@testing-library/user-event)、Suspense 骨架屏回退和语义 ARIA 角色。
  • 步骤 4:Playwright 集成与水合/视觉规范([ComponentName].spec.ts)

    • 使用 Playwright 编写端到端规范。
    • 断言即时 App Shell 渲染(使用来自 @next/playwright 的 instant())。
    • 确认零水合不匹配(通过控制台事件监听器)。
    • 跨主题(浅色/深色)和方向(LTR/RTL)捕获视觉快照。
    • 测试网络降级场景(缓慢的 API、错误边界)。
  • 步骤 5:Next DevTools 运行时诊断

    • 在实施后查询 next-devtools MCP 以检查构建状态和运行时错误。
    • 通过自动化工具修复任何已识别的问题。
  • 步骤 6:最终验证与批准

    • 运行完整的测试套件:单元测试和 Playwright e2e 规范。
    • 运行 scripts/verify-dev.ps1(Windows)或 scripts/verify-dev.sh(Linux)以执行最终的一致性检查。
    • 等待用户最终批准。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

BIGboss248/nextjs-wordpress

Create, configure, manage, and validate Google Antigravity customizations including skills, rules, MCP servers, lifecycle hooks, plugins, and custom JSON configs. Use when adding new capabilities to Antigravity, configuring MCP servers, writing rules, creating skills, setting up hooks, or modernizing legacy workflows.

BIGboss248/nextjs-wordpress

Spawn multiple agents into a shared conversation where they debate, disagree, and converge on a solution via a shared chat.json file. Use for architecture decisions, code review debates, design trade-offs, or any problem that benefits from adversarial reasoning. Triggers on "chatroom", "agent debate", "have agents discuss", "agent chatroom", "debate this", or /agent-chatrooms. Also triggers on phrases like "have 3 agents argue about", "multi-agent discussion", or "let them debate".

BIGboss248/nextjs-wordpress

Always-active code intelligence, search, and navigation skill utilizing the codebase-memory MCP server. Enforces an index-first protocol (verifying and refreshing the knowledge graph via index_repository or index_status before searching, required because background auto_watch is disabled to eliminate editor stutter and system lag), followed by graph-first exploration (search_graph, trace_path, get_code_snippet, query_graph, get_architecture, detect_changes) instead of naive text grep or full-file reads. Always activate before searching the codebase, inspecting unknown architecture, finding symbols, or tracing callers/callees.

BIGboss248/nextjs-wordpress

>- Discover, interview, and craft comprehensive UX/UI design specifications (design-spec.md) and design tokens for web components. Triggers on "/component-design", "design component", "design section", "design UI", "wireframe component", or "create design spec".

BIGboss248/nextjs-wordpress

>- Configure and query WooCommerce APIs including WPGraphQL, WooGraphQL, and JWT auth for headless frontends. Use when connecting Next.js to WooCommerce or fetching store catalog data.

BIGboss248/nextjs-wordpress

Orchestrate parallel browser automation using multiple Chrome DevTools MCP instances. Use when a task requires doing the same browser action across many targets simultaneously (e.g., submitting contact forms, filling applications, scraping pages that need JS rendering). Spin up 1-5 parallel Chrome agents.

BIGboss248/nextjs-wordpress

Workflow for spawning an independent subagent to conduct unbiased code reviews and inject adversarial edge-case tests ([ComponentName].edge.test.tsx).

BIGboss248/nextjs-wordpress

>- Bootstrap, configure, and verify the complete Next.js App Router development environment, developer tooling, testing suites, MCP servers, Docker containerization, and CI/CD. Triggers on "/nextjs-dev-setup", "setup nextjs dev environment", "start a nextjs project", or "containerize nextjs app".

BIGboss248/nextjs-wordpress

>- Configure production health monitoring endpoints (/api/health), Docker Compose probes, and runtime metrics in Next.js App Router applications. Use when asked to "setup health check", "add health endpoint", "docker compose healthcheck nextjs", "configure health monitor", or "/nextjs-healthcheck".

BIGboss248/nextjs-wordpress

Bootstrap, configure, and verify next-intl App Router internationalization (proxy.ts/middleware.ts, next/root-params, [locale] layout, routing). Triggers on "/nextjs-i18n-setup", "setup i18n", "install next-intl", "configure next-intl", "add internationalization", "setup locale routing", "migrate to [locale]".

BIGboss248/nextjs-wordpress

Read/write translation dictionaries (messages/[locale].json), next-intl hooks (getTranslations/useTranslations), providers (Storybook/tests/subtrees), and BiDi styling. Triggers on "/nextjs-i18n-usage", "i18n dictionary", "use translations", "read dictionary", "i18n provider", "next-intl hooks", "storybook i18n", "test i18n", "add translation keys", "localize component", "create a component", "update a component".

BIGboss248/nextjs-wordpress

>- Configure, test, and verify OpenTelemetry (OTel) observability in Next.js App Router applications. Triggers on "/nextjs-otel", "setup otel", "configure opentelemetry", "test otel", or "verify opentelemetry".

BIGboss248/nextjs-wordpress

Step-by-step workflow for designing and building Next.js App Router pages (RSC page.tsx, loading skeleton, metadata, JSON-LD schema, and dynamic static params). Triggers on "/nextjs-page-dev", "create page", "new page", "develop page", "build route", or "implement page".

BIGboss248/nextjs-wordpress

>- Orchestrate end-to-end planning for Next.js App Router projects, generating canonical specifications, design systems, and a 7-phase modular implementation roadmap in docs/plan/. Triggers on "/nextjs-plan", "plan a nextjs project", "plan nextjs app", "create nextjs project plan", "outline nextjs architecture", or "generate plan".

BIGboss248/nextjs-wordpress

Workflow and engineering standards for crafting co-located Storybook CSF3 stories ([ComponentName].stories.tsx) with interactive controls, action spies, and 4 canonical theme variants.

BIGboss248/nextjs-wordpress

>- Build Next.js e-commerce frontends backed by WooCommerce APIs, handling ISR catalogs, cart sessions, and JWT authentication. Use when building or querying Next.js stores with WooCommerce.

BIGboss248/nextjs-wordpress

Self-correcting rules engine and feedback loop that learns from user corrections, mistakes, and project-specific constraints by maintaining a persistent autofix ruleset. Scans learned rules before starting any task, resolves conflicts, and automatically appends new rules upon corrections. Triggers on user corrections ("no, do it this way", "never do X", "always use Y"), /learn, "self repair", "add rule", "update rules", or when diagnosing assumptions and bugs. CRITICAL ALWAYS-ACTIVE LIFECYCLE SKILL. Must always be kept in context, loaded at session start, and consulted before starting ANY task to read and apply active constraints from autofix.json. MUST ALWAYS be triggered immediately whenever the user provides ANY correction, preference, criticism, rejection of an approach, or adjustment ("no", "don't do X", "use Y", "remember", "prefer"), or when any mistake/bug is identified. Automatically and immediately formulates and appends the new imperative rule to the project's autofix.json ruleset file.

BIGboss248/nextjs-wordpress

Setup, automate, and execute SEO audits, CI/CD pre-push/pre-deploy checks, and ranking optimizations using the seo CLI and MCP server.

BIGboss248/nextjs-wordpress

End-to-end repository onboarding and development environment setup skill. Scans repository structure, configures project metadata (docs/project.json), sets up the codebase-memory-mcp code intelligence knowledge graph server (in workspace mcp.json and globally for AGY only), configures git hooks with Husky and Commitlint, establishes multi-stage production Docker containerization, and automates credit-optimized Release Please CI/CD with multi-arch (AMD64 & ARM64) GHCR package deployment. Triggers on "/setup-repository", "setup repository", "setup repo", "initialize repository", "new repo setup", or when preparing any repository for development and AI agent workflows.

BIGboss248/nextjs-wordpress

AI screen scaffolding, layout generation, and variant exploration workflow powered by Google Stitch (StitchMCP). Consumes a component design specification (docs/design/components/[page name]/[component name]/design-spec.md), verifies and reuses the central Stitch project in docs/project.json (or creates/persists one if absent), seeds the project's design system into Stitch, synthesizes layout prompts to generate a screen and create one variant of the given design spec file, downloads and saves Stitch JPG screenshots and HTML code files directly into docs/design/components/[page name]/[component name]/stitch/ using binary-safe PowerShell Invoke-WebRequest, outputs image prompts to the user if visual assets are needed (without calling generate_image to conserve tokens), updates design-spec.md with Stitch layout benchmarks, and audits asset download integrity with an independent subagent. Triggers on "/stitch-design", "generate stitch screen", "create stitch variant", "scaffold screen with stitch", or "stitch...

相关技能