Agent Skillst4t5/rencal › add-astro-icon

add-astro-icon

GitHub

将用户提供的原始SVG标记转换为Astro图标组件。自动命名文件,清理冗余属性,替换颜色为currentColor,添加Props接口,并写入website/src/icons/目录,支持通过Tailwind控制大小。

.agents/skills/add-astro-icon/SKILL.md t4t5/rencal

Trigger Scenarios

用户提供SVG代码并要求创建Astro图标 需要将SVG集成到Astro项目

Install

npx skills add t4t5/rencal --skill add-astro-icon -g -y
More Options

Non-standard path

npx skills add https://github.com/t4t5/rencal/tree/main/.agents/skills/add-astro-icon -g -y

Use without installing

npx skills use t4t5/rencal@add-astro-icon

指定 Agent (Claude Code)

npx skills add t4t5/rencal --skill add-astro-icon -a claude-code -g -y

安装 repo 全部 skill

npx skills add t4t5/rencal --all -g -y

预览 repo 内 skill

npx skills add t4t5/rencal --list

SKILL.md

Frontmatter
{
    "name": "add-astro-icon",
    "description": "Turn raw SVG markup into an Astro icon component in website\/src\/icons\/. Use when the user provides SVG markup and wants it added as a website Astro icon."
}

You are turning raw SVG markup the user provides into an Astro icon component in website/src/icons/.

Workflow

  1. Get the SVG: The user will give you raw SVG markup (often copy-pasted from Streamline, Figma, etc.).

  2. Pick a filename: Use a short kebab-case name describing the icon (e.g. settings.astro, arrow-right.astro). Infer obvious icon names without asking. For common brand logos, use the brand name (e.g. GitHub → github.astro). Ask the user only if the name is truly ambiguous.

  3. Transform the SVG:

    • Add this Astro frontmatter at the top:

      ---
      interface Props {
        class?: string
      }
      
      const { class: className } = Astro.props
      ---
      
    • On the <svg> tag: keep xmlns, fill, and viewBox. Add class={className}. Remove hardcoded width and height — size is controlled by Tailwind (size-4, size-6, etc.).

    • Replace every hardcoded stroke color (e.g. stroke="#000000") with stroke="currentColor". Same for fill if it's a color — but leave fill="none" alone. Brand icons that should inherit text color should use fill="currentColor".

    • Strip noise: id attributes, <desc> tags, <title> tags, and any other vendor metadata.

    • Keep stroke-width, stroke-linecap, stroke-linejoin, d, and other geometry-defining attributes. Preserve valid Astro/HTML attribute casing for SVG markup.

  4. Write the file to website/src/icons/<name>.astro immediately. Use bash with a quoted heredoc instead of the write tool to avoid slow line-by-line UI rendering:

    cat > website/src/icons/<name>.astro <<'EOF'
    ...
    EOF
    

Speed rules

  • Do not inspect existing icon files unless necessary.
  • Infer obvious icon names without asking.
  • For common brand logos, use the brand name.
  • Immediately write website/src/icons/<name>.astro after transforming.
  • Prefer bash with a quoted heredoc for file creation; do not use the write tool unless bash is unavailable.
  • Do not run checks unless the user asks.

Example

Input:

<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" id="Foo" height="24" width="24">
  <desc>Some vendor blurb</desc>
  <g id="group"><path id="p1" stroke="#000000" d="M6 0v14" stroke-width="2" /></g>
</svg>

Output (website/src/icons/foo.astro):

---
interface Props {
  class?: string
}

const { class: className } = Astro.props
---

<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class={className}>
  <g>
    <path stroke="currentColor" d="M6 0v14" stroke-width="2" />
  </g>
</svg>

Usage: <FooIcon class="size-4 text-primary" /> when imported with an alias, or import the .astro component directly and render it with class="size-4 text-primary".

Version History

  • 22a53df Current 2026-07-05 10:46

Same Skill Collection

.agents/skills/add-icon/SKILL.md
.agents/skills/generate-release-notes/SKILL.md
.agents/skills/performance-analysis/SKILL.md

Metadata

Files
0
Version
22a53df
Hash
ff2ab85b
Indexed
2026-07-05 10:46

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-09 04:18
浙ICP备14020137号-1 $Гость$