Communitygithub.com

BIGboss248/nextjs-wordpress

在 Next.js App Router 应用中配置生产级健康监控端点(/api/health)、Docker Compose 探针和运行时指标。适用于“设置健康检查”、“添加健康端点”、“Docker Compose Next.js 健康检查”、“配置健康监控”或“/nextjs-healthcheck”等场景。

nextjs-wordpress 是什么?

该技能为 Next.js App Router 应用提供了一套模块化、生产就绪的健康检查与可观测性工作流。它能够自动扫描项目中的数据库依赖(如 Prisma、Drizzle、PostgreSQL 等)和 Docker Compose 文件,根据扫描结果生成对应的 `/api/health` 路由处理器模板,并自动将零依赖的 Node.js fetch 健康探针注入到 Docker Compose 服务配置中。该技能还强制实现非阻塞的 V8 堆饱和度、事件循环延迟(p99)等运行时指标,并通过严格的 HTTP 状态码规范(200 表示健康/降级,503 表示不健康)确保监控的准确性和可靠性。它适用于所有使用 Next.js App Router 并希望在生产环境中建立标准化健康检查机制的项目,尤其适合容器化部署场景。

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

在你喜欢的 AI 中提问

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

文档

Next.js 健康检查与可观测性技能 (nextjs-healthcheck)

一个模块化、生产就绪的工作流,用于在 Next.js App Router 应用中创建和维护健康检查端点(/api/health)、零依赖的 Docker Compose 健康探针以及 Node.js 运行时指标。


工作流概述

flowchart TD
    A["1. 扫描项目<br/>(数据库和 Docker Compose)"] --> B["2. 生成 /api/health<br/>(包含指标的模板)"]
    B --> C["3. 注入 Docker 探针<br/>(docker-compose.yml)"]
    C --> D["4. 验证与测试<br/>(curl 和 docker compose ps)"]

逐步执行手册

请按以下清单顺序执行,以实现和验证应用健康监控:

1. 项目发现与依赖检查

  • 定位路由处理器路径:确定项目使用 app/ 还是 src/app/(目标路径:app/api/health/route.ts 或 src/app/api/health/route.ts)。
  • 检测数据库/外部存储:扫描 package.json 查找 ORM 和客户端(Prisma、Drizzle、Supabase、Mongoose、PostgreSQL、Redis)。请参考 database-probes.md。
  • 定位 Docker Compose 文件:发现 docker-compose.yml、docker-compose.prod.yml 或其他编排文件。请参考 docker-compose-probes.md。

2. 实现健康检查路由处理器

  • 选择路由模板:
  • 强制动态执行:确保包含 export const dynamic = "force-dynamic"; 以及 Cache-Control: no-store, no-cache, must-revalidate 头部。
  • 配置非阻塞指标:收集 V8 堆饱和度、事件循环延迟(通过 perf_hooks 计算的 p99 延迟)和进程运行时间。请参考 status-and-metrics.md。
  • 强制 HTTP 状态码规范:对于 healthy/degraded 状态返回 200 OK,对于 unhealthy 状态返回 503 Service Unavailable。

3. 配置 Docker Compose 健康探针

  • 识别 Next.js 服务:检查已发现的编排文件中的 Next.js 服务块(nextjs-app、web、app)。
  • 注入健康检查块:从 docker-compose.healthcheck.template.yml 添加零依赖的 Node.js fetch 健康探针。

4. 验证与测试

  • 本地 API 测试:
    curl -i http://localhost:3000/api/health
    
    验证 HTTP 200 响应,并包含有效的 JSON 负载(status、timestamp、uptimeSeconds、checks)。
  • Compose 健康状态检查:
    docker compose ps
    
    验证服务状态在初始启动期后转变为 (healthy)。

边缘情况与已知 AI 陷阱

[!WARNING]

  • 缺少 force-dynamic:如果省略 export const dynamic = "force-dynamic",Next.js App Router 可能会静态评估或缓存路由响应,导致时间戳过时和运行时间指标冻结。
  • 挂起的数据库连接:切勿在没有竞态超时(最长 2000ms)的情况下查询外部数据库。未处理的网络延迟将导致请求池耗尽。
  • 容器中的外部工具依赖:不要在 Docker 健康检查中依赖 curl 或 wget;生产环境的最小化镜像(例如 node:alpine 或 distroless)通常缺少这些工具。请使用 Node.js 原生 fetch 通过 node -e 执行。
  • 密钥泄露:切勿在公开的 /api/health 响应负载中打印数据库连接 URL、密码或内部原始错误跟踪信息。

输出摘要模式

完成健康检查设置后,提供简洁的摘要报告:

### 健康监控配置完成

- **路由处理器**:`[app/api/health/route.ts](file:///...)`
- **数据库探针**:[已配置:Prisma / Drizzle / 无] (超时:2000ms)
- **运行时指标**:V8 堆饱和度和事件循环延迟 (p99)
- **更新的 Docker Compose 堆栈**:`docker-compose.yml`、`docker-compose.prod.yml`
- **验证状态**:通过 (HTTP 200 / 容器健康)

参考指南与模板

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

>- Build Next.js App Router React components with Suspense skeletons, semantic OKLCH tokens, Jest + RTL unit tests, Playwright visual/hydration checks, and Tailwind logical styling. Triggers on "/nextjs-component-dev", "create component", "new component", "build component", or "develop component".

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

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...

相关技能