はじめに
こんにちは!株式会社 Hacobu で Vista というプロダクトのフロントエンドエンジニアをしている cho です。
最近、社内で「Agentic Coding を眺める会」というイベントを開催しました。普段どんな感じで Claude Code を使って開発しているかを同僚に共有したところ、想像以上に反響があったんです。
特に、Custom slash commandsの部分で会議室がざわついて…
「え、そんなことできるの?」
「これめっちゃ便利そう!」
「自分でも作ってみたい!」
という声がたくさん上がりました 😊
イベント後、参加者から「これ、もっと詳しく知りたい!」「他のチームにも共有したい」という要望が続々と…
そこで、実際に業務で使える Custom slash commandsをより多くの開発者に知ってもらいたいと思い、この記事を書くことにしました。
実際に社内で反響があった内容
- セキュリティ対策の自動化:複数ファイル確認 → 依存関係調査 → 修正手順検討の一連作業をコマンド一発で完了
- Mermaid による図の自動生成:「こんなのも作れるの?」という驚きの声
- UI 改善案の ASCII wireframe 自動生成:PdM & デザイナーとの議論で使える複数のレイアウト案を瞬時に作成
同じような課題を抱えているチームの参考になれば嬉しいです 🙌
なぜ Custom slash commands なのか?
最近、Claude Code や Cursor の基本的な使い方を紹介する記事はたくさん見かけるようになりました。でも、実務で本当に使える具体的な commandsって意外と紹介されていないんですよね…
そこで今回は、私が実際に業務で使っている Custom slash commands(以下、slash commands)を中心に、Agentic Codingの実践方法をご紹介します。
なお、slash commands の基本的な作成方法についてはClaude Code 公式ドキュメントをご参照ください。この記事では実際の業務での活用例に焦点を当てています。
Agentic Coding とは?
改めて整理すると、Agentic Codingとは
AI エージェントが開発者の指示に基づき、計画立案・コード生成・テスト・修正までの一連のコーディング操作を自立的に実行するプログラミング手法
簡単に言えば、AI とやり取りしながらコーディングをするということです。
昔は自分の頭で考えて、一つ一つコマンドを叩いて実行していた作業を、slash commands で自動化できるようになったんです。これがめちゃくちゃ便利で… 🔥
実際に使っている commands
私が普段から愛用している command は 6〜7 個ほど。今回はその中でも、特に社内での反応が良かった 3 つを厳選してご紹介します!
1. /dependabot-check
– セキュリティ対策の自動化
セキュリティ対策として、Dependabot のセキュリティアラートを定期的にチェックしています。
従来の手順
- プロジェクトディレクトリに移動
-
package.json
を確認 -
pnpm-lock.yaml
を参照 - 依存関係ツリーを調査
- 修正方法を検討
今は
/dependabot-check https://github.com/org/repo/security/dependabot/123
実際のコード全体
私が実際に使っている dependabot-check コマンドの全体コードです。
なお、コマンド内容を英語で記述しているのは、Claude Code が英語での指示に対してより正確で詳細な処理を実行してくれるから+トークン効率も良いからです。
.claude/commands/dependabot-check.md
---
allowed-tools: Bash(gh:*), Bash(git:*), Bash(pnpm:*)
description: Analyze Dependabot security advisory and provide resolution strategy
---
## Context
Dependabot URL (GitHub Security Advisory or PR URL): {{ dependabot_url }}
## Your task
Analyze Dependabot security advisory and provide resolution strategy.
### Step 1: Gather Advisory Information
Execute the following commands to collect information:
**Query Dependabot Information:**
First, determine the URL type and use appropriate command:
- If URL contains `/security/dependabot/[number]`: Use `gh api /repos/[owner]/[repo]/dependabot/alerts/[number]`
- If URL contains `/pull/`: Use `gh pr view {{ dependabot_url }} --json title,body,commits`
- If URL contains GitHub Security Advisory ID (GHSA-xxxx): Use `gh api /advisories/[GHSA-ID]`
**Important**: Only execute the command that matches the provided URL type to avoid 404 errors.
**Check Current Project Status:**
- git status
- pnpm list --depth=0 (check direct dependencies)
- If vulnerable package found: pnpm why [package-name]
**Verify Actual Usage (to avoid cache issues):**
- grep -r "[package-name]" package.json pnpm-lock.yaml (check if package exists in lock files)
- If package not found in lock files: likely already resolved or cache issue
### Step 2: Dependency Analysis
Analyze the vulnerable package as follows:
1. **Check Direct vs Indirect Dependency**
- Check if the package exists in package.json
- If yes: Direct dependency
- If no: Indirect dependency
2. **Analyze Dependency Tree**
- Analyze pnpm why [package-name] results
- Identify which parent packages depend on this package
### Step 3: Resolution Strategy
**For Direct Dependencies:**
# Update the package directly
pnpm update [package-name]
# Or modify package.json version then
pnpm install
**For Indirect Dependencies:**
1. **Analyze Parent Package Update Requirements**
# Check what version of parent package would resolve the vulnerability
pnpm info [parent-package-name] versions --json
# Check current version in package.json
cat package.json | grep [parent-package-name]
2. **Resolution Options Analysis**
- Check if parent package update is **minor/patch** (low risk) or **major** (high risk)
- For minor/patch updates: Recommend direct parent package update
- For major updates: Provide both options with trade-off analysis
3. **Option A: Update Parent Package (Recommended for minor/patch)**
pnpm update [parent-package-name]@[specific-version]
4. **Option B: Use Overrides (Recommended for major updates)**
// Add to package.json
{
"pnpm": {
"overrides": {
"[package-name]": "^[safe-version]"
}
}
}
### Step 4: Generate Analysis Report
Present the analysis results in the following format:
## 🚨 Dependabot Advisory Analysis
**Reference URL**: {{ dependabot_url }}
### Vulnerable Package
- **Package Name**: [package-name] ([direct/indirect dependency])
- **Current Version**: [current-version] → **Recommended**: [recommended-version]
- **Severity**: [severity-level]
### 🔧 Resolution Strategy
**For indirect dependencies, include this analysis:**
- **Parent Package**: [parent-package] ([current] → [required version])
- **Update Level**: [Major/Minor/Patch]
- **Recommended Method**: [Parent package update/Use overrides]
- **Reason**: [Major update has breaking changes risk/Minor update has minimal impact, etc.]
[Specific resolution steps]
### 📋 Checklist
- [ ] Verify if only pnpm-lock.yaml changed without package.json changes
- [ ] For indirect dependencies, dependency source identified
- [ ] Package actually exists in lock files (not stale cache)
- [ ] Breaking changes reviewed
**Execute all commands and provide comprehensive analysis results in the above format.**
実際の実行結果
実際にコマンドを実行すると、以下のような分析結果が生成されます。
Github – Dependabot alertの詳細画面
/dependabot-check
コマンドで実際のセキュリティアラートを分析してもらった結果
このコマンドが、従来は手動で行っていた一連の調査・分析作業を全て自動で実行してくれます。
特にセキュリティ対策の自動化は、手動でやると「プロジェクトディレクトリ移動 → package.json 確認 → pnpm-lock.yaml 参照 → 依存関係ツリー調査 → 修正手順検討 → 実行」と一連の手順を踏む必要があった作業が、コマンド一発で完了するので、参加者からの反応もすごく良かったです 😊
この分析レポートで原因は一目瞭然!あとはサクッとコードを修正して、おなじみの /pr
コマンドでプルリクエストを作成するだけです。この連携がまた気持ちいいんですよね…!
2. /pr
– プルリクエストの自動作成
プルリクエストの作成も自動化しています。
オプション付きで柔軟に対応
- 通常実行:PR description 作成のみ
-
-p
オプション:push + PR description 作成 -
-u
オプション:既存 PR の description 更新
実際のコード全体
.claude/commands/pr.md
---
allowed-tools: Bash(gh:*), Bash(git:*)
description: Generate PR description and automatically create pull request on GitHub
---
## Context
- Current git status: !`git status`
- Changes in this PR: !`git diff master...HEAD`
- Commits in this PR: !`git log --oneline master..HEAD`
- PR template: @.github/pull_request_template.md
## Your task
Based on the provided option, perform one of the following actions:
### Options:
- **No option or default**: Generate PR description and create pull request
- **-p**: Push current branch and create pull request
- **-u**: Update existing pull request description only
### Default behavior (no option):
1. Create a PR description following the **exact format** of the PR template in Japanese
2. **Add a Mermaid diagram** that visualizes the changes made in this PR
3. Execute `gh pr create --draft` with the generated title and description
### With -p option:
1. Push current branch to remote repository using `git push -u origin `
2. Create a PR description following the **exact format** of the PR template in Japanese
3. **Add a Mermaid diagram** that visualizes the changes made in this PR
4. Execute `gh pr create --draft` with the generated title and description
### With -u option:
1. Create a PR description following the **exact format** of the PR template in Japanese
2. **Add a Mermaid diagram** that visualizes the changes made in this PR
3. Update existing pull request description using `gh pr edit --body `
### Requirements:
1. Follow the template structure exactly
2. Use Japanese for all content
3. Include specific implementation details
4. List concrete testing steps
5. Always include a Mermaid diagram that shows:
- Architecture changes (if any)
- Data flow modifications
- Component relationships
- Process flows affected by the changes
6. Be comprehensive but concise
### Mermaid Diagram Guidelines:
- Use appropriate diagram types (flowchart, sequence, class, etc.)
- Show before/after states if applicable
- Highlight new or modified components
- Use consistent styling and colors
- Add the diagram in a dedicated section of the PR description
**Generate the PR description and create the pull request automatically.**
この Mermaid で図を生成するというアイデアは、2 週間前に Devin を久しぶりに使った時に、Devin が自動で diagram を追加してくれるのを見て「あ、これ Claude Code でも真似できそう!」と思って実装したんです。一目で修正内容が分かるので、レビュワーにも好評です 👍
実際の生成結果
先ほどの /dependabot-check
で見つけた脆弱性を修正した後、早速 /pr
コマンドを叩いてみます。すると…
じゃーん!こんな感じのプルリクエストが自動で立ち上がります。
/pr
コマンドで自動生成された修正 PR
そして注目してほしいのが、この PR 説明欄に自動で埋め込まれた Mermaid 図です。これがあるだけで、変更内容が一発で理解できるので、レビュワーからも「めっちゃ分かりやすい!」と大好評です。
実際の PR に自動生成された Mermaid 図
/pr
コマンドは単に Mermaid 図を作るだけでなく
- git diff を分析して変更点を理解
-
.github/pull_request_template.md
に合わせた形式で記述 - 一貫性のある PR 説明文を自動生成
- 技術的な変更内容を分かりやすく要約
このおかげで、どのメンバーが作っても PR の品質が統一されるようになりました。
特に Mermaid 図の自動生成は、「こんなのも作れるの?」という驚きの声をたくさんいただきました 😊
3. /ui-advice
– UI デザインパターンの提案
プロトタイプ開発でよく使う command です。
使い方
/ui-advice [画像URL or 画像アップロード]
実際のコード全体
.claude/commands/ui-advice.md
---
allowed-tools: WebFetch, mcp__contex7__search
description: Provides UI/UX design pattern advice and generates text wireframes
---
## Context
You are a UI/UX design expert with knowledge from world-renowned designers. When users ask about specific UI elements or screens, you provide various design pattern options and explain their pros and cons.
## Your task
Analyze the user's UI/UX design requirements and provide:
1. **Design Pattern Suggestions**: Propose 3-5 design patterns suitable for the requirements
2. **Pattern Explanations**: Features, pros/cons, and use cases for each pattern
3. **Text Wireframes**: Simple ASCII text wireframes for each pattern
4. **Recommendations**: Most suitable pattern for the user's situation
### Guidelines:
- Reference patterns from famous design systems (Material Design, Apple HIG, Ant Design, etc.)
- Consider usability, accessibility, and current trends
- Create wireframes that are simple yet easy to understand
- Include implementation complexity for each pattern
- Given that users primarily use Mantine, use the mcp__contex7__search tool to retrieve latest Mantine component information and analyze implementation feasibility
### Wireframe Creation Rules:
┌─────────────────────────┐
│ Header Title │
├─────────────────────────┤
│ [ Button ] [ Button ] │
│ │
│ Content Area │
│ ┌─────┐ ┌─────┐ │
│ │Card │ │Card │ │
│ └─────┘ └─────┘ │
└─────────────────────────┘
Use simple ASCII characters to clearly express the structure like this.
実際の生成結果
例として、Anthropic の公式ページのレイアウトを分析してもらいました。
分析対象の Anthropic 公式ページ
実際にコマンドを実行すると、以下のような詳細な分析結果が生成されます
/ui
コマンドで実際の UI 提案コマンドの実行結果
実際の効果
プロトタイプ開発での活用可能性
このような詳細な分析結果を見ると、新規事業やプロトタイプ開発で大きく役立ちそうです
- スピード重視の場面: 「既存ページをもう少しモダンに」という要望に 1~2 分で複数案を提示
- 技術的実現性: Context7 MCP を経由して、プロダクトで採用中の UI ライブラリに適した実装可能なコンポーネントを提案
- コミュニケーション改善: 抽象的なデザイン議論から「この 3 つのうちどれ?」という具体的選択に変換
特に ASCII wireframe の自動生成は、社内で「え、これも AI で作れるの?」という驚きの反応が多く、プロトタイプ開発の効率化への関心が高まりました。
実務での効果
作業時間の短縮
「で、実際どれくらい早くなったの?」って気になりますよね 🤔
正直、自分でも驚くほど効果がありました。手作業でやっていた頃と比べると、こんな感じです。
-
セキュリティ対策
- Before: 手動での調査・分析に 10〜15 分かかっていたのが…
-
After:
/dependabot-check
実行で 約 3~5 分に短縮!
-
PR 作成
- Before: 差分確認から説明文を丁寧に書こうとすると、大体10 分くらい。正直、Mermaid 図は手間がかかりすぎるので作っていませんでした…
- After: なんと Mermaid 図を自動生成しながら、約 1〜2 分で完了!
-
UI プロトタイプ作成
- Before: デザインパターン調査やワイヤーフレーム作成に 30 分以上…
-
After:
/ui-advice
で複数案を 約 1 分でゲット!
特に、/dependabot-check
のように少し時間のかかる処理には hooks で通知を設定しているので、コマンド実行後は他の作業に集中できます。完了したら音が鳴って知らせてくれるので、待ち時間も有効活用できるのが最高なんです 🎵
品質の向上
- 統一された PR フォーマット(Mermaid 図付き)
- 体系的なセキュリティ対策(見落とし防止)
- デザインパターンベースの UI 設計
チーム全体への波及効果
社内でコマンドを共有するリポジトリ「coding-agent-toolkit」も作成しました。
みんなで便利なコマンドを共有することで、チーム全体の生産性が向上しています。
まとめ
Custom slash commandsを使うことで、Agentic Coding がより実践的になります。
分かったこと
- 繰り返し作業の自動化は想像以上に効果的だった
- コマンドの共有でチーム全体の生産性が向上する
- 実際に使える commands の価値は想像以上に高かった
今後の展開
- 新しい AI ツールが出ても、既存のコマンドを活用できる
- チームメンバーの便利コマンドを共有する文化
- より複雑なワークフローの自動化
おわりに
私が「Agentic Coding を眺める会」で共有した内容が、同じような課題を抱えている開発者の方々の参考になれば嬉しいです!
slash command を作る際は、まずは小さなものから始めて、徐々に高度なものに挑戦していくのがおすすめです 🚀
皆さんもぜひ、自分だけの実務に役立つ slash command を作ってみませんか?
参考リンク
Views: 0