Reusable Skills as Prompt Files
Introduction
Some tasks come up again and again during a project — turning a requirement into a technical spec, generating unit tests for a change, running the build and interpreting the result. Retyping the same detailed instructions into chat every time is wasteful and error-prone: two developers asking "generate some tests" in slightly different words will get inconsistent results.
GitHub Copilot's answer to this is the prompt file: a reusable, named prompt saved once and invoked from chat with a short slash command, e.g. /architecting. Think of a prompt file as a "skill" — a packaged, repeatable capability that any agent (or any developer) can call on without re-explaining how it should be done.
GitHub Copilot tip: Prompt files can reference variables like ${selection} or ${file}, so the same skill can operate on whatever you currently have open, rather than being hard-coded to one file.
Concepts
What a prompt file is
- Location:
.github/prompts/<name>.prompt.md. - Frontmatter declares
mode(ask,edit, oragent) and a shortdescription. - Invoked in Copilot Chat by typing
/<name>. - The body is the actual instructions — as detailed as a task needs, written once.
Skills for this project
| Skill | Prompt file | Purpose |
|---|---|---|
| Architecting | architecting.prompt.md | Turn a plain-English requirement into a structured technical spec. |
| Unit Test Case Generator | unit-testcase-generator.prompt.md | Generate tests for a specific change, matching this repo's test conventions. |
| Build and Packaging | build-and-packaging.prompt.md | Run the backend and frontend build/test commands and summarise the result. |
Why prompt files, not just remembering to ask well
- Consistency: every invocation of
/architectingproduces a spec with the same sections. - Composability: agents (covered in the next chapter) can invoke a skill by name instead of embedding its full instructions.
- Discoverability: typing
/in Copilot Chat lists every skill available in the repo.
Examples
.github/prompts/architecting.prompt.md:
---
mode: "agent"
description: "Turn a requirement into a technical spec"
---
You are producing a technical spec for the account dashboard project (Spring Boot backend,
React frontend). Given a requirement description:
1. Summarise the requirement in one paragraph.
2. List the backend changes needed: new/changed endpoints, services, entities.
3. List the frontend changes needed: new/changed components, API client calls.
4. List the test cases that must exist for this change to be considered done.
5. Note any open questions or risks.
Follow the coding standards in the repository's copilot-instructions.md. Write the result as
a Markdown file.
.github/prompts/unit-testcase-generator.prompt.md:
---
mode: "agent"
description: "Generate tests for a specific change"
---
Given a described code change, generate the tests needed to cover it:
- Backend: JUnit 5 tests for services (mock collaborators) and MockMvc tests for controllers.
- Frontend: React Testing Library tests co-located as `<Component>.test.jsx`.
- Include at least one happy-path case and one validation/error case per public method
or user-facing behaviour touched by the change.
- Do not generate tests for behaviour that already has equivalent coverage.
.github/prompts/build-and-packaging.prompt.md:
---
mode: "agent"
description: "Build and package the application, report pass/fail"
---
Run the project's build and test commands:
- Backend: `./mvnw clean verify` from `backend/`.
- Frontend: `npm test -- --watchAll=false` then `npm run build` from `frontend/`.
Report clearly whether each step passed or failed. If a step fails, quote the first relevant
error only — do not paste the entire log.
Challenges
1. Create the Architecting skill
- Create
.github/prompts/architecting.prompt.mdwithmode: "agent". - Have it produce a spec with the five sections shown above.
Ask Copilot: What's the difference between prompt mode: "ask" and mode: "agent"?
💡 Show Answer
ask mode is a one-shot question-and-answer with no file edits or tool calls. agent mode allows Copilot to take multiple steps — reading files, running commands, editing code — to complete the task, which is what a skill that needs to produce a spec file or run a build requires.
2. Create the Unit Test Case Generator skill
- Create
.github/prompts/unit-testcase-generator.prompt.md. - Make sure it references this repo's actual test conventions (JUnit 5 + MockMvc for backend, React Testing Library co-located as
<Component>.test.jsxfor frontend) rather than generic advice.
Ask Copilot: Why should a test-generation skill say "do not duplicate existing coverage" explicitly?
💡 Show Answer
Without that instruction, an agent invoking this skill repeatedly (once per change) will keep re-generating overlapping tests for code paths already covered, bloating the test suite and slowing the build without adding real coverage.
3. Create the Build and Packaging skill
- Create
.github/prompts/build-and-packaging.prompt.md. - Make sure it names the exact commands from this repo (
./mvnw clean verify,npm test,npm run build), not placeholder commands.
Ask Copilot: Why should this skill say "quote the first relevant error only" instead of pasting the full log?
💡 Show Answer
Build/test logs can be very long. An agent that pastes the entire log into every chat response wastes context and buries the actually useful line (the first failing assertion or compile error) under noise.
4. Invoke a skill directly
- In Copilot Chat, type
/architectingand, when prompted, describe a small made-up requirement (e.g. "add an endpoint to show the last 5 transactions"). - Confirm the output follows the five-section structure from the prompt file.
💡 Show Answer
Copilot should produce a Markdown document with a summary, backend changes, frontend changes, required tests, and open questions/risks — in that order, because the prompt file's numbered list dictates the structure of the response.