agentleFS
aniq-ui-proaniq-ui-pro/agent-skills/skills/nextjs-hooks/SKILL.md

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.

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
  1. Very specific:

    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 …

    line 21
  2. Distinctive:

    Check: each prints a count.

    line 31
  3. Very specific:

    Check: .claude/hooks/ holds lib.mjs and the chosen scripts, and .claude/settings.json parses (node -e …

    line 39
  4. Very specific:

    Check: every line says exit 0.

    line 48
  5. Very specific:

    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 …

    line 50
  6. Very specific:

    Check: each installed script prints exit 2 and names its problem, and the file is gone.

    line 54
  7. Very specific:

    Hand over: Ask the user to type /hooks in Claude Code, and suggest committing .claude/hooks/ and .claude/settings.json so the whole team …

    line 56
  8. Very specific:

    Check: /hooks lists the scripts under PostToolUse.

    line 58

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

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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.

ScriptFilesReports
check-types.mjs.ts .tsx .mts .ctstsc --noEmit errors in the app that owns the file (nearest tsconfig.json)
check-rtl-classes.mjs.tsx .jsx .ts .js .mdx .html .cssml-*, pr-*, left-*, text-right, rounded-l-*, border-r in the added text, with the logical class
check-i18n-keys.mjssource files, message JSONt("key") calls whose key a locale lacks, and message files whose keys differ between locales

Steps

  1. Map the project. List each app: a folder with its own package.json and tsconfig.json. 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 not). Leave out i18n when no package.json lists next-intl, and rtl when no locale is right to left (ar, he, fa, ur) unless the user wants it.
  2. Take a baseline, for each app:
    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>
    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, Cannot find module './.next/types/...' means the route types were never generated: run npx next typegen once.
  3. Install into the repository root:
    node ${CLAUDE_SKILL_DIR}/scripts/install.mjs <repo-root> --only types,rtl,i18n
    Check: .claude/hooks/ holds lib.mjs and the chosen scripts, and .claude/settings.json parses (node -e 'JSON.parse(require("fs").readFileSync(".claude/settings.json","utf8"))') and lists each script under hooks.PostToolUse with the matcher Edit|Write. Other settings in the file are kept, and a second run adds nothing.
  4. Prove a clean edit passes:
    node ${CLAUDE_SKILL_DIR}/scripts/try-hooks.mjs <repo-root> <a real .tsx file>
    Check: every line says exit 0. Tell the user the type-check time it printed.
  5. 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 className="ml-2 text-left", and, with next-intl, const t = useTranslations("<a real namespace>") and t("noSuchKey"). Run try-hooks on it as in step 4, then delete the file. Check: each installed script prints exit 2 and names its problem, and the file is gone.
  6. Hand over. Ask the user to type /hooks in Claude Code, and suggest committing .claude/hooks/ and .claude/settings.json so the whole team runs the same checks. Check: /hooks lists the scripts under PostToolUse. 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": true in .claude/settings.local.json.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.