Skip to content

Commit e182efd

Browse files
hubwriterCopilot
andauthored
Copilot CLI: Add info on how a Copilot skill can run a script. (#60461)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent f7c9a95 commit e182efd

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

data/reusables/copilot/creating-adding-skills.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ To add a skill, you save the `SKILL.md` file, and any subsidiary resources, to a
2727
* **license** (optional): A description of the license that applies to this skill.
2828
* A Markdown body, with the instructions, examples and guidelines for {% data variables.product.prodname_copilot_short %} to follow.
2929

30-
1. Optionally, add scripts, examples or other resources to your skill's directory.
30+
1. Optionally, add scripts, examples or other resources to your skill's directory.
3131

32-
For example, if you were writing a skill for converting images between different formats, you might include a script for converting SVG images to PNG. The skill instructions should tell {% data variables.product.prodname_copilot_short %} when, and how, to use these resources.
32+
For more information, see "[Enabling a skill to run a script](#enabling-a-skill-to-run-a-script)."
3333

3434
### Example `SKILL.md` file
3535

@@ -51,3 +51,38 @@ To debug failing {% data variables.product.prodname_actions %} workflows in a pu
5151
4. Try to reproduce the failure yourself in your own environment.
5252
5. Fix the failing build. If you were able to reproduce the failure yourself, make sure it is fixed before committing your changes.
5353
```
54+
55+
### Enabling a skill to run a script
56+
57+
When a skill is invoked, {% data variables.product.prodname_copilot_short %} automatically discovers all of the files in the skill's directory and makes them available alongside the skill's instructions. This means you can include scripts or other resources in the skill directory and reference them in your `SKILL.md` instructions.
58+
59+
To create a skill that runs a script:
60+
61+
1. **Add the script to your skill's directory.** For example, a skill for converting SVG images to PNG might have the following structure.
62+
63+
```text
64+
.github/skills/image-convert/
65+
├── SKILL.md
66+
└── convert-svg-to-png.sh
67+
```
68+
69+
1. **Optionally pre-approve the tools the skill needs.** In your `SKILL.md` frontmatter, you can use the `allowed-tools` field to list the tools {% data variables.product.prodname_copilot_short %} may use without asking for confirmation each time. If a tool is not listed in the `allowed-tools` field, {% data variables.product.prodname_copilot_short %} will prompt you for permission before using it.
70+
71+
```markdown
72+
---
73+
name: image-convert
74+
description: Converts SVG images to PNG format. Use when asked to convert SVG files.
75+
allowed-tools: shell
76+
---
77+
```
78+
79+
> [!WARNING]
80+
> Only pre-approve the `shell` or `bash` tools if you have reviewed this skill and any referenced scripts, and you fully trust their source. Pre-approving `shell` or `bash` removes the confirmation step for running terminal commands and can allow attacker-controlled skills or prompt injections to execute arbitrary commands in your environment. When in doubt, omit `shell` and `bash` from `allowed-tools` so that {% data variables.product.prodname_copilot_short %} must ask for your explicit confirmation before running terminal commands.
81+
82+
1. **Write instructions that tell {% data variables.product.prodname_copilot_short %} how to use the script.** In the Markdown body of `SKILL.md`, describe when and how to run the script.
83+
84+
```markdown
85+
When asked to convert an SVG to PNG, run the `convert-svg-to-png.sh` script
86+
from this skill's base directory, passing the input SVG file path as the
87+
first argument.
88+
```

0 commit comments

Comments
 (0)