skills-best-practices
Build high-quality Agent Skills for any agent - opinionated best practices distilled from the Agent Skills spec, official Anthropic guidance, and production experience. Covers SKILL.md structure, frontmatter, description writing, single-file vs references/ layout, progressive dis
Install
npx skills add https://github.com/tenequm/skills/tree/main/skills/skills-best-practices
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install tenequm-skills@llmmart
git clone https://github.com/tenequm/skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole tenequm/skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Skills Best Practices
Opinionated guide to building Agent Skills for any agent - distilled from the Agent Skills open standard, Anthropic's official guidance, and production experience, with deviations from the official line marked where they occur. Skills are folders (often just a single file) containing instructions, scripts, and resources that teach an agent how to handle specific tasks.
Quick Start
A minimal skill is a directory with a SKILL.md file:
my-skill/
├── SKILL.md # Required - instructions with YAML frontmatter
├── references/ # Optional - detailed docs loaded on demand
├── scripts/ # Optional - executable code
└── assets/ # Optional - templates, fonts, icons
Minimal SKILL.md:
---
name: my-skill-name
description: What it does. Use when [specific triggers].
---
# My Skill Name
[Instructions here]
Only name and description are required in frontmatter.
Core Design Principles
Single File vs. references/ (Most Important)
Default to a single SKILL.md. One file can be pasted to a person, gisted, embedded in a CLI binary, and printed by a <tool> skill subcommand - a directory cannot. Split into references/ only when both hold:
- Conditional loading: a meaningful chunk of content is needed by only a subset of invocations (e.g. a tracked-changes doc most DOCX tasks never touch). If every invocation reads everything anyway, splitting adds Read round-trips and costs shareability while saving nothing.
- Size pressure: the body exceeds the recommended budget below.
Distribution is a veto. If the skill must travel as one file - shipped inside a CLI, printed by a command, shared by paste - stay single-file regardless of size and condense instead. Condensing means cutting redundancy, filler, and over-explanation while preserving every load-bearing instruction; losing substance to hit a line count is the failure mode, not the fix. See the single-file CLI-embedded pattern under Patterns.
Size guidance (opinionated thresholds drawn from experience, not enforced spec limits) - measure with wc -c SKILL.md. Chars track token cost closely (~4 chars per token); line counts are not a metric - identical content varies 2x in lines by formatting style:
| Tier | Chars | Beyond it |
|---|---|---|
| Recommended | 25k | Condense carefully; split only if the conditional-loading test passes |
| Hard ceiling | 50k | Must condense or split |
Official Anthropic guidance says to split at 500 lines. That advice assumes registry-installed skills with rarely-needed subtopics, and measures size in a unit that formatting distorts - this skill deliberately deviates on both.
When a skill does split, information loads in three levels:
| Level | When Loaded | Token Cost | Content |
|---|---|---|---|
| 1: Metadata | Always (startup) | ~chars / 4 + 25 - see Length |
name + description from frontmatter |
| 2: Instructions | When skill triggers | <5k tokens (recommended) | SKILL.md body |
| 3: Resources | As needed | Effectively unlimited | Bundled files, scripts |
Reference detail files from SKILL.md so they load only when the task requires them:
## Advanced features
- **Form filling**: See [FORMS.md](FORMS.md)
- **API reference**: See [reference.md](reference.md)
Composability
Skills work alongside other skills. Don't assume yours is the only one loaded.
Portability
Skills work across Claude.ai, Claude Code, API, and Agent SDK without modification (if dependencies are available).
Writing the Description (Critical)
The description is the single most important field - it determines when your skill activates. Claude uses it to decide relevance from potentially 100+ available skills.
Rules
- Write in third person ("Processes files..." - first or second person breaks discovery)
- Include WHAT it does + WHEN to use it
- No XML angle brackets; see Length for the size target
- Be slightly "pushy" - Claude tends to undertrigger rather than overtrigger
- Include specific trigger phrases users would naturally say, plus file types where relevant
- Write natural prose, not keyword dumps - matching is semantic, so a long "Triggers on X, Y, Z..." list adds little over a clear sentence
- If the skill depends on an MCP server, name it ("...via MCP. Requires Linear MCP server connected.")
Length
Target 250 characters. The spec's 1024 is a ceiling, not a budget. The description is the only part of a skill that costs tokens on every turn of every session, whether or not the skill ever fires. Past ~250 chars you are diluting the trigger, not sharpening it: descriptions are dispatch signals, not summaries.
Compressing an over-long description, in the order that usually pays:
- Cut stack enumerations restated in prose. Listing the stack once is enough; restating it as "covers the frontend ... and the backend ..." is pure padding
- Cut selling points. "Includes exhaustive API tables" describes the body, not when to fire
- Collapse trigger lists. One clear clause beats three quoted phrases plus four "when" clauses - matching is semantic, so near-duplicate triggers add nothing
- Keep exclusions and disambiguations. "Not for session state", "not the LanceDB product" run 30-40 chars and are the only thing preventing wrong-skill dispatch
Good vs Bad
# GOOD - specific, actionable, includes triggers
description: Extract text and tables from PDF files, fill forms, merge
documents. Use when working with PDF files or when the user mentions
PDFs, forms, or document extraction.
# BAD - too vague
description: Helps with documents.
# BAD - missing triggers
description: Creates sophisticated multi-page documentation systems.
Negative Triggers
When a skill overtriggers, add boundaries directly in the description:
description: Advanced data analysis for CSV files. Use for statistical
modeling, regression, clustering. Do NOT use for simple data
exploration (use data-viz skill instead).
Manually-Invoked Skills
disable-model-invocation: true stops a skill from auto-triggering - its description shows only in the / menu, so trigger phrases do nothing for it, and it is skipped for subagent preload and scheduled tasks too.
Don't reach for it by default. Users ask for a workflow in prose ("polish this before committing") far more often than they type /name, and the flag turns those requests into a hand-rolled, degraded version of the skill. Reserve it for genuinely destructive one-shots. When it is set, write a plain one-line summary and skip the trigger-tuning.
Frontmatter Reference
Required Fields
| Field | Rules |
|---|---|
name |
Kebab-case, max 64 chars, lowercase + numbers + hyphens only. No "claude" or "anthropic" |
description |
Non-empty, max 1024 chars, no XML tags. WHAT + WHEN |
The agentskills.io standard and the Claude API require both fields. Claude Code is more lenient: name falls back to the directory name, and description falls back to the first markdown paragraph. Write both anyway for portability.
The spec also defines optional license, compatibility, and metadata fields. compatibility is capped at 500 characters and states environment requirements (intended product, system packages, network access).
Optional Fields (Claude Code)
| Field | Purpose |
|---|---|
argument-hint |
Autocomplete hint, e.g. [issue-number] |
when_to_use |
Extra trigger context, appended to description in the skill listing |
arguments |
Named positional arguments for $name substitution (space-separated string or list) |
disable-model-invocation |
true = only user can invoke; also blocks subagent preload and scheduled tasks. Rarely worth it - see Manually-Invoked Skills |
user-invocable |
false = hidden from / menu (background knowledge) |
allowed-tools |
Pre-approves tools (no permission prompt) for the current turn; space-separated, e.g. Read Grep Glob. In the spec allowlist but tagged (Experimental) |
disallowed-tools |
Removes tools from Claude's pool while the skill is active; clears on your next message |
model |
Override model for this skill; accepts inherit. Lasts the current turn only |
effort |
Override effort level: low, medium, high, xhigh, max |
context |
fork = run in isolated subagent |
agent |
Subagent type when context: fork (e.g. Explore, Plan) |
background |
false opts a forked skill out of background execution (v2.1.218+) |
shell |
bash (default) or powershell |
hooks |
Hooks scoped to this skill's lifecycle |
paths |
Glob patterns limiting when skill activates |
Publishing caveat: every field above except
allowed-toolsis Claude Code-specific. They work in Claude Code at runtime, but the officialagentskills validatespec validator rejects them - it allows onlyname,description,license,compatibility,metadata,allowed-tools, with no relax flag. If your repo or CI runs that validator (most ClawHub-publishing repos do), a skill using these fields fails validation unless you strip them from the copy you validate/publish. The ClawHub registry itself tends to tolerate extra top-level fields on publish, but the reference validator in your pipeline will not. See Validate Against the Spec.
Naming Conventions
The name (and its folder) must: be 1-64 chars; use only lowercase letters, numbers, and hyphens; not start or end with a hyphen; not contain consecutive hyphens (--); and match the parent directory name. Anthropic surfaces also reject the reserved words claude and anthropic.
Prefer gerund form for clarity:
processing-pdfs,analyzing-spreadsheets,managing-databases- Also acceptable:
pdf-processing,process-pdfs - Avoid:
helper,utils,tools,documents
Claude Code Specifics
Official docs cover most Claude Code skill behavior: the skills docs (invocation control, argument substitution, discovery and priority, tool permissions, skillOverrides, context budget), the commands reference for the current bundled-skills roster (it churns every few releases - never hardcode it), and the settings reference. Below is only what those docs miss or what bites in practice.
Dynamic-Injection Footgun
Claude Code preprocesses SKILL.md at load: an exclamation mark immediately touching a backticked command executes that command before Claude sees the content (dynamic context injection). The preprocessor is not markdown-aware:
- A literal example executes at load even inside a code fence or inline code span, and a failing placeholder command errors the whole skill at load
- The inline form fires only at line start or after whitespace; a prefix defuses it (
KEY=before the!leaves it literal) - A fence opened with
!right after the backticks is the multi-line form and is equally live references/files are read with the Read tool and never preprocessed - the only safe home for live examples. In a SKILL.md, break the!-to-backtick adjacency instead (wrap the!in its own code span, as this section does)"disableSkillShellExecution": truein settings disables execution for user/project/plugin skills- In a skill you publish, prefer prose over an
!block. Dynamic injection is host-specific: on other surfaces the block arrives as literal text, and it dragsallowed-toolsalong purely to suppress its own permission prompts. Instructing the agent to run the command costs one tool call and works everywhere
Undocumented Behavior
display-name,default-enabled, andfallbackfrontmatter keys exist but are absent from the official frontmatter table- Frontmatter keys parse case-insensitively - kebab-case, snake_case, and camelCase resolve to the same field; boolean fields also accept
yes/no/on/off/1/0(v2.1.218+)
Behavior That Bites
context: forkskills run in the background by default since v2.1.218 (background: falseopts out); backgrounded forks get a narrower tool set and their edits bypass checkpoints, so/rewindcannot undo them.Explore/Planforks skip CLAUDE.md and git status; since v2.1.198Exploreinherits the session model- Skills stack:
/skill-a /skill-b argsin one message loads up to six skills (v2.1.199+) permissions.additionalDirectoriesdoes not load skills from those directories - only the--add-dirflag and/add-dircommand do- The
allowed-toolsgrant lasts the current turn - it clears when the user sends their next message, not when the skill "finishes" - The
/commandname comes from the skill's directory; frontmatternameis only a display label (plugin skills excepted). Nested skills are invocable by qualified name, e.g./apps/web:deploy - Invoked skill content stays in context all session and is not re-read - write standing instructions, not one-time steps. After auto-compaction, each skill's most recent invocation is re-attached with its first 5,000 tokens from a shared 25,000-token budget filled most-recent-first; re-invoke to restore full content
- Skill descriptions load at startup within a listing budget of 1% of the context window; least-used descriptions drop first (names always kept), each entry capped at 1,536 chars. Diagnose with
/doctor; tune viaskillListingBudgetFraction,skillListingMaxDescChars, orSLASH_COMMAND_TOOL_CHAR_BUDGET
Structuring Instructions
Be Concise
The agent is smart. Only add context it doesn't already have - a skill that explains what a PDF is, or lists four libraries before picking one, spends tokens telling the agent things it knows:
# BAD: "PDF files are a common format containing text and images. To extract
# text you need a library. There are many available..."
# GOOD: "Use pdfplumber for text extraction."
Avoid Too Many Options
Give one default with an escape hatch, not a menu:
# BAD: "Use pypdf, or pdfplumber, or PyMuPDF, or pdf2image..."
# GOOD: "Use pdfplumber. For scanned PDFs needing OCR, use pdf2image with pytesseract."
Set Degrees of Freedom
- High freedom (text guidelines): Multiple approaches valid, context-dependent
- Medium freedom (pseudocode/templates): Preferred pattern exists, some variation OK
- Low freedom (exact scripts): Operations are fragile, consistency critical
Recommended SKILL.md Structure
# Skill Name
## Quick start
[Minimal working example]
## Workflow Decision Tree
[Route to the right approach based on task type]
## Detailed Instructions
[Step-by-step for each workflow]
## Examples
[Concrete input/output pairs]
## Troubleshooting
[Common errors and fixes]
Reference Files
Keep references one level deep from SKILL.md. "Depth" means the reference chain (a file linking to a file linking to a file), not filesystem nesting - a references/ subdirectory is fine. In a chain, Claude may preview files with partial reads (head) and miss content.
# BAD: Too deep
SKILL.md -> advanced.md -> details.md -> actual info
# GOOD: One level
SKILL.md -> advanced.md (contains the info directly)
SKILL.md -> reference.md (contains the info directly)
For reference files >100 lines, include a table of contents at the top. Watch file size too: a single reference of many hundreds of lines defeats progressive disclosure even at one level deep, because Claude loads the whole file for any subtopic. Split large references by subtopic so each task pulls only what it needs.
Patterns
Common Workflow Shapes
Name the shape explicitly in the body rather than assuming the agent infers it:
- Sequential: numbered steps, each naming the exact command to run
- Decision tree: route on task type up front ("Creating new content? -> Creation workflow")
- Feedback loop: validate, fix, re-validate - and state that the loop exits only on a pass
- Checklist: for long tasks, have the agent copy a checklist and tick items as it goes
Single-File Skill Embedded in a CLI
For skills documenting a CLI tool: keep SKILL.md as one file next to the CLI source, compile it into the binary (go:embed, Rust include_str!, or equivalent), and add a <tool> skill subcommand that prints it. The printed guide always matches the installed version, and one command fetches the whole doc - playwright-cli, browser-use (browser-use skill show), and agent-browser (agent-browser skills get core) all converge on this shape. Never split such a skill into references/; condense carefully instead.
Working with MCP and Subagents
MCP provides tool access; skills provide the workflow knowledge for using those tools well. Reference MCP tools by qualified name (BigQuery:bigquery_schema, GitHub:create_issue). Skills are portable expertise; subagents are isolated execution - in Claude Code, context: fork frontmatter runs a skill inside a subagent.
Developing Skills with Claude (A/B Loop)
Build skills with two Claude instances: Claude A helps design and refine (it knows the format and what agents need); Claude B is a fresh instance with the skill loaded, tested on real tasks. Notice what context you repeatedly supply during normal work, have A capture it as a skill, test with B, bring B's specific failures back to A ("it forgot to filter test accounts"), and repeat. Iterate on observed behavior, not assumptions. For output-style skills, input/output example pairs communicate the desired style better than any description.
Scripts
When your skill includes executable code:
- Solve, don't punt: Handle errors explicitly instead of letting them fail
- Justify constants: No magic numbers - document why each value was chosen
- Prefer execution over loading: Scripts run without entering context; only output consumes tokens
- Clarify intent: "Run
analyze.py" (execute) vs "Seeanalyze.py" (read as reference) - List dependencies in SKILL.md and verify availability
Testing
Build Evaluations First
Create evaluations before writing extensive instructions - this proves the skill solves a real problem. Run Claude on representative tasks without the skill and document the failures; build ~3 scenarios that test those gaps; measure a baseline; then write the minimum instructions needed to pass. Iterate against the baseline.
Triggering Tests
Should trigger:
- "Help me set up a new project in [Service]"
- "I need to create a project" (paraphrased)
Should NOT trigger:
- "What's the weather?" (unrelated)
- "Write Python code" (too generic)
Functional Tests
Test normal operations, edge cases, and out-of-scope requests. Run the same request 3-5 times to check consistency.
Debug Triggering
Ask Claude: "When would you use the [skill-name] skill?" - it quotes the description back. Adjust based on what's missing.
Validate Against the Spec
Run the official Agent Skills validator before publishing:
uvx --from skills-ref agentskills validate path/to/skill
Exit 0 means valid. It checks SKILL.md format and enforces the spec's strict frontmatter allowlist (name, description, license, compatibility, metadata, allowed-tools). Most registries (e.g. ClawHub) and CI gates run this, so validating locally catches failures early. If you rely on Claude Code-only frontmatter (see the publishing caveat under Frontmatter Reference), strip those fields from the copy you validate.
Pre-Publish Checklist
Calibrate to scope: for a project-local or single-user skill, skip the triggering-accuracy and distribution-hygiene items.
- Folder and
namekebab-case and matching; file is exactlySKILL.md - Description: third person, WHAT + WHEN, specific triggers, under 1024 chars, no angle brackets
- Single file unless conditionally-loaded content justifies references/; within size budget (
wc -c) - Critical instructions at the top; working examples, not pseudocode; consistent terminology
- If split: references linked from SKILL.md, one level deep, TOC for files over 100 lines
- Scripts: explicit error handling, no unexplained constants, dependencies listed, execute-vs-read intent clear
- Triggering tested: fires on direct and paraphrased requests, silent on unrelated and similar-but-distinct ones
- Functional: normal and edge cases pass, output consistent across 3-5 runs, tested on more than one model
- No time-sensitive info, Windows-style paths, or deprecated APIs
- Spec validator exits 0 (command above)
- After upload: monitor under/over-triggering in real conversations, iterate the description, bump version on every change
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Skill never loads | Description too vague | Add specific triggers and key terms |
| Skill loads for wrong tasks | Description too broad | Add negative triggers, be more specific |
| Instructions not followed | Too verbose or buried | Put critical instructions at top, use headers |
| Slow/degraded responses | SKILL.md too large | Condense first; split to references/ only if content is conditionally loaded (see Single File vs. references/) |
| "Could not find SKILL.md" | Wrong filename | Must be exactly SKILL.md (case-sensitive) |
| "Invalid skill name" | Spaces or capitals | Use kebab-case: my-skill-name |
| Whole skill silently skipped at load | Description exceeds 1024 chars | Trim it - the loader rejects the file, not just the description |
| Frontmatter fails to parse | An unquoted description is a plain YAML scalar, so any colon-space (Triggers: , Use when: ) or straight "quotes" inside it breaks parsing |
Rewrite the colon as -, or quote the whole value |
| A doc example runs a shell command | A ! directly touching a backticked command executes on load, even inside a code fence |
Move the example to references/ or break the !-backtick adjacency (see Dynamic-Injection Footgun) |
Distribution
| Surface | How to Deploy |
|---|---|
| Claude.ai | Settings > Features > Upload zip |
| Claude Code (personal) | ~/.claude/skills/<name>/SKILL.md |
| Claude Code (project) | .claude/skills/<name>/SKILL.md |
| Claude Code (plugin) | <plugin>/skills/<name>/SKILL.md |
| API | Upload via the Skill Management API, use via the Messages API |
| Enterprise | Managed settings (org-wide) |
Skills don't sync across surfaces - deploy separately to each.
Using Skills with the API
Custom skills are uploaded through the Skill Management API; anthropic-type skills are pre-built by Anthropic. Both are used identically - pass them in the Messages API container parameter, each as {type, skill_id, version} where type is anthropic or custom. Up to 8 Skills per request, 30 MB max upload (all files combined), and all files must share a common root directory. Requires the code execution tool and the beta headers code-execution-2025-08-25 and skills-2025-10-02 (plus files-api-2025-04-14 for file upload/download).
Network access differs by surface. The API code execution environment has no network access and no runtime package installation - bundle dependencies or use pre-installed packages. On claude.ai, by contrast, Skills can install packages from npm and PyPI and pull from GitHub.
Also: a pause_turn stop reason signals a long-running Skill operation; reuse containers across turns via container.id; generated files come back via the Files API; changing the Skills list breaks prompt caching; Skills are not ZDR-eligible.
Security
- Only use skills from trusted sources
- No XML angle brackets in frontmatter (injection risk)
- Audit all bundled scripts and resources before using third-party skills
- Be cautious of skills that fetch from external URLs
- Documenting the dynamic-injection syntax is itself a hazard - the loader executes examples at load, even inside code fences. See the Dynamic-Injection Footgun before writing any
Additional References
- ClawHub publishing - source-mined moderation quirks: reason codes and fixes, LLM-review survival tactics, constraints absent from ClawHub's docs
Official Resources
Files (skills)
-
references
-
clawhub-publishing.md 6 KB
# Publishing to ClawHub ClawHub ([clawhub.ai](https://clawhub.ai)) is a public registry for Agent Skills. Its own docs now cover most of the surface - read them first: - [skill-format.md](https://github.com/openclaw/clawhub/blob/main/docs/skill-format.md) - `metadata.openclaw` schema, env-var rules (required vars in `requires.env`, optional in `envVars` with `required: false`), install specs, 50 MB bundle limit, forced MIT-0 license, immutable semver + mutable tags - [publishing.md](https://github.com/openclaw/clawhub/blob/main/docs/publishing.md) - `clawhub skill publish` flags (`--slug`, `--name`, `--categories`, `--topics`, `--dry-run`, ...) and catalog metadata - [cli.md](https://github.com/openclaw/clawhub/blob/main/docs/cli.md) - full command surface: `inspect`, `scan`, `delete`/`undelete` (30-day slug hold), `skill rename`/`merge`, `sync`, `token` - [security-audits.md](https://github.com/openclaw/clawhub/blob/main/docs/security-audits.md) - moderation pipeline (SkillSpector + VirusTotal telemetry + ClawScan risk analysis, worst signal wins), public statuses (Pass / Review / Warn / Malicious / Pending / Error), OWASP Agentic Skills Top 10 lens - [moderation.md](https://github.com/openclaw/clawhub/blob/main/docs/moderation.md) - appeals and publisher abuse-pressure scoring Below is only what those docs do not tell you: source-mined constraints and hard-won moderation knowledge. Verified against clawhub CLI v0.23.3, moderation engine v2.4.26, on 2026-08-07. ## Reason Codes: What Fires and How to Fix It The engine defines exactly 26 reason codes (source of truth: [`convex/lib/moderationReasonCodes.ts`](https://github.com/openclaw/clawhub/blob/main/convex/lib/moderationReasonCodes.ts)). The verdict derives from code prefixes: any `malicious.*` means malicious, any `suspicious.*` means suspicious, only `review.*` means the "Review" tier. The LLM review emits `review.llm_review` - a distinct `review.` tier, not "suspicious". The codes authors actually hit: | Code | Trigger | Fix | |---|---|---| | `review.llm_review` | Metadata-runtime mismatch, capability overreach, internal contradictions | Declare every env/bin/config the body references. Add `homepage`. Resolve flag contradictions (below) | | `suspicious.exposed_secret_literal` | Long hex (`0x[a-f0-9]{40,}`), JWT-shaped strings, base64 blobs | Placeholders (`<USDC_MAINNET>`) + one canonical address/key reference table | | `suspicious.destructive_delete_command` | Literal `rm -rf`, even in pedagogical "don't do this" context | Reword ("force-recursive removal") or break the literal with markup | | `suspicious.potential_exfiltration` | Skill packages user data and sends it off-host | Document the destination and data-handling policy; may be intrinsic to design | | `suspicious.generated_source_template_injection` | `${VAR}` placeholders in code blocks | Declare those env vars in `metadata.openclaw` - usually a metadata-mismatch echo | | `suspicious.dangerous_exec` / `suspicious.dynamic_code_execution` | Shelling out to or eval-ing dynamically built code | Call fixed, auditable commands; no runtime code generation | | `suspicious.obfuscated_code` | Base64/hex-encoded or minified payloads | Ship readable source; never bundle encoded blobs | Only `suspicious.env_credential_access` is externally self-clearable; every other code requires a fixed re-publish. **Hard-block codes** (`malicious.install_terminal_payload`, `malicious.crypto_mining`, `malicious.known_blocked_signature`) auto-hide the skill and place the uploader in manual moderation. The most common is `install_terminal_payload`: install instructions telling users to paste obfuscated shell payloads (base64-decoded `curl | bash`). Never include these, even as examples. ## Surviving the LLM Review ClawScan reviews content coherence - stated purpose vs. actual instructions. Fixes are **always content-side**: - Declare every env var, binary, and config path the body references in `metadata.openclaw`; undeclared usage is the top mismatch flag - Defensive scoping language backfires: "this skill does NOT make payments" adds the very trigger words it disclaims. Remove or rephrase; never disclaim - Don't combine `disable-model-invocation: true` with internal `Agent(model: ...)` overrides in the body - the contradiction triggers high-confidence suspicious (subagents inherit the parent model anyway) - `always: true` fires `suspicious.privileged_always` unless paired with `homepage` and explicit credential declarations ## Constraints Not in the Prose Docs (Source-Verified) - GitHub account must be at least 14 days old (`githubAccount.ts`) - Rate limit: 200 **new** skills per 24 hours; updates to existing skills are uncapped (`skills.rateLimit.test.ts`) - 10 MB per-file cap inside the 50 MB bundle (`publishLimits.ts`) - Binaries are accepted (the old text-only upload rule is gone); scanners receive the full artifact - Slug rules: `^[a-z0-9](?:(?!--)[a-z0-9-])*[a-z0-9]$`, 3-96 chars, plus reserved slugs and protected affixes (`openclaw-*`, `*-official`, `*-verified`, `*-admin`, ...) - source: [`skillSlugValidator.ts`](https://github.com/openclaw/clawhub/blob/main/convex/lib/skillSlugValidator.ts) - Extra `metadata.openclaw` fields live in the schema but absent from skill-format.md: `links`, `author`, `cliHelp`, `dependencies[]`, `install[].id/label/tap` ## Debugging a Flagged or Blocked Version ```bash # Owner-visible moderation block (verdict, reasonCodes, engineVersion) curl -sS -H "Authorization: Bearer $(clawhub token)" \ https://clawhub.ai/api/v1/skills/<slug> | jq .moderation # Stored scan report for a blocked/hidden version clawhub scan download <slug> --version <v> # ZIP: clawscan, skillspector, static-analysis, virustotal + manifest ``` ## Catalog Gotcha for CI Pipelines Skills published via the reusable CI workflow or `clawhub sync` land in the `other` category - the workflow has no categories input. Pass `--categories`/`--topics` once from the CLI (max 3 categories / 5 topics, fixed slug list) or set them in the web UI. Passing them republishes even unchanged content.
-
-
CHANGELOG.md 11.5 KB
# Changelog All notable changes to this skill will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/), and this skill adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ## [0.9.0] - 2026-09-09 ### Added - A `Length` subsection under Writing the Description - target 250 chars, with the compression order that actually pays (cut restated stack enumerations and selling points, collapse trigger lists, keep exclusions and disambiguations). - Guidance to prefer prose over an `!` block in a published skill: dynamic injection is host-specific, arrives elsewhere as literal text, and drags `allowed-tools` along to suppress its own prompts. ### Changed - Level 1 metadata cost was a flat "~100 tokens"; it is a function of description length, roughly `chars / 4 + 25`. - `disable-model-invocation` now carries a "don't reach for it by default" warning - it blocks the prose invocation path users actually use, plus subagent preload and scheduled tasks. - The frontmatter parse-failure row generalized from `Triggers:` to any colon-space in a plain YAML scalar, with ` - ` given as the rewrite. - The four generic workflow templates condensed to a four-bullet list, and the Be Concise example shortened (it also nested a fence inside a fence of the same type). ## [0.8.2] - 2026-09-09 ### Changed - Description condensed to fit the repo's 250-character limit. ## [0.8.1] - 2026-08-21 ### Changed - Declared ClawHub browse categories (`agents, knowledge`) and topics in `metadata`, so the release pipeline publishes them instead of leaving the skill in the `other` category. ### Removed - `skill-card.md`. The ClawHub CLI strips a root `skill-card.md` from every publish and the registry generates its own card, so the authored file never reached ClawHub. ## [0.8.0] - 2026-08-07 ### Changed - Consolidated references into SKILL.md following the skill's own single-file-first stance: description-guide.md, patterns.md, and checklist.md folded in (negative triggers, manually-invoked-skills note, CLI-embedded pattern, MCP/subagent guidance, Claude A/B loop, compact pre-publish checklist); redundant examples and generic workflow patterns dropped. - claude-code-features.md merged into a new "Claude Code Specifics" section after verifying every claim against official docs (Claude Code v2.1.224): ~85% is now covered verbatim by the expanded official skills docs and collapsed to links; kept the injection footgun, undocumented frontmatter keys (display-name, default-enabled, fallback, case-insensitive parsing), and behavior deltas (fork background-by-default since v2.1.218, per-turn allowed-tools grant, directory-derived command names, compaction re-attach budgets, listing budget mechanics, skill stacking, additionalDirectories not loading skills). - clawhub-publishing.md rewritten quirks-only (~5.5k chars, was 16.7k) and kept as the sole reference (conditional-loading test: needed only when publishing). Doc-covered material replaced with links to ClawHub's five docs; verified against clawhub CLI v0.23.3 and moderation engine v2.4.26. - Size guidance is now chars-only: 25k recommended / 50k hard ceiling via `wc -c`; line counts dropped as a metric (identical content varies 2x in lines depending on formatting). - Frontmatter table completed with `background` and `shell` fields. ### Removed - Stale ClawHub facts: the capability-tags system (retired upstream 2026-06-17), the "5 new skills/hour" rate limit (now 200 new skills per 24 hours), the "text-based files only" upload rule (binaries now accepted), and the claim that `--slug`/`--name`/`--changelog`/`--tags` left the CLI (all alive in v0.23.3, plus new `--categories`/`--topics`). - Stale Claude Code facts: outdated bundled-skills table (roster churns; linked to the commands reference instead), unconditional PowerShell env-var requirement, `/review` listed as a Skill-tool built-in (now an alias of `/code-review`). ### Fixed - `allowed-tools` documented as a per-turn grant (was "while the skill is active"). ## [0.7.0] - 2026-08-07 ### Changed - Repositioned the skill as opinionated guidance for any agent, distilled from the spec, official docs, and production experience (was "following Anthropic's official guidelines"); deviations from official guidance are now marked where they occur. - Replaced "Progressive Disclosure (Most Important)" with "Single File vs. references/ (Most Important)": single-file SKILL.md is the default; split only when content is conditionally loaded (big chunks needed by only some invocations) AND size pressure exists. Distribution is a veto - skills that must travel as one file (CLI-embedded, pasted, printed by a command) stay single-file and get condensed carefully, never lossily trimmed. - Size guidance is now two-tier: 500 lines / 25k chars recommended, 1000 lines / 50k chars hard ceiling, checked with `wc -c` (chars are easier for models to verify than tokens). - Troubleshooting row and quality checklist reworded to match the new stance. ### Added - references/patterns.md: "Single-File Skill Embedded in a CLI" pattern (compile SKILL.md into the binary, print via a `<tool> skill` subcommand - the shape playwright-cli, browser-use, and agent-browser converge on). ## [0.6.3] - 2026-07-22 ### Added - skill-card.md release record following NVIDIA's skill-card format ## [0.6.2] - 2026-07-10 ### Changed - CHANGELOG preamble pinned to Keep a Changelog 2.0.0 (format unchanged; KaC 2.0.0 keeps existing changelogs valid). ## [0.6.1] - 2026-07-10 ### Fixed - SKILL.md itself committed the footgun it documents: the troubleshooting row and Security bullet contained a live inline-injection literal (whitespace, then `!` touching a backticked placeholder command), which the Claude Code loader executed at load and errored on. Both rewritten to keep the `!` and backtick from touching. ### Changed - Security guidance: replaced the zero-width-space suggestion (invisible, non-ASCII) with wrapping the `!` in its own code span; clarified that `references/` files are safe because they are read with the Read tool, never preprocessed. - references/claude-code-features.md: added an explicit "documenting this syntax is itself a footgun" warning covering inline and fenced forms. ## [0.6.0] - 2026-07-01 ### Added - Claude Code: `disallowed-tools` frontmatter field; `${CLAUDE_PROJECT_DIR}` substitution (v2.1.196+) and literal-`$` backslash escape; `disableBundledSkills` setting + env var; `/reload-skills` (v2.1.152+) and SessionStart `reloadSkills: true`; frontmatter keys `display-name`/`default-enabled`/`fallback` and case-insensitive key parsing; skills-dir plugins (`.claude-plugin/plugin.json`), symlinked-dir dedup, same-name override of bundled skills; `name`-is-display-label, nested qualified invocation (`/apps/web:deploy`), and malformed-frontmatter `--debug` behavior; `/context` post-budget Skills size. - ClawHub: per-file 10 MB cap; blocked-version triage via `clawhub scan --slug` / `scan download`; net-new `metadata.openclaw` fields (`nix`, `config`, `links`, `author`, `cliHelp`, `dependencies[]`, install `id`/`label`/`tap`); public audit status taxonomy (Pass/Review/Warn/Malicious/Pending/Error) and risk levels; more reason codes noted as a curated subset of ~26. - API: 30 MB upload cap + common-root requirement; claude.ai-vs-API network contrast; pointers to `pause_turn`, container reuse, Files-API download, prompt-cache break, non-ZDR. Spec `compatibility` 500-char cap; `allowed-tools` marked Experimental. - Troubleshooting footguns: over-1024-char description skipped at load; unquoted-YAML frontmatter breakage; `` !`cmd` `` executing inside doc code fences. ### Changed - ClawHub reason codes: LLM verdict is `review.llm_review` (new `review.` tier), not `suspicious.llm_suspicious`; VirusTotal reframed as telemetry (no `vt_*` code); hard-block code `malicious.install_terminal_payload`; engine `v2.4.26`. - ClawHub slug rules corrected (`^[a-z0-9](?:(?!--)[a-z0-9-])*[a-z0-9]$`, length 3-96, reserved/protected-affix blocklist); "never reused" -> 30-day soft-delete reservation. - ClawHub CLI: canonical `clawhub skill publish`; removed `--clawscan-note`; "3 scanners" -> SkillSpector + VirusTotal + risk analysis, with static analysis internal-only. - Claude Code: setting `maxSkillDescriptionChars` -> `skillListingMaxDescChars`; `disable-model-invocation` also blocks subagent preload + scheduled tasks; bundled-skills list refreshed (`/code-review`, `/design-sync`, `/fewer-permission-prompts`; `/simplify` cleanup-only since v2.1.154). - Trimmed the SKILL.md description's keyword-dump tail (semantic matching, not keyword overlap). ### Removed - ClawHub `download` install kind from the schema-field list (rejected by the parser; contradicted the skill's own install-specs section). ### Fixed - Checklist validator command aligned to `uvx --from skills-ref agentskills validate`. ## [0.5.0] - 2026-06-05 ### Added - "Validate Against the Spec" testing section recommending `uvx --from skills-ref agentskills validate <skill>` before publishing. - Publishing caveat under Frontmatter Reference: Claude Code-only fields (`argument-hint`, `when_to_use`, `model`, `context`, etc.) are rejected by the strict `agentskills validate` spec validator that ClawHub-publishing repos run, and must be stripped from the validated/published copy. ## [0.4.0] - 2026-05-21 ### Added - Claude Code frontmatter fields `when_to_use`, `arguments`, `hooks`; substitutions `$name` and `${CLAUDE_EFFORT}`. - Multi-line ` ```! ` injection block; `skillOverrides` and `disableSkillShellExecution` settings; skill content lifecycle / compaction re-attach budget; built-in commands reachable through the Skill tool. - Evaluation-driven development; "Claude A / Claude B" iterative pattern; "avoid offering too many options" anti-pattern. - API usage model (`container` parameter, `anthropic` vs `custom` Skills, up to 8 per request, beta headers). - Agent Skills spec `license` and `compatibility` fields; `skills-ref` validator. - ClawHub capability tags `financial-authority` and `requires-paid-service`; `--clawscan-note` flag; OWASP Agentic Skills Top 10 note. - Reference-file size guidance; checklist calibration note for project-local skills. ### Changed - `effort` adds `xhigh`; `model` accepts `inherit` (turn-scoped override). - `allowed-tools` clarified: pre-approves tools, does not restrict them; space-separated. - Skill listing budget is 1% of context (was 2%); added `skillListingBudgetFraction` and the 1,536-character per-entry cap. - Bundled skills list adds `/run`, `/verify`, `/run-skill-generator`. - Inline `!command` injection recognized only at line start or after whitespace. - Custom commands merged into skills; a skill takes precedence over a same-named command. - `name` documented as optional in Claude Code (directory-name fallback); `description` falls back to the first markdown paragraph; completed the naming rules. - Progressive-disclosure Level 2 budget framed as a recommendation. - Cut-off skill descriptions diagnosed with `/doctor`. - Description guidance: Claude matches semantic meaning, not keyword stuffing. - ClawHub capability-tag derivation: purchase / transaction-signing authority now yields `financial-authority`, not `crypto`/`requires-wallet`. ### Removed - ClawHub `download` install kind (no longer supported; schema is `brew`/`node`/`go`/`uv`). ### Fixed - Clarified "one level deep" means reference-chain depth, not filesystem nesting. - Corrected stale ClawHub doc source links and removed an unverifiable model identifier. ## [0.3.0] - 2026-04-30 - Initial CHANGELOG; tracking established. -
LICENSE.txt 8.9 KB
Apache License Version 2.0, January 2004 https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS -
SKILL.md 25.5 KB
--- name: skills-best-practices description: Opinionated best practices for building Agent Skills - SKILL.md structure, frontmatter, description writing, progressive disclosure, testing, distribution. Use when creating or reviewing a skill, or debugging why one will not trigger. metadata: version: "0.9.0" categories: "agents, knowledge" topics: "agent-skills, skill-authoring, prompt-design, spec, best-practices" openclaw: homepage: https://github.com/tenequm/skills/tree/main/skills/skills-best-practices emoji: "📐" --- # Skills Best Practices Opinionated guide to building Agent Skills for any agent - distilled from the [Agent Skills open standard](https://agentskills.io), Anthropic's official guidance, and production experience, with deviations from the official line marked where they occur. Skills are folders (often just a single file) containing instructions, scripts, and resources that teach an agent how to handle specific tasks. ## Quick Start A minimal skill is a directory with a `SKILL.md` file: ``` my-skill/ ├── SKILL.md # Required - instructions with YAML frontmatter ├── references/ # Optional - detailed docs loaded on demand ├── scripts/ # Optional - executable code └── assets/ # Optional - templates, fonts, icons ``` Minimal `SKILL.md`: ```yaml --- name: my-skill-name description: What it does. Use when [specific triggers]. --- # My Skill Name [Instructions here] ``` Only `name` and `description` are required in frontmatter. ## Core Design Principles ### Single File vs. references/ (Most Important) **Default to a single SKILL.md.** One file can be pasted to a person, gisted, embedded in a CLI binary, and printed by a `<tool> skill` subcommand - a directory cannot. Split into `references/` only when **both** hold: 1. **Conditional loading**: a meaningful chunk of content is needed by only a subset of invocations (e.g. a tracked-changes doc most DOCX tasks never touch). If every invocation reads everything anyway, splitting adds Read round-trips and costs shareability while saving nothing. 2. **Size pressure**: the body exceeds the recommended budget below. **Distribution is a veto.** If the skill must travel as one file - shipped inside a CLI, printed by a command, shared by paste - stay single-file regardless of size and condense instead. Condensing means cutting redundancy, filler, and over-explanation while preserving every load-bearing instruction; losing substance to hit a line count is the failure mode, not the fix. See the single-file CLI-embedded pattern under [Patterns](#patterns). **Size guidance** (opinionated thresholds drawn from experience, not enforced spec limits) - measure with `wc -c SKILL.md`. Chars track token cost closely (~4 chars per token); line counts are not a metric - identical content varies 2x in lines by formatting style: | Tier | Chars | Beyond it | |------|-------|-----------| | Recommended | 25k | Condense carefully; split only if the conditional-loading test passes | | Hard ceiling | 50k | Must condense or split | > Official Anthropic guidance says to split at 500 lines. That advice assumes registry-installed skills with rarely-needed subtopics, and measures size in a unit that formatting distorts - this skill deliberately deviates on both. When a skill does split, information loads in three levels: | Level | When Loaded | Token Cost | Content | |-------|------------|------------|---------| | **1: Metadata** | Always (startup) | ~`chars / 4 + 25` - see [Length](#length) | `name` + `description` from frontmatter | | **2: Instructions** | When skill triggers | <5k tokens (recommended) | SKILL.md body | | **3: Resources** | As needed | Effectively unlimited | Bundled files, scripts | Reference detail files from SKILL.md so they load only when the task requires them: ```markdown ## Advanced features - **Form filling**: See [FORMS.md](FORMS.md) - **API reference**: See [reference.md](reference.md) ``` ### Composability Skills work alongside other skills. Don't assume yours is the only one loaded. ### Portability Skills work across Claude.ai, Claude Code, API, and Agent SDK without modification (if dependencies are available). ## Writing the Description (Critical) The description is the **single most important field** - it determines when your skill activates. Claude uses it to decide relevance from potentially 100+ available skills. ### Rules - Write in **third person** ("Processes files..." - first or second person breaks discovery) - Include **WHAT** it does + **WHEN** to use it - No XML angle brackets; see [Length](#length) for the size target - Be slightly "pushy" - Claude tends to **undertrigger** rather than overtrigger - Include specific trigger phrases users would naturally say, plus file types where relevant - Write natural prose, not keyword dumps - matching is semantic, so a long "Triggers on X, Y, Z..." list adds little over a clear sentence - If the skill depends on an MCP server, name it ("...via MCP. Requires Linear MCP server connected.") ### Length **Target 250 characters. The spec's 1024 is a ceiling, not a budget.** The description is the only part of a skill that costs tokens on every turn of every session, whether or not the skill ever fires. Past ~250 chars you are diluting the trigger, not sharpening it: descriptions are dispatch signals, not summaries. Compressing an over-long description, in the order that usually pays: - **Cut stack enumerations restated in prose.** Listing the stack once is enough; restating it as "covers the frontend ... and the backend ..." is pure padding - **Cut selling points.** "Includes exhaustive API tables" describes the body, not when to fire - **Collapse trigger lists.** One clear clause beats three quoted phrases plus four "when" clauses - matching is semantic, so near-duplicate triggers add nothing - **Keep exclusions and disambiguations.** "Not for session state", "not the LanceDB product" run 30-40 chars and are the only thing preventing wrong-skill dispatch ### Good vs Bad ```yaml # GOOD - specific, actionable, includes triggers description: Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction. # BAD - too vague description: Helps with documents. # BAD - missing triggers description: Creates sophisticated multi-page documentation systems. ``` ### Negative Triggers When a skill overtriggers, add boundaries directly in the description: ```yaml description: Advanced data analysis for CSV files. Use for statistical modeling, regression, clustering. Do NOT use for simple data exploration (use data-viz skill instead). ``` ### Manually-Invoked Skills `disable-model-invocation: true` stops a skill from auto-triggering - its description shows only in the `/` menu, so trigger phrases do nothing for it, and it is skipped for subagent preload and scheduled tasks too. **Don't reach for it by default.** Users ask for a workflow in prose ("polish this before committing") far more often than they type `/name`, and the flag turns those requests into a hand-rolled, degraded version of the skill. Reserve it for genuinely destructive one-shots. When it is set, write a plain one-line summary and skip the trigger-tuning. ## Frontmatter Reference ### Required Fields | Field | Rules | |-------|-------| | `name` | Kebab-case, max 64 chars, lowercase + numbers + hyphens only. No "claude" or "anthropic" | | `description` | Non-empty, max 1024 chars, no XML tags. WHAT + WHEN | The agentskills.io standard and the Claude API require both fields. Claude Code is more lenient: `name` falls back to the directory name, and `description` falls back to the first markdown paragraph. Write both anyway for portability. The spec also defines optional `license`, `compatibility`, and `metadata` fields. `compatibility` is capped at 500 characters and states environment requirements (intended product, system packages, network access). ### Optional Fields (Claude Code) | Field | Purpose | |-------|---------| | `argument-hint` | Autocomplete hint, e.g. `[issue-number]` | | `when_to_use` | Extra trigger context, appended to `description` in the skill listing | | `arguments` | Named positional arguments for `$name` substitution (space-separated string or list) | | `disable-model-invocation` | `true` = only user can invoke; also blocks subagent preload and scheduled tasks. Rarely worth it - see [Manually-Invoked Skills](#manually-invoked-skills) | | `user-invocable` | `false` = hidden from `/` menu (background knowledge) | | `allowed-tools` | Pre-approves tools (no permission prompt) for the current turn; space-separated, e.g. `Read Grep Glob`. In the spec allowlist but tagged **(Experimental)** | | `disallowed-tools` | Removes tools from Claude's pool while the skill is active; clears on your next message | | `model` | Override model for this skill; accepts `inherit`. Lasts the current turn only | | `effort` | Override effort level: `low`, `medium`, `high`, `xhigh`, `max` | | `context` | `fork` = run in isolated subagent | | `agent` | Subagent type when `context: fork` (e.g. `Explore`, `Plan`) | | `background` | `false` opts a forked skill out of background execution (v2.1.218+) | | `shell` | `bash` (default) or `powershell` | | `hooks` | Hooks scoped to this skill's lifecycle | | `paths` | Glob patterns limiting when skill activates | > **Publishing caveat:** every field above except `allowed-tools` is Claude Code-specific. They work in Claude Code at runtime, but the **official `agentskills validate` spec validator rejects them** - it allows only `name`, `description`, `license`, `compatibility`, `metadata`, `allowed-tools`, with no relax flag. If your repo or CI runs that validator (most ClawHub-publishing repos do), a skill using these fields fails validation unless you strip them from the copy you validate/publish. The ClawHub registry itself tends to tolerate extra top-level fields on publish, but the reference validator in your pipeline will not. See [Validate Against the Spec](#validate-against-the-spec). ### Naming Conventions The `name` (and its folder) must: be 1-64 chars; use only lowercase letters, numbers, and hyphens; not start or end with a hyphen; not contain consecutive hyphens (`--`); and match the parent directory name. Anthropic surfaces also reject the reserved words `claude` and `anthropic`. Prefer **gerund form** for clarity: - `processing-pdfs`, `analyzing-spreadsheets`, `managing-databases` - Also acceptable: `pdf-processing`, `process-pdfs` - Avoid: `helper`, `utils`, `tools`, `documents` ## Claude Code Specifics Official docs cover most Claude Code skill behavior: the [skills docs](https://code.claude.com/docs/en/skills) (invocation control, argument substitution, discovery and priority, tool permissions, `skillOverrides`, context budget), the [commands reference](https://code.claude.com/docs/en/commands#all-commands) for the current bundled-skills roster (it churns every few releases - never hardcode it), and the [settings reference](https://code.claude.com/docs/en/settings#available-settings). Below is only what those docs miss or what bites in practice. ### Dynamic-Injection Footgun Claude Code preprocesses SKILL.md at load: an exclamation mark immediately touching a backticked command executes that command before Claude sees the content ([dynamic context injection](https://code.claude.com/docs/en/skills#inject-dynamic-context)). The preprocessor is **not markdown-aware**: - A literal example executes at load even inside a code fence or inline code span, and a failing placeholder command errors the whole skill at load - The inline form fires only at line start or after whitespace; a prefix defuses it (`KEY=` before the `!` leaves it literal) - A fence opened with `!` right after the backticks is the multi-line form and is equally live - `references/` files are read with the Read tool and never preprocessed - the only safe home for live examples. In a SKILL.md, break the `!`-to-backtick adjacency instead (wrap the `!` in its own code span, as this section does) - `"disableSkillShellExecution": true` in settings disables execution for user/project/plugin skills - **In a skill you publish, prefer prose over an `!` block.** Dynamic injection is host-specific: on other surfaces the block arrives as literal text, and it drags `allowed-tools` along purely to suppress its own permission prompts. Instructing the agent to run the command costs one tool call and works everywhere ### Undocumented Behavior - `display-name`, `default-enabled`, and `fallback` frontmatter keys exist but are absent from the official frontmatter table - Frontmatter keys parse case-insensitively - kebab-case, snake_case, and camelCase resolve to the same field; boolean fields also accept `yes`/`no`/`on`/`off`/`1`/`0` (v2.1.218+) ### Behavior That Bites - `context: fork` skills run **in the background by default** since v2.1.218 (`background: false` opts out); backgrounded forks get a narrower tool set and their edits bypass checkpoints, so `/rewind` cannot undo them. `Explore`/`Plan` forks skip CLAUDE.md and git status; since v2.1.198 `Explore` inherits the session model - Skills stack: `/skill-a /skill-b args` in one message loads up to six skills (v2.1.199+) - `permissions.additionalDirectories` does **not** load skills from those directories - only the `--add-dir` flag and `/add-dir` command do - The `allowed-tools` grant lasts the current turn - it clears when the user sends their next message, not when the skill "finishes" - The `/command` name comes from the skill's **directory**; frontmatter `name` is only a display label (plugin skills excepted). Nested skills are invocable by qualified name, e.g. `/apps/web:deploy` - Invoked skill content stays in context all session and is not re-read - write standing instructions, not one-time steps. After auto-compaction, each skill's most recent invocation is re-attached with its first 5,000 tokens from a shared 25,000-token budget filled most-recent-first; re-invoke to restore full content - Skill descriptions load at startup within a listing budget of **1% of the context window**; least-used descriptions drop first (names always kept), each entry capped at 1,536 chars. Diagnose with `/doctor`; tune via `skillListingBudgetFraction`, `skillListingMaxDescChars`, or `SLASH_COMMAND_TOOL_CHAR_BUDGET` ## Structuring Instructions ### Be Concise The agent is smart. Only add context it doesn't already have - a skill that explains what a PDF is, or lists four libraries before picking one, spends tokens telling the agent things it knows: ```markdown # BAD: "PDF files are a common format containing text and images. To extract # text you need a library. There are many available..." # GOOD: "Use pdfplumber for text extraction." ``` ### Avoid Too Many Options Give one default with an escape hatch, not a menu: ```markdown # BAD: "Use pypdf, or pdfplumber, or PyMuPDF, or pdf2image..." # GOOD: "Use pdfplumber. For scanned PDFs needing OCR, use pdf2image with pytesseract." ``` ### Set Degrees of Freedom - **High freedom** (text guidelines): Multiple approaches valid, context-dependent - **Medium freedom** (pseudocode/templates): Preferred pattern exists, some variation OK - **Low freedom** (exact scripts): Operations are fragile, consistency critical ### Recommended SKILL.md Structure ```markdown # Skill Name ## Quick start [Minimal working example] ## Workflow Decision Tree [Route to the right approach based on task type] ## Detailed Instructions [Step-by-step for each workflow] ## Examples [Concrete input/output pairs] ## Troubleshooting [Common errors and fixes] ``` ### Reference Files Keep references **one level deep** from SKILL.md. "Depth" means the reference *chain* (a file linking to a file linking to a file), not filesystem nesting - a `references/` subdirectory is fine. In a chain, Claude may preview files with partial reads (`head`) and miss content. ```markdown # BAD: Too deep SKILL.md -> advanced.md -> details.md -> actual info # GOOD: One level SKILL.md -> advanced.md (contains the info directly) SKILL.md -> reference.md (contains the info directly) ``` For reference files >100 lines, include a **table of contents** at the top. Watch file *size* too: a single reference of many hundreds of lines defeats progressive disclosure even at one level deep, because Claude loads the whole file for any subtopic. Split large references by subtopic so each task pulls only what it needs. ## Patterns ### Common Workflow Shapes Name the shape explicitly in the body rather than assuming the agent infers it: - **Sequential**: numbered steps, each naming the exact command to run - **Decision tree**: route on task type up front ("Creating new content? -> Creation workflow") - **Feedback loop**: validate, fix, re-validate - and state that the loop exits only on a pass - **Checklist**: for long tasks, have the agent copy a checklist and tick items as it goes ### Single-File Skill Embedded in a CLI For skills documenting a CLI tool: keep SKILL.md as one file next to the CLI source, compile it into the binary (`go:embed`, Rust `include_str!`, or equivalent), and add a `<tool> skill` subcommand that prints it. The printed guide always matches the installed version, and one command fetches the whole doc - playwright-cli, browser-use (`browser-use skill show`), and agent-browser (`agent-browser skills get core`) all converge on this shape. Never split such a skill into references/; condense carefully instead. ### Working with MCP and Subagents MCP provides tool access; skills provide the workflow knowledge for using those tools well. Reference MCP tools by qualified name (`BigQuery:bigquery_schema`, `GitHub:create_issue`). Skills are portable expertise; subagents are isolated execution - in Claude Code, `context: fork` frontmatter runs a skill inside a subagent. ### Developing Skills with Claude (A/B Loop) Build skills with two Claude instances: **Claude A** helps design and refine (it knows the format and what agents need); **Claude B** is a fresh instance with the skill loaded, tested on real tasks. Notice what context you repeatedly supply during normal work, have A capture it as a skill, test with B, bring B's specific failures back to A ("it forgot to filter test accounts"), and repeat. Iterate on observed behavior, not assumptions. For output-style skills, input/output example pairs communicate the desired style better than any description. ## Scripts When your skill includes executable code: - **Solve, don't punt**: Handle errors explicitly instead of letting them fail - **Justify constants**: No magic numbers - document why each value was chosen - **Prefer execution over loading**: Scripts run without entering context; only output consumes tokens - **Clarify intent**: "Run `analyze.py`" (execute) vs "See `analyze.py`" (read as reference) - **List dependencies** in SKILL.md and verify availability ## Testing ### Build Evaluations First Create evaluations **before** writing extensive instructions - this proves the skill solves a real problem. Run Claude on representative tasks *without* the skill and document the failures; build ~3 scenarios that test those gaps; measure a baseline; then write the minimum instructions needed to pass. Iterate against the baseline. ### Triggering Tests ``` Should trigger: - "Help me set up a new project in [Service]" - "I need to create a project" (paraphrased) Should NOT trigger: - "What's the weather?" (unrelated) - "Write Python code" (too generic) ``` ### Functional Tests Test normal operations, edge cases, and out-of-scope requests. Run the same request 3-5 times to check consistency. ### Debug Triggering Ask Claude: "When would you use the [skill-name] skill?" - it quotes the description back. Adjust based on what's missing. ### Validate Against the Spec Run the official Agent Skills validator before publishing: ```bash uvx --from skills-ref agentskills validate path/to/skill ``` Exit 0 means valid. It checks `SKILL.md` format and enforces the spec's strict frontmatter allowlist (`name`, `description`, `license`, `compatibility`, `metadata`, `allowed-tools`). Most registries (e.g. ClawHub) and CI gates run this, so validating locally catches failures early. If you rely on Claude Code-only frontmatter (see the publishing caveat under [Frontmatter Reference](#frontmatter-reference)), strip those fields from the copy you validate. ## Pre-Publish Checklist Calibrate to scope: for a project-local or single-user skill, skip the triggering-accuracy and distribution-hygiene items. - [ ] Folder and `name` kebab-case and matching; file is exactly `SKILL.md` - [ ] Description: third person, WHAT + WHEN, specific triggers, under 1024 chars, no angle brackets - [ ] Single file unless conditionally-loaded content justifies references/; within size budget (`wc -c`) - [ ] Critical instructions at the top; working examples, not pseudocode; consistent terminology - [ ] If split: references linked from SKILL.md, one level deep, TOC for files over 100 lines - [ ] Scripts: explicit error handling, no unexplained constants, dependencies listed, execute-vs-read intent clear - [ ] Triggering tested: fires on direct and paraphrased requests, silent on unrelated and similar-but-distinct ones - [ ] Functional: normal and edge cases pass, output consistent across 3-5 runs, tested on more than one model - [ ] No time-sensitive info, Windows-style paths, or deprecated APIs - [ ] Spec validator exits 0 (command above) - [ ] After upload: monitor under/over-triggering in real conversations, iterate the description, bump version on every change ## Troubleshooting | Symptom | Cause | Fix | |---------|-------|-----| | Skill never loads | Description too vague | Add specific triggers and key terms | | Skill loads for wrong tasks | Description too broad | Add negative triggers, be more specific | | Instructions not followed | Too verbose or buried | Put critical instructions at top, use headers | | Slow/degraded responses | SKILL.md too large | Condense first; split to references/ only if content is conditionally loaded (see Single File vs. references/) | | "Could not find SKILL.md" | Wrong filename | Must be exactly `SKILL.md` (case-sensitive) | | "Invalid skill name" | Spaces or capitals | Use kebab-case: `my-skill-name` | | Whole skill silently skipped at load | Description exceeds 1024 chars | Trim it - the loader rejects the file, not just the description | | Frontmatter fails to parse | An unquoted `description` is a plain YAML scalar, so any colon-space (`Triggers: `, `Use when: `) or straight `"quotes"` inside it breaks parsing | Rewrite the colon as ` - `, or quote the whole value | | A doc example runs a shell command | A `!` directly touching a backticked command executes on load, even inside a code fence | Move the example to `references/` or break the `!`-backtick adjacency (see [Dynamic-Injection Footgun](#dynamic-injection-footgun)) | ## Distribution | Surface | How to Deploy | |---------|--------------| | Claude.ai | Settings > Features > Upload zip | | Claude Code (personal) | `~/.claude/skills/<name>/SKILL.md` | | Claude Code (project) | `.claude/skills/<name>/SKILL.md` | | Claude Code (plugin) | `<plugin>/skills/<name>/SKILL.md` | | API | Upload via the Skill Management API, use via the Messages API | | Enterprise | Managed settings (org-wide) | Skills don't sync across surfaces - deploy separately to each. ### Using Skills with the API Custom skills are uploaded through the Skill Management API; `anthropic`-type skills are pre-built by Anthropic. Both are used identically - pass them in the Messages API `container` parameter, each as `{type, skill_id, version}` where `type` is `anthropic` or `custom`. Up to 8 Skills per request, 30 MB max upload (all files combined), and all files must share a common root directory. Requires the code execution tool and the beta headers `code-execution-2025-08-25` and `skills-2025-10-02` (plus `files-api-2025-04-14` for file upload/download). **Network access differs by surface.** The API code execution environment has **no network access and no runtime package installation** - bundle dependencies or use pre-installed packages. On claude.ai, by contrast, Skills **can** install packages from npm and PyPI and pull from GitHub. Also: a `pause_turn` stop reason signals a long-running Skill operation; reuse containers across turns via `container.id`; generated files come back via the Files API; changing the Skills list breaks prompt caching; Skills are not ZDR-eligible. ## Security - Only use skills from **trusted sources** - No XML angle brackets in frontmatter (injection risk) - Audit all bundled scripts and resources before using third-party skills - Be cautious of skills that fetch from external URLs - Documenting the dynamic-injection syntax is itself a hazard - the loader executes examples at load, even inside code fences. See the [Dynamic-Injection Footgun](#dynamic-injection-footgun) before writing any ## Additional References - [ClawHub publishing](references/clawhub-publishing.md) - source-mined moderation quirks: reason codes and fixes, LLM-review survival tactics, constraints absent from ClawHub's docs ## Official Resources - [Agent Skills Spec](https://agentskills.io/specification) - [Claude Code Skills Docs](https://code.claude.com/docs/en/skills) - [API Skills Guide](https://platform.claude.com/docs/en/build-with-claude/skills-guide) - [Best Practices](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices) - [Anthropic Skills Repo](https://github.com/anthropics/skills) - [Engineering Blog: Agent Skills](https://claude.com/blog/equipping-agents-for-the-real-world-with-agent-skills) - [Complete Guide PDF](https://resources.anthropic.com/hubfs/The-Complete-Guide-to-Building-Skill-for-Claude.pdf)
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.