|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides guidance to AI coding agents working with code in this repository. |
| 4 | + |
| 5 | +## Repository Overview |
| 6 | + |
| 7 | +A collection of Agent Skills for the Rspack ecosystem (Rspack, Rsbuild, Rslib, Rstest, Rsdoctor). Skills are packaged instructions and scripts that extend agent capabilities for debugging, profiling, and development workflows. |
| 8 | + |
| 9 | +## Creating a New Skill |
| 10 | + |
| 11 | +### Directory Structure |
| 12 | + |
| 13 | +``` |
| 14 | +skills/ |
| 15 | + {skill-name}/ # kebab-case directory name |
| 16 | + SKILL.md # Required: skill definition with YAML frontmatter |
| 17 | + scripts/ # Optional: executable scripts (.js, .cjs, .sh) |
| 18 | + references/ # Optional: detailed documentation loaded on-demand |
| 19 | + assets/ # Optional: templates, images, data files |
| 20 | +``` |
| 21 | + |
| 22 | +### Naming Conventions |
| 23 | + |
| 24 | +- **Skill directory**: `kebab-case` (e.g., `rspack-debugging`, `rstest-cdp`) |
| 25 | +- **SKILL.md**: Always uppercase, always this exact filename |
| 26 | +- **Scripts**: `snake_case.js` or `snake_case.cjs` (e.g., `analyze_trace.js`, `setup_debug_deps.cjs`) |
| 27 | + |
| 28 | +### SKILL.md Format |
| 29 | + |
| 30 | +```markdown |
| 31 | +--- |
| 32 | +name: { skill-name } |
| 33 | +description: |
| 34 | + { |
| 35 | + What the skill does AND when to use it. Include trigger phrases and error messages that should activate this skill., |
| 36 | + } |
| 37 | +compatibility: |
| 38 | + { Optional: environment requirements like Node version, CLI tools, etc. } |
| 39 | +--- |
| 40 | + |
| 41 | +# {Skill Title} |
| 42 | + |
| 43 | +## When to Use This Skill |
| 44 | + |
| 45 | +{Clear trigger conditions — error messages, scenarios, user requests} |
| 46 | + |
| 47 | +## Workflow |
| 48 | + |
| 49 | +{Numbered steps explaining how to use the skill} |
| 50 | + |
| 51 | +## Detailed Guides |
| 52 | + |
| 53 | +{Links to reference files for progressive disclosure} |
| 54 | + |
| 55 | +## Troubleshooting |
| 56 | + |
| 57 | +{Common issues and solutions} |
| 58 | +``` |
| 59 | + |
| 60 | +### Best Practices for Context Efficiency |
| 61 | + |
| 62 | +Skills use progressive disclosure — only name and description load at startup. The full `SKILL.md` loads when the agent decides the skill is relevant. |
| 63 | + |
| 64 | +- **Keep SKILL.md under 500 lines** — put detailed guides in `references/` directory |
| 65 | +- **Write specific descriptions** — include exact error messages and trigger phrases |
| 66 | +- **One level deep references** — link directly from SKILL.md to supporting files |
| 67 | +- **Prefer scripts over inline code** — script execution doesn't consume context (only output does) |
| 68 | +- **No time-sensitive information** — avoid dates or version-specific instructions that will become stale |
| 69 | + |
| 70 | +### Script Requirements |
| 71 | + |
| 72 | +- Use CommonJS (`require`/`module.exports`) for `.cjs` files |
| 73 | +- Include clear usage help: `console.error('Usage: node script.js <args>')` |
| 74 | +- Handle errors explicitly with actionable messages |
| 75 | +- Use emoji prefixes for user-facing logs: `📍`, `✅`, `❌`, `⚠️`, `👉` |
| 76 | +- Document magic constants: `const MIN_VERSION = '1.3.14'; // First version with debug symbols` |
| 77 | + |
| 78 | +### Validating Skills |
| 79 | + |
| 80 | +Use the [skills-ref](https://github.com/agentskills/agentskills/tree/main/skills-ref) library: |
| 81 | + |
| 82 | +```bash |
| 83 | +npx skills-ref validate ./skills/{skill-name} |
| 84 | +``` |
| 85 | + |
| 86 | +## Resources |
| 87 | + |
| 88 | +- [Agent Skills Specification](https://agentskills.io/specification) |
| 89 | +- [Skill Authoring Best Practices](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices) |
0 commit comments