Iii iii-channels
install
source · Clone the upstream repo
git clone https://github.com/iii-hq/iii
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/iii-hq/iii "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/iii-channels" ~/.claude/skills/iii-hq-iii-iii-channels && rm -rf "$T"
manifest:
skills/iii-channels/SKILL.mdsource content
Channels
Comparable to: Unix pipes, gRPC streaming, WebSocket data streams
Key Concepts
Use the concepts below when they fit the task. Not every worker needs channels.
- A Channel is a WebSocket-backed binary stream between two endpoints (writer and reader)
returns a writer/reader pair plus serializable refs that can be passed to other workerscreateChannel()- StreamChannelRef is a serializable reference (channel_id, access_key, direction) that can be included in function payloads
- Writers send binary data (chunked into 64KB frames) and text messages
- Readers consume binary chunks via
or receive text messages via callbacksreadAll() - Consumers must construct a reader from a serializable
(e.g.,StreamChannelRef
) rather than using the producer-side reader object returned byChannelReader::new(...)createChannel() - Channels work cross-worker and cross-language — a Python writer can stream to a Rust reader
Architecture
A function creates a channel via
createChannel(), receiving a writer and reader pair. The writer ref or reader ref is passed to another function (potentially in a different worker/language) via a trigger payload. The engine brokers the WebSocket connection between the two endpoints. Binary data flows directly between workers through the engine's channel endpoint.
iii Primitives Used
| Primitive | Purpose |
|---|---|
| Create a channel, returns writer + reader pair |
| Send binary data (chunked into 64KB frames) |
| Send a text message through the channel |
| Close the writer end |
| Read entire stream into a single buffer |
| Register callback for text messages |
| Serializable reference to pass between workers |
Reference Implementation
- TypeScript: ../references/channels.js
- Python: ../references/channels.py
- Rust: ../references/channels.rs
Each reference shows the same patterns (channel creation, binary streaming, text messages, cross-function handoff) in its respective language.
Common Patterns
Code using this pattern commonly includes, when relevant:
— create a channel pair (producer access)const channel = await iii.createChannel()
/channel.writer.stream.write(buffer)
— send binary datachannel.writer.write(data)
— send text metadatachannel.writer.sendMessage(JSON.stringify({ type: 'metadata', ... }))
— signal end of streamchannel.writer.close()- Pass
orchannel.readerRef
in trigger payloads for cross-worker streamingchannel.writerRef - Consumer must reconstruct the reader from the ref: e.g.,
new ChannelReader(iii.address, readerRef)
— read entire stream (consumer behavior)const data = await reader.readAll()
— handle text messages (consumer behavior)reader.onMessage(msg => { ... })
Adapting This Pattern
Use the adaptations below when they apply to the task.
- Use channels for large data transfers that shouldn't be serialized into JSON payloads
- Pass
to a processing function andreaderRef
to a producing function for pipeline patternswriterRef - Use text messages for metadata/signaling alongside binary data streams
- Set
when the reader may be slower than the writer to apply backpressurebufferSize - Channels work cross-language — a TypeScript producer can stream to a Rust consumer
Pattern Boundaries
- For key-value state persistence, prefer
.iii-state-management - For stream CRUD (named streams with groups/keys), prefer
.iii-realtime-streams - For pub/sub messaging, prefer triggers with
type.subscribe - Stay with
when the primary problem is binary data streaming between workers.iii-channels
When to Use
- Use this skill when the task is primarily about
in the iii engine.iii-channels - Triggers when the request directly asks for this pattern or an equivalent implementation.
Boundaries
- Never use this skill as a generic fallback for unrelated tasks.
- You must not apply this skill when a more specific iii skill is a better fit.
- Always verify environment and safety constraints before applying examples from this skill.