Skip to content

Add Next.js + TypeScript rules (annotated, with enforcement hooks)#308

Open
iPythoning wants to merge 3 commits into
PatrickJS:mainfrom
iPythoning:add-nextjs-typescript-annotated-enforced
Open

Add Next.js + TypeScript rules (annotated, with enforcement hooks)#308
iPythoning wants to merge 3 commits into
PatrickJS:mainfrom
iPythoning:add-nextjs-typescript-annotated-enforced

Conversation

@iPythoning

@iPythoning iPythoning commented Jun 9, 2026

Copy link
Copy Markdown

Adds an annotated Next.js + TypeScript ruleset as a single .mdc under rules/, plus its README entry (alphabetical, in the Next.js group).

What differentiates it from the existing Next.js + TS entries:

  • Every rule states the reason it exists (Why: ...). In practice this materially improves how reliably the agent follows a rule — a model that understands why any is banned won't quietly reintroduce it, whereas a bare "don't use any" gets ignored.
  • It documents the real Next.js failure modes AI agents hit by reflex — RSC/Client boundaries, useEffect-fetching waterfalls, copying server data into client stores, empty catch {} — not just generic "use TypeScript, write clean code".
  • The .mdc is kept in sync with a Claude Code CLAUDE.md + .claude/settings.json enforcement hooks (Prettier/ESLint on edit, tsc --noEmit on session stop), so for teams using Cursor + Claude Code the rules enforce themselves instead of being politely ignored.

Format: modern Project Rules .mdc with description / globs / alwaysApply frontmatter, per contributing.md. MIT-licensed, free, single-file, no signup. Source repo linked in the file header. Happy to adjust naming or the README line to match list conventions.

Summary by CodeRabbit

  • Documentation

    • Added a reference entry for Next.js + TypeScript (Annotated + Enforced), describing the guidelines, rationale, and how to apply them.
  • Chores

    • Introduced a new configuration that enforces strict TypeScript practices, React/Next.js conventions, explicit error handling, state and style guidelines, security requirements, and mandatory build/lint/test checks for completion.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new Cursor rules file for Next.js (App Router) + React 19 + strict TypeScript and updates the README to reference it, describing annotated explanations and enforcement hooks (Prettier/ESLint on edit, tsc --noEmit on stop).

Changes

Next.js + TypeScript Cursor Rules

Layer / File(s) Summary
Rules configuration and documentation
rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc, README.md
New Cursor rules file targets TypeScript/TSX files and enforces scope discipline, strict typing (no any), server-component-first React patterns, explicit error handling and input validation, immutability and style constraints, security requirements (no hardcoded secrets, parameterized DB queries), and mandatory build/lint/test checks. README entry documents the rule and notes Prettier/ESLint and tsc --noEmit enforcement hooks.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • PatrickJS

Poem

A rabbit hops through README and dots,
Adds rules for Next and typed TypeScript plots,
Strict checks and hooks to keep code bright,
No stray secrets, types held tight,
Hooray — the repo grows by moonlight! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main changeset: adding a new Next.js + TypeScript rule file with annotated explanations and enforcement hook support.
Description check ✅ Passed The description covers all required template sections: Summary (concise), Contribution Type (New rule file), Value to Users (explains practical benefits), and Added/Changed Files (lists the two files). Quality checklist items are addressed (original content, descriptive filename, proper frontmatter, README link, neutral tone, licensing noted).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Line 88: Update the README entry for "Next.js + TypeScript (Annotated +
Enforced)" to remove the implicit claim that enforcement hooks are bundled, and
either (A) mention that the Claude Code enforcement hook files (CLAUDE.md and
.claude/settings.json) must be obtained separately from the source repository
and provide a pointer to where they live, or (B) add those enforcement files to
this PR; specifically edit the phrase "paired with Claude Code enforcement hooks
(Prettier/ESLint on edit, `tsc --noEmit` on stop) so the rules run, not just
suggest" to explicitly state which of the two options is true. Ensure you
reference the CLAUDE.md and .claude/settings.json filenames in the updated
README so users know whether to expect them in this package or fetch them
elsewhere.

