Write a skill
A skill tells an agent how to carry out one kind of task, step by step. Writing a skill turns a workflow you keep explaining, such as how your team fixes a bug or reviews tests, into steps every agent follows the same way. A useful skill names the task that should trigger it, orders the steps, and cites the rules each step applies.
This guide covers deciding between a skill and a rule, creating a skill, writing and checking it, setting its level in a library, and versioning it. For every field and check, see Skill format.
Skill or rule?
Section titled “Skill or rule?”Choose by granularity.
- A rule states one best practice and when it applies, such as “never write secrets to logs.” A project can adopt, exclude, or replace it on its own, and it has its own version. It applies to any work that matches it, whatever task the agent is doing.
- A skill is coarse-grained: a playbook, technique, or way of coordinating one kind of task, such as “reproduce the bug, find the cause, fix it, then check the test.” It combines many practices, and applies when an agent takes on that task.
When a step needs a practice followed, cite the rule rather than restating it. A project can then exclude or replace the rule, and the skill follows the project’s choice; when the rule gets a new version, the skill applies it without a change of its own; and reviewers check the work against the same rule the implementing agent read.
Write a rule when:
- You’d correct the same mistake whatever the task, such as a missing test at a retry limit.
- The expectation needs its own exceptions, examples, or validation.
Write a skill when:
- The order of the work matters, such as writing a failing test before the fix.
- A task combines several rules, tools, or scripts that agents keep combining differently.
- You’d like an agent to run the same review the same way every time.
If a step in your draft explains how to do something well, and the explanation would hold outside this task, move it into a rule and cite the rule. See Write a rule.
Choose a type
Section titled “Choose a type”A skill can declare one type in trailguide-skill-type:
playbook: ordered steps for carrying out one kind of engineering task, citing the rules each step applies, such as building a feature or fixing a bug.review: examines existing work, such as a diff, a plan, or a test suite, against stated criteria and reports findings.
Ask what the skill’s main job is: a playbook changes the work, and a review judges work that already exists. A playbook can include a review step, and a review can offer to fix what it found. If neither fits, leave the type out. The type is a label for people and for catalogs that browse skills by type; Trailguide treats every skill the same way.
Create the skill
Section titled “Create the skill”A library keeps the skills you write in skills/src/ at the repository root, and trailguide library build builds the copies projects install into skills/dist/. A project keeps its own skills, and its forks of a source’s skills, in .trailguide/skills/, one folder per skill; see Skill folders.
In a library
Section titled “In a library”Create a draft:
trailguide library add skill fix-bug \ --description 'Fix a reported bug and prove it with a regression test. Use when a task starts from a bug report, a failing behavior, or an error someone saw.' \ --type playbookThis writes skills/src/skills/fix-bug/SKILL.md with your name, description, and type in its frontmatter, and a body with the trailguide:draft marker, then runs trailguide library build. trailguide library check fails until you replace the body, remove the marker, and build again.
When skills work together, such as skills that build with one component library, put them in a stack with --stack:
trailguide library add skill fk-build-ui --stack fk-stack \ --description 'Build pages from the FK components. Use when building or changing a page.'This writes skills/src/stacks/fk-stack/skills/fk-build-ui/SKILL.md. Describe the stack in skills/src/stacks/fk-stack/README.md, and put what its skills share, such as component examples, in skills/src/stacks/fk-stack/shared/. See Share files between skills.
The folder’s path becomes the skill’s ID, skills/fix-bug, and its name becomes the folder name of every installed copy, unless a project gives it an alias. Use 1 to 64 lowercase letters, digits, and hyphens, and keep the name stable once projects install the skill; see Skill IDs.
Write the description for an agent deciding whether to load the skill: say what the skill does, then when to use it, naming the task or request that should trigger it.
In a project
Section titled “In a project”A skill that only one project needs can stay in that project:
trailguide project create skill release-checklist \ --description "Prepare this service's release pull request. Use when asked to cut or prepare a release." \ --type playbookThis writes .trailguide/skills/release-checklist/SKILL.md. A skill in a repository that isn’t a library has no version. It can cite rules from your sources by project ID, with the source name, such as fabrica:practices/testing/verify-retry-limits, and your own rules by their bare ID, such as practices/release/tag-from-main.
To change a skill you include from a source for one project, fork it instead of starting over:
trailguide project fork skill fabrica:skills/fix-bug \ --reason 'We fix bugs behind a feature flag first.'The fork copies the version the project installs into .trailguide/skills/fix-bug/, rewrites its citations to project IDs, and records it in skills.forks, so the fork installs in place of the source’s skill. A required skill can’t be forked. See Fork a skill for editing a fork and merging the source’s later changes into it. A skill your library source curates from another repository forks the same way, such as trailguide project fork skill fabrica:mattpocock:skills/to-spec.
In a library, fork a skill from one of the library’s sources, such as a third party’s skill you want to publish with your own changes:
trailguide library fork skill pstack:pstack/skills/show-me-your-work \ --reason 'We ask for evidence before every claim.'The fork copies the skill at the revision the source’s ref names into skills/src/skills/show-me-your-work/, builds it, and records the skill it forks and the commit it copied in skills.forks in .trailguide/library.yaml. When a level listed the curated skill, the fork takes its place there. When skills.aliases gave the skill an alias, the fork takes the alias as its name, and the alias goes; your skills that named the curated skill in trailguide-skills-used must name the fork instead. When you move the source’s ref, trailguide library check lists what the source changed in the original since that commit. See library fork skill.
A source can exist only to track forks. Declaring a third party’s repository to fork from it publishes nothing of it: projects get a source’s skills only when a level lists one or one of your skills uses one. Keep the source declared for as long as you want check to compare your forks with it, and move its ref to compare with a newer revision. To stop tracking a fork, delete its skills.forks entry, and the source once nothing else uses it; the fork stays a skill of your own, with the same ID and folder, and the skills index names your library as its origin.
Write the steps
Section titled “Write the steps”Replace the draft’s body with the skill’s instructions:
- Number the steps, in the order the agent takes them. Give each step one outcome the agent can check before moving on, such as “a test that fails because of the bug.”
- Name the rules each step applies. Mention the rule by its ID in the step, such as
practices/testing/test-behavior-not-implementation, and list it intrailguide-rules-used. The installed copy ends with a section that maps each ID to the project’s version of the rule, including an authored rule that replaces it. - Say when to stop. Tell the agent what to do when a step can’t be completed, such as a bug it can’t reproduce, instead of leaving it to improvise.
- Say what to report. End with what the agent hands back: what it changed, what it verified, and what it couldn’t.
- Keep
SKILL.mdshort. Agents load the whole file when they use the skill. Move long background, examples, and checklists intoreferences/, and link to them from the step that needs them. The Agent Skills format recommends keepingSKILL.mdunder 500 lines. - Put repeatable commands in scripts. A script in
scripts/runs the same way every time. Make it executable and commit it with its mode; Trailguide keeps the mode when it installs the skill.
Links must stay inside the skill’s folder or be absolute URLs, because each installed copy stands alone. Cite rules in trailguide-rules-used instead of linking to them.
Cite rules and skills
Section titled “Cite rules and skills”List the rules the skill applies in trailguide-rules-used, and the other skills it uses in trailguide-skills-used, one ID per line in a YAML block string:
metadata: trailguide-skill-type: playbook trailguide-rules-used: | practices/testing/reproduce-bugs-with-a-failing-test practices/testing/test-behavior-not-implementation trailguide-skills-used: | skills/review-testsA bare ID names a rule or skill this repository authors. A library’s skills cite only bare IDs, because each project chooses its own source names. A project that installs the skill takes every cited rule, even ones its rule include doesn’t name, and installs every skill it calls.
The cited rules are for the skill. They don’t join the project’s RULES.md, so installing your skill never adds rules to unrelated work. Cite every rule a step depends on, including rules from rule groups you’d expect projects to include anyway: a project may not have included them.
A library’s skill can’t cite a rule or call a skill from another library. If your skill depends on another library’s practice, write or adapt the rule in your library first. A skill in a repository that isn’t a library can cite its sources’ rules with project IDs, such as fabrica:practices/testing/verify-retries; trailguide project check fails when one of those rules is retired, so your skill never points at a rule that’s gone.
Set the text agents show
Section titled “Set the text agents show”Some agents, such as Codex, show skills in their interface with a display name, a short description, and a prompt that starts the skill. Set that text in metadata, not in an agent’s own file:
metadata: display-name: "Fix Bug" short-description: "Reproduce, fix, and test a bug" default-prompt: "Use $fix-bug to reproduce and fix this bug."All three are optional. When a project installs the skill, Trailguide writes the file each agent reads, such as agents/openai.yaml in the .agents/skills/ copy for Codex. If you also need settings the keys don’t cover, such as icons, tool dependencies, or a policy that stops Codex from using the skill on its own, ship your own agents/openai.yaml instead: projects install it as it is, and Trailguide generates nothing for the skill. Library check warns about a shipped file that sets only the text the keys cover. In default-prompt, Codex recognizes the skill when the prompt names it with $, as in $fix-bug. Keep short-description to one line; agents still decide when to use the skill from its description. See Text agents show.
Example: a playbook
Section titled “Example: a playbook”This original example is a complete playbook in a library named fabrica, skills/src/skills/fix-bug/SKILL.md:
---name: fix-bugdescription: Fix a reported bug and prove it with a regression test. Use when a task starts from a bug report, a failing behavior, or an error someone saw.license: MITmetadata: trailguide-skill-type: playbook trailguide-rules-used: | practices/testing/reproduce-bugs-with-a-failing-test practices/testing/test-behavior-not-implementation practices/error-handling/make-errors-actionable trailguide-skills-used: | skills/review-tests---
# Fix a bug
Fix one reported bug and leave a test that would catch it again. Before each step, read in full the rules it names, using the project's versions listed under "Rules this skill applies".
## 1. Reproduce the bug
Restate the report as the behavior observed and the behavior expected. Write a test that fails because of the bug, following practices/testing/reproduce-bugs-with-a-failing-test, and run it. Confirm it fails for the reported reason, not because of its setup.
If you can't reproduce the bug, stop. Report what you tried and what you observed instead, and ask for more detail.
## 2. Find the cause
Trace the failing test to the code that produces the wrong behavior. Name the cause in one sentence before changing anything. If several causes are plausible, add a check that tells them apart rather than fixing all of them.
## 3. Fix the cause
Make the smallest change that removes the cause. Don't refactor unrelated code in the same change. If the bug showed a user or caller a misleading error, fix the message too, following practices/error-handling/make-errors-actionable.
## 4. Check the test
Run the new test and confirm it passes. Then check that it tests behavior, following practices/testing/test-behavior-not-implementation: temporarily undo the fix, confirm the test fails again, and restore the fix. Run the rest of the test suite.
## 5. Review the tests
Use the review-tests skill on every test you added or changed. Fix the findings that apply to your change.
## 6. Report
Report the cause, the fix, the test that now covers the bug, and the result of the full test suite. List anything you couldn't verify.Each step has one outcome, names the rules it applies, and says what to do when it can’t be completed. The opinions about how to write a failing test or an actionable error live in the cited rules, so a project that replaces one of those rules gets its own practice in step 1 or step 3.
Example: a review
Section titled “Example: a review”A review skill states what it examines, the criteria, and what it reports, and leaves the work unchanged. This is skills/src/skills/review-tests/SKILL.md in the same library:
---name: review-testsdescription: Review added or changed tests for whether they would catch the behavior they claim to cover. Use when reviewing a pull request or diff that adds or changes tests.license: MITmetadata: trailguide-skill-type: review trailguide-rules-used: | practices/testing/test-behavior-not-implementation practices/testing/verify-retry-limits---
# Review tests
1. List each test the change adds or modifies, and the behavior it claims to cover.2. Check each test against every rule listed under "Rules this skill applies" whose conditions match it, and against any other testing rule the project's RULES.md selects for this work.3. For each finding, report the test, the rule's ID and version, the evidence, and the consequence. Separate confirmed failures from suspicions you couldn't verify.4. Don't change the code. Offer fixes only when asked.Share files between skills
Section titled “Share files between skills”A skill’s own folder holds what only it needs, such as scripts/ and references/. When several skills need the same material, keep one copy in a shared/ folder and link to it: skills/src/shared/ for anything in the library, or a stack’s shared/ for its skills only. Link to a file or a whole folder:
Use the [components](../../shared/components/) and the [brand tokens](../../../../shared/brand/tokens.css).trailguide library build copies each shared file or folder a skill links to into the top of its built folder, under its own name, and points the link at the copy, so the installed skill reads components/ and tokens.css beside its SKILL.md. Link to another of the library’s skills by its source folder, such as ../fix-bug/SKILL.md; the build points the link at that skill’s built folder. A link to anything else outside the skill’s folder, such as a rule or another stack’s shared/, fails, because projects install the skill on its own: cite rules with trailguide-rules-used instead.
Write the skill’s README
Section titled “Write the skill’s README”In a library, a skill’s README.md is its page for people reading the repository: GitHub shows it when someone opens the skill’s folder in skills/src/. Say what the skill is for, how to use it, and anything a developer needs to know. Catalogs such as Skillmart show it too, in a README tab, and show its opening section, up to its first ## heading, or its ## Overview section if it has one, as the skill’s overview when the skill has no overview page. So open it with a short summary.
The README.md never ships in the built skill, so agents don’t read it, and neither do the files only it links to. Write images in Markdown, give every image alt text, keep local images in the skill’s folder, such as in media/, and keep each one at 2 MB or less; trailguide library check fails otherwise, and on an HTML <img> tag, which it can’t verify.
Write the overview page
Section titled “Write the overview page”People browsing a catalog such as Skillmart decide in a few seconds whether a skill is worth installing. Give each skill and stack in a library a short page for them in overview.md, beside its README.md, as a product has a page on its marketing site: what the skill does, why it exists, and how it works, at a high level, and, when it helps, slides, screenshots, or a demo video. Skillmart shows the page as the skill’s Overview tab, and the summary and cover on its cards. Like the README.md, the page and its media/ folder never ship, so agents never read them.
---tagline: Let your agent do more on its own by verifying its own work.summary: Let agents prove their changes on the running app.video: file: media/demo.mp4 poster: media/demo-poster.png captions: media/demo.vtt title: Generate a verify skill and prove a feature with itgallery: - file: media/slide-1.png alt: A bar chart in which writing a change takes an agent minutes and proving it takes a person much longer caption: Agents write code in minutes. Checking it is now the slow part. - file: media/slide-2.png alt: Two columns comparing what automated tests check with what a verify skill checks---
Generate a verify skill for your project, so any agent can launch your real app, drive a feature the way a userwould, and hand back evidence that it works.
## Why it exists
Coding agents finish a change long before anyone can confirm it works. ...
## How it works
1. It reads the repository to learn how the app starts, what a user touches, and what can drive it.2. ...Write the copy for someone who has never heard of the skill:
- Tagline. Pitch the headline at the right height. Too high, and it’s generic: the reader can’t see how the skill could deliver it. Too low, and it’s a feature: the reader asks “so what?”. Name the outcome and how the skill gets there, as in “Let your agent do more on its own by verifying its own work.”
- Pitch. The first paragraph says what to do with the skill, in the imperative: “Generate a verify skill for your project”, not “Generates a verify skill”.
- Sections. Follow it with a few short
##sections, such as Why it exists, What you get, and How it works. Leave install steps out: catalogs show them beside the page. - Summary. Give a line of up to 100 characters for cards and lists, where a skill’s
SKILL.mddescription, written for agents, is usually too long. Without one, cards show the tagline.
Show the skill, when a picture says it faster than words:
- Slides suit a skill whose value is an idea, such as one that keeps a feature map from drifting from the app. Make one point per slide: open with the problem on its own slide, then how the skill solves it, then the details.
- Screenshots suit a skill that makes something you can see, such as a page, a canvas, or a report.
- A fork gets a slide that says it’s a fork, names the original (its source, repository, path, and the commit it’s based on), and says why you couldn’t use the original, from its
reasoninskills.forks, so readers know whose work it builds on. - A demo video is a walkthrough, not a clip: about 60 to 90 seconds that show the problem, the skill running, and the result. Narration is up to you; add captions so it works muted. Keep it to 10 MB or less: an MP4 with H.264 at 1080p usually fits.
The first gallery image, or the video’s poster when there’s a video, is the skill’s cover; set cover to choose another. Keep every file the page shows in the skill’s media/ folder, and point the README.md at the same files when you want GitHub readers to see them too. A stack’s overview.md and media/ go in the stack’s folder, beside its README.md. Overview page lists every field and check.
The page is optional: write one when you want the skill to stand out in a catalog. Without one, catalogs show the opening of the skill’s README.md, and library check only notes the missing page. Set skills.overviewPages in .trailguide/library.yaml once to decide for the whole library, so nobody, agents included, has to ask again: off when the library doesn’t need pages, which stops the note, and required when every skill and stack must have one, which fails check without one. Releases before 0.14.0 reject the setting, so trailguide library build raises minTrailguideVersion to 0.14.0 when you add it:
skills: overviewPages: offtrailguide library add skill --overview, or library add skill in a library that requires pages, writes a starter overview.md with placeholders and the trailguide:draft marker. Replace the placeholders, add your media, and remove the marker; library check fails while the marker is there, so a starter page never reaches a catalog. If the skill doesn’t need a page yet and the library doesn’t require pages, delete the file.
trailguide library check fails when the page names a file that doesn’t exist or isn’t in media/, a file whose extension has capital letters, such as .PNG, an image that isn’t a PNG, JPEG, WebP, or GIF of at most 2 MB with an extension that matches its format, a video that isn’t an MP4 or WebM of at most 10 MB, or captions that aren’t WebVTT, and on an image without alt text. It also notes each skill and stack that has no overview page yet, unless skills.overviewPages is off. That note never fails the check, unless skills.overviewPages is required. The first time your sources have an overview page other than a starter page, or a file in a media/ folder, a release of trailguide library build raises the library’s minTrailguideVersion to its own version, unless it already names 0.14.0 or newer, since earlier releases would ship the page in the built skill; commit .trailguide/library.yaml with the build. Library check fails with stale-build while the sources have pages or media and the minimum names an earlier release, or none, so a page never reaches a release that older Trailguide releases would build wrong. Catalogs read overview pages from library releases, so publish a library release to show a new or changed page; a change to only overview pages and media is enough for one, with no change note.
Build and check the skill
Section titled “Build and check the skill”In a library, build the skills, then check them, along with the rest of the library:
trailguide library buildtrailguide library checkBuild writes skills/dist/ and the skills index, skills/README.md. Commit both with the sources: check fails when they aren’t what skills/src/ builds, and names the source to edit, never skills/dist/.
Check validates the folder, the frontmatter, the trailguide- keys, the rules and skills they name, and every link, and lists each problem it finds:
Error: skills don't pass library check: - skills/src/skills/fix-bug/SKILL.md: trailguide-rules-used names practices/testing/reproduce-bug-with-a-failing-test, which isn't a rule in this library - skills/src/skills/fix-bug/SKILL.md: trailguide-skill-type is workflow; use playbook or review, or leave it outValidation lists every check and its message.
In a project, run trailguide project build, which validates your skills and installs them into the project’s skill targets, then trailguide project check.
Check validates the format, not the guidance. Before publishing, try the skill: ask an agent to carry out a real task with it, and revise any step the agent skipped, misread, or had to ask about.
Set the skill’s level
Section titled “Set the skill’s level”In a library, decide how strongly projects should take the skill, and list it in the manifest, .trailguide/library.yaml:
schemaVersion: 3name: fabricaskills: required: [skills/ship-service] recommended: [skills/fix-bug, skills/review-tests]- Required skills install in every project that uses the library, whatever the project includes, and no project can exclude or fork them. Require only what every project must follow, such as your organization’s release procedure.
- Recommended skills install in projects that include
recommended. - Available skills install only when a project names them or includes
"*". A skill you don’t list is available, so list only the skills you have an opinion about.
When one of your skills uses a curated skill that no level lists, projects install the curated skill with the skills that call it, and can’t choose it alone; see Dependencies.
Levels are library-wide settings, like rule group metadata: changing one needs no change note, and the next library release publishes it. Projects see a level change, such as recommended to required, in their update preview. trailguide library check fails when two skills you list, including skills you curate from other repositories, have the same name, so your projects never inherit a clash.
Record a change note
Section titled “Record a change note”Skills are versioned like rules. Before your library’s first library release, skills need no change notes; the first library release gives every skill version 1.0.0. After it, record every new or changed skill with trailguide library change, in the same pull request as the change.
For a new skill, leave out --bump:
trailguide library change skills/fix-bug \ --summary 'Add a playbook for fixing a reported bug with a regression test.'For a changed skill, choose the level from what the change does to what the skill produces and requires:
trailguide library change skills/fix-bug \ --bump minor \ --summary 'Add a step that reviews the changed tests.'- Major: someone relying on the previous version could get a different result, such as a removed or reordered step people rely on, a new required input, or a new rule or skill the skill uses.
- Minor: the skill adds steps or guidance without breaking that.
- Patch: the skill only clarifies its wording.
When unsure, choose the larger level. Any change in the built folder counts, including scripts, references, a script’s executable bit, and a shared file the build copies in, so a change to a shared file changes every skill that links to it. A change to a skill’s README.md alone needs no note, since it doesn’t ship. Version your rules covers the levels and publishing in full.
Skills in a repository that isn’t a library have no versions and need no notes.
Retire or replace a skill
Section titled “Retire or replace a skill”To stop publishing a library skill, delete its source folder, run trailguide library build, which removes its built folder, remove it from the manifest’s levels, and record the retirement. Name the skill that replaces it, when there is one:
trailguide library change skills/triage-bug \ --retire \ --replaced-by skills/fix-bug \ --summary 'Covered by the fix-bug playbook, which also writes the regression test.'Only a skill can replace a skill. A retired skill’s ID can’t be reused, and projects see the retirement, with its replacement, in their update preview. Update any skill that names the retired one in trailguide-skills-used in the same pull request; trailguide library check fails until you do.
To rename a skill, rename its folder and its name field, then record one note that retires the old ID, replaced by the new one, and adds the new ID:
summary: Rename to say what the playbook produces.skills: skills/triage-bug: change: retired replacedBy: skills/fix-bug skills/fix-bug: newIn a project, replace a skill you include from a source by forking it with trailguide project fork skill, or by writing your own in .trailguide/skills/<name>/ and adding a skills.forks entry keyed by skills/<name>, with the source’s skill as from; see Configuration. To remove one of your own skills, delete its folder and any skills.forks entry keyed by it, then run trailguide project build.
Next steps
Section titled “Next steps”- Skill format defines every field and check.
- Install skills shows how projects include and install your skills.
- Version your rules covers change notes and publishing library releases.
- Write a rule covers the rules your skills cite.