How to use agents, skills, and instructions in Copilot CLI | Tutorial for beginners
By GitHub
Key Concepts
- Copilot Instructions: Markdown-based configuration files that provide global or file-specific context to ensure code generation adheres to organizational standards.
- Agent Skills: Specialized tools or scripts (defined in
.github/skills) that enable Copilot to perform specific, repeatable tasks or workflows. - Custom Agents: Specialized "workers" (defined in
.github/agents) designed to handle complex, multi-faceted tasks that require specific context and expertise. - Slash Commands: Interface shortcuts (e.g.,
/init,/agent) used to trigger specific Copilot behaviors or configurations.
1. Copilot Instructions
Instructions serve as the foundational layer for Copilot, defining the "what" and "how" of code generation.
- Centralized Instructions (
copilot-instructions.md): A project-level file that remains in context globally. It is used for universal requirements, such as mandating docstrings in all functions. - Targeted Instructions (
.instructionsfiles): These allow for granular control by targeting specific file types or directories. Theapply tofield in these files defines the path (e.g.,server/routes/*.py) where the specific instructions should be active. - Implementation: The
/initslash command is recommended to generate a baseline instruction file. A repository of templates is available atgh.io/awesome-copilot.
2. Agent Skills
Skills act as tools in Copilot’s toolbox, enabling it to execute lower-level tasks or complex workflows.
- Definition: Defined via markdown files and scripts located in the
.github/skillsdirectory. - Functionality: Skills can be invoked via explicit slash commands (e.g.,
/make-contribution) or triggered dynamically through natural language requests. - Example: A "contribution" skill can be configured to scan for existing
CONTRIBUTING.mdfiles, issue templates, and pull request templates. When triggered, it automates the process of creating a branch, grouping commits, and opening a PR according to repository standards.
3. Custom Agents
Custom agents are designed for complex, specialized scenarios that require a broader scope than a single skill.
- Purpose: They act as specialized workers for specific domains, such as accessibility (a11y) or SEO, which may require modifications across multiple files.
- Execution: Activated using the
/agentcommand. Once active, the agent maintains its own specific context, allowing it to perform deep reviews or systemic updates that a general Copilot instance might miss. - Workflow: A user can ask an accessibility agent to "perform a review," receive a list of impactful updates, and then instruct the agent to apply those changes directly to the codebase.
4. Strategic Integration
The video emphasizes that these three components are not mutually exclusive but are designed to work in harmony:
- Instructions provide the context (the "rules of the road").
- Skills provide the tools (the "actions" to take).
- Agents provide the specialization (the "expert persona" for complex tasks).
By combining these, organizations can ensure that Copilot mimics the exact patterns and practices of human developers, ensuring consistency and quality across the entire development lifecycle.
Synthesis and Conclusion
The core takeaway is that Copilot is most effective when it is "trained" on organizational standards rather than used as a generic tool. By utilizing Instructions for global standards, Skills for repeatable workflows, and Agents for complex domain-specific tasks, teams can create a cohesive, automated development environment. This framework ensures that Copilot’s output is not just functional, but compliant with the specific architectural and stylistic requirements of the organization.
Chat with this Video
AI-PoweredHi! I can answer questions about this video "How to use agents, skills, and instructions in Copilot CLI | Tutorial for beginners". What would you like to know?