X
Url Shorten
@Xejrax
npx machina-cli add skill @Xejrax/url-shorten --openclawFiles (1)
SKILL.md
676 B
URL Shorten
Shorten URLs via tinyurl or bitly API. Requires BITLY_TOKEN env var for bitly; falls back to tinyurl if not set.
Commands
# Shorten a URL (uses tinyurl by default, bitly if BITLY_TOKEN is set)
url-shorten "https://example.com/very/long/path/to/resource"
Install
No installation needed. curl is always present on the system. Optionally set BITLY_TOKEN environment variable to use the bitly API instead of tinyurl.
Overview
Shortens long URLs by calling TinyURL or Bitly. It uses curl and requires no installation, only an optional BITLY_TOKEN to switch to Bitly. If BITLY_TOKEN is not set, it falls back to TinyURL.
How This Skill Works
Accepts a URL argument and performs a curl request to the chosen API. If BITLY_TOKEN is provided, it uses Bitly's API; otherwise it calls TinyURL's API. The command outputs the shortened URL returned by the API.
When to Use It
- Share long URLs in social posts or chats by shortening them.
- Enable Bitly-based analytics by setting BITLY_TOKEN to use Bitly API.
- Use in any environment where curl is available and no extra tools are needed.
- Include shorter links in marketing emails or docs to improve readability.
- Prepare campaign links and reuse short URLs across channels.
Quick Start
- Step 1: Ensure curl is available on your system.
- Step 2: (Optional) export BITLY_TOKEN=your_bitly_token to enable Bitly.
- Step 3: Run url-shorten "https://example.com/very/long/path" and use the output.
Best Practices
- Prefer Bitly when BITLY_TOKEN is set to gain tracking and customization.
- Validate the API response and extract the shortened URL safely.
- Avoid exposing API tokens in logs or error messages.
- Test a shortened URL before publishing to ensure it redirects properly.
- If no token is configured, rely on TinyURL as a reliable fallback.
Example Use Cases
- url-shorten "https://example.com/very/long/path/to/resource"
- url-shorten "https://shop.example.com/products/2024/release/limited-edition"
- Set BITLY_TOKEN=yourtoken && url-shorten "https://example.com/campaign/landing-page"
- Shorten a link for a tweet or chat: url-shorten "https://example.com/long-url"
- Create a short link to place in a printed flyer or QR code: url-shorten "https://example.com/offer"
Frequently Asked Questions
Add this skill to your agents