Need AI Training/Help?CloudYeti.io/meet
MarkdownMe
Agent instruction guide

CLAUDE.md Repo Boundaries and Rules

Write CLAUDE.md rules that tell agents which files to edit, which files to avoid, and how to handle dirty worktrees safely.

Direct answer

CLAUDE.md should make repo boundaries explicit: which folders are source, generated, docs, infra, or deploy output; which files should not be edited; how to handle dirty worktrees; and what verification is required before final. Boundary rules prevent agents from making broad unrelated changes just to satisfy a narrow task.

Open CLAUDE.md Reviewer

When to use this

  • The repo has generated output, vendored files, migrations, or deploy artifacts.
  • Agents keep touching unrelated files.
  • Multiple people or agents work in the same worktree.

Steps

  1. Name source folders, generated folders, docs folders, and deploy output.
  2. List files or directories that require extra care.
  3. Add dirty-worktree rules.
  4. Define the expected edit scope for normal tasks.
  5. Run the reviewer and tighten any vague boundaries.

Example review focus

CLAUDE.md excerpt
# CLAUDE.md

## Project
Next.js static export.

## Rules
- Follow existing patterns.
- Be safe with files.
What to fix
Replace vague safety language with concrete boundaries: source lives in `src/`, static files in `public/`, export output in `out/`, and generated build artifacts should not be manually edited. Add `do not revert unrelated user changes` and `stage only files related to the task`.

Common mistakes

  • Do not say be careful when you can name the exact file boundary.
  • Do not let generated output and source files look equally editable.
  • Do not forget dirty-worktree rules for shared workspaces.

FAQ

What is a repo boundary in CLAUDE.md?
A repo boundary tells the agent where source files live, what is generated, what is owned by another system, and what should not be changed during normal tasks.
Should CLAUDE.md mention dirty git status?
Yes. Shared worktrees need rules like do not revert unrelated changes and stage only task-related files.
Can this reduce accidental refactors?
Yes. Clear boundaries make it easier for the agent to keep edits scoped to the requested behavior.

Related CLAUDE.md guides