-
Notifications
You must be signed in to change notification settings - Fork 1
Implement Agent Skills discovery with progressive disclosure #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add SkillFrontMatter struct with required name and description fields - Add skillSearchPaths function to search .agents/skills directories - Implement discoverSkills function for skill discovery with selector filtering - Update Result struct to include Skills slice - Add skills metadata output in XML format to main.go - Create example skills (pdf-processing, data-analysis) - Add comprehensive tests for skill discovery - Skills load only metadata (name/description) for progressive disclosure - Skills can be filtered by selectors just like rules Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
- Add README.md for skills directory with usage examples - Add reference documentation (REFERENCE.md) for pdf-processing skill - Add example Python script (extract.py) for PDF text extraction - Update .gitignore to exclude test workspaces - Clean up temporary test files Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
alexec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/codingcontext/context.go
Outdated
| } | ||
|
|
||
| // Check if the skill matches the selectors | ||
| if !cc.includes.MatchesIncludes(frontmatter.BaseFrontMatter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot move this filtering before the name and description checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 9ac54d1. Selector filtering now happens before name and description validation checks.
pkg/codingcontext/result.go
Outdated
| Prompt string // Combined prompt: all rules and task content | ||
| Rules []markdown.Markdown[markdown.RuleFrontMatter] // List of included rule files | ||
| Task markdown.Markdown[markdown.TaskFrontMatter] // Task file with frontmatter and content | ||
| Skills []markdown.Markdown[markdown.SkillFrontMatter] // List of discovered skills (metadata only) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't include the skills as Markdown. Instead lets have some new package for skills use the encoding/xml package in main.go to render them.
- skills.AvailalableSkills
- skills.Name
- skills.Description
- skills.Location - the absolute path to the skill
skills.AvailalableSkills.String() should produce the XML output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 9ac54d1. Created new pkg/codingcontext/skills package with:
skills.AvailableSkillscollection typeskills.Skillwith Name, Description, and Location (absolute path) fieldsskills.String()method that produces XML output with proper escaping- Result.Skills is now
skills.AvailableSkillsinstead of markdown slice
pkg/codingcontext/context.go
Outdated
| rules []markdown.Markdown[markdown.RuleFrontMatter] // Collected rule files | ||
| task markdown.Markdown[markdown.TaskFrontMatter] // Parsed task | ||
| rules []markdown.Markdown[markdown.RuleFrontMatter] // Collected rule files | ||
| skills []markdown.Markdown[markdown.SkillFrontMatter] // Discovered skills (metadata only) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be
| skills []markdown.Markdown[markdown.SkillFrontMatter] // Discovered skills (metadata only) | |
| skills skills.AvailableSkills |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 9ac54d1. Context.skills field is now skills.AvailableSkills type.
- Create new pkg/codingcontext/skills package with Skill and AvailableSkills types - Add XML escaping for safe output - Move selector filtering before validation checks - Add length validation for name (1-64 chars) and description (1-1024 chars) - Store absolute path to SKILL.md in Location field - Update Result to use skills.AvailableSkills instead of []Markdown - Update main.go to use skills.String() method for XML output - Add comprehensive tests for skills package and length validation - All tests passing Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot Use encoding/xml to produce the XML output. If that returns an error, change String() to AsXML() |
- Change String() to AsXML() method that returns (string, error) - Use xml.MarshalIndent() for proper XML encoding with built-in escaping - Update main.go to handle AsXML() error - Return errors instead of logging warnings for missing/invalid frontmatter - Update tests to expect errors for validation failures - Remove custom xmlEscape function (no longer needed) - All tests passing with proper error handling Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Done in 904db7c. Changed to use |
|
@copilot You don't need to check for empty, then check for length < 1. You can just check empty. |
- Remove redundant len() < 1 checks since empty string check already covers this - Remove empty guard in main.go:176 (skillsXML cannot be empty if there are skills) - Return error instead of logging warning when filepath.Abs fails - Remove empty check in AsXML() to always return XML even if empty - Update test to expect XML output for empty skills - All tests passing Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
alexec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot The Result contains a Prompt field. Add a "Skills" section after the rules with an explanation to agent on how to use skills and the skills.
- Add "Skills" section to Result.Prompt after rules and before task - Include explanation on how agents can use skills - Show available skills in XML format within the prompt - Skills section only added if there are discovered skills - Agents can now see skills directly in the prompt with instructions - All tests passing Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Done in 972c561. Added "Skills" section to the Prompt field after rules with explanation on how agents can use skills. The section includes instructions and displays available skills in XML format. Only appears when skills are discovered. |
There was a problem hiding this 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 implements Agent Skills discovery with progressive disclosure, allowing agents to discover and load specialized capabilities on demand. The implementation adds skill discovery from .agents/skills/ directories, loads only metadata (name and description) at startup, and integrates skill information into the agent prompt.
Key Changes
- Added
skillspackage withSkillandAvailableSkillstypes supporting XML serialization - Implemented skill discovery in
discoverSkills()that parsesSKILL.mdfrontmatter, validates required fields, and applies selector filtering - Integrated skills into the prompt with usage instructions and XML-formatted metadata
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/codingcontext/skills/skills.go |
Defines Skill and AvailableSkills types with XML marshaling support |
pkg/codingcontext/skills/skills_test.go |
Table-driven tests for XML serialization including edge cases |
pkg/codingcontext/context.go |
Implements skill discovery, validation, and prompt integration |
pkg/codingcontext/context_test.go |
Comprehensive tests for skill discovery, validation, and selector filtering |
pkg/codingcontext/markdown/frontmatter.go |
Adds SkillFrontMatter struct with required and optional fields |
pkg/codingcontext/result.go |
Extends Result struct to include discovered skills |
pkg/codingcontext/paths.go |
Adds skillSearchPaths function for .agents/skills directory |
main.go |
Adds XML output for discovered skills in normal mode |
examples/agents/skills/*/SKILL.md |
Example skills demonstrating the format (pdf-processing, data-analysis) |
examples/agents/skills/README.md |
Documentation explaining the Agent Skills format and usage |
.gitignore |
Excludes test workspace from version control |
- Change Location field from xml:"-" to xml:"location" to serialize it - Update tests to expect location in XML output - Agents can now see the absolute path to SKILL.md files - Matches the prompt text that references "at the location provided" - All tests passing Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Agent Skills Implementation - Final
All feedback addressed:
Latest Changes
Include location in XML output (3033327)
xml:"location"instead ofxml:"-"Added Skills section to prompt (972c561)
Result.Promptafter rules and before task contentSimplified validation logic (c9b8959)
len() < 1checks (empty string check already covers this)Improved error handling (c9b8959)
filepath.AbsfailsRemoved redundant guards (c9b8959)
if skillsXML != ""check in main.go (cannot be empty if skills exist)if len(a.Skills) == 0check inAsXML()(always return XML)<available_skills></available_skills>Implementation
discoverSkills()searches.agents/skills/, parsesSKILL.mdfrontmatter, validates required fields, and filters by selectorspkg/codingcontext/skillswithSkillandAvailableSkillstypesencoding/xmlpackage with proper escapingExample Output
Skills appear in two places with location included:
Testing
Original prompt
Your task is to implement Agent Skills. Skills will live in .agents/skills. Skill should be selectable. (just like rules).
Overview
Copy page
A simple, open format for giving agents new capabilities and expertise.
Agent Skills are folders of instructions, scripts, and resources that agents can discover and use to do things more accurately and efficiently.
Why Agent Skills?
Agents are increasingly capable, but often don’t have the context they need to do real work reliably. Skills solve this by giving agents access to procedural knowledge and company-, team-, and user-specific context they can load on demand. Agents with access to a set of skills can extend their capabilities based on the task they’re working on.
For skill authors: Build capabilities once and deploy them across multiple agent products.
For compatible agents: Support for skills lets end users give agents new capabilities out of the box.
For teams and enterprises: Capture organizational knowledge in portable, version-controlled packages.
What can Agent Skills enable?
Domain expertise: Package specialized knowledge into reusable instructions, from legal review processes to data analysis pipelines.
New capabilities: Give agents new capabilities (e.g. creating presentations, building MCP servers, analyzing datasets).
Repeatable workflows: Turn multi-step tasks into consistent and auditable workflows.
Interoperability: Reuse the same skill across different skills-compatible agent products.
What are skills?
Copy page
Agent Skills are a lightweight, open format for extending AI agent capabilities with specialized knowledge and workflows.
At its core, a skill is a folder containing a SKILL.md file. This file includes metadata (name and description, at minimum) and instructions that tell an agent how to perform a specific task. Skills can also bundle scripts, templates, and reference materials.
my-skill/
├── SKILL.md # Required: instructions + metadata
├── scripts/ # Optional: executable code
├── references/ # Optional: documentation
└── assets/ # Optional: templates, resources
How skills work
Skills use progressive disclosure to manage context efficiently:
Discovery: At startup, agents load only the name and description of each available skill, just enough to know when it might be relevant.
Activation: When a task matches a skill’s description, the agent reads the full SKILL.md instructions into context.
Execution: The agent follows the instructions, optionally loading referenced files or executing bundled code as needed.
This approach keeps agents fast while giving them access to more context on demand.
The SKILL.md file
Every skill starts with a SKILL.md file containing YAML frontmatter and Markdown instructions:
name: pdf-processing
description: Extract text and tables from PDF files, fill forms, merge documents.
PDF Processing
When to use this skill
Use this skill when the user needs to work with PDF files...
How to extract text
How to fill forms
...
The following frontmatter is required at the top of SKILL.md:
name: A short identifier
description: When to use this skill
The Markdown body contains the actual instructions and has no specific restrictions on structure or content.
This simple format has some key advantages:
Self-documenting: A skill author or user can read a SKILL.md and understand what it does, making skills easy to audit and improve.
Extensible: Skills can range in complexity from just text instructions to executable code, assets, and templates.
Portable: Skills are just files, so they’re easy to edit, version, and share.
pecification
Copy page
The complete format specification for Agent Skills.
This document defines the Agent Skills format.
Directory structure
A skill is a directory containing at minimum a SKILL.md file:
skill-name/
└── SKILL.md # Required
You can optionally include additional directories such as scripts/, references/, and assets/ to support your skill.
SKILL.md format
The SKILL.md file must contain YAML frontmatter followed by Markdown content.
Frontmatter (required)
name: skill-name
description: A description of what this skill does and when to use it.
With optional fields:
name: pdf-processing
description: Extract text and tables from PDF files, fill forms, merge documents.
license: Apache-2.0
metadata:
author: example-org
version: "1.0"
Field Required Constraints
name Yes Max 64 characters. Lowercase letters, numbers, and hyphens only. Must not start or end with a hyphen.
description Yes Max 1024 characters. Non-empty. Describes what the skill does and when to use it.
license No License name or reference to a bundled license file.
compatibility No Max 500 characters. Indicates environment requirements (intended product, system packages, network access, etc.).
metadata No Arbitrary key-value mapping for additional metadata.
allowed-tools No...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.