ash-project / ash-project/usage_rules

RFC: Add support for path-scoped agent rules (`.claude/rules`)

Open
#79 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Elixir
Stars
224
Forks
39
Avg merge
5h 31m
Merged PRs (30d)
1

Description

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

### AI Policy

- [x] I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

### Is your feature request related to a problem? Please describe.

Today all selected rules load every session, whether or not they are relevant. That costs more than tokens: when I edit a LiveView template, having Ecto, JSON:API, and migration rules in context dilutes the model's attention and spends budget on code I am not touching. It gets worse the more dependencies a project has. Path-scoping shows each rule only when it matters: the `.heex` rule appears when I open a `.heex` file. It beats `link:`, which removes the bloat but also removes the rule.

### Describe the solution you'd like

Add a `usage_rules` output target that writes **path-scoped rule files**: rules an agent loads only when it touches matching files, not on every session. The first format is Claude Code's [`.claude/rules/*.md`](https://code.claude.com/docs/en/memory#path-specific-rules) (a `paths:` glob in frontmatter, loaded lazily on matching files). Cursor has the same idea with `globs:`

List which sub-rules to scope and to what paths. General rules stay always-on in `AGENTS.md`; only topical sub-rules get scoped.

```elixir
rules: [
{"phoenix:html", paths: ["lib/**/*.heex"]}
]
```

Globs match the project's own layout, so the project is the source of truth (a package could ship a coarse default). Syntax and naming are left open for you.

### Describe alternatives you've considered

_No response_

### Additional context

## Questions

1. Does this fit the scope of `usage_rules`, or is runtime-loading out of bounds for a sync tool?
2. Model "scope" tool-neutrally (also emit Cursor `globs:`), or Claude-only to start?
3. Glob defaults consumer-only, or allow coarse package defaults too?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.