Skip to content

feiskyer/claude-code-settings / skills/skill-creator

skill-creator

Verified

Create, refine, and benchmark agent skills. Use when building a new skill, updating an existing one, running evals, checking trigger quality, or improving a skill description.

FileKindSize
LICENSE.txtmarkdown11.1 KB
README.mdmarkdown462 B
SKILL.mdskill md30.0 KB
agents/analyzer.mdmarkdown10.4 KB
agents/comparator.mdmarkdown6.9 KB
agents/grader.mdmarkdown9.1 KB
assets/eval_review.htmlother6.9 KB
eval-viewer/generate_review.pyscript16.0 KB
eval-viewer/viewer.htmlother43.9 KB
references/schemas.mdmarkdown11.6 KB
scripts/__init__.pyscript0 B
scripts/aggregate_benchmark.pyexecutablescript14.5 KB
scripts/generate_report.pyexecutablescript13.0 KB
scripts/improve_description.pyscript16.2 KB
scripts/package_skill.pyexecutablescript4.1 KB
scripts/platforms/__init__.pyscript54 B
scripts/platforms/base.pyscript2.2 KB
scripts/platforms/claude_code.pyscript6.3 KB
scripts/platforms/codex.pyscript5.4 KB
scripts/platforms/openclaw.pyscript4.3 KB
scripts/quick_validate.pyscript9.6 KB
scripts/run_eval.pyexecutablescript8.2 KB
scripts/run_loop.pyexecutablescript15.0 KB
scripts/utils.pyscript3.4 KB

scripts/platforms/claude_code.py

View on GitHub
"""Claude Code platform adapter for skill trigger evaluation.

Registers temporary skills under .claude/skills/ and detects triggering via
the claude -p stream-json output (Skill/Read tool call inspection).
"""

import json
import os
import select
import subprocess
import time
from pathlib import Path

from scripts.platforms.base import PlatformAdapter, QueryRunResult, RegisteredSkill


class ClaudeCodeAdapter(PlatformAdapter):
    """Adapter for Claude Code (claude CLI)."""

    def __init__(self, model: str | None = None):
        self._model = model

    def find_project_root(self) -> Path:
        """Find the project root by walking up from cwd looking for .claude/."""
        current = Path.cwd()
        for parent in [current, *current.parents]:
            if (parent / ".claude").is_dir():
                return parent
        return current

    def register_skill(self, skill_name: str, description: str, sentinel: str) -> RegisteredSkill:
        """Write a temporary skill folder into .claude/skills/."""
        project_root = self.find_project_root()
        skill_dir = project_root / ".claude" / "skills" / skill_name
        skill_dir.mkdir(parents=True, exist_ok=True)

        skill_md = skill_dir / "SKILL.md"
        indented_desc = "\n  ".join(description.split("\n"))
        skill_md.write_text(
            f"---\n"
            f"name: {skill_name}\n"
            f"description: |\n"
            f"  {indented_desc}\n"
            f"---\n\n"
            f"# {skill_name}\n\n"
            f"This skill handles: {description}\n"
        )
        return RegisteredSkill(
            name=skill_name,
            detection_token=skill_name,
            detection_mode="authoritative",
            detection_details="Parsed Claude Code Skill/Read tool events from stream-json output.",
            cleanup_paths=[skill_md, skill_dir],
        )

    def run_query(self, query: str, timeout: int, model: str | None) -> QueryRunResult | None:
        """Run claude -p and return raw stdout, or None on failure."""
        cmd = [
            "claude",
            "-p", query,
            "--output-format", "stream-json",
            "--verbose",
            "--include-partial-messages",
        ]
        used_model = model or self._model
        if used_model:
            cmd.extend(["--model", used_model])

        # Remove CLAUDECODE env var to allow nesting claude -p inside a
        # Claude Code session.
        env = {k: v for k, v in os.environ.items() if k != "CLAUDECODE"}

        try:
            process = subprocess.Popen(
                cmd,
                stdout=subprocess.PIPE,
                stderr=subprocess.DEVNULL,
                cwd=str(self.find_project_root()),
                env=env,
            )
        except FileNotFoundError:
            return None

        output_lines: list[str] = []
        start_time = time.time()
        buffer = ""

        try:
            while time.time() - start_time < timeout:
                if process.poll() is not None:
                    remaining = process.stdout.read()
                    if remaining:
                        buffer += remaining.decode("utf-8", errors="replace")
                    break
                ready, _, _ = select.select([process.stdout], [], [], 1.0)
                if not ready:
                    continue
                chunk = os.read(process.stdout.fileno(), 8192)
                if not chunk:
                    break
                buffer += chunk.decode("utf-8", errors="replace")
                while "\n" in buffer:
                    line, buffer = buffer.split("\n", 1)
                    output_lines.append(line.strip())
        finally:
            if process.poll() is None:
                process.kill()
                process.wait()

        raw_output = "\n".join(output_lines)
        return QueryRunResult(response_text=raw_output, raw_output=raw_output)

    def detect_trigger(self, run_result: QueryRunResult, registration: RegisteredSkill) -> bool:
        """Parse Claude's stream-json output for Skill/Read tool calls referencing the temp skill."""
        token = registration.detection_token
        pending_tool_name: str | None = None
        accumulated_json = ""

        for line in run_result.raw_output.splitlines():
            if not line:
                continue
            try:
                event = json.loads(line)
            except json.JSONDecodeError:
                continue

            if event.get("type") == "stream_event":
                se = event.get("event", {})
                se_type = se.get("type", "")

                if se_type == "content_block_start":
                    cb = se.get("content_block", {})
                    if cb.get("type") == "tool_use":
                        tool_name = cb.get("name", "")
                        if tool_name in ("Skill", "Read"):
                            pending_tool_name = tool_name
                            accumulated_json = ""
                        continue

                elif se_type == "content_block_delta" and pending_tool_name:
                    delta = se.get("delta", {})
                    if delta.get("type") == "input_json_delta":
                        accumulated_json += delta.get("partial_json", "")
                        if token in accumulated_json:
                            return True

                elif se_type in ("content_block_stop", "message_stop"):
                    if pending_tool_name and token in accumulated_json:
                        return True
                    pending_tool_name = None
                    accumulated_json = ""
                    continue

            elif event.get("type") == "assistant":
                message = event.get("message", {})
                for content_item in message.get("content", []):
                    if content_item.get("type") != "tool_use":
                        continue
                    tool_name = content_item.get("name", "")
                    tool_input = content_item.get("input", {})
                    if tool_name == "Skill" and token in tool_input.get("skill", ""):
                        return True
                    if tool_name == "Read" and token in tool_input.get("file_path", ""):
                        return True

            elif event.get("type") == "result":
                continue

        return False
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 319kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 319kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 319kUpdated Claude CodeCodexVerifiedInstall