捆綁的 skills 隨 Claude Code 一起提供,在每個工作階段中都可用。與內建命令不同,內建命令直接執行固定邏輯,捆綁的 skills 是基於提示的:它們為 Claude 提供詳細的劇本,並讓它使用其工具來協調工作。這意味著捆綁的 skills 可以生成平行代理、讀取檔案並適應您的程式碼庫。您以與任何其他 skill 相同的方式呼叫捆綁的 skills:輸入 / 後跟 skill 名稱。
/simplify:檢查您最近更改的檔案以查找程式碼重用、品質和效率問題,然後修復它們。在實現功能或錯誤修復後執行它以清理您的工作。它並行生成三個審查代理(程式碼重用、程式碼品質、效率),彙總其發現並應用修復。傳遞可選文字以專注於特定問題:/simplify focus on memory efficiency。
/batch <instruction>:在程式碼庫中並行協調大規模變更。提供變更的描述,/batch 研究程式碼庫,將工作分解為 5 到 30 個獨立單位,並提出計畫供您批准。批准後,它為每個單位生成一個背景代理,每個都在隔離的 git worktree 中。每個代理實現其單位、執行測試並開啟拉取請求。需要 git 存放庫。範例:/batch migrate src/ from Solid to React。
/debug [description]:透過讀取工作階段偵錯日誌來排查您目前的 Claude Code 工作階段。可選地描述問題以專注分析。
/loop [interval] <prompt>:在工作階段保持開啟時以間隔重複執行提示。Claude 解析間隔、排程循環 cron 任務並確認節奏。適用於輪詢部署、監督 PR 或定期重新執行另一個 skill。範例:/loop 5m check if the deploy finished。請參閱按排程執行提示。
/claude-api:為您的專案語言(Python、TypeScript、Java、Go、Ruby、C#、PHP 或 cURL)載入 Claude API 參考資料,以及 Python 和 TypeScript 的 Agent SDK 參考。涵蓋工具使用、串流、批次、結構化輸出和常見陷阱。當您的程式碼匯入 anthropic、@anthropic-ai/sdk 或 claude_agent_sdk 時也會自動啟動。
每個 skill 都需要一個 SKILL.md 檔案,包含兩部分:YAML frontmatter(在 --- 標記之間),告訴 Claude 何時使用該 skill,以及包含 Claude 在呼叫該 skill 時遵循的說明的 markdown 內容。name 欄位變成 /slash-command,description 幫助 Claude 決定何時自動載入它。建立 ~/.claude/skills/explain-code/SKILL.md:
回報錯誤代碼
複製
詢問AI
---name: explain-codedescription: Explains code with visual diagrams and analogies. Use when explaining how code works, teaching about a codebase, or when the user asks "how does this work?"---When explaining code, always include:1. **Start with an analogy**: Compare the code to something from everyday life2. **Draw a diagram**: Use ASCII art to show the flow, structure, or relationships3. **Walk through the code**: Explain step-by-step what happens4. **Highlight a gotcha**: What's a common mistake or misconception?Keep explanations conversational. For complex concepts, use multiple analogies.
Skill 檔案可以包含任何說明,但思考您想如何呼叫它們有助於指導要包含的內容:參考內容新增 Claude 應用於您目前工作的知識。慣例、模式、風格指南、領域知識。此內容內聯執行,以便 Claude 可以將其與您的對話上下文一起使用。
回報錯誤代碼
複製
詢問AI
---name: api-conventionsdescription: API design patterns for this codebase---When writing API endpoints:- Use RESTful naming conventions- Return consistent error formats- Include request validation
任務內容為 Claude 提供特定操作的逐步說明,如部署、提交或程式碼生成。這些通常是您想使用 /skill-name 直接呼叫的操作,而不是讓 Claude 決定何時執行它們。新增 disable-model-invocation: true 以防止 Claude 自動觸發它。
回報錯誤代碼
複製
詢問AI
---name: deploydescription: Deploy the application to productioncontext: forkdisable-model-invocation: true---Deploy the application:1. Run the test suite2. Build the application3. Push to the deployment target
預設情況下,您和 Claude 都可以呼叫任何 skill。您可以輸入 /skill-name 直接呼叫它,Claude 可以在與您的對話相關時自動載入它。兩個 frontmatter 欄位讓您限制此行為:
disable-model-invocation: true:只有您可以呼叫該 skill。用於具有副作用或您想控制時機的工作流程,如 /commit、/deploy 或 /send-slack-message。您不希望 Claude 因為您的程式碼看起來準備好就決定部署。
user-invocable: false:只有 Claude 可以呼叫該 skill。用於不可作為命令操作的背景知識。legacy-system-context skill 解釋舊系統如何運作。Claude 在相關時應該知道這一點,但 /legacy-system-context 對使用者來說不是有意義的操作。
此範例建立一個只有您可以觸發的部署 skill。disable-model-invocation: true 欄位防止 Claude 自動執行它:
回報錯誤代碼
複製
詢問AI
---name: deploydescription: Deploy the application to productiondisable-model-invocation: true---Deploy $ARGUMENTS to production:1. Run the test suite2. Build the application3. Push to the deployment target4. Verify the deployment succeeded
---name: fix-issuedescription: Fix a GitHub issuedisable-model-invocation: true---Fix GitHub issue $ARGUMENTS following our coding standards.1. Read the issue description2. Understand the requirements3. Implement the fix4. Write tests5. Create a commit
---name: migrate-componentdescription: Migrate a component from one framework to another---Migrate the $ARGUMENTS[0] component from $ARGUMENTS[1] to $ARGUMENTS[2].Preserve all existing behavior and tests.
---name: migrate-componentdescription: Migrate a component from one framework to another---Migrate the $0 component from $1 to $2.Preserve all existing behavior and tests.
---name: deep-researchdescription: Research a topic thoroughlycontext: forkagent: Explore---Research $ARGUMENTS thoroughly:1. Find relevant files using Glob and Grep2. Read and analyze the code3. Summarize findings with specific file references
Skills 可以捆綁並執行任何語言的指令碼,為 Claude 提供超越單個提示可能的功能。一個強大的模式是生成視覺輸出:在您的瀏覽器中開啟的互動式 HTML 檔案,用於探索資料、偵錯或建立報告。此範例建立一個程式碼庫探索器:一個互動式樹狀檢視,您可以在其中展開和摺疊目錄、一目瞭然地查看檔案大小,並按顏色識別檔案類型。建立 Skill 目錄:
建立 ~/.claude/skills/codebase-visualizer/SKILL.md。描述告訴 Claude 何時啟動此 Skill,說明告訴 Claude 執行捆綁的指令碼:
回報錯誤代碼
複製
詢問AI
---name: codebase-visualizerdescription: Generate an interactive collapsible tree visualization of your codebase. Use when exploring a new repo, understanding project structure, or identifying large files.allowed-tools: Bash(python *)---# Codebase VisualizerGenerate an interactive HTML tree view that shows your project's file structure with collapsible directories.## UsageRun the visualization script from your project root:```bashpython ~/.claude/skills/codebase-visualizer/scripts/visualize.py .```textThis creates `codebase-map.html` in the current directory and opens it in your default browser.## What the visualization shows- **Collapsible directories**: Click folders to expand/collapse- **File sizes**: Displayed next to each file- **Colors**: Different colors for different file types- **Directory totals**: Shows aggregate size of each folder
建立 ~/.claude/skills/codebase-visualizer/scripts/visualize.py。此指令碼掃描目錄樹並生成一個自包含的 HTML 檔案,包含:
若要測試,在任何專案中開啟 Claude Code 並詢問「視覺化此程式碼庫。」Claude 執行指令碼、生成 codebase-map.html 並在您的瀏覽器中開啟它。此模式適用於任何視覺輸出:依賴關係圖、測試覆蓋率報告、API 文件或資料庫架構視覺化。捆綁的指令碼完成繁重工作,而 Claude 處理協調。