GitHub Copilot Agent Skills: Teaching AI Your Repository Patterns
Source: Dev.to
Announced December 18 2025
Example Repository: SeleniumSelfHealing.Reqnroll
Why This Matters
Every test‑automation engineer eventually hits the same wall: you spend weeks building a robust framework with custom patterns, only to have AI assistants suggest brittle, outdated code that ignores your architecture.
GitHub’s Agent Skills (released Dec 18 2025) let you ship instruction sets alongside your code so Copilot can automatically apply the right logic when it detects a relevant prompt. The feature works in:
- Copilot Coding Agent
- Copilot CLI
- Agent mode in Visual Studio Code
Below is a step‑by‑step walkthrough of how we taught Copilot our self‑healing Selenium patterns.
What Are Agent Skills?
“Agent Skills allow you to teach Copilot how to perform specialized tasks in a specific, repeatable way. When Copilot determines a skill is relevant to your task, it loads the instructions and follows them.” – GitHub announcement
How They Work
- Add a skill folder under
.github/skills/. - Create a
SKILLS.mdfile that contains:- A short description.
- Usage examples.
- Any helper scripts or data files.
- Commit the changes.
- Copilot automatically loads the skill when it detects a matching context—no manual activation required.
The Problem: Brittle Selenium Tests
Typical Selenium code couples tests to fragile selectors:
// Example of a brittle approach
var button = driver.FindElement(By.XPath("//button[@id='submit-2023']"));
button.Click();
When an element’s ID changes, the test crashes.
Our framework replaces hard‑coded selectors with semantic, AI‑driven element recovery. Without a skill, Copilot kept suggesting the old pattern.
Creating the Agent Skill
Directory Layout
.github/
└─ skills/
└─ selenium-self-healing/
├─ SKILLS.md
├─ recover-element.js # optional helper script
└─ README.md # optional documentation
SKILLS.md (the heart of the skill)
# Selenium Self‑Healing Automation Skill
## Goal
Teach Copilot to generate Selenium code that uses our **semantic‑selector** helper instead of brittle XPath/CSS selectors.
## How It Works
1. Call `FindElementByDescription(string description)` – a wrapper around our AI‑powered recovery engine.
2. The method returns a `IWebElement` that is resilient to UI changes.
3. Use the returned element exactly as you would a normal Selenium element.
## Example Usage
```csharp
// ❌ Old, brittle code
var submitBtn = driver.FindElement(By.XPath("//button[@id='submit-2023']"));
submitBtn.Click();
// ✅ New, self‑healing code
var submitBtn = driver.FindElementByDescription("the submit button on the login page");
submitBtn.Click();
Implementation Details
- The helper lives in
SeleniumSelfHealing.Extensionsnamespace. - It internally calls
ElementRecoveryService.RecoverAsync(description). - If recovery fails, it falls back to the original selector (if provided).
When to Trigger the Skill
- Prompt contains phrases like “find the submit button”, “click the login button”, or “use our self‑healing selector”.
- The file being edited is a
.cstest file under aTests/folder.
FAQ
Q: Do I need to import a namespace?
A: Yes. Add using SeleniumSelfHealing.Extensions; at the top of the file.
Q: Can I customise the description language?
A: The recovery engine uses a fuzzy‑match algorithm; natural language works best.
### Optional Helper Script (`recover-element.js`)
If you need a quick Node‑JS demo for the CLI, you can expose a tiny wrapper:
```js
// recover-element.js
const { recoverElement } = require('./element-recovery-service');
async function main() {
const description = process.argv[2];
const element = await recoverElement(description);
console.log(JSON.stringify(element));
}
main().catch(console.error);
Using the Skill in Practice
-
Open a test file (e.g.,
LoginTests.cs). -
Start typing a natural‑language description:
// Find the login button using our self‑healing selector var loginBtn = driver.FindElementByDescription("the login button on the sign‑in page"); loginBtn.Click(); -
Copilot detects the phrase “Find the … using our self‑healing selector” → loads the Selenium Self‑Healing skill → suggests the correct wrapper method and imports.
Copilot CLI Example
# Generate a new test method with the skill automatically applied
copilot generate test \
--description "verify that a user can log in using the semantic selector for the login button"
The CLI will output a ready‑to‑run test that uses FindElementByDescription.
Tips & Best Practices
| Tip | Why It Helps |
|---|---|
Keep SKILLS.md concise (≤ 500 words) | Copilot parses the file quickly and gives higher relevance scores. |
| Add multiple usage examples | More examples improve the model’s ability to match varied prompts. |
| Version‑control the skill folder | Changes to the skill are tracked just like any other code. |
| Use clear, domain‑specific terminology | Phrases like “self‑healing selector” act as strong signals for the skill. |
| Test the skill locally | Run copilot chat with a prompt that should trigger the skill to verify the output. |
Conclusion
GitHub Copilot Agent Skills turn a generic AI assistant into a domain‑aware partner. By packaging our Selenium self‑healing logic as a skill, we:
- Eliminate brittle selector suggestions.
- Reduce manual refactoring when UI changes.
- Keep the AI aligned with our architectural standards.
Give it a try in your own test‑automation repo—add a .github/skills/ folder, write a clear SKILLS.md, and watch Copilot adapt to your workflow automatically. Happy coding!
Purpose
Enable Copilot to:
- Generate robust Selenium UI tests.
- Use AI‑powered self‑healing locator strategies.
- Follow BDD patterns with Reqnoll.
Hard Rules
Must
- Use self‑healing WebDriver extensions
- Prefer element descriptions over raw locators
- Generate async step definitions
- Log all healing attempts
Must Not
- Hardcode XPath or CSS selectors
- Use
Thread.Sleep - Bypass self‑healing logic
Golden Example
Step‑definition pattern
[When(@"I click the ""(.*)""")]
public async Task WhenIClickElement(string elementDescription)
{
await _driver.Click(
By.CssSelector(""),
elementDescription
);
}
Gherkin scenario
Scenario: Search for Selenium
Given I navigate to "https://www.wikipedia.org"
When I enter "Selenium" into the "search box"
And I click the "search button"
Then I should see "Selenium"
After adding the skill, developers type
// Create step definition to click login button
Copilot now generates
[When(@"I click the ""(.*)""")]
public async Task WhenIClickElement(string elementDescription)
{
await _driver.Click(By.CssSelector(""), elementDescription);
}
Result: The generated code follows our self‑healing pattern, using semantic descriptions instead of brittle locators.
Key Components That Work
- Clear Rules – Define explicit must‑do and must‑not‑do items. Specificity yields better results.
- Working Examples – Use real code from your repository; Copilot learns from actual patterns, not theory.
- Context About Structure – Explain your project’s organization so Copilot places code in the right location.
- Templates – Provide scaffolding for scenarios developers encounter frequently.
Verifying It Works
- Open Copilot Chat and ask: “How should I create a new step definition?”
- Look for references to your
SKILLS.mdin the response. - Check suggestions – they should match your patterns (async methods, element‑description parameters, self‑healing extensions).
- Create a test file with a comment that triggers your pattern and observe Copilot’s suggestion.
Important Requirements
- GitHub Copilot Agent Skills requires a paid plan (Individual, Business, or Enterprise).
- The feature is available with:
- Copilot coding agent,
- GitHub Copilot CLI, and
- Agent mode in VS Code Insiders (support in the stable VS Code release is coming soon).
- Without a paid plan, the
SKILLS.mdstill serves as valuable documentation for the team. - New skill files may need 5–10 minutes to be indexed; reload your IDE if suggestions don’t appear immediately.
Why This Matters for Test Automation
Testing frameworks are evolving beyond standard practices.
Self‑healing locators, AI‑powered recovery, custom assertions—these patterns are not part of Copilot’s base training. By writing your own skills (or using community‑contributed ones), you transform Copilot from a generic code suggester into a tool that understands and enforces your specific methodology. The benefit isn’t just speed; it’s generating code that preserves your architecture’s quality standards.
Getting Started
- Create the directory
/.github/skills/your-skill/. - Add a
SKILLS.mdfile that documents your most critical pattern. - Include one golden example (the step‑definition pattern shown above).
- Test the skill with a new file that contains a triggering comment.
- Expand the file as you discover additional patterns.
Tip: Start small—focus on the pattern that matters most. You can broaden the skill set later.
Currently, skills can only be created at the repository level; organization‑ and enterprise‑level support is coming soon.
Additional Resources
- GitHub Changelog: GitHub Copilot now supports Agent Skills
- Documentation: About Agent Skills — GitHub Docs
- Community Skills: github/awesome-copilot
What patterns would you teach GitHub Copilot in your test‑automation projects?