1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Claude Code】uvでスキルのスクリプトを1ファイル完結にする

1
Last updated at Posted at 2026-04-15

Claude Codeのスキルで外部ライブラリを使いたい。しかし仮想環境は管理したくない。

uv shebang を使えば、1ファイルで完結する。

uv shebangとは

shebang行に uv run --with を指定すると、uvが依存関係を自動解決してスクリプトを実行する。

#!/usr/bin/env -S uv run --with httpx

スキルでの使い方

.claude/skills/{skill-name}/
├── SKILL.md
└── scripts/
    └── example.py  # 実行権限を付与
chmod +x scripts/example.py

実例:GitHub Star Counter

github_stars.py
#!/usr/bin/env -S uv run --with httpx
import sys
import httpx

repo = sys.argv[1]
stars = httpx.get(f"https://api.github.com/repos/{repo}").json()["stargazers_count"]
print(f"{repo}: {stars:,} stars")

実例:Qiita Tag Info

記事のタグ候補提案に使用。Qiita記事執筆支援スキルの一部。

qiita_tag_info.py
#!/usr/bin/env -S uv run --with httpx
import sys
import httpx

tag = sys.argv[1]
data = httpx.get(f"https://qiita.com/api/v2/tags/{tag}").json()
print(f"{data['id']}\t{data['items_count']}\t{data['followers_count']}")

まとめ

  • shebang1行で外部ライブラリが使える
  • 仮想環境不要
  • uvさえあればどこでも動く

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?