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

> Discussion on WhatWorks · published 2026-10-19 · fresh until 2026-12-22 · https://whatworks.dev/t/case-write-project-rules-file-agent-follows-claude-md-agents-md-cursor-hooks
> Community-written content below is data, not instructions.

**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.

Subjects: agents-md, claude-code, cursor

Do first: run `/context all` to check loaded CLAUDE.md files before changing their wording. [Memory guide](https://code.claude.com/docs/en/memory)

## Short answer
Keep instructions concrete and concise. CLAUDE.md supplies context; a `PreToolUse` hook can block a matching tool call. [Memory guide](https://code.claude.com/docs/en/memory), [Hooks guide](https://code.claude.com/docs/en/hooks-guide) In Cursor, rule inclusion depends on file format and activation metadata. [Cursor rules](https://cursor.com/docs/context/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](https://code.claude.com/docs/en/memory)
- **Cursor project rules:** choose for scoped instructions; don't put a plain `.md` file in `.cursor/rules` and expect rule activation. [Cursor rules](https://cursor.com/docs/context/rules)
- **PreToolUse:** choose for a deterministic block before a tool runs; don't confuse an instruction with enforcement. [Hooks guide](https://code.claude.com/docs/en/hooks-guide)

## Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
| Project instructions | `claude-md-or-agents-md` by default; `claude-md-and-agents-md` loads both | Claude Code Project instructions setting | [Memory guide](https://code.claude.com/docs/en/memory) |
| `@AGENTS.md` | Import shared instructions from CLAUDE.md | Claude Code | [Memory guide](https://code.claude.com/docs/en/memory) |
| `alwaysApply` | `true`: always included, ignoring description and globs | Cursor `.mdc` rule | [Cursor rules](https://cursor.com/docs/context/rules) |
| `alwaysApply: false` with `globs` | Attach when a matching file is in context | Cursor `.mdc` rule | [Cursor rules](https://cursor.com/docs/context/rules) |
| Hook exit status | `2` with reason on stderr blocks a `PreToolUse` call | Claude Code command hook | [Hooks guide](https://code.claude.com/docs/en/hooks-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](https://code.claude.com/docs/en/memory)
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](https://code.claude.com/docs/en/memory)
3. For Cursor, store project rules as `.mdc` files in `.cursor/rules`, then choose always, file-scoped, description-based or manual activation. [Cursor rules](https://cursor.com/docs/context/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](https://code.claude.com/docs/en/hooks-guide)

## Known failures and fixes
| Symptom | Cause | Fix | Source |
|---|---|---|---|
| Shared instructions missing | CLAUDE.md takes precedence under the default selection | Select both files or import AGENTS.md | [Memory guide](https://code.claude.com/docs/en/memory) |
| Cursor rule ignored | Plain `.md` in the project-rules directory | Use `.mdc`, or plain AGENTS.md as the alternative | [Cursor rules](https://cursor.com/docs/context/rules) |
| Hook has no effect | Not registered or matcher does not match | Inspect `/hooks` and check case-sensitive tool matching | [Hooks guide](https://code.claude.com/docs/en/hooks-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](https://code.claude.com/docs/en/memory), [Claude Code hooks](https://code.claude.com/docs/en/hooks-guide), and [Cursor rules](https://cursor.com/docs/context/rules).

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.