-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: adopt .agents skills convention #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e087a0d
fix: make feature-data-flow frontmatter valid YAML
michalurbanek 982be3f
feat: expose skills via .agents/skills cross-client convention
michalurbanek 872c0e5
feat: add skill validation script to the skill-creation workflow
michalurbanek 999e1b7
refactor: make .agents/skills the canonical skills location
michalurbanek 3909209
refactor: move templates to .agents and remove the ai folder
michalurbanek 10e47d4
fix: make skill validator self-contained
michalurbanek 0c98919
fix: validate skill allowed tools syntax
michalurbanek 7c3db6a
fix: harden skill validator checks
michalurbanek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion
5
ai/skills/feature-data-flow/SKILL.md → .agents/skills/feature-data-flow/SKILL.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| #!/usr/bin/env python3 | ||
| """Validate .agents/skills/* against the Agent Skills spec (agentskills.io/specification) | ||
| and this repo's skill-exposure convention (see AGENTS.md "Creating a new skill"). | ||
|
|
||
| Checks per skill: | ||
| - SKILL.md exists with parseable YAML frontmatter (strict — lenient parsers in | ||
| some clients mask errors that make other clients silently skip the skill) | ||
| - name: required, 1-64 chars, lowercase alphanumerics and single hyphens, | ||
| no leading/trailing hyphen, matches the directory name | ||
| - description: required, 1-1024 chars | ||
| - unknown top-level frontmatter fields (spec fields + known Claude Code | ||
| extensions are accepted; anything else is a warning) | ||
| - SKILL.md body under 500 lines (spec recommendation; warning) | ||
| - Claude Code exposure exists: | ||
| .claude/skills/<name> symlink and .claude/commands/<name>.md slash command | ||
|
|
||
| Exits 1 on errors, 0 if only warnings. | ||
| """ | ||
|
|
||
| import os | ||
| import re | ||
| import sys | ||
|
|
||
| REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
| SKILLS_DIR = os.path.join(REPO_ROOT, ".agents", "skills") | ||
|
|
||
| SPEC_FIELDS = {"name", "description", "license", "compatibility", "metadata", "allowed-tools"} | ||
| CLAUDE_EXTENSIONS = {"model", "user-invocable", "disable-model-invocation"} | ||
| NAME_RE = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*$") | ||
| MAX_BODY_LINES = 500 | ||
|
|
||
| try: | ||
| import yaml | ||
| except ImportError: | ||
| yaml = None | ||
|
|
||
|
|
||
| def parse_frontmatter(text: str) -> dict[str, object]: | ||
| if yaml is not None: | ||
| fm = yaml.safe_load(text) | ||
| if not isinstance(fm, dict): | ||
| raise ValueError("frontmatter is not a YAML mapping") | ||
| return fm | ||
|
|
||
| data: dict[str, object] = {} | ||
| lines = text.splitlines() | ||
| index = 0 | ||
| while index < len(lines): | ||
| line = lines[index] | ||
| index += 1 | ||
| if not line.strip(): | ||
| continue | ||
| if line.startswith((" ", "\t")) or ":" not in line: | ||
| raise ValueError("frontmatter uses YAML syntax that requires PyYAML") | ||
|
|
||
| key, value = line.split(":", 1) | ||
| key = key.strip() | ||
| value = value.strip() | ||
| if not key: | ||
| raise ValueError("frontmatter contains an empty key") | ||
|
|
||
| if value in {">", "|"}: | ||
| block_lines: list[str] = [] | ||
| while index < len(lines) and (lines[index].startswith((" ", "\t")) or not lines[index].strip()): | ||
| block_lines.append(lines[index].strip()) | ||
| index += 1 | ||
| data[key] = "\n".join(block_lines).strip() if value == "|" else " ".join(block_lines).strip() | ||
| continue | ||
|
|
||
| if value.lower() == "true": | ||
| data[key] = True | ||
| elif value.lower() == "false": | ||
| data[key] = False | ||
| else: | ||
| data[key] = value.strip("\"'") | ||
|
|
||
| return data | ||
|
|
||
|
|
||
| def check_skill(skill_dir: str) -> tuple[list[str], list[str]]: | ||
| errors: list[str] = [] | ||
| warnings: list[str] = [] | ||
| dirname = os.path.basename(skill_dir) | ||
| skill_md = os.path.join(skill_dir, "SKILL.md") | ||
|
|
||
| if not os.path.isfile(skill_md): | ||
| return [f"missing SKILL.md"], warnings | ||
|
|
||
| text = open(skill_md, encoding="utf-8").read() | ||
| match = re.match(r"^---\n(.*?)\n---\n?(.*)$", text, re.S) | ||
| if not match: | ||
| return ["SKILL.md has no YAML frontmatter block"], warnings | ||
|
|
||
| try: | ||
| fm = parse_frontmatter(match.group(1)) | ||
| except Exception as exc: | ||
| msg = str(exc).splitlines()[0] | ||
| return [f"frontmatter is not valid YAML ({msg}) — " | ||
| "quote values containing colons or use a '>' block scalar"], warnings | ||
|
|
||
| name = fm.get("name") | ||
| if not name: | ||
| errors.append("missing required field: name") | ||
| else: | ||
| if name != dirname: | ||
| errors.append(f"name '{name}' does not match directory '{dirname}'") | ||
| if not NAME_RE.fullmatch(str(name)): | ||
| errors.append(f"name '{name}' violates spec charset rules") | ||
| if len(str(name)) > 64: | ||
| errors.append("name exceeds 64 characters") | ||
|
|
||
| description = fm.get("description") | ||
| if not description: | ||
| errors.append("missing required field: description") | ||
| elif len(str(description)) > 1024: | ||
| errors.append(f"description is {len(str(description))} chars (max 1024)") | ||
|
|
||
|
michalurbanek marked this conversation as resolved.
|
||
| for key in fm: | ||
| if key not in SPEC_FIELDS | CLAUDE_EXTENSIONS: | ||
| warnings.append(f"unknown frontmatter field '{key}' " | ||
| "(spec suggests nesting extras under 'metadata:')") | ||
|
|
||
| body_lines = match.group(2).count("\n") + 1 | ||
| if body_lines > MAX_BODY_LINES: | ||
| warnings.append(f"body is {body_lines} lines (spec recommends < {MAX_BODY_LINES}; " | ||
| "consider moving detail into references/)") | ||
|
|
||
| for rel, kind in [ | ||
| (os.path.join(".claude", "skills", dirname), "Claude Code symlink"), | ||
| (os.path.join(".claude", "commands", f"{dirname}.md"), "slash command"), | ||
| ]: | ||
| path = os.path.join(REPO_ROOT, rel) | ||
| if not os.path.exists(path): | ||
| errors.append(f"missing {kind}: {rel}") | ||
|
michalurbanek marked this conversation as resolved.
Outdated
|
||
|
|
||
| return errors, warnings | ||
|
|
||
|
|
||
| def main() -> int: | ||
| if not os.path.isdir(SKILLS_DIR): | ||
| print(f"error: skills directory not found: {SKILLS_DIR}") | ||
| return 1 | ||
|
|
||
| total_errors = 0 | ||
| total_warnings = 0 | ||
| for entry in sorted(os.listdir(SKILLS_DIR)): | ||
| skill_dir = os.path.join(SKILLS_DIR, entry) | ||
| if not os.path.isdir(skill_dir): | ||
| continue | ||
| errors, warnings = check_skill(skill_dir) | ||
| total_errors += len(errors) | ||
| total_warnings += len(warnings) | ||
| status = "FAIL" if errors else ("WARN" if warnings else "OK") | ||
| print(f"{status:4} {entry}") | ||
| for issue in errors: | ||
| print(f" error: {issue}") | ||
| for issue in warnings: | ||
| print(f" warning: {issue}") | ||
|
|
||
| print(f"\n{total_errors} error(s), {total_warnings} warning(s)") | ||
| return 1 if total_errors else 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,20 @@ | ||
| @../AGENTS.md | ||
|
|
||
| Project-specific reusable AI workflows live in `../ai/skills/` and are surfaced | ||
| to Claude Code two ways: | ||
| Project-specific reusable AI workflows live in `../.agents/skills/` — the | ||
| standard cross-client Agent Skills location — and are surfaced to Claude Code | ||
| two ways: | ||
| - **auto-discovery**: `./skills/<name>` is a symlink with target | ||
| `../../ai/skills/<name>` (resolved from `.claude/skills/`, this points | ||
| at `<repo>/ai/skills/<name>`), so Claude reads the SKILL.md frontmatter | ||
| `../../.agents/skills/<name>` (resolved from `.claude/skills/`, this points | ||
| at `<repo>/.agents/skills/<name>`), so Claude reads the SKILL.md frontmatter | ||
| and triggers them based on context. | ||
| - **slash commands**: `./commands/<name>.md` exposes each skill as an explicit | ||
| command. Current commands mirror the skills listed in `AGENTS.md`, including | ||
| `/project-setup`, `/feature-screen`, `/feature-data-flow`, `/prd`, | ||
| `/techspec`, `/tasks`, `/implement`, `/implement-tasks-sequence`, | ||
| `/start-job`, `/build-verify`, `/lint-format`, `/create-pr`, | ||
| `/review-pr-comments`, `/upgrade`, `/release-prepare`, `/release-builds`, | ||
| `/secrets-bootstrap`, and `/pr-review`. | ||
| `/start-job`, `/build-verify`, `/lint-format`, `/widget-test`, | ||
| `/layout-debug`, `/create-pr`, `/review-pr-comments`, `/upgrade`, | ||
| `/release-prepare`, `/release-builds`, `/secrets-bootstrap`, and | ||
| `/pr-review`. | ||
|
|
||
| See the "Reusable Workflows" section of `AGENTS.md` for the canonical list of | ||
| skills and the four-step convention for adding a new one. | ||
| skills and the five-step convention for adding a new one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/build-verify | ||
| ../../.agents/skills/build-verify |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/create-pr | ||
| ../../.agents/skills/create-pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/feature-data-flow | ||
| ../../.agents/skills/feature-data-flow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/feature-screen | ||
| ../../.agents/skills/feature-screen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/implement | ||
| ../../.agents/skills/implement |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/implement-tasks-sequence | ||
| ../../.agents/skills/implement-tasks-sequence |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/layout-debug | ||
| ../../.agents/skills/layout-debug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/lint-format | ||
| ../../.agents/skills/lint-format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ../../ai/skills/pr-review | ||
| ../../.agents/skills/pr-review |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.