Skip to content

Add path-scoped rules, mechanical enforcement, and React no-useEffect rule#2

Merged
jrenaldi79 merged 8 commits intomainfrom
claude/evaluate-harness-system-Y3taF
Mar 23, 2026
Merged

Add path-scoped rules, mechanical enforcement, and React no-useEffect rule#2
jrenaldi79 merged 8 commits intomainfrom
claude/evaluate-harness-system-Y3taF

Conversation

@jrenaldi79
Copy link
Copy Markdown
Owner

@jrenaldi79 jrenaldi79 commented Mar 23, 2026

Summary

Extracts path-scoped rules, adds mechanical enforcement from competitive analysis, and improves README framing.

Path-scoped rules extraction

  • Extract inline rules from global-claude.md and project-claude.md into dedicated .claude/rules/ files: tdd.md, code-quality.md, testing.md, typescript.md
  • Each rule uses globs: frontmatter for automatic activation by file pattern
  • Templates slimmed down (~185 lines removed, ~616 lines added across new files)

Mechanical enforcement improvements (from Factory.ai analysis)

  • Add check-test-colocation.js — blocks commits when src/ files lack matching test files
  • Add max-lines-per-function and no-console to ESLint base config
  • Wire test colocation check into pre-commit hook
  • Add competitive-analysis.md reference doc

React no-useEffect rule

  • Add templates/rules/react.md — bans direct useEffect, teaches 5 replacement patterns
  • install-enforcement.js now accepts --framework flag, only installs react.md for vite/nextjs
  • SKILL.md Phase 4 updated to pass --framework through

README updates

  • Credit Factory.ai and Akshay Kothari as sources
  • Add Karpathy's "agents don't listen" quote to frame the enforcement philosophy
  • Add check-test-colocation.js to customization table

Test plan

  • Run /setup with --framework=vite — verify all 5 rule files including react.md are copied
  • Run /setup with --framework=express — verify react.md is not copied
  • Verify pre-commit hook runs test colocation check
  • Verify ESLint config includes max-lines-per-function and no-console
  • Confirm existing test in tests/scripts/install-enforcement.test.js still passes

Summary by CodeRabbit

  • New Features

    • Test colocation enforcement: automatically verifies test files exist for source files during commits.
    • Path-scoped rules system: rules now auto-load based on file patterns for more targeted guidance.
    • Enhanced ESLint configuration: added function length limits (50 lines), console usage restrictions, and default export prohibitions.
  • Documentation

    • New rule templates for React, TypeScript, Testing, Code Quality, and TDD workflows.
    • Restructured guidance with clearer rule hierarchy and auto-loaded rule enforcement.

claude added 8 commits March 23, 2026 18:38
Move path-specific guidance (TDD, code quality, testing patterns,
TypeScript conventions) from CLAUDE.md templates into dedicated
.claude/rules/ files with globs: YAML frontmatter for native Claude
Code path-scoping. Rules only load when Claude works on matching files,
reducing context bloat.

- Add 4 rule templates: tdd.md, code-quality.md, testing.md, typescript.md
- Slim global-claude.md from ~308 to ~241 lines (removes ~67 lines)
- Slim project-claude.md by removing duplicated quality rules
- Add "Adding New Rules" section with enforcement hierarchy guidance
- Add "Rule Enforcement Hierarchy" principle to operating principles
- Update install-enforcement.js to copy rules/ to target .claude/rules/
- Update SKILL.md to document rules installation for all stacks

https://claude.ai/code/session_012hMekSRkdWfhdBKvpQYv7Z
- Add rules/ directory to file tree with glob descriptions
- Add Rules step to setup table
- Update Two-Tier section to three-layer system (CLAUDE.md + rules/ + docs/)
- Add "What Belongs Where" guidance for rules vs CLAUDE.md vs docs/
- Update progressive disclosure to four tiers (1, 1.5, 2, 3)
- Expand "Keep in CLAUDE.md" table with rules/ column
- Update "Linters over instructions" best practice row

https://claude.ai/code/session_012hMekSRkdWfhdBKvpQYv7Z
Add Factory.ai and Akshay Kothari (Notion COO) to the industry best
practices section. Modify existing rows rather than duplicating: Factory
added to "Linters over instructions", Akshay added to "Mechanical
enforcement". One new row for "Grep-ability" (genuinely new concept).

Add .claude/rules/ history note documenting v2.0.64 introduction.

Save full competitive analysis as reference file with honest gap
assessment (what's worth doing vs. what's theater).

https://claude.ai/code/session_012hMekSRkdWfhdBKvpQYv7Z
- ESLint: add max-lines-per-function (50), no-console, import/no-default-export
- New check-test-colocation.js script blocks commits missing colocated tests
- Expand rules/typescript.md with named exports and absolute imports rationale
- Update pre-commit hook (now 6 checks), install script, README, and tests

https://claude.ai/code/session_012hMekSRkdWfhdBKvpQYv7Z
His complaint — agents bloat abstractions, copy-paste code, and ignore
style guidance in AGENTS.md — is the real-world case for why mechanical
enforcement matters more than advisory prose. Added to source bullet
and "Linters over instructions" row.

https://claude.ai/code/session_012hMekSRkdWfhdBKvpQYv7Z
Stronger hook: the person who coined "context engineering" admits
agents ignore his instructions. The answer isn't better prose —
it's mechanical enforcement.

https://claude.ai/code/session_012hMekSRkdWfhdBKvpQYv7Z
…extjs

Bans direct useEffect in favor of five replacement patterns (derived state,
data-fetching libraries, event handlers, useMountEffect, key props).
install-enforcement.js now accepts --framework flag and only copies react.md
for React-based frameworks.

Inspired by: https://gist.github.com/alvinsng/5dd68c6ece355dbdbd65340ec2927b1d

https://claude.ai/code/session_012hMekSRkdWfhdBKvpQYv7Z
@jrenaldi79 jrenaldi79 merged commit 8ab6e5c into main Mar 23, 2026
1 check passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 23, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8e630f78-2989-4f50-9306-8aa801378e2d

📥 Commits

Reviewing files that changed from the base of the PR and between da93c26 and 4d61af8.

📒 Files selected for processing (15)
  • README.md
  • skills/setup/SKILL.md
  • skills/setup/references/competitive-analysis.md
  • skills/setup/scripts/hooks/pre-commit
  • skills/setup/scripts/install-enforcement.js
  • skills/setup/scripts/lib/check-test-colocation.js
  • skills/setup/templates/eslint-base.js
  • skills/setup/templates/global-claude.md
  • skills/setup/templates/project-claude.md
  • skills/setup/templates/rules/code-quality.md
  • skills/setup/templates/rules/react.md
  • skills/setup/templates/rules/tdd.md
  • skills/setup/templates/rules/testing.md
  • skills/setup/templates/rules/typescript.md
  • tests/scripts/install-enforcement.test.js

📝 Walkthrough

Walkthrough

This PR introduces a path-scoped rules system within .claude/rules/ that auto-loads based on file globs, adds test colocation enforcement, updates the install workflow to copy rules templates, expands ESLint configuration, and refactors global CLAUDE.md templates to delegate specific guidance to the new rules structure.

Changes

Cohort / File(s) Summary
Documentation & References
README.md, skills/setup/SKILL.md, skills/setup/references/competitive-analysis.md
Updated README with context-engineering framing around mechanical enforcement and path-scoped rules. Enhanced SKILL.md with --framework parameter and new rules auto-loading via .claude/rules/. Added new competitive-analysis.md reference comparing framework capabilities against Claude Code and Factory.ai approaches.
Enforcement Scripts & Hooks
skills/setup/scripts/hooks/pre-commit, skills/setup/scripts/install-enforcement.js, skills/setup/scripts/lib/check-test-colocation.js
Updated pre-commit hook to add test colocation check as step 4. Extended install-enforcement.js with --framework flag and new copyRules() function to scaffold framework-scoped rules (gating react.md for Vite/Next.js). Added check-test-colocation.js script that enforces colocated test files via git hooks with configurable glob patterns.
Global Templates
skills/setup/templates/eslint-base.js, skills/setup/templates/global-claude.md, skills/setup/templates/project-claude.md
Added ESLint rules for function line limits (50), console usage restrictions, and no default exports. Refactored global-claude.md to delegate TDD and code-quality rules to .claude/rules/ with new "Rule Enforcement Hierarchy" section. Simplified project-claude.md by removing in-file size/complexity constraints and pointing to .claude/rules/code-quality.md.
Path-Scoped Rules Templates
skills/setup/templates/rules/code-quality.md, skills/setup/templates/rules/react.md, skills/setup/templates/rules/tdd.md, skills/setup/templates/rules/testing.md, skills/setup/templates/rules/typescript.md
Added five new rules template files with glob-based frontmatter for auto-loading: code-quality.md (file/function length limits, doc sync), react.md (useEffect alternatives), tdd.md (test-first workflow), testing.md (patterns and review checklist), and typescript.md (naming conventions, imports/exports).
Tests
tests/scripts/install-enforcement.test.js
Updated enforcement scripts test to expect check-test-colocation.js, increasing expected script count from 5 to 6.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Hop by hop, rules now bloom,
In .claude/rules/ find your room,
Path-scoped globs guide the way,
Tests colocate, hooks obey,
Enforcement springs forth—no more gloom! 🌱

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/evaluate-harness-system-Y3taF

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.

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.

2 participants