Skip to content

Commit 4cd809b

Browse files
clevin95claude
andauthored
Flatten skill names to include full path generated_<category>_<skill> (#68)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8a5e13c commit 4cd809b

5 files changed

Lines changed: 21 additions & 18 deletions

File tree

entry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ const HOOKS: Record<HookName, Hook> = {
484484
/** Files that match this pattern should never be processed */
485485
const GLOBAL_EXCLUDES = (() => {
486486
const FOLDER_EXCLUDES = [
487-
".claude/skills/.generated",
487+
".claude/skills/generated_*",
488488
"build",
489489
"node_modules",
490490
];

sync_ai_rules/generators/skills_generator.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python3
22
"""
33
Skills Generator - generates Claude Code skills from .cursor/rules/.
4-
Each rule becomes a separate SKILL.md file in .claude/skills/.generated/,
5-
mirroring the folder structure of .cursor/rules/.
4+
Each rule becomes a separate SKILL.md file in .claude/skills/,
5+
with a flat name encoding the full path: generated_<category>_<skill-name>.
66
"""
77

88
import logging
@@ -14,7 +14,7 @@
1414
from sync_ai_rules.core.generator_interface import OutputGenerator
1515
from sync_ai_rules.core.rule_metadata import RuleMetadata
1616

17-
_SKILLS_DIR = ".claude/skills/.generated"
17+
_SKILLS_DIR = ".claude/skills"
1818
_SOURCE_DIR = ".cursor/rules"
1919
_YAML_UNSAFE = re.compile(r"[:\#\[\]\{\}&*!|>'\"%@`]")
2020

@@ -43,30 +43,33 @@ def is_multi_file(self) -> bool:
4343
def generate_files(
4444
self, rules: Dict[str, List[RuleMetadata]], project_root: str
4545
) -> None:
46-
"""Generate skill files mirroring the .cursor/rules/ folder structure."""
46+
"""Generate skill files as direct children of .claude/skills/."""
4747
skills_root = os.path.join(project_root, _SKILLS_DIR)
4848

49-
# Clean .generated directory on each run
50-
if os.path.exists(skills_root):
51-
shutil.rmtree(skills_root)
49+
# Remove any existing generated_* dirs before regenerating
50+
if os.path.isdir(skills_root):
51+
for entry in os.listdir(skills_root):
52+
if entry.startswith("generated_"):
53+
shutil.rmtree(os.path.join(skills_root, entry))
5254

5355
for category_rules in rules.values():
5456
for rule in category_rules:
55-
# Mirror the source folder structure:
56-
# .cursor/rules/arch/my-rule.mdc → .generated/arch/my-rule/SKILL.md
57+
# Flatten full path into a single skill dir name:
58+
# .cursor/rules/arch/my-rule.mdc → .claude/skills/generated_arch_my-rule/SKILL.md
59+
# .cursor/rules/my-rule.mdc → .claude/skills/generated_my-rule/SKILL.md
5760
rel_path = _strip_source_prefix(rule.relative_path)
58-
skill_name = os.path.splitext(os.path.basename(rel_path))[0]
59-
skill_dir = os.path.join(
60-
skills_root, os.path.dirname(rel_path), skill_name
61-
) if os.path.dirname(rel_path) else os.path.join(skills_root, skill_name)
61+
path_parts = rel_path.replace(os.sep, "/").split("/")
62+
path_parts[-1] = os.path.splitext(path_parts[-1])[0]
63+
skill_name = "generated_" + "_".join(path_parts)
64+
skill_dir = os.path.join(skills_root, skill_name)
6265
skill_file = os.path.join(skill_dir, "SKILL.md")
6366

6467
try:
6568
content = _format_skill(rule, skill_name)
6669
os.makedirs(skill_dir, exist_ok=True)
6770
with open(skill_file, "w", encoding="utf-8") as f:
6871
f.write(content)
69-
print(f" ✓ Created skill: {os.path.relpath(skill_dir, skills_root)}")
72+
print(f" ✓ Created skill: {skill_name}")
7073
except OSError as e:
7174
logger.warning("Failed to write skill %s: %s", skill_name, e)
7275
print(f" ✗ Failed to create skill: {skill_name}")

test/after/.claude/skills/.generated/architecture/architecture-rule/SKILL.md renamed to test/after/.claude/skills/generated_architecture_architecture-rule/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: architecture-rule
2+
name: generated_architecture_architecture-rule
33
description: Architecture rule description
44
---
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: rule
2+
name: generated_rule
33
description: Rule description
44
---
55

test/after/.claude/skills/.generated/testing/testing-rule/SKILL.md renamed to test/after/.claude/skills/generated_testing_testing-rule/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: testing-rule
2+
name: generated_testing_testing-rule
33
description: Testing rule description
44
---
55

0 commit comments

Comments
 (0)