Skip to content

Directory-scoped rules system — per-path instruction files with glob support #83

Description

@canoo

Problem

NEXUS currently uses a single monolithic instruction file applied to the entire project. The AI coding tool ecosystem has moved toward scoped rules — instructions that apply only to specific directories or file types.

Cursor's MDC format and GitHub Copilot's applyTo globs are the leading implementations of this pattern (r/cursor, April 2026). A single global rules file is increasingly at odds with where tooling is heading.

Solution

Support a scoped rules directory in .nexus/rules/:

.nexus/
  rules/
    global.md          # applies to all files (projected to all tools)
    src/api.md         # applies only when working in src/api/
    src/ui.md          # applies only when working in src/ui/
    tools/tui.md       # applies when editing the TUI source

Each file supports YAML frontmatter for scope definition:

---
applyTo: "src/api/**"
tools: [claude-code, cursor, copilot]
---
# API Rules
Always validate request bodies at the boundary...

Projection behaviour

  • global.md → projected to all tools as the base instruction
  • Scoped files → projected to tools that support glob scoping (Cursor MDC, Copilot instructions)
  • For tools without glob support (Windsurf, Cline) → scoped rules are appended to the global file with a section header

Dependencies

Requires #17 (driver system) and #80 (AGENTS.md projection).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions