add-icon
Add a Font Awesome icon to the user's project. This skill handles icon name resolution, project detection, and code generation for every Font Awesome integration method.
Scripts referenced from suggest-icon are relative to plugins/icons/skills/suggest-icon/. Scripts referenced from add-icon are relative to plugins/icons/skills/add-icon/. Run them from their respective directories.
Tool selection
At the start, run command -v fa to check whether the fa CLI is available on PATH.
The fa kit subcommand requires fa version 0.8.0 or newer. If the fa kit subcommand is needed, recommend the user upgrade fa, using instructions here: https://docs.fontawesome.com/web/use-with/fa-cli
- If
fais found: use it for icon lookups and kit fetching (it returns structured JSON). For kit operations (fa kitsandfa kit), check auth first: runfa whoamito see if the user is logged in. If logged in, these will work directly. If not logged in butFA_API_TOKENis set, they will also work. If neither, tell the user: "You need to be logged in to the Font Awesome CLI for kit operations. Runfa loginin a separate terminal, then come back here and try again." If they cannot log in, fall back tofetch-kit.py. When the project uses a Kit,fa kit icon --kit-token <TOKEN> <icon>tells you whether a specific icon is in the Kit's subset and which family styles it's available in — use it to avoid adding an icon the Kit doesn't include (see step 3). - If
fais not found: fall back to the Python scripts described below. - Use
latest-version.pyto get the latest version.
Steps
1. Resolve the icon name
First, determine whether the project uses a Kit for integrating Font Awesome. If the project has a .font-awesome.md file, read it to determine whether a Kit is in use.