一键导入
claude-api-go
Claude API / Anthropic Go SDK usage patterns, prompt caching, streaming, tool use, and model selection for Go applications.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Claude API / Anthropic Go SDK usage patterns, prompt caching, streaming, tool use, and model selection for Go applications.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
ann-benchmarks フレームワーク規約(algos.yaml/HDF5/Pareto frontier分析)と ANN ベクトル検索の SIMD 距離カーネル最適化における落とし穴パターン(AVX2/AVX-512 ディスパッチャ検証・量子化の数学的等価性確認・部分集合とフルスケールの混同防止)。ArcFlare/NGT/NGTAQ 等の ANN R&D 作業時の参照用。実装作業自体は ann-perf-engineer agent に委譲する。
Use this skill to measure performance baselines, detect regressions before/after PRs, and compare stack alternatives.
C++ coding standards based on the C++ Core Guidelines (isocpp.github.io). Use when writing, reviewing, or refactoring C++ code to enforce modern, safe, and idiomatic practices.
Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications.
非推奨・後方互換用リダイレクト。旧 dig(コードベース深掘り分析→設計インタビュー→実装計画→自律実行)は swarm-loop に完全統合された。/dig と入力された場合は本ファイルの指示に従い、そのまま swarm-loop skill を 同じ目標・同じ引数で起動すること。dig 独自のロジックはここには存在しない。
GitHub Actions workflow design, matrix builds, secrets management, caching, and CI/CD patterns for Go/Rust/Protobuf projects with make-based build systems.
| name | claude-api-go |
| description | Claude API / Anthropic Go SDK usage patterns, prompt caching, streaming, tool use, and model selection for Go applications. |
| trigger | /claude-api-go |
go get github.com/anthropics/anthropic-sdk-go
import "github.com/anthropics/anthropic-sdk-go"
client := anthropic.NewClient() // reads ANTHROPIC_API_KEY from env
msg, err := client.Messages.New(ctx, anthropic.MessageNewParams{
Model: anthropic.ModelClaude3_5SonnetLatest,
MaxTokens: 1024,
Messages: []anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock("Hello")),
},
})
if err != nil {
return fmt.Errorf("claude: %w", err)
}
fmt.Println(msg.Content[0].Text)
// Mark reusable content with cache_control
systemBlock := anthropic.TextBlockParam{
Type: anthropic.F(anthropic.TextBlockParamTypeText),
Text: anthropic.F(longSystemPrompt),
CacheControl: anthropic.F[anthropic.CacheControlEphemeralParam](
anthropic.CacheControlEphemeralParam{
Type: anthropic.F(anthropic.CacheControlEphemeralParamTypEphemeral),
},
),
}
msg, err := client.Messages.New(ctx, anthropic.MessageNewParams{
Model: anthropic.ModelClaude3_5SonnetLatest,
MaxTokens: 1024,
System: []anthropic.TextBlockParam{systemBlock},
Messages: messages,
})
Cache rules:
stream := client.Messages.NewStreaming(ctx, anthropic.MessageNewParams{
Model: anthropic.ModelClaude3_5SonnetLatest,
MaxTokens: 2048,
Messages: messages,
})
for stream.Next() {
event := stream.Current()
switch delta := event.Delta.(type) {
case anthropic.ContentBlockDeltaEventDelta:
if delta.Type == anthropic.ContentBlockDeltaEventDeltaTypeTextDelta {
fmt.Print(delta.Text)
}
}
}
if err := stream.Err(); err != nil {
return fmt.Errorf("stream: %w", err)
}
tools := []anthropic.ToolParam{
{
Name: anthropic.F("get_weather"),
Description: anthropic.F("Get current weather for a location"),
InputSchema: anthropic.F(anthropic.ToolInputSchemaParam{
Type: anthropic.F(anthropic.ToolInputSchemaParamTypeObject),
Properties: anthropic.F(map[string]interface{}{
"location": map[string]string{
"type": "string",
"description": "City name",
},
}),
Required: anthropic.F([]string{"location"}),
}),
},
}
for {
msg, _ := client.Messages.New(ctx, anthropic.MessageNewParams{
Model: anthropic.ModelClaude3_5SonnetLatest,
Tools: tools,
Messages: messages,
})
if msg.StopReason == anthropic.MessageStopReasonEndTurn {
break
}
messages = append(messages, msg.ToParam())
var toolResults []anthropic.ToolResultBlockParam
for _, block := range msg.Content {
if block.Type == anthropic.ContentBlockTypeToolUse {
result := callTool(block.Name, block.Input)
toolResults = append(toolResults, anthropic.NewToolResultBlock(block.ID, result, false))
}
}
messages = append(messages, anthropic.NewToolResultMessage(toolResults...))
}
| Use Case | Model |
|---|---|
| Complex reasoning, coding | anthropic.ModelClaude_Opus_4_7 |
| Balanced cost/performance | anthropic.ModelClaude_Sonnet_4_6 |
| Fast, simple tasks | anthropic.ModelClaude_Haiku_4_5_20251001 |
msg, err := client.Messages.New(ctx, params)
var apiErr *anthropic.Error
if errors.As(err, &apiErr) {
switch apiErr.StatusCode {
case 429:
// rate limited — exponential backoff
case 529:
// overloaded — retry with backoff
}
}
MaxTokens set too low (causes mid-response truncation)StopReason in tool use loop (may miss tool calls)