What problem does it solve?
AT Protocol codebases built on the legacy @atproto/api, @atproto/lexicon, and @atproto/xrpc stack need to be modernized onto @atproto/lex, but the migration touches many API surfaces — agents, error handling, headers, CIDs, BlobRefs, datetimes, and type guards — making manual conversion error-prone and inconsistent.
Core Features & Use Cases
- Agent-to-Client Migration: Replaces
AtpAgent with Client, converting agent.api.<ns>.<method>() calls into client.call(), client.xrpc(), or xrpcSafe() depending on whether the call site needs the body, headers, or typed error handling.
- Data Type Modernization: Converts
jsonStringToLex/stringifyLex to lexParse/lexStringify, CID from multiformats to Cid/parseCid, BlobRef instanceof checks to isBlobRef/getBlobCidString, and ISO date strings to branded DatetimeString helpers.
- Error Handling Upgrades: Replaces try/catch with
instanceof XRPCError by xrpcSafe() discriminated results, including toDownstreamError() remapping and schema-declared error narrowing.
- Use Case: While modernizing a Bluesky service package, you reach an
agent.api.app.bsky.feed.getFeedSkeleton() call — this Skill rewrites it to a typed client.xrpc() call with standard Headers access and branded DidString types at the boundaries.
Quick Start
Migrate this file's outgoing XRPC calls from AtpAgent and @atproto/api to the @atproto/lex Client API.