Skip to content

Commit ede9495

Browse files
committed
Add AUthoring guidelines
1 parent 96bb3c8 commit ede9495

2 files changed

Lines changed: 154 additions & 2 deletions

File tree

AUTHORING.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Authoring AMD Skills
2+
3+
A short guide for writing skills that agents pick up reliably and execute well. For repository structure and contribution paths, see the [README](README.md). For the full Anthropic reference, see [Skill authoring best practices](https://docs.anthropic.com/en/docs/agents-and-tools/agent-skills/best-practices).
4+
5+
## Is this task a good fit for a skill?
6+
7+
Skills earn their keep on repeated, opinionated workflows. Before writing one, check that the task has these properties:
8+
9+
- **Single clear outcome.** One job, one measurable success condition. If you can't state success in one sentence, split the skill.
10+
- **Well-defined inputs and outputs.** Predictable shape, minimal ambiguity. The agent should know what to ask for and what to produce.
11+
- **Tool-bounded.** Uses only the tools and data it truly needs. Fewer moving parts means fewer ways to fail.
12+
- **Deterministic where possible.** Same input should produce a similar output across runs. Lean on scripts for the deterministic parts.
13+
- **Short execution path.** Few steps, low latency, low token cost. Long workflows belong in a checklist or split skills.
14+
- **Recoverable failures.** Detects errors and either retries or exits cleanly with a useful message — never leaves the user mid-state.
15+
- **Context-light.** Works from the user's prompt and the skill body. Doesn't require long conversation history or hidden setup.
16+
17+
If the task fails several of these, it is probably documentation, a runbook, or a one-off prompt — not a skill.
18+
19+
## Write the description for the goal, not the mechanics
20+
21+
The `description` is the only part of the skill always loaded into context. The agent uses it to decide *whether* to load the rest. Treat it as a routing signal, not marketing copy.
22+
23+
### Describe the user's goal, not how the skill works
24+
25+
The agent matches descriptions against what the user is trying to *achieve*. Internal mechanics (which library, which container, which API) belong in the body of `SKILL.md`.
26+
27+
```yaml
28+
# Good — names the goal and the trigger surface
29+
description: >-
30+
Port a CUDA kernel to HIP and flag anything that needs manual review.
31+
Use when the user wants to run CUDA code on AMD GPUs, mentions hipify,
32+
HIP, ROCm porting, or asks how to convert a .cu file.
33+
34+
# Bad — describes how the skill works internally
35+
description: >-
36+
Runs hipify-perl on .cu files, parses the output, and post-processes
37+
the result with regex rules.
38+
```
39+
40+
### Description checklist
41+
42+
- **Third person.** The description is injected into the system prompt. Use *"Ports CUDA kernels..."*, not *"I help you port..."* or *"You can use this to..."*.
43+
- **State WHAT and WHEN.** What the skill produces, and the situations in which the agent should reach for it.
44+
- **Include the trigger surface.** List the words and phrases a user is likely to say — product names, file extensions, API names, error messages. Missing triggers cause under-triggering.
45+
- **Add negative triggers when boundaries are easily crossed.** *"Do not use for system-wide installs — see X instead."*
46+
- **Be pushy when the use case is ambiguous.** It is better to err toward being invoked than to be silently skipped.
47+
- **Stay under ~1024 characters** (the hard cap on Anthropic-compatible runtimes).
48+
49+
### Naming
50+
51+
Use `lowercase-with-hyphens`, max 64 characters, no `anthropic` or `claude` substrings. Prefer gerund or action-oriented names tied to the outcome:
52+
53+
- Good: `porting-cuda-to-hip`, `tuning-mi300x`, `picking-rocm-container`
54+
- Avoid: `helper`, `utils`, `gpu-stuff`
55+
56+
## SKILL.md body
57+
58+
The body loads only when the description matches. Once loaded, every token competes with conversation history and other context.
59+
60+
### Be concise
61+
62+
Assume the agent already knows general programming, common libraries, and standard CLI tools. Only add what it would *otherwise guess wrong*. Challenge each paragraph: *"does this justify its tokens?"*
63+
64+
Keep the body under ~500 lines. Push reference material into sibling files (`reference.md`, `examples.md`, etc.) and link to them from `SKILL.md`.
65+
66+
### Match degrees of freedom to the task
67+
68+
| Freedom | Use when | Form |
69+
| --- | --- | --- |
70+
| **Low** | Operation is fragile, exact sequence matters | Specific scripts, exact commands |
71+
| **Medium** | Preferred pattern with acceptable variation | Pseudocode, parameterized templates |
72+
| **High** | Multiple valid approaches, context-dependent | Text instructions, heuristics |
73+
74+
Database migrations want low freedom. Code review wants high freedom. Mismatched freedom is a top cause of skills that frustrate users.
75+
76+
### Use progressive disclosure, one level deep
77+
78+
Link from `SKILL.md` directly to reference files. Do not chain references through intermediate files — agents may only partially read deeply nested content.
79+
80+
```
81+
skill-name/
82+
SKILL.md # overview, quick start, links
83+
reference.md # full API / flag reference
84+
examples.md # worked examples
85+
scripts/ # executable utilities
86+
```
87+
88+
For reference files longer than ~100 lines, put a table of contents at the top so the agent can see the full scope even when it previews with `head`.
89+
90+
### Provide a default, not a menu
91+
92+
```
93+
Bad: "You can use pdfplumber, pypdf, PyMuPDF, or pdf2image..."
94+
Good: "Use pdfplumber for text extraction. For scanned PDFs that need OCR,
95+
use pdf2image with pytesseract instead."
96+
```
97+
98+
One opinionated path with a single named escape hatch beats a buffet.
99+
100+
### Be consistent with terminology
101+
102+
Pick one term per concept and stick with it. Mixing *"endpoint"*, *"URL"*, *"route"*, and *"path"* in the same skill makes instructions harder for the agent to follow.
103+
104+
### Avoid time-sensitive content
105+
106+
`"Before August 2025, use the old API"` becomes wrong on its own schedule. Instead, write a `## Current method` section and tuck legacy guidance into a collapsed `## Old patterns` block.
107+
108+
### Use forward slashes everywhere
109+
110+
`scripts/helper.py`, never `scripts\helper.py`. Forward slashes work on every platform; backslashes break on Linux and macOS.
111+
112+
## Scripts and tools
113+
114+
Pre-made scripts beat generated code: more reliable, fewer tokens, consistent across runs.
115+
116+
- **Solve, don't punt.** Handle expected error cases inside the script. Don't return a stack trace and hope the agent figures it out.
117+
- **No voodoo constants.** If a timeout is 47 seconds, say *why* in a comment. If you don't know the right value, neither will the agent.
118+
- **State dependencies.** List required packages and target versions in `SKILL.md`. Don't assume `rocm-smi`, `hipify-perl`, or any framework is on the path.
119+
- **Make execution intent explicit.** Write *"Run `analyze.py`..."* (execute) or *"See `analyze.py` for the algorithm"* (read), never both.
120+
- **Use fully qualified MCP tool names.** `ServerName:tool_name`, e.g. `BigQuery:bigquery_schema`. Bare names fail when multiple servers are registered.
121+
122+
## AMD-specific guidance
123+
124+
- **State prerequisites up front.** ROCm version, kernel version, GPU architecture (`gfx942`, `gfx90a`, `gfx1100`, ...), container image, driver branch.
125+
- **Pin to a known-good container when one exists.** Don't make the agent guess between `rocm/pytorch`, `rocm/dev-ubuntu-22.04`, etc.
126+
- **Call out silent footguns.** Environment variables that change behavior without warning (`HSA_OVERRIDE_GFX_VERSION`, `PYTORCH_HIP_ALLOC_CONF`, `HIP_VISIBLE_DEVICES`) deserve their own section.
127+
- **Note unsupported architectures explicitly.** A skill that only works on CDNA should say so, not fail mysteriously on RDNA.
128+
129+
## Iterate against real usage
130+
131+
Test the skill the way users will hit it:
132+
133+
1. Run a fresh agent against ~10 prompts that *should* trigger the skill and ~10 that *shouldn't*. The description should route both sets correctly.
134+
2. Run the skill end-to-end on a real machine. Watch where the agent hesitates, asks unnecessary questions, or goes off-script.
135+
3. Bring those observations back into the skill — usually as a sharper description, a clearer default, or a missing prerequisite — rather than adding more prose.
136+
137+
## Pre-publish checklist
138+
139+
- [ ] Description states the user's goal and includes likely trigger phrases
140+
- [ ] Description is third person and under 1024 characters
141+
- [ ] Skill name is lowercase-with-hyphens and ties to the outcome
142+
- [ ] `SKILL.md` body is under 500 lines
143+
- [ ] Reference files are linked one level deep from `SKILL.md`
144+
- [ ] One opinionated default per decision, with named escape hatches
145+
- [ ] Consistent terminology throughout
146+
- [ ] No time-sensitive statements outside an `Old patterns` section
147+
- [ ] All paths use forward slashes
148+
- [ ] Scripts handle expected errors and document their constants and dependencies
149+
- [ ] Prerequisites (ROCm version, GPU arch, container, env vars) are stated explicitly
150+
- [ ] Tested end-to-end on the target hardware against real prompts

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Concretely:
104104
- The `cuda-to-hip` skill lives with the HIP project.
105105
- `rocm-doctor` lives with the ROCm release tree.
106106
- `ryzen-ai-deploy` ships with Ryzen AI.
107-
- `local-ai-app-integration` is incubating in this repo today and will graduate to `lemonade-sdk/lemonade` so it ships and versions with the `lemond` binary it drives.
107+
- `local-ai-app-integration` is incubating in this repo today and will graduate to `lemonade-sdk/lemonade`.
108108

109109
Each skill stays close to the engineers who ship the underlying product, the CI that validates it, and the release tag that pins it.
110110

@@ -201,7 +201,9 @@ Best for skills that should ship and version with a product (HIP, MIGraphX, Ryze
201201

202202
### Writing tips
203203

204-
- Optimize the `description` for *agent routing*, not marketing copy. It is what decides whether the skill gets loaded.
204+
See [AUTHORING.md](AUTHORING.md) for the full authoring guide — when a task is a good fit for a skill, how to write a description that routes correctly, and the conventions every AMD skill should follow. The essentials:
205+
206+
- Optimize the `description` for *agent routing*, not marketing copy. Describe the user's goal, not how the skill works internally.
205207
- Be explicit about prerequisites: ROCm version, kernel, GPU architecture, container image.
206208
- Prefer scripts and runnable commands over prose where possible.
207209
- Call out known pitfalls — driver mismatches, unsupported architectures, environment variables that silently change behavior.

0 commit comments

Comments
 (0)