home / skills / antvis / chart-visualization-skills / icon-retrieval

icon-retrieval skill

/skills/icon-retrieval

This skill retrieves up to five matching icon SVG strings from a library, helping you quickly source visuals for dashboards, designs, and infographics.

npx playbooks add skill antvis/chart-visualization-skills --skill icon-retrieval

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
3.7 KB
---
name: icon-retrieval
description: Search and retrieve icon SVG strings from icon library. Returns up to 5 matching icons by default, customizable via topK parameter.
dependency:
  nodejs: ">=18.0.0"
---

# Icon Search

This skill provides icon search and SVG string retrieval capabilities. It helps users find appropriate icons for various use cases including infographics, web development, design, and more.

## Purpose

This skill helps discover available icons by:
- Searching the icon library by keywords
- Retrieving SVG strings directly for use in your projects
- Providing icon metadata including names and URLs

## How to Use

### Search for Icons

To search for icons, use the search script with a keyword or phrase:

```bash
node ./scripts/search.js '<search_query>' [topK]
```

**Parameters:**
- `search_query` (required): The keyword or phrase to search for
- `topK` (optional): Maximum number of results to return (default: 5)

**Examples:**
```bash
# Search for document icons (default 5 results)
node ./scripts/search.js 'document'

# Search for security icons with top 10 results
node ./scripts/search.js 'security' 10

# Search for technology icons with top 20 results
node ./scripts/search.js 'tech' 20
```

### Understanding Results

The script returns a JSON object containing:
- `query`: The search query used
- `topK`: Maximum number of results requested
- `count`: Actual number of results returned (may be less than topK)
- `results`: Array of icon objects, each containing:
  - `url`: The source URL of the icon
  - `svg`: The complete SVG string content

## Workflow

1. **Identify the Icon Need**: Determine what concept you want to represent with an icon (e.g., "security", "speed", "data")

2. **Search for Icons**: Run the search script with relevant keywords
   ```bash
   # Default search (returns up to 5 results)
   node ./scripts/search.js 'security'
   
   # Or specify a custom topK value
   node ./scripts/search.js 'security' 10
   ```

3. **Review Results**: The script returns the requested number of matching icons with:
   - Icon source URLs
   - SVG content for preview or direct use

4. **Use the Icon**: Use the SVG content directly in your project (web pages, designs, infographics, etc.)

## Important Notes

- **Default Result Count**: By default, the search returns up to 5 icons. You can customize this by providing the `topK` parameter
- **Customizable Results**: Use the optional `topK` parameter to get more or fewer results (e.g., `node ./scripts/search.js 'icon' 20`)
- **SVG Strings**: The script returns complete SVG strings fetched from the icon service
- **Multiple Use Cases**: Icons can be used in infographics, web development, design projects, and more

## Output Format

```json
{
  "query": "document",
  "topK": 5,
  "count": 2,
  "results": [
    {
      "url": "https://example.com/icon1.svg",
      "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">...</svg>"
    },
    {
      "url": "https://example.com/icon2.svg",
      "svg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">...</svg>"
    }
  ]
}
```

## Error Handling

The script handles various error scenarios:

- **Missing Query**: If no search query is provided, returns usage instructions
- **Network Errors**: If the icon service is unavailable, returns an error message
- **Empty Results**: If no icons match the query, returns an empty results array with a warning
- **Invalid Response**: If the API returns invalid data, returns an error message

## Tips

- Use descriptive, single-word queries for best results
- Try variations of keywords (e.g., "security", "secure", "shield")
- Review the results to find the most appropriate icon for your needs
- Icons can be used across various scenarios: infographics, web development, design, and more

Overview

This skill searches an icon library and returns SVG strings and metadata for matching icons. It returns up to 5 results by default and allows adjusting the number of matches with a topK parameter. Use it to quickly find, preview, and embed SVG icons in projects.

How this skill works

The skill accepts a keyword or phrase and queries the icon index for relevant matches. It returns a JSON payload that includes the query, requested topK, actual count, and an array of results with source URLs and full SVG strings. Results are limited by topK (default 5) and the service handles network and response errors with clear messages.

When to use it

  • You need inline SVGs to embed directly into web pages or components
  • Prototyping UI or generating design mockups with consistent iconography
  • Automating asset retrieval for build scripts or design systems
  • Searching for alternative icons when refining visual metaphors
  • Batch fetching multiple icons for dashboards or infographics

Best practices

  • Use concise single-word keywords for higher relevance (e.g., "security", "document")
  • Try synonyms and related words to expand result variety (e.g., "shield" for security)
  • Set topK to a small number (5–10) for quick results or larger for broader exploration
  • Validate returned SVGs before production use (check viewBox, dimensions, and IDs)
  • Cache retrieved SVGs if you fetch the same icons frequently to reduce network calls

Example use cases

  • Embed an SVG icon directly into a React/Vue component from the returned svg string
  • Search and download a set of security icons for a product settings page (node ./scripts/search.js 'security' 10)
  • Generate an icon palette for an infographic by querying related keywords and choosing the best visuals
  • Integrate icon retrieval into a build step to compile necessary SVGs into your design system
  • Find alternative icons during a design review by searching several synonyms and comparing results

FAQ

What happens if I omit the search query?

The skill returns usage instructions and asks for a required search query parameter.

How do I change the number of results returned?

Provide an optional topK parameter; the default is 5 and you can increase it (for example: node ./scripts/search.js 'tech' 20).

What if no icons match my query?

The response contains an empty results array and a warning indicating no matches were found.