Token导航 LogoToken导航TokenDH.com
AI 工具需要联网github未标认证来源可访问clear审计通过

axiom-networking-migrationAxiom 网络迁移

Agent Skill

axiom-networking-migration 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,818

周安装

164

GitHub Stars

873

下载量

1,338
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:axiom-networking-migration(Axiom 网络迁移)
来源仓库:https://github.com/charleswiltgen/axiom
仓库路径:skills/axiom-networking-migration
安装命令:
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-networking-migration
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-networking-migration

简介

提供从 BSD Sockets、NWConnection 向现代网络 API 迁移的系统化指南。

  • 明确区分 URLSession(HTTP 首选)与 Network.framework(自定义协议)的适用边界。
  • 包含 Migration 1(BSD→NWConnection)与 Migration 2(completion handler→async/await)的具体步骤。
  • 使用前应评估当前网络栈架构,避免在不必要的情况下进行大规模重构。
  • 建议结合 Instruments 工具验证迁移后的性能与稳定性表现。

SKILL.md

Network Framework Migration Guides

Do I Need to Migrate?

What networking API are you using?

├─ URLSession for HTTP/HTTPS REST APIs?
│   └─ Stay with URLSession — it's the RIGHT tool for HTTP
│      URLSession handles caching, cookies, auth challenges,
│      HTTP/2/3, and is heavily optimized for web APIs.
│      Network.framework is for custom protocols, NOT HTTP.
│
├─ BSD Sockets (socket, connect, send, recv)?
│   └─ Migrate to NWConnection (iOS 12+)
│      → See Migration 1 below
│
├─ NWConnection / NWListener?
│   ├─ Need async/await? → Migrate to NetworkConnection (iOS 26+)
│   │   → See Migration 2 below
│   └─ Callback-based code working fine? → Stay (not deprecated)
│
├─ URLSession StreamTask for TCP/TLS?
│   └─ Need UDP or custom protocols? → NetworkConnection
│      Need just TCP/TLS for HTTP? → Stay with URLSession
│      → See Migration 3 below
│
├─ SCNetworkReachability?
│   └─ DEPRECATED — Replace with NWPathMonitor (iOS 12+)
│      let monitor = NWPathMonitor()
│      monitor.pathUpdateHandler = { path in
│          print(path.status == .satisfied ? "Online" : "Offline")
│      }
│
└─ CFSocket / NSStream?
    └─ DEPRECATED — Replace with NWConnection (iOS 12+)
       → See Migration 1 below

Migration 1: From BSD Sockets to NWConnection

Migration mapping

BSD SocketsNWConnectionNotes
socket() + connect()NWConnection(host:port:using:) + start()Non-blocking by default
send() / sendto()connection.send(content:completion:)Async, returns immediately
recv() / recvfrom()connection.receive(minimumIncompleteLength:maximumLength:completion:)Async, returns immediately
bind() + listen()NWListener(using:on:)Automatic port binding
accept()listener.newConnectionHandlerCallback for each connection
getaddrinfo()Let NWConnection handle DNSSmart resolution with racing
SCNetworkReachabilityconnection.stateUpdateHandler waiting stateNo race conditions
setsockopt()NWParameters configurationType-safe options

Example migration

Before (BSD Sockets)

// BEFORE — Blocking, manual DNS, error-prone
var hints = addrinfo()
hints.ai_family = AF_INET
hints.ai_socktype = SOCK_STREAM

var results: UnsafeMutablePointer<addrinfo>?
getaddrinfo("example.com", "443", &hints, &results)

let sock = socket(results.pointee.ai_family, results.pointee.ai_socktype, 0)
connect(sock, results.pointee.ai_addr, results.pointee.ai_addrlen) // BLOCKS

let data = "Hello".data(using: .utf8)!
data.withUnsafeBytes { ptr in
    send(sock, ptr.baseAddress, data.count, 0)
}

After (NWConnection)

// AFTER — Non-blocking, automatic DNS, type-safe
let connection = NWConnection(
    host: NWEndpoint.Host("example.com"),
    port: NWEndpoint.Port(integerLiteral: 443),
    using: .tls
)

connection.stateUpdateHandler = { state in
    if case .ready = state {
        let data = Data("Hello".utf8)
        connection.send(content: data, completion: .contentProcessed { error in
            if let error = error {
                print("Send failed: \(error)")
            }
        })
    }
}

connection.start(queue: .main)

Benefits

  • 20 lines → 10 lines
  • No manual DNS, no blocking, no unsafe pointers
  • Automatic Happy Eyeballs, proxy support, WiFi Assist

