Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Claude Code Api Streaming

ASecurity

Use when implementing server-side SSE streaming compatibility for a Claude Code Anthropic gateway, including message_start/content_block_delta/message_delta events, tool_use streaming, stream:false fallback, timeouts, and malformed stream behavior.

4 stars
0 votes
0 copies
0 views
Added 9/20/2026
ai-agentsbashapi

Works with

claude codeapi

Security Analysis

A100/100

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add ZipperCode/lingma2api --skill claude-code-api-streaming --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Claude Code Api Streaming?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Claude Code Api Streaming
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/zippercode-claude-code-api-streaming/badge)](https://www.skillsdirectory.com/skills/zippercode-claude-code-api-streaming)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: claude-code-api-streaming
description: Use when implementing server-side SSE streaming compatibility for a Claude Code Anthropic gateway, including message_start/content_block_delta/message_delta events, tool_use streaming, stream:false fallback, timeouts, and malformed stream behavior.
---

# Claude Code 网关 SSE 流式响应

## 目标

根据本 skill,实现 `/v1/messages` 在 `stream:true` 时的服务端 SSE 响应。你要输出 Anthropic raw stream event,不是写客户端 stream parser。

详细事件字段见 `references/stream-events-wire-format.md`。

## 最小事件序列

文本回复必须按顺序输出:

```text
message_start
content_block_start
content_block_delta*
content_block_stop
message_delta
message_stop
```

服务端用 `Content-Type: text/event-stream`,每个 SSE frame 同时带 `event:` 和 JSON `data:`。

## 文本流

1. `message_start`:创建 assistant message,usage 中 `output_tokens` 可先为 0。
2. `content_block_start`:`index:0`,`content_block:{ "type":"text", "text":"" }`。
3. 多个 `content_block_delta`:`delta:{ "type":"text_delta", "text":"..." }`。
4. `content_block_stop`:结束该 block。
5. `message_delta`:写最终 `stop_reason` 和 output usage。
6. `message_stop`:结束流。

## 工具调用流

当模型需要工具:

- `content_block_start` 使用 `content_block:{ "type":"tool_use", "id":"toolu_...", "name":"Bash", "input":{} }`。
- 工具参数通过多个 `input_json_delta.partial_json` 分片输出。
- `message_delta.delta.stop_reason` 必须是 `tool_use`。
- 客户端下一轮会把工具执行结果作为 user message 的 `tool_result` block 发回 `/v1/messages`。

## Thinking 与 server tool

- thinking block 使用 `thinking_delta` 和可选 `signature_delta`。
- 不支持 thinking 时不要输出 thinking block。
- `server_tool_use` 可用于 advisor 等服务端工具;外部网关通常可以不实现。

## 非流式 fallback

Claude Code 在这些情况下可能走 `stream:false`:

- 流式创建 404。
- SSE 无事件、缺少 `message_start`、缺少完整 stop。
- 中途异常或超时。
- 主动发起非流式后台任务。

网关必须保证 `stream:false` 返回完整 message JSON,结构与流式聚合后的最终 message 一致。

## 兼容要求

- 不要只输出纯 `data:` 文本;Claude Code 需要 Anthropic event JSON。
- 不要省略 `message_delta`;最终 usage 和 `stop_reason` 依赖它。
- `input_json_delta.partial_json` 可以分片,但最终拼接后必须是合法 JSON。
- 0 事件流会被视为坏流。
- 429/529/5xx 中断应返回 HTTP 错误,而不是半截成功 SSE。

Attribution

ZipperCodeZipperCode
View sourceMore from ZipperCode →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Caveman

Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.

1023331 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

686011 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3331 votes

catchup

Recovers prior coding-agent session context by running `catchup <agent> --since-compact`, which extracts a clean summary of a previous Codex, Claude Code, Antigravity, OpenCode, or Pi Agent session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", or asks to recover/summarize a previous session before continuing. Do NOT use for the current conversation, git history, or any non-agent log.

611 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →