published fresh until

Claude Code: how do I make project rules load and apply?

Summary Write concise, concrete project instructions, confirm which files load, and use the correct Cursor activation mode where applicable. Use a PreToolUse hook for actions that must be blocked; instruction text guides behavior but is not an enforced boundary.

Not for cross-session memory or a universal guarantee that instruction text will be followed.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: run /context all to check loaded CLAUDE.md files before changing their wording. Memory guide

Short answer

Keep instructions concrete and concise. CLAUDE.md supplies context; a PreToolUse hook can block a matching tool call. Memory guide, Hooks guide In Cursor, rule inclusion depends on file format and activation metadata. Cursor rules

Choose / don't choose

  • CLAUDE.md or AGENTS.md: choose for project guidance; don't assume both load by default when both exist. Memory guide
  • Cursor project rules: choose for scoped instructions; don't put a plain .md file in .cursor/rules and expect rule activation. Cursor rules
  • PreToolUse: choose for a deterministic block before a tool runs; don't confuse an instruction with enforcement. Hooks guide

Settings that matter

Setting or flagValue / defaultApplies toSource
Project instructionsclaude-md-or-agents-md by default; claude-md-and-agents-md loads bothClaude Code Project instructions settingMemory guide
@AGENTS.mdImport shared instructions from CLAUDE.mdClaude CodeMemory guide
alwaysApplytrue: always included, ignoring description and globsCursor .mdc ruleCursor rules
alwaysApply: false with globsAttach when a matching file is in contextCursor .mdc ruleCursor rules
Hook exit status2 with reason on stderr blocks a PreToolUse callClaude Code command hookHooks guide

Order of operations

1. Write specific commands and conventions, group related rules, and remove contradictions; target under 200 lines per CLAUDE.md. Memory guide 2. Check the loaded files. If using shared AGENTS.md through CLAUDE.md, use an import rather than prose asking for a read. Memory guide 3. For Cursor, store project rules as .mdc files in .cursor/rules, then choose always, file-scoped, description-based or manual activation. Cursor rules 4. Register a PreToolUse command hook for the actions requiring a block. Read its JSON input from stdin and return the blocking outcome for matching calls. Hooks guide

Known failures and fixes

SymptomCauseFixSource
Shared instructions missingCLAUDE.md takes precedence under the default selectionSelect both files or import AGENTS.mdMemory guide
Cursor rule ignoredPlain .md in the project-rules directoryUse .mdc, or plain AGENTS.md as the alternativeCursor rules
Hook has no effectNot registered or matcher does not matchInspect /hooks and check case-sensitive tool matchingHooks guide

Missing

  • How much will these instructions improve adherence in your repository? The sources give loading and enforcement behavior, not a project-specific adherence measurement.
  • Which hook conditions cover every dangerous action in your project? The guide's examples do not establish that coverage.

Checked

2026-11-23: read Claude Code memory, Claude Code hooks, and Cursor rules.

Started from a post by @WhatWorks editors, packaged by the editor.

Subjects

More in agents.md

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code: how do I make project rules load and apply?
Summary: Write concise, concrete project instructions, confirm which files load, and use the correct Cursor activation mode where applicable. Use a PreToolUse hook for actions that must be blocked; instruction text guides behavior but is not an enforced boundary.
Copy for agent
get the whatworks thread case-write-project-rules-file-agent-follows-claude-md-agents-md-cursor-hooks and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread case-write-project-rules-file-agent-follows-claude-md-agents-md-cursor-hooks
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp