dyz-gongwen-skills
公文写作 Skills|AI 公文写作助手:防编造、守保密、GB/T 9704 一键排版,覆盖 22 种文书,支持 Claude Code / Codex / Cursor
翻訳待ち
リポジトリ情報はまだ収集していません。
No updates detected yet. GitHub releases will appear here.
Claude Code Skill that finds every unnecessary "use client" in a Next.js App Router project, measures its cost and gives a safe fix from your own code. By Rady Elkasas.
翻訳待ち
Loading the full README.
Read the full README ↗A Claude Code Skill that finds every unnecessary "use client" in a Next.js App Router project, shows what each one costs, and gives you a safe, concrete fix built from your own code.
nextjs-client-audit/ ← this repo
├── nextjs-client-audit/ ← the Skill (copy this folder into ~/.claude/skills/)
├── dist/nextjs-client-audit.skill ← packaged Skill (also attached to each Release)
└── docs/index.html ← the showcase site (GitHub Pages)
Live site: https://radyelkasas.github.io/nextjs-client-audit/
"use client" is not a switch that makes an error go away. It is a boundary: the file and everything it imports is shipped to the browser, downloaded, parsed and hydrated. One directive at the top of a page can quietly turn the whole page tree into client JavaScript.
Ask Claude "why is my page heavy?" or "audit use client" and this skill:
"use client" that is a real directive, and ignores the same text in comments, strings and code samples. It also flags directives written after the imports, which Next.js silently ignores.next/dynamic with ssr:false, createContext, class components.paths aliases included) and counts how many modules each boundary drags into the client bundle. This is an estimate in modules, clearly labelled, never presented as bytes.| Fix | When |
|---|---|
REMOVE | The file uses nothing client-only. Delete the directive. |
PUSH_DOWN | Move "use client" to the smallest child that needs it: a child file, an extracted form, a hook moved into the one leaf that uses it, or a small client "shell" for shared state. |
CHILDREN_PATTERN | Keep a thin client wrapper (a Modal) and pass the heavy server content in as children. |
MOVE_FETCH | The component is client only to fetch data in useEffect / useQuery. Make it an async Server Component. |
next build.use* hook from a package, a third-party component whose package does not declare "use client", an import it could not resolve."use client".children if it does not use the wrapper's state and is not already in the client bundle through another component.{children} stay Server Components. The report says exactly that.fetch("/api/…") won't work on the server.Claude Code (recommended)
git clone https://github.com/radyelkasas/nextjs-client-audit.git
mkdir -p ~/.claude/skills
cp -R nextjs-client-audit/nextjs-client-audit ~/.claude/skills/
Or download nextjs-client-audit.skill from Releases and unzip it into ~/.claude/skills/ (a .skill file is a zip):
unzip nextjs-client-audit.skill -d ~/.claude/skills/
For one project only, put the folder in <your-project>/.claude/skills/ instead.
Claude.ai: Settings → Capabilities → Skills → upload nextjs-client-audit.skill.
Requires Node.js 18+. No dependencies: it uses the typescript (or @babel/parser) already installed in your Next.js project, and falls back to a careful regex scan, with a warning, if neither is there.
Open your Next.js project in Claude Code and ask:
audit use client in this project
Or "why is my dashboard bundle so big?", "check my client components", "review Server vs Client components".
You can also run the script directly:
node ~/.claude/skills/nextjs-client-audit/scripts/audit.js . --format md # Markdown report
node ~/.claude/skills/nextjs-client-audit/scripts/audit.js . --json audit.json # machine-readable JSON
Exit codes: 0 audit ran · 2 not an App Router project · 1 error.
Add .client-audit.json to your project root to teach it your own libraries:
{
"clientLibraries": { "@acme/motion": "any", "acme-flags": "hooks" },
"serverSafeHooks": ["useFeatureFlag"],
"extraScanDirs": ["src/features"],
"ignore": ["src/legacy/**"]
}
See references/rules.md for every rule and the reasoning behind it, and references/patterns.md for Before/After examples of each fix.
nextjs-client-audit/
├── SKILL.md instructions Claude follows (when to run, how to verify, how to present)
├── scripts/audit.js the analyzer (Node.js, zero dependencies, JSON or Markdown output)
├── references/rules.md Server vs Client rules, with reasoning
├── references/patterns.md Before/After for every fix type
├── tests/fixtures/ 3 small Next.js projects + a Pages Router control
└── tests/run-tests.js runs the audit on every fixture with every available parser
node tests/run-tests.js
This is the beginning of the README. Read the rest at the original. Read the full README ↗