using-claude
Working with Claude Code features, debugging hooks, MCP integration, snippet verification, headless automation, and Agent SDK. Use this skill when the user asks about Claude Code features, hooks, memory, statusline, debugging, MCP servers, headless use patterns, CI/CD automation, Python/TypeScript Agent SDK, or building custom agents.
What this skill does
# Using Claude Code
## Overview
This skill provides guidance for working with Claude Code programmatically and understanding its features.
**What you'll learn:**
- **Model selection** - When to use Opus, Sonnet, or Haiku
- **Documentation access** - How to fetch latest Claude Code docs
- **Headless automation** - CI/CD, batch processing, scripted workflows
- **Agent SDK** - Building custom agents in Python and TypeScript
- **Debugging** - Testing hooks, plugins, and configurations
- **MCP servers** - Configuring and managing external tools
- **Snippet verification** - Ensuring snippets inject correctly
---
# Model Selection: Opus vs Sonnet vs Haiku
**Quick decision guide:**
| Use Case | Model | Why |
| ----------------------------------------------------- | ---------- | ----------------------------------------------- |
| Complex reasoning, architecture design, code reviews | **Opus** | Highest intelligence, best at nuanced decisions |
| General coding, refactoring, debugging, documentation | **Sonnet** | Best balance of capability and speed |
| Simple tasks, formatting, quick edits, explanations | **Haiku** | Fastest and most cost-effective |
## Detailed Guidance
### Use Opus When:
_Highest intelligence • Slower • Most expensive_
- **Architectural decisions** - Designing system architecture, evaluating trade-offs
- **Complex refactoring** - Large-scale code restructuring requiring deep understanding
- **Security audits** - Thorough security analysis and vulnerability detection
- **Code reviews** - Comprehensive review requiring contextual understanding
- **Research and exploration** - Open-ended investigation of unfamiliar codebases
**Example:**
```python
options = ClaudeAgentOptions(
model="opus", # Use highest intelligence
max_turns=10
)
```
### Use Sonnet When (Default):
_Best balance • Fast • Moderate cost_
- **General development** - Day-to-day coding tasks
- **Debugging** - Finding and fixing bugs
- **Writing tests** - Creating test suites
- **Documentation** - Generating API docs, READMEs
- **Refactoring** - Standard code improvements
- **Feature implementation** - Building new functionality
**Example:**
```python
options = ClaudeAgentOptions(
model="sonnet", # Default choice for most tasks
max_turns=5
)
```
### Use Haiku When:
_Fast • Cheapest • Good for simple tasks_
- **Simple edits** - Formatting, typo fixes, minor changes
- **Explanations** - Explaining code or concepts
- **Quick queries** - Simple questions that don't require deep analysis
- **Batch processing** - Processing many simple tasks where speed matters
- **Cost optimization** - When budget is a primary concern
**Example:**
```python
options = ClaudeAgentOptions(
model="haiku", # Fast and economical
max_turns=3
)
```
---
# Documentation Access
**ALWAYS fetch the latest Claude Code documentation directly** when you need to implement any of the features.
## Available Documentation
```bash
# Core Features
curl -s https://docs.claude.com/en/docs/claude-code/hooks.md
curl -s https://docs.claude.com/en/docs/claude-code/memory.md
curl -s https://docs.claude.com/en/docs/claude-code/statusline.md
curl -s https://docs.claude.com/en/docs/claude-code/snippets.md
curl -s https://docs.claude.com/en/docs/claude-code/commands.md
curl -s https://docs.claude.com/en/docs/claude-code/configuration.md
# Agent SDK
curl -s https://docs.claude.com/en/api/agent-sdk/python.md
curl -s https://docs.claude.com/en/api/agent-sdk/typescript.md
curl -s https://docs.claude.com/en/api/agent-sdk/overview.md
```
## Usage Pattern
When user asks about Claude Code features:
1. **Identify relevant documentation** from the list above
2. **Fetch using curl** via the Bash tool
3. **Read and apply** the fetched content to answer accurately
---
# Quick Start Guides
## Headless Automation
**For CI/CD, batch processing, and scripted workflows.**
### Basic One-Shot Command
```bash
# Simple task
claude -p "analyze this code"
# With automation settings
claude --permission-mode bypassPermissions --max-turns 5 -p "run tests and fix failures"
# Read-only analysis
claude --allowed-tools "Read,Grep,Glob" -p "review codebase structure"
```
### Structured Output for Parsing
```bash
# JSON output for scripts
claude --output-format "stream-json" -p "task" | jq .
# Extract specific fields
claude --output-format "stream-json" -p "task" | \
jq -r 'select(.type == "result") | .total_cost_usd'
```
### Session Continuation
```bash
# Capture session ID
SESSION=$(claude --debug -p "first task" 2>&1 | grep -o '"session_id":"[^"]*"' | cut -d'"' -f4)
# Continue conversation
claude -c "$SESSION" -p "follow-up task"
```
**📖 Complete guide:** See [reference/headless-patterns.md](reference/headless-patterns.md)
**💻 Working example:** See `scripts/headless-example.sh`
---
## Agent SDK (Python)
**For building custom agents programmatically.**
### Installation
```bash
pip install claude-agent-sdk
```
### Simple Query
```python
from claude_agent_sdk import query, ClaudeAgentOptions
async for message in query(
prompt="What is 2+2?",
options=ClaudeAgentOptions(
model="sonnet", # Choose model based on task complexity
permission_mode="bypassPermissions",
allowed_tools=[]
)
):
if message.type == "result":
print(message.result)
```
### Continuous Conversation
```python
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions
async with ClaudeSDKClient(options=ClaudeAgentOptions(model="sonnet")) as client:
await client.query("Remember: my name is Alice")
async for msg in client.receive_response():
if msg.type == "result": break
await client.query("What's my name?") # Remembers context
async for msg in client.receive_response():
if msg.type == "result": break
```
### Custom Tools
```python
from claude_agent_sdk import tool, create_sdk_mcp_server
@tool("add", "Add two numbers", {"a": float, "b": float})
async def add(args):
return {"content": [{"type": "text", "text": f"Sum: {args['a'] + args['b']}"}]}
server = create_sdk_mcp_server(name="calc", tools=[add])
options = ClaudeAgentOptions(
mcp_servers={"calc": server},
allowed_tools=["mcp__calc__add"]
)
```
**📖 Complete guide:** See [reference/agent-sdk-patterns.md](reference/agent-sdk-patterns.md)
**💻 Working example:** See `scripts/sdk-python-example.py`
---
## Agent SDK (TypeScript)
**For building custom agents in Node.js/TypeScript.**
### Installation
```bash
npm install @anthropic-ai/claude-agent-sdk
```
### Simple Query
```typescript
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const msg of query({
prompt: "What is 2+2?",
options: {
model: "sonnet",
permissionMode: "bypassPermissions",
},
})) {
if (msg.type === "result") console.log(msg.result);
}
```
### Custom Tools with Zod
```typescript
import { tool, createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk";
import { z } from "zod";
const addTool = tool(
"add",
"Add two numbers",
z.object({ a: z.number(), b: z.number() }),
async (args) => ({
content: [{ type: "text", text: `Sum: ${args.a + args.b}` }],
}),
);
const server = createSdkMcpServer({ name: "calc", tools: [addTool] });
```
**📖 Complete guide:** See [reference/agent-sdk-patterns.md](reference/agent-sdk-patterns.md)
**💻 Working example:** See `scripts/sdk-typescript-example.ts`
---
## Debugging Claude Code
**Testing hooks, plugins, snippets, and configurations.**
### Debug Mode
```bash
# Always use --debug when testing modifications
claude --debug -p "test prompt"
# Structured output with debug info
claude --debug --verbose --output-format "stream-json" -p "test" | jq .
# Debug logs saved to ~/.claude/debug/{session_id}/
ls ~/.claude/debug/
```
### Testing Hooks
```bash
# 1. Check hooks are registered
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.