Agent Skillst4t5/rencal › add-astro-icon

add-astro-icon

GitHub

将原始SVG标记转换为Astro图标组件,自动命名、清理元数据并适配Tailwind样式,通过bash heredoc快速写入文件。

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

触发场景

用户提供SVG代码并要求创建Astro图标 需要将外部SVG集成到网站图标库

安装

npx skills add t4t5/rencal --skill add-astro-icon -g -y
更多选项

非标准路径

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

不安装直接使用

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".

版本历史

  • 22a53df 当前 2026-07-05 10:46

同 Skill 集合

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

元信息

文件数
0
版本
40ee85c
Hash
ff2ab85b
收录时间
2026-07-05 10:46

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-13 22:43
浙ICP备14020137号-1 $访客地图$