Migration 2: From NWConnection to NetworkConnection (iOS 26+)

Why migrate

  • Async/await eliminates callback hell
  • TLV framing and Coder protocol built-in
  • No [weak self] needed (async/await handles cancellation)
  • State monitoring via async sequences

Migration mapping

NWConnection (iOS 12-25)NetworkConnection (iOS 26+)Notes
connection.stateUpdateHandler = {state in}for await state in connection.states {}Async sequence
connection.send(content:completion:)try await connection.send(content)Suspending function
connection.receive(minimumIncompleteLength:maximumLength:completion:)try await connection.receive(exactly:)Suspending function
Manual JSON encode/decodeCoder(MyType.self, using:.json)Built-in Codable support
Custom framerTLV {TLS()}Built-in Type-Length-Value
[weak self] everywhereNo [weak self] neededTask cancellation automatic

Example migration

Before (NWConnection)

// BEFORE — Completion handlers, manual memory management
let connection = NWConnection(host: "example.com", port: 443, using: .tls)

connection.stateUpdateHandler = { [weak self] state in
    switch state {
    case .ready:
        self?.sendData()
    case .waiting(let error):
        print("Waiting: \(error)")
    case .failed(let error):
        print("Failed: \(error)")
    default:
        break
    }
}

connection.start(queue: .main)

func sendData() {
    let data = Data("Hello".utf8)
    connection.send(content: data, completion: .contentProcessed { [weak self] error in
        if let error = error {
            print("Send error: \(error)")
            return
        }
        self?.receiveData()
    })
}

func receiveData() {
    connection.receive(minimumIncompleteLength: 10, maximumLength: 10) { [weak self] (data, context, isComplete, error) in
        if let error = error {
            print("Receive error: \(error)")
            return
        }
        if let data = data {
            print("Received: \(data)")
        }
    }
}

After (NetworkConnection)

// AFTER — Async/await, automatic memory management
let connection = NetworkConnection(
    to: .hostPort(host: "example.com", port: 443)
) {
    TLS()
}

// Monitor states in background task
Task {
    for await state in connection.states {
        switch state {
        case .preparing:
            print("Connecting...")
        case .ready:
            print("Ready")
        case .waiting(let error):
            print("Waiting: \(error)")
        case .failed(let error):
            print("Failed: \(error)")
        default:
            break
        }
    }
}

// Send and receive with async/await
func sendAndReceive() async throws {
    let data = Data("Hello".utf8)
    try await connection.send(data)

    let received = try await connection.receive(exactly: 10).content
    print("Received: \(received)")
}

Benefits

  • 30 lines → 15 lines
  • No callback nesting, no [weak self]
  • Errors propagate naturally with throws
  • Automatic cancellation on Task exit

Migration 3: From URLSession StreamTask to NetworkConnection

When to migrate

  • Need UDP (StreamTask only supports TCP)
  • Need custom protocols beyond TCP/TLS
  • Need low-level control (packet pacing, ECN, service class)

When to STAY with URLSession

  • Doing HTTP/HTTPS (URLSession optimized for this)
  • Need WebSocket support
  • Need built-in caching, cookie handling

Example migration

Before (URLSession StreamTask)

// BEFORE — URLSession for TCP/TLS stream
let task = URLSession.shared.streamTask(withHostName: "example.com", port: 443)

task.resume()

task.write(Data("Hello".utf8), timeout: 10) { error in
    if let error = error {
        print("Write error: \(error)")
    }
}

task.readData(ofMinLength: 10, maxLength: 10, timeout: 10) { data, atEOF, error in
    if let error = error {
        print("Read error: \(error)")
        return
    }
    if let data = data {
        print("Received: \(data)")
    }
}

After (NetworkConnection)

// AFTER — NetworkConnection for TCP/TLS
let connection = NetworkConnection(
    to: .hostPort(host: "example.com", port: 443)
) {
    TLS()
}

func sendAndReceive() async throws {
    try await connection.send(Data("Hello".utf8))
    let data = try await connection.receive(exactly: 10).content
    print("Received: \(data)")
}

Resources

Skills: axiom-ios-networking, axiom-networking-legacy

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.29%
按下载量换算365

Codex

26.86%
按下载量换算359

OpenCode

16.54%
按下载量换算221

Antigravity

14.18%
按下载量换算190

Cursor

8.16%
按下载量换算109

windsurf

3.61%
按下载量换算48

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills