-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Install Claude Code as native skills and align preset/integration flows #2051
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 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
115dd94
Use Claude skills for generated commands
afurm 9daa86b
Fix Claude integration and preset skill flows
afurm ce96610
Group Claude tests in integration suite
afurm aa88f9c
Align Claude skill frontmatter across generators
afurm cf6d5d6
Merge origin/main into af/2031-claude-skills
afurm f40bfe8
Fix native skill preset cleanup
afurm 3cec78d
Keep legacy AI skills test on legacy path
afurm 56fb2ac
Move Claude here-mode test to CLI suite
afurm 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,111 @@ | ||
| """Claude Code integration.""" | ||
|
|
||
| from ..base import MarkdownIntegration | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import yaml | ||
|
|
||
| from ...agents import CommandRegistrar | ||
| from ..base import IntegrationBase | ||
| from ..manifest import IntegrationManifest | ||
|
|
||
|
|
||
| class ClaudeIntegration(IntegrationBase): | ||
| """Integration for Claude Code skills.""" | ||
|
|
||
| class ClaudeIntegration(MarkdownIntegration): | ||
| key = "claude" | ||
| config = { | ||
| "name": "Claude Code", | ||
| "folder": ".claude/", | ||
| "commands_subdir": "commands", | ||
| "commands_subdir": "skills", | ||
| "install_url": "https://docs.anthropic.com/en/docs/claude-code/setup", | ||
| "requires_cli": True, | ||
| } | ||
| registrar_config = { | ||
| "dir": ".claude/commands", | ||
| "dir": ".claude/skills", | ||
| "format": "markdown", | ||
| "args": "$ARGUMENTS", | ||
| "extension": ".md", | ||
| "extension": "/SKILL.md", | ||
| } | ||
| context_file = "CLAUDE.md" | ||
|
|
||
| def command_filename(self, template_name: str) -> str: | ||
| """Claude skills live at .claude/skills/<name>/SKILL.md.""" | ||
| skill_name = f"speckit-{template_name.replace('.', '-')}" | ||
| return f"{skill_name}/SKILL.md" | ||
|
|
||
| def _render_skill(self, template_name: str, frontmatter: dict[str, Any], body: str) -> str: | ||
| """Render a processed command template as a Claude skill.""" | ||
| skill_name = f"speckit-{template_name.replace('.', '-')}" | ||
| description = frontmatter.get( | ||
| "description", | ||
| f"Spec-kit workflow command: {template_name}", | ||
| ) | ||
| skill_frontmatter = { | ||
| "name": skill_name, | ||
| "description": description, | ||
| # Spec-kit workflows should only run when explicitly invoked. | ||
| "disable-model-invocation": True, | ||
| "compatibility": "Requires spec-kit project structure with .specify/ directory", | ||
| "metadata": { | ||
| "author": "github-spec-kit", | ||
| "source": f"templates/commands/{template_name}.md", | ||
| }, | ||
| } | ||
| frontmatter_text = yaml.safe_dump(skill_frontmatter, sort_keys=False).strip() | ||
| return f"---\n{frontmatter_text}\n---\n\n{body.strip()}\n" | ||
|
|
||
| def setup( | ||
| self, | ||
| project_root: Path, | ||
| manifest: IntegrationManifest, | ||
| parsed_options: dict[str, Any] | None = None, | ||
| **opts: Any, | ||
| ) -> list[Path]: | ||
| """Install Claude skills into .claude/skills.""" | ||
| templates = self.list_command_templates() | ||
| if not templates: | ||
| return [] | ||
|
|
||
| project_root_resolved = project_root.resolve() | ||
| if manifest.project_root != project_root_resolved: | ||
| raise ValueError( | ||
| f"manifest.project_root ({manifest.project_root}) does not match " | ||
| f"project_root ({project_root_resolved})" | ||
| ) | ||
|
|
||
| dest = self.commands_dest(project_root).resolve() | ||
|
afurm marked this conversation as resolved.
Outdated
|
||
| try: | ||
| dest.relative_to(project_root_resolved) | ||
| except ValueError as exc: | ||
| raise ValueError( | ||
| f"Integration destination {dest} escapes " | ||
| f"project root {project_root_resolved}" | ||
| ) from exc | ||
| dest.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| script_type = opts.get("script_type", "sh") | ||
| arg_placeholder = self.registrar_config.get("args", "$ARGUMENTS") | ||
| registrar = CommandRegistrar() | ||
| created: list[Path] = [] | ||
|
|
||
| for src_file in templates: | ||
| raw = src_file.read_text(encoding="utf-8") | ||
| processed = self.process_template(raw, self.key, script_type, arg_placeholder) | ||
| frontmatter, body = registrar.parse_frontmatter(processed) | ||
| if not isinstance(frontmatter, dict): | ||
| frontmatter = {} | ||
|
|
||
| rendered = self._render_skill(src_file.stem, frontmatter, body) | ||
| dst_file = self.write_file_and_record( | ||
| rendered, | ||
| dest / self.command_filename(src_file.stem), | ||
| project_root, | ||
| manifest, | ||
| ) | ||
| created.append(dst_file) | ||
|
|
||
| created.extend(self.install_scripts(project_root, manifest)) | ||
| return created | ||
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
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.