agentleFS
andr-caandr-ca/agentharness/.cursor/rules/file-placement-policy.mdc

agentharness / rules

Cursor rule1 starsChanged 2 months agoMITView on GitHub

Use before creating any new file or directory in an established project — covers guarded root paths, docs/, src/, conf/, the allowed-additions escape hatch, and how to ask for permission. Load this skill at the start of every session in a project that has .agentharness-guarded-paths.json.

We split this file-placement-policy.mdc into the rules it gives an agent

7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Load this skill at session start: if the project has .agentharness-guarded-paths.json.

    line 7
  2. Distinctive:

    Before creating any new file or directory, check whether the target location is guarded:

    line 12
  3. Distinctive:

    If the path is guarded: stop and ask the user for permission.

    line 24
  4. Very specific:

    Wait for an explicit yes/ok/go ahead response.

    line 37
  5. Very specific:

    Add the approved path to .agentharness-allowed-additions.txt:

    line 41
  6. Very specific:

    If .agentharness-guarded-paths.json doesn't exist:

    line 51
  7. Very specific:

    If accepted, create the structure and generate the config: python3 tools/analyze_structure.py .

    line 55

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
file-placement-policy.mdc
---
description: "Use before creating any new file or directory in an established project — covers guarded root paths, docs/, src/, conf/, the allowed-additions escape hatch, and how to ask for permission. Load this skill at the start of every session in a project that has .agentharness-guarded-paths.json."
---

## File Placement Policy

**Load this skill at session start** if the project has
`.agentharness-guarded-paths.json`. Read the file before touching anything.

### Rule: check before creating

Before creating any new file or directory, check whether the target
location is guarded:

```bash
python3 -c "
import json
d = json.load(open('.agentharness-guarded-paths.json'))
print('Root guarded:', d['guard_root_level_new_items'])
print('Guarded dirs:', d['guarded_dirs'])
"
```

If the path is guarded: **stop and ask the user for permission.**

### What counts as guarded

- Any new file at the root level (when `guard_root_level_new_items: true`)
- Any file under `src/`, `docs/`, `tests/`, `conf/`, `logs/`, etc.
- Any root-level config file already listed in `guarded_root_files`

### Asking for permission

> "I need to create `docs/architecture/NEW_SECTION.md` to document X.
> This is in the guarded `docs/` directory. May I proceed?"

Wait for an explicit `yes`/`ok`/`go ahead` response.

### After getting permission: record it

Add the approved path to `.agentharness-allowed-additions.txt`:

```bash
echo "docs/architecture/NEW_SECTION.md" >> .agentharness-allowed-additions.txt
```

The pre-commit hook reads this file to allow the commit.

### No guarded-paths file = early-stage project

If `.agentharness-guarded-paths.json` doesn't exist:

1. Run: `python3 tools/analyze_structure.py . --recommend`
2. Present the recommendations to the user.
3. If accepted, create the structure and generate the config:
   `python3 tools/analyze_structure.py . --output .agentharness-guarded-paths.json`

### Pre-commit enforcement

The hook at `tools/check-file-placement.sh` runs automatically before
every commit. If a staged file is in a guarded location and not in
`.agentharness-allowed-additions.txt`, the commit is blocked with a
clear message.

### Reference

Full protocol: `patterns/file-placement-policy/POLICY.md`
Analyzer: `tools/analyze_structure.py`
Hook: `tools/check-file-placement.sh`

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.