AgentSkillsCN

add-toolr

依据通用最佳实践,为任意项目诊断并配置代码检查。 当您被要求:设置代码检查、配置 ESLint、添加代码质量规则、修复代码检查配置, 设置提交前钩子、提升代码质量工具链,或当出现诸如“代码检查”、“代码质量”、“静态分析”、“ESLint”、“Ruff”、“Clippy”、“Checkstyle”等关键词时,此功能便能助您一臂之力。 支持:JavaScript/TypeScript(ESLint + SonarJS、Unicorn)、React/Vue/Angular、Python(Ruff)、 Java(Checkstyle、Google 风格)、Rust(Clippy)、Go(golangci-lint)。同样适用于单体仓库。

SKILL.md
--- frontmatter
name: add-toolr
description: |
  Add new content (skills, hooks, agents, plugins, MCP servers, settings, commands) to the seedr registry.
  Trigger on: "/add-toolr <path>", "add toolr item", "register this hook/skill/agent/plugin/mcp/settings".
  Accepts a filesystem path, auto-detects the content type from path segments, asks clarifying
  questions (scope, compatibility, name, description), copies content into registry/, and updates
  registry/manifest.json. For toolr-sourced items only.

Add Toolr Item

Add a new item to the seedr registry from a local filesystem path.

Workflow

1. Parse the argument

Extract <path> from the user's input (e.g. /add-toolr /Users/daniel/whatever/.claude/hooks/abc). Verify the path exists (file or directory) using Bash ls or Read.

2. Detect content type

Infer ComponentType from the path. Use the deepest matching segment:

Path containsType
/skills/ or file named SKILL.mdskill
/hooks/hook
/agents/agent
/plugins/ or .claude-plugin/plugin
/mcp/ or .mcp.jsonmcp
/settings/ or settings.jsonsettings
/commands/command

If ambiguous, ask the user with AskUserQuestion.

3. Derive a default slug

From the path's final meaningful segment (directory name or filename without extension), kebab-case it. Example: /Users/daniel/whatever/.claude/hooks/pre-commit-lint -> slug pre-commit-lint.

4. Ask clarifying questions

Use AskUserQuestion to collect metadata. Ask in batches to minimize round-trips.

Batch 1 — Identity & scope:

code
questions:
  - question: "What name should this <type> have in the registry?"
    header: "Name"
    options:
      - label: "<auto-derived name>"  # Title-cased from slug
        description: "Auto-derived from the path"
      - label: "Custom name"
        description: "Enter a custom display name"

  - question: "What is the recommended install scope?"
    header: "Scope"
    options:
      - label: "project (Recommended)"
        description: "Install into the current project directory"
      - label: "user"
        description: "Install into the user's home config"
      - label: "local"
        description: "Install into .local config (Claude only)"

  - question: "Which AI tools is this compatible with?"
    header: "Compat"
    multiSelect: true
    options:
      - label: "claude"
        description: "Anthropic Claude Code"
      - label: "copilot"
        description: "GitHub Copilot"
      - label: "gemini"
        description: "Google Gemini CLI"
      - label: "opencode"
        description: "OpenCode CLI"

Note: For hooks, agents, settings, and commands, default compatibility to ["claude"] only since those types are Claude-specific. Pre-select accordingly.

Batch 2 — Description:

After the user answers batch 1, read the source content to auto-generate a description. Then ask:

code
questions:
  - question: "Use this description? '<auto-generated description>'"
    header: "Description"
    options:
      - label: "Yes, use it"
        description: "Accept the auto-generated description"
      - label: "Edit it"
        description: "Provide your own description"

5. For hooks: Extract triggers from settings

If the detected type is hook and the path points to a .sh script file:

  1. Find the parent .claude/ directory from the script path
  2. Read both settings.json and settings.local.json in that directory
  3. Search the hooks object for entries that reference this script file
  4. Extract all triggers (event + matcher combinations)

Example settings.json structure:

json
{
  "hooks": {
    "PreToolUse": [
      { "matcher": "Bash", "hooks": [{ "type": "command", "command": ".claude/hooks/my-hook.sh" }] },
      { "matcher": "Write", "hooks": [{ "type": "command", "command": ".claude/hooks/my-hook.sh" }] }
    ]
  }
}

From this, extract triggers:

json
[
  { "event": "PreToolUse", "matcher": "Bash" },
  { "event": "PreToolUse", "matcher": "Write" }
]

Match the script by comparing the filename at the end of the command path.

6. Copy content to registry

Based on the detected type:

  • skill: Copy directory to registry/skills/<slug>/. Expect a SKILL.md inside.
  • hook: Copy the .sh script file to registry/hooks/<slug>/.
  • agent: Copy .md file to registry/agents/<slug>/.
  • plugin: Copy directory to registry/plugins/<slug>/.
  • mcp: Copy config to registry/mcp/<slug>/.
  • settings: Copy config to registry/settings/<slug>/.
  • command: Copy to registry/commands/<slug>/.

Create the target directory if it doesn't exist. Use cp -r for directories, cp for files.

7. Build file tree for manifest

After copying, build a FileTreeNode[] from the copied content. Walk the directory recursively:

code
FileTreeNode = { name: string, type: "file" | "directory", children?: FileTreeNode[] }

Use find <dir> | sort and parse the output to build the tree.

8. Write item.json and compile manifest

Write the item metadata as registry/<type>s/<slug>/item.json:

json
{
  "slug": "<slug>",
  "name": "<name from user>",
  "type": "<detected type>",
  "description": "<description>",
  "compatibility": ["<from user answers>"],
  "sourceType": "toolr",
  "author": { "name": "Toolr Suite", "url": "https://github.com/toolr-suite" },
  "externalUrl": "https://github.com/twiced-technology-gmbh/seedr/tree/main/registry/<type>s/<slug>",
  "updatedAt": "<current ISO 8601 date>",
  "contents": { "files": [<file tree>] },
  "recommendedScope": "<scope from user>"
}

For hooks, also include triggers in the contents object:

json
{
  "contents": {
    "files": [{ "name": "my-hook.sh", "type": "file" }],
    "triggers": [
      { "event": "PreToolUse", "matcher": "Bash" },
      { "event": "PreToolUse", "matcher": "Write" }
    ]
  }
}

Write with JSON.stringify(item, null, 2) + "\n".

Then recompile the manifest:

bash
npx tsx scripts/compile-manifest.ts

9. Confirm

Print a summary:

  • Type, slug, name
  • Path copied to
  • item.json written and manifest compiled
  • Remind user to commit and push

Important notes

  • sourceType is always "toolr" — this skill is for manually-maintained items only
  • The sync script (pnpm sync) preserves toolr items and only replaces synced items
  • If registry/<type>s/<slug>/item.json already exists, warn the user and ask whether to update or abort
  • For skills, validate that a SKILL.md exists in the source directory
  • featured defaults to false — do not set it unless the user asks