In `@rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc`:
- Around line 8-9: Update the wording that claims "pairs with a synced Claude
Code CLAUDE.md + .claude/settings.json hooks" to accurately reflect that those
files are not included in this PR: either add CLAUDE.md and
.claude/settings.json to the contribution or change the sentence in
rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc to state
they live in an external repository and must be obtained separately (or linked),
and mention where to get them; locate the exact phrase "pairs with a synced
Claude Code CLAUDE.md + .claude/settings.json hooks" and edit it accordingly so
the README and file description match the actual contents of the PR.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3d66252-14f7-4d57-aa48-e2c373198847

📥 Commits

Reviewing files that changed from the base of the PR and between b044f95 and d46097e.

📒 Files selected for processing (2)
  • README.md
  • rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc

Comment thread README.md Outdated
Comment thread rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc Outdated
Addresses CodeRabbit review on PR PatrickJS#308: README + .mdc implied the Claude
Code hook files (CLAUDE.md, .claude/settings.json) ship with this entry.
They do not — they live in the linked companion repo. Reworded both to say
the rules work standalone in Cursor and the hooks are optional, linked.
@iPythoning

Copy link
Copy Markdown
Author

Thanks @coderabbitai — addressed in the latest commit. Both the README entry and the .mdc now state the rules work standalone in Cursor, and that the Claude Code enforcement hooks (CLAUDE.md + .claude/settings.json) are an optional companion living in the linked repo, not bundled in this entry. No overclaim about what ships here.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@iPythoning: That's a clean resolution — the standalone Cursor usage is clear upfront, and the Claude Code hooks are correctly framed as an optional companion rather than something bundled here. The separation of concerns is well communicated now. Thanks for the update!

(◕‿◕✿) 🐇

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
README.md (1)

88-88: ⚡ Quick win

Clarify or link to the companion repository for enforcement hooks.

The phrase "the linked repo" is ambiguous because the only link on this line points to the .mdc file in this repository, not to the companion repository where the enforcement hooks actually live. Users interested in the optional hooks must click through to the .mdc file to discover the companion repo URL.

Consider either:

  • Adding a direct inline reference: (get hooks from [this companion repo](https://github.com/iPythoning/claude-cursor-config-nextjs)), or
  • Rephrasing to: "Works standalone in Cursor; optional Claude Code hooks (Prettier/ESLint on edit, tsc --noEmit on stop) available in the source repo."

The current wording is technically correct but could be more user-friendly.

📝 Suggested clarification
-- [Next.js + TypeScript (Annotated + Enforced)](https://github.com/PatrickJS/awesome-cursorrules/blob/main/rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc) - Next.js + TypeScript rules where every rule states *why* it exists. Works standalone in Cursor; the linked repo also ships optional Claude Code hooks (Prettier/ESLint on edit, `tsc --noEmit` on stop) so the rules run, not just suggest.
+- [Next.js + TypeScript (Annotated + Enforced)](https://github.com/PatrickJS/awesome-cursorrules/blob/main/rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc) - Next.js + TypeScript rules where every rule states *why* it exists. Works standalone in Cursor; optional Claude Code hooks (Prettier/ESLint on edit, `tsc --noEmit` on stop) available in the [source repo](https://github.com/iPythoning/claude-cursor-config-nextjs).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 88, Update the README entry for "Next.js + TypeScript
(Annotated + Enforced)" to clarify where the optional enforcement hooks live by
adding an explicit inline reference or rephrasing; either append a parenthetical
like "(get hooks from this companion repo:
https://github.com/iPythoning/claude-cursor-config-nextjs)" or change the
sentence to "Works standalone in Cursor; optional Claude Code hooks
(Prettier/ESLint on edit, `tsc --noEmit` on stop) are available in the
source/companion repository" so users can find the enforcement hooks without
opening the .mdc file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@README.md`:
- Line 88: Update the README entry for "Next.js + TypeScript (Annotated +
Enforced)" to clarify where the optional enforcement hooks live by adding an
explicit inline reference or rephrasing; either append a parenthetical like
"(get hooks from this companion repo:
https://github.com/iPythoning/claude-cursor-config-nextjs)" or change the
sentence to "Works standalone in Cursor; optional Claude Code hooks
(Prettier/ESLint on edit, `tsc --noEmit` on stop) are available in the
source/companion repository" so users can find the enforcement hooks without
opening the .mdc file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 081e6d76-f317-4278-a83b-b8492635811e

📥 Commits

Reviewing files that changed from the base of the PR and between d46097e and 1f90808.

📒 Files selected for processing (2)
  • README.md
  • rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc
✅ Files skipped from review due to trivial changes (1)
  • rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc

@iPythoning

Copy link
Copy Markdown
Author

Addressed the nitpick — the entry now links the companion repo inline so readers can find the optional hooks without opening the .mdc. Thanks @coderabbitai.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@iPythoning: Perfect — surfacing the companion repo link inline in the README means readers get everything they need at a glance without having to dig into the .mdc. Nice clean finish. Thanks for the quick follow-through! 🐇✨


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
README.md (1)

88-88: 💤 Low value

Consider aligning entry format with existing Next.js entries.

The entry uses Next.js + TypeScript (Annotated + Enforced) with a plus sign, which differs from the surrounding entries that use the pattern Next.js (Spec1, Spec2). While this doesn't break functionality, consistent formatting improves scannability.

📝 Optional format alignment

Consider reformatting to match the established pattern:

-- [Next.js + TypeScript (Annotated + Enforced)](https://github.com/PatrickJS/awesome-cursorrules/blob/main/rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc) - Next.js + TypeScript rules where every rule states *why* it exists. Works standalone in Cursor; optional Claude Code hooks (Prettier/ESLint on edit, `tsc --noEmit` on stop) are available in the [companion repo](https://github.com/iPythoning/claude-cursor-config-nextjs) so the rules run, not just suggest.
+- [Next.js (TypeScript - Annotated & Enforced)](https://github.com/PatrickJS/awesome-cursorrules/blob/main/rules/nextjs-typescript-annotated-enforced-cursorrules-prompt-file.mdc) - Next.js + TypeScript rules where every rule states *why* it exists. Works standalone in Cursor; optional Claude Code hooks (Prettier/ESLint on edit, `tsc --noEmit` on stop) are available in the [companion repo](https://github.com/iPythoning/claude-cursor-config-nextjs) so the rules run, not just suggest.

However, if the "+" emphasizes the tight integration between Next.js and TypeScript for this specific ruleset, keeping the current format is also acceptable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 88, Update the README entry that currently reads "Next.js
+ TypeScript (Annotated + Enforced)" to match the surrounding Next.js entry
format (e.g., "Next.js (TypeScript, Annotated, Enforced)") so the style is
consistent; locate the exact string "Next.js + TypeScript (Annotated +
Enforced)" in README.md and replace it with the chosen parenthetical style while
preserving the link and the companion repo sentence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@README.md`:
- Line 88: Update the README entry that currently reads "Next.js + TypeScript
(Annotated + Enforced)" to match the surrounding Next.js entry format (e.g.,
"Next.js (TypeScript, Annotated, Enforced)") so the style is consistent; locate
the exact string "Next.js + TypeScript (Annotated + Enforced)" in README.md and
replace it with the chosen parenthetical style while preserving the link and the
companion repo sentence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0101b546-6905-40ed-9878-454bd0fc629d

📥 Commits

Reviewing files that changed from the base of the PR and between 1f90808 and e008902.

📒 Files selected for processing (1)
  • README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant