Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

Commands can now specify selectors in their frontmatter to automatically pull in required rules (database drivers, auth libraries, MCPs, etc.) when invoked. Command selectors combine with task and CLI selectors using OR logic.

Changes

  • Added Selectors field to CommandFrontMatter - Commands declare their rule dependencies
  • Extract mergeSelectors helper - Eliminates duplication between task/command selector handling
  • Updated findCommand - Processes command selectors before rule collection

Example

Command file with selectors:

---
selectors:
  database: postgres
  feature: auth
---

Configure PostgreSQL with authentication.

When a task uses /setup-db, rules tagged with database: postgres or feature: auth are automatically included without requiring every task to manually specify them.

Combined with task selectors:

---
selectors:
  env: production
---

Deploy to production. /setup-db

Rules matching env: production OR database: postgres OR feature: auth are included.

Original prompt

Currently, we ignore command front-matter. This is a problem, a command might need additional tools, MCPs or rules. Any selectors that the command might need should be combined with the task selectors and used to select rules.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 23, 2025 20:11
- Added Selectors field to CommandFrontMatter struct
- Updated findCommand to extract and merge command selectors with task selectors
- Added table-driven tests for command selectors functionality
- Created example command file with selectors

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
- Added documentation for selectors field in command frontmatter
- Explained how command selectors combine with task selectors
- Provided examples of using command selectors

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
- Extracted mergeSelectors helper function
- Updated task and command selector handling to use the helper
- Addresses code review feedback

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title [WIP] Update handling of command front-matter for tool integration Add selector support to command frontmatter Dec 23, 2025
Copilot AI requested a review from alexec December 23, 2025 20:19
@alexec alexec marked this pull request as ready for review December 23, 2025 20:22
Copilot AI review requested due to automatic review settings December 23, 2025 20:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds selector support to command frontmatter, allowing commands to declare their rule dependencies (e.g., database drivers, auth libraries) directly. When a task uses a command with selectors, those selectors are automatically merged with task and CLI selectors using OR logic for rule filtering.

Key Changes

  • Commands can now specify selectors in their frontmatter to pull in required rules automatically
  • Extracted mergeSelectors helper function to eliminate code duplication between task and command selector handling
  • Command selectors are processed during task parsing, before rule collection, ensuring correct filtering behavior

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/codingcontext/markdown/frontmatter.go Added Selectors field to CommandFrontMatter struct with documentation
pkg/codingcontext/context.go Extracted mergeSelectors helper and integrated command selector processing in findCommand
pkg/codingcontext/context_test.go Added comprehensive tests for command selectors and their combination with task selectors
examples/agents/commands/setup-database.md Added example command demonstrating selector usage
docs/reference/file-formats.md Documented the new selectors field with examples and usage patterns

@alexec alexec merged commit a315a3c into main Dec 23, 2025
7 checks passed
@alexec alexec deleted the copilot/update-front-matter-handling branch December 23, 2025 21:19
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.

2 participants