Skip to content

[None][chore] Enforce Claude Code skill and agent naming convention via pre-commit#14285

Merged
kaiyux merged 1 commit into
NVIDIA:mainfrom
kaiyux:user/kaiyu/skills_name_convention
May 19, 2026
Merged

[None][chore] Enforce Claude Code skill and agent naming convention via pre-commit#14285
kaiyux merged 1 commit into
NVIDIA:mainfrom
kaiyux:user/kaiyu/skills_name_convention

Conversation

@kaiyux
Copy link
Copy Markdown
Member

@kaiyux kaiyux commented May 19, 2026

Summary by CodeRabbit

  • Chores
    • Added automated validation for naming conventions of Claude skills and agents to ensure consistency and maintainability across the codebase.

Review Change Stack

Description

Enforces the Claude Code skill (and agent) naming convention documented in .claude/README.md via a pre-commit hook:

  1. Every skill (.claude/skills/*/SKILL.md) and agent (.claude/agents/*.md) on-disk name must start with one of the approved domain prefixes — ad-, exec-, kernel-, perf-, trtllm- — followed by a descriptive suffix.
  2. The frontmatter name: field must match the on-disk name (directory name for skills, file stem for agents).

The hook runs scripts/check_skill_naming_convention.py whenever a skill, agent, or the checker itself is touched, and fails the commit with a list of violations. This keeps new contributions aligned with the convention without manual review.

Test Coverage

  • python scripts/check_skill_naming_convention.py exits 0 on the current tree; all existing skills and agents already comply with the documented prefixes.
  • The hook's files: filter scopes runs to .claude/skills/<name>/SKILL.md, .claude/agents/*.md, and the checker script itself, so it only fires on relevant changes.

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

@kaiyux kaiyux requested review from a team as code owners May 19, 2026 03:29
@kaiyux kaiyux requested review from dpitman-nvda and niukuo May 19, 2026 03:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

This PR introduces a naming convention validation system for Claude skills and agents. A new Python script discovers all skill and agent files, validates their names against allowed prefixes, and ensures YAML frontmatter name fields match on-disk names. The script is registered as a pre-commit hook to enforce these rules automatically.

Changes

Claude Skill/Agent Naming Convention Validation

Layer / File(s) Summary
Naming convention checker script
scripts/check_skill_naming_convention.py
Python CLI script that loads allowed skill/agent name prefixes, discovers all .claude/skills/*/SKILL.md and .claude/agents/*.md files, validates their directory/file-derived names against the prefix rules, parses YAML frontmatter to extract the name: field, and reports any violations to stderr with a non-zero exit code.
Pre-commit hook registration
.pre-commit-config.yaml
Registers the naming convention checker as a local pre-commit hook with PyYAML dependency, configured to run on skill/agent markdown files and the checker script itself without passing filenames as arguments.

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#14234: Introduces the same Claude skill/agent naming validation system that targets .claude/skills/*/SKILL.md and .claude/agents/*.md frontmatter name fields.

Suggested reviewers

  • laikhtewari
  • nv-guomingz
  • yihwang-nv
  • QiJune
  • venkywonka
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a pre-commit hook to enforce skill and agent naming conventions.
Description check ✅ Passed The PR description includes all required sections with substantive content: clear explanation of the problem, solution details, test coverage validation, and a completed checklist.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
scripts/check_skill_naming_convention.py (2)

22-22: 💤 Low value

Optional: Remove unnecessary future import.

The from __future__ import annotations import is not required in Python 3.10+, which this codebase targets. Modern type hints like str | None and list[tuple[Path, str]] work natively.

Based on learnings: "In TensorRT-LLM (Python requires >=3.10 and <4 as per setup.py), you can use Python 3.10+ features (e.g., PEP 585 generics like dict[str, int], list[str], etc.) throughout the codebase, and you do not need to add from future import annotations."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check_skill_naming_convention.py` at line 22, Remove the unnecessary
future import by deleting the line "from __future__ import annotations" at the
top of the module; the codebase targets Python 3.10+ (so annotations are native)
and no other changes to functions or type hints (e.g., any usage of PEP 585
generics or union operators) are needed in this file.

46-52: ⚡ Quick win

Consider adding error handling for file I/O and YAML parsing.

The function can raise exceptions from path.read_text() (e.g., FileNotFoundError, PermissionError, UnicodeDecodeError) and yaml.safe_load() (e.g., yaml.YAMLError). While unhandled exceptions are visible in pre-commit output, catching these and reporting them as violations would provide clearer feedback.

🛡️ Suggested improvement
 def load_frontmatter_name(path: Path) -> str | None:
-    m = FRONTMATTER_RE.match(path.read_text())
+    try:
+        content = path.read_text()
+    except (FileNotFoundError, PermissionError, UnicodeDecodeError) as e:
+        return None  # Caller can detect missing name and report violation
+    m = FRONTMATTER_RE.match(content)
     if not m:
         return None
-    data = yaml.safe_load(m.group(1)) or {}
+    try:
+        data = yaml.safe_load(m.group(1)) or {}
+    except yaml.YAMLError:
+        return None  # Malformed YAML treated as missing name
     name = data.get("name")
     return name if isinstance(name, str) else None
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check_skill_naming_convention.py` around lines 46 - 52, Wrap the body
of load_frontmatter_name in a try/except that surrounds path.read_text() and
yaml.safe_load() to prevent uncaught I/O and parse errors; specifically catch
FileNotFoundError, PermissionError, UnicodeDecodeError and yaml.YAMLError, and
on those exceptions log a concise error (e.g., via logging.error or writing to
stderr) that includes the path and exception details, then return None so the
caller treats it as a missing/invalid frontmatter; preserve the existing
FRONTMATTER_RE matching and the final type-check for name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/check_skill_naming_convention.py`:
- Line 22: Remove the unnecessary future import by deleting the line "from
__future__ import annotations" at the top of the module; the codebase targets
Python 3.10+ (so annotations are native) and no other changes to functions or
type hints (e.g., any usage of PEP 585 generics or union operators) are needed
in this file.
- Around line 46-52: Wrap the body of load_frontmatter_name in a try/except that
surrounds path.read_text() and yaml.safe_load() to prevent uncaught I/O and
parse errors; specifically catch FileNotFoundError, PermissionError,
UnicodeDecodeError and yaml.YAMLError, and on those exceptions log a concise
error (e.g., via logging.error or writing to stderr) that includes the path and
exception details, then return None so the caller treats it as a missing/invalid
frontmatter; preserve the existing FRONTMATTER_RE matching and the final
type-check for name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1cf2f749-a0cb-4663-882d-d923bd3439a5

📥 Commits

Reviewing files that changed from the base of the PR and between 89e1410 and 1be6b91.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • scripts/check_skill_naming_convention.py

@kaiyux kaiyux changed the title [None][chore] Add pre-commit hook to enforce skill naming convention [None][chore] Enforce Claude Code skill and agent naming convention via pre-commit May 19, 2026
Copy link
Copy Markdown
Collaborator

@QiJune QiJune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Enforces the Claude Code skill (and agent) naming convention documented
in .claude/README.md: every entry under .claude/skills/*/SKILL.md and
.claude/agents/*.md must start with an approved domain prefix (ad-,
exec-, kernel-, perf-, trtllm-) and its on-disk name must match the
frontmatter `name:` field.

Signed-off-by: Kaiyu Xie <26294424+kaiyux@users.noreply.github.com>
@kaiyux kaiyux force-pushed the user/kaiyu/skills_name_convention branch from 1be6b91 to 3db81d1 Compare May 19, 2026 07:46
@kaiyux
Copy link
Copy Markdown
Member Author

kaiyux commented May 19, 2026

/bot skip --comment "skill related changes"

@kaiyux kaiyux enabled auto-merge (squash) May 19, 2026 07:46
@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #49142 [ skip ] triggered by Bot. Commit: 3db81d1 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #49142 [ skip ] completed with state SUCCESS. Commit: 3db81d1
Skipping testing for commit 3db81d1

Link to invocation

@kaiyux kaiyux merged commit ba68504 into NVIDIA:main May 19, 2026
8 checks passed
@kaiyux kaiyux deleted the user/kaiyu/skills_name_convention branch May 19, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants