|
| 1 | +# Bundled Agent Skills |
| 2 | + |
| 3 | +The shiny package ships [Agent Skills](https://agentskills.io) under |
| 4 | +`shiny/.agents/skills/` — one directory per skill, each with a `SKILL.md`, |
| 5 | +following the [Agent Skills specification](https://agentskills.io/specification). |
| 6 | +They are **package data**: they ship in the wheel and are discovered by |
| 7 | +installers such as [library-skills](https://library-skills.io) (which symlinks |
| 8 | +them into a project's `.agents/skills/` or `.claude/skills/`). A `shiny skills |
| 9 | +list|get` CLI subcommand is planned as a zero-dependency way to read them. |
| 10 | + |
| 11 | +**Audience:** coding agents *using* shiny to build, test, and debug apps — not |
| 12 | +contributors to shiny itself. Contributor-facing guidance belongs in |
| 13 | +`.claude/references/`, not here. If a topic serves both audiences, the bundled |
| 14 | +skill documents the public API and the reference file documents the internals. |
| 15 | + |
| 16 | +## Layout |
| 17 | + |
| 18 | +Per the spec, a skill is a directory containing at minimum a `SKILL.md`, plus |
| 19 | +three conventional optional directories: |
| 20 | + |
| 21 | +``` |
| 22 | +shiny/.agents/skills/ |
| 23 | + <skill-name>/ |
| 24 | + SKILL.md # required: frontmatter + instructions |
| 25 | + scripts/ # optional: self-contained runnable code |
| 26 | + references/ # optional: on-demand docs (loaded only when needed) |
| 27 | + assets/ # optional: templates, images, data files |
| 28 | +``` |
| 29 | + |
| 30 | +- Skill names are short topics: `debugging`, `testing`, `modules`, `express`, ... |
| 31 | +- Names are **unprefixed** (no `shiny-` prefix): installers namespace skills |
| 32 | + by package, and the description scopes the skill to Shiny for Python. |
| 33 | +- Keep everything in `SKILL.md` until a file earns its keep. Heavy reference |
| 34 | + material (100+ lines) goes in `references/` — agents load those on demand, |
| 35 | + so smaller focused files cost less context. Link with relative paths from |
| 36 | + the skill root (`references/REFERENCE.md`) and keep references one level |
| 37 | + deep — no chains of files pointing at files. |
| 38 | + |
| 39 | +## Frontmatter |
| 40 | + |
| 41 | +```yaml |
| 42 | +--- |
| 43 | +name: <skill-name> |
| 44 | +description: <what the skill covers and when to use it> |
| 45 | +--- |
| 46 | +``` |
| 47 | + |
| 48 | +Required fields (spec constraints): |
| 49 | + |
| 50 | +- `name` — 1-64 characters; lowercase letters, numbers, and hyphens only; no |
| 51 | + leading, trailing, or consecutive hyphens; **must match the directory name**. |
| 52 | +- `description` — 1-1024 characters, non-empty. Covers both *what the skill |
| 53 | + does* and *when to use it*, with keywords agents would match on. |
| 54 | + |
| 55 | +How to write the description (this is the only part of a skill loaded at |
| 56 | +startup — agents decide from it alone whether to activate the skill): |
| 57 | + |
| 58 | +- Lead with a one-clause summary of what the skill covers, then "Use when…" |
| 59 | + listing triggering conditions, symptoms, and search phrases — including the |
| 60 | + *wrong* approach an agent might be about to take (e.g. "…or when tempted to |
| 61 | + add print statements or hidden outputs"). |
| 62 | +- Do **not** summarize the skill's workflow or step-by-step process: agents |
| 63 | + that get the recipe from the description follow it and skip the body. |
| 64 | +- Third person. Descriptions across skills must not overlap: agents pick a |
| 65 | + skill by description alone, so two skills matching the same symptom means |
| 66 | + the wrong one gets loaded. When adding a skill, re-read the other |
| 67 | + descriptions and sharpen the boundaries. |
| 68 | + |
| 69 | +Optional fields (`license`, `compatibility`, `metadata`, `allowed-tools`) are |
| 70 | +defined by the spec but usually unnecessary here: skills inherit the package's |
| 71 | +MIT license, and `compatibility` is only for skills with environment |
| 72 | +requirements beyond shiny itself (e.g. requires Playwright installed). |
| 73 | + |
| 74 | +The name/directory match and description presence are enforced by |
| 75 | +`tests/pytest/test_packaging.py`. |
| 76 | + |
| 77 | +## Body content |
| 78 | + |
| 79 | +The body is loaded in full once a skill activates, so size it for progressive |
| 80 | +disclosure: keep `SKILL.md` under ~500 lines (well under 5000 tokens), moving |
| 81 | +detail to `references/`. Skills are reference docs, not tutorials. The shape |
| 82 | +that works: |
| 83 | + |
| 84 | +1. **Overview** — the core principle in 1-3 sentences, including what NOT to |
| 85 | + do (the workaround the skill replaces). |
| 86 | +2. **Task-oriented sections** — one per job the agent came to do, each with a |
| 87 | + short runnable example against the **public API only** (imports included, |
| 88 | + copy-paste ready). One excellent example per pattern; no variations. |
| 89 | +3. **Quick-reference table** for enumerable facts (env vars, flags, marker |
| 90 | + strings). |
| 91 | +4. **Common mistakes** — concrete symptom → fix pairs, especially the |
| 92 | + non-obvious gotchas (e.g. module namespacing of ids, 404 when a feature |
| 93 | + flag is off). |
| 94 | + |
| 95 | +Keep a skill focused on one topic and roughly 400-800 words. If a section |
| 96 | +outgrows that, it is probably a second skill. Prefer extending an existing |
| 97 | +skill over creating a new one; create a new directory only for a genuinely |
| 98 | +separate topic with its own triggering conditions. |
| 99 | + |
| 100 | +Anything in `scripts/` must be self-contained (or clearly document its |
| 101 | +dependencies), emit helpful error messages, and handle edge cases — agents |
| 102 | +run these directly. |
| 103 | + |
| 104 | +## Maintenance |
| 105 | + |
| 106 | +- Bundled skills are **user-facing documentation**. When a PR changes an API |
| 107 | + that a skill documents, update the skill in the same PR — grep |
| 108 | + `shiny/.agents/skills/` for the API name as part of the change. |
| 109 | +- Skills describe behavior as shipped, not as planned: never document an API |
| 110 | + before it is merged. |
| 111 | +- Adding or materially changing a skill warrants a CHANGELOG entry. |
| 112 | + |
| 113 | +## Validation |
| 114 | + |
| 115 | +- `pytest tests/pytest/test_packaging.py` — checks the frontmatter contract |
| 116 | + and that every file under `shiny/.agents/` is matched by the |
| 117 | + `[tool.setuptools.package-data]` globs in `pyproject.toml`. The explicit |
| 118 | + `.agents/**` glob is required because `**` does not match hidden |
| 119 | + directories; without it skills silently drop out of the wheel. |
| 120 | +- The spec's reference validator checks frontmatter and naming conventions: |
| 121 | + `uvx --from skills-ref agentskills validate shiny/.agents/skills/<name>` |
| 122 | + (see [skills-ref](https://github.com/agentskills/agentskills/tree/main/skills-ref)). |
| 123 | +- To confirm against a real build: |
| 124 | + `uv build --wheel && unzip -l dist/shiny-*.whl | grep .agents` |
| 125 | +- For a new skill, do a before/after check: give a fresh agent (no skill) a |
| 126 | + task the skill targets and note what it reaches for; then repeat with the |
| 127 | + skill available. If the "after" run doesn't change the approach, the |
| 128 | + description isn't triggering or the body isn't teaching — fix before |
| 129 | + shipping. |
0 commit comments