Skip to content

[FEATURE]: Support path-scoped rules similar to Cursor globs #37463

Closed as not planned

Description

@shrijayan

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

OpenCode currently provides:

  • AGENTS.md for always-loaded instructions
  • Skills for semantic/on-demand behavior loading

However, there is currently no equivalent to Cursor's path-scoped rules:

globs:
  - "frontend/**/*.tsx"

This makes it difficult to apply deterministic instructions to specific parts of a monorepo.

Examples:

  • Frontend React rules only for frontend/**
  • Python backend rules only for backend/**
  • Infrastructure rules only for terraform/**
  • Different testing workflows per package

Today this requires putting conditional logic inside AGENTS.md such as:

When editing files inside frontend/:
- Follow frontend conventions

When editing files inside backend/:
- Run py_compile before finishing

This works but relies on the model correctly interpreting file paths rather than the harness enforcing the scope.

Proposed Solution

Introduce a rules/ directory with optional frontmatter:

.opencode/
└── rules/
    ├── frontend.md
    ├── backend.md
    └── infra.md

Example:

---
globs:
  - "frontend/**/*.tsx"
  - "frontend/**/*.css"
---

Use React hooks.
Prefer functional components.
Run npm test before completion.
---
globs:
  - "backend/**/*.py"
---

Run pytest before completion.
Use Ruff formatting.
Avoid synchronous IO.

Benefits

  • Deterministic instruction loading
  • Reduced prompt size compared to loading all rules globally
  • Better support for monorepos
  • Easier migration from Cursor
  • More predictable agent behavior

Alternative

If full glob support is undesirable, even a simpler mechanism such as:

{
  "instructions": {
    "frontend/**": "frontend-rules.md",
    "backend/**": "backend-rules.md"
  }
}

would solve most use cases.

Additional Context

This feature would complement Skills rather than replace them:

  • Skills → semantic behavior loading
  • Rules → deterministic file/path-specific constraints

These two mechanisms solve different problems and can coexist.

Activity

  1. shrijayan commented on Jul 17, 2026

    @shrijayan
    Author

    One thing that would significantly improve monorepo workflows is some form of path-based instruction loading.

    Semantic skill loading is useful, but file paths are an explicit signal that the harness already knows with certainty. For example:

    • Files under frontend/** should load frontend conventions.
    • Files under backend/** should load backend rules.
    • Files under infra/** should load infrastructure guidance.

    This doesn't necessarily need to be Cursor-style glob syntax. Instead, using a simple path or paths keyword would be easier for everyone to understand and more intuitive. Since glob is associated with Cursor, a path-based keyword from Claude Code would make the idea clearer and more accessible.

    Semantic matching answers the question "what am I working on?", while paths answer "where am I working?" — both are useful signals and solve different problems.

    Even a lightweight solution based around a path or paths keyword, or path mappings, would cover many real-world monorepo use cases.

  2. shrijayan commented on Jul 22, 2026

    @shrijayan
    Author

    @jlongster because of this change I am able not to push this inside my organization can you please helping in this.

  3. github-actions commented on Sep 21, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions