Skip to content

feat: add context filtering to exclude instruction files#17980

Open
lbrsilva wants to merge 1 commit intoanomalyco:devfrom
lbrsilva:dev
Open

feat: add context filtering to exclude instruction files#17980
lbrsilva wants to merge 1 commit intoanomalyco:devfrom
lbrsilva:dev

Conversation

@lbrsilva
Copy link
Copy Markdown

@lbrsilva lbrsilva commented Mar 17, 2026

Issue for this PR

Some projects have instruction files (like AGENTS.md) with directives specific to other AI tools (e.g., Claude Code). These files can interfere with opencode's behavior and cause confusion in context understanding. With this change, users can exclude such files from being loaded.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Some projects have instruction files like AGENTS.md or CLAUDE.md with directives specific to other AI tools. These files can interfere with opencode and cause unexpected behavior.
This PR adds a context configuration option to exclude specific files from automatic context loading:

{
  ...
  "context": {
    "exclude": ["AGENTS.md", "CLAUDE.md"]
  }
  ...
}

The feature uses glob patterns via minimatch to match filenames, relative paths, and full paths. It applies to both instruction files and external skill directories.

How did you verify your code works?

Tested locally with various glob patterns (e.g., *.md, private/**) to verify files are excluded from instruction discovery and external skill scanning.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
    If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@lbrsilva lbrsilva force-pushed the dev branch 4 times, most recently from 621793e to 7507bde Compare April 9, 2026 22:06
Add context.exclude config option to filter which instruction files
and external skill directories are automatically loaded.

- Add ContextMap utility returning Effect directly
- Integrate in instruction.ts to filter paths and skip ignored files
- Integrate in skill/index.ts to filter external skill directories

Example config:
{
  "context": {
    "exclude": ["AGENTS.md", "CLAUDE.md"]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant