# How to exclude Cursor rules in subdirectories?

**URL:** <https://forum.cursor.com/t/how-to-exclude-cursor-rules-in-subdirectories/75432>\
**Category:** Help\
**Created:** [April 5, 2025, 1:08pm UTC](https://forum.cursor.com/t/how-to-exclude-cursor-rules-in-subdirectories/75432 "2025-04-05T13:08:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timelytree](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/timelytree/32/44455_2.png) [@timelytree](https://forum.cursor.com/u/timelytree)\
**Post date:** [April 5, 2025, 1:08pm UTC](https://forum.cursor.com/t/how-to-exclude-cursor-rules-in-subdirectories/75432/1 "2025-04-05T13:08:41Z")

</div>

Hi everyone 👋

Is it possible to selectively apply Cursor rules to some directories and exclude them from nested subdirectories?

Okay so here’s my directory setup, slimmed down for example purposes:

```txt
packages
  client
    components
      button.vue
    assets
      main.css
    special
      a-file.ts

```

I created two Cursor rules, with `.mdc` extensions in `.cursor/rules/*`. Here they are:

**rule-1.mdc**

```mdc
---
description: 
globs: packages/client/ **/*,!packages/client/special/** /*
alwaysApply: false
---

Apply rule to client dir but not to special dir

```

**rule-2.mdc**

```mdc
---
description: 
globs: packages/special/**/*
alwaysApply: false
---

Only apply rule to special dir

```

–

**Expected behaviour**

- Opening any file in the `client` dir and all of its subdirs/files (_excluding `special`_) would _only_ attach `rule-1.mdc`
- Opening any file in `special` dir and all of its subdirs/files would _only_ attach `rule-2.mdc`

**What actually happens**

- `rule-2.mdc` for the `special` dir and files is attached as expected
- `rule-1.mdc` is never attached anywhere

–

I also tried the following syntax and it didn’t work:

**rule-1.mdc**

```mdc
---
description: 
globs:
  - packages/client/**/*
  - !packages/client/special/**/*
alwaysApply: false
---

Always do this and that

```

Thanks in advance for the help 🙂

---

<div class="post-metadata">

**Author:** ![yaireo](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/yaireo/32/4017_2.png) [@yaireo](https://forum.cursor.com/u/yaireo)\
**Post date:** [August 25, 2025, 11:03am UTC](https://forum.cursor.com/t/how-to-exclude-cursor-rules-in-subdirectories/75432/2 "2025-08-25T11:03:21Z")

</div>

I am also interested. I’m surprised no one answered to such a basic and important question

---

<div class="post-metadata">

**Author:** ![orbiri-ns](https://avatars.discourse-cdn.com/v4/letter/o/838e76/32.png) [@orbiri-ns](https://forum.cursor.com/u/orbiri-ns)\
**Post date:** [December 2, 2025, 11:09am UTC](https://forum.cursor.com/t/how-to-exclude-cursor-rules-in-subdirectories/75432/3 "2025-12-02T11:09:30Z")

</div>

Did someone find an answer? 🙏🏼
