nextjs-hooks
Skill1 starsChanged 2 days agoMITView on GitHub
Installs three Claude Code PostToolUse hooks in a Next.js (App Router) or NestJS TypeScript repository and proves they work. After every Edit or Write they type-check the app that owns the file, flag physical left/right Tailwind classes that break right-to-left pages, and flag next-intl keys missing from a locale. Use when setting up Claude Code hooks for a Next.js, next-intl or NestJS project, or when asked to catch type errors, RTL class mistakes or missing translations while Claude edits.
In this repository10 other files it gives its agents.
- add-admin-dashboardSkill
- app-screenshotsSkill
- design-rulesSkill
- docs-checkSkill
- i18n-keys-checkSkill
- nextjs-claude-mdSkill
- production-checkSkill
- rtl-checkSkill
- template-rebrandSkill
- vps-deploySkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Check: node --version is v20 or later, and <app>/node_modules/typescript/bin/tsc exists for each app (run the package manager's install if …
- Distinctive: line 31
Check: each prints a count.
- Very specific: line 39
Check: .claude/hooks/ holds lib.mjs and the chosen scripts, and .claude/settings.json parses (node -e …
- Very specific: line 48
Check: every line says exit 0.
- Very specific: line 50
Prove a bad edit is reported: Write a throwaway src/hook-test.tsx in one app with export const n: string = 1;, an element with …
- Very specific: line 54
Check: each installed script prints exit 2 and names its problem, and the file is gone.
- Very specific: line 56
Hand over: Ask the user to type /hooks in Claude Code, and suggest committing .claude/hooks/ and .claude/settings.json so the whole team …
- Very specific: line 58
Check: /hooks lists the scripts under PostToolUse.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Next.js hooks: types, RTL classes, next-intl keys
Three Node scripts with no dependencies run after each Edit or Write. A clean edit exits 0 and
Claude sees nothing. A bad one exits 2 with a short report on stderr; on PostToolUse that report
goes to Claude, which fixes it in its next step. The edit has already happened and stays.
| Script | Files | Reports |
check-types.mjs | .ts .tsx .mts .cts | tsc --noEmit errors in the app that owns the file (nearest tsconfig.json) |
check-rtl-classes.mjs | .tsx .jsx .ts .js .mdx .html .css | ml-*, pr-*, left-*, text-right, rounded-l-*, border-r in the added text, with the logical class |
check-i18n-keys.mjs | source files, message JSON | t("key") calls whose key a locale lacks, and message files whose keys differ between locales |
Steps
- Map the project. List each app: a folder with its own
package.jsonandtsconfig.json. Check:node --versionis v20 or later, and<app>/node_modules/typescript/bin/tscexists for each app (run the package manager's install if not). Leave outi18nwhen nopackage.jsonlistsnext-intl, andrtlwhen no locale is right to left (ar, he, fa, ur) unless the user wants it. - Take a baseline, for each app:
Check: each prints a count. Anything above 0 is reported again on every edit in that app, so show the list to the user and ask whether to fix it first. In Next.js,node ${CLAUDE_SKILL_DIR}/scripts/check-types.mjs --all <app> node ${CLAUDE_SKILL_DIR}/scripts/check-rtl-classes.mjs --all <app>/src node ${CLAUDE_SKILL_DIR}/scripts/check-i18n-keys.mjs --all <app>Cannot find module './.next/types/...'means the route types were never generated: runnpx next typegenonce. - Install into the repository root:
Check:node ${CLAUDE_SKILL_DIR}/scripts/install.mjs <repo-root> --only types,rtl,i18n.claude/hooks/holdslib.mjsand the chosen scripts, and.claude/settings.jsonparses (node -e 'JSON.parse(require("fs").readFileSync(".claude/settings.json","utf8"))') and lists each script underhooks.PostToolUsewith the matcherEdit|Write. Other settings in the file are kept, and a second run adds nothing. - Prove a clean edit passes:
Check: every line saysnode ${CLAUDE_SKILL_DIR}/scripts/try-hooks.mjs <repo-root> <a real .tsx file>exit 0. Tell the user the type-check time it printed. - Prove a bad edit is reported. Write a throwaway
src/hook-test.tsxin one app withexport const n: string = 1;, an element withclassName="ml-2 text-left", and, with next-intl,const t = useTranslations("<a real namespace>")andt("noSuchKey"). Run try-hooks on it as in step 4, then delete the file. Check: each installed script printsexit 2and names its problem, and the file is gone. - Hand over. Ask the user to type
/hooksin Claude Code, and suggest committing.claude/hooks/and.claude/settings.jsonso the whole team runs the same checks. Check:/hookslists the scripts underPostToolUse. If it lists nothing, the folder's workspace trust has not been accepted yet, or the JSON does not parse.
Limits
- One app at a time: a renamed API field is caught in the API, not in the frontend that sends it.
- Keys or namespaces built at runtime (
t(`tabs.${tab}`)) are counted and skipped. - Errors an app already has are reported on every edit there until they are fixed.
- To pause the hooks, set
"disableAllHooks": truein.claude/settings.local.json.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

