{"slug": "claude-design-sync-a-deep-dive-into-protocol-archaeology", "title": "Claude Design Sync: A Deep Dive into Protocol Archaeology", "summary": "A developer reverse-engineered Anthropic's undocumented Claude Design API to build a CLI tool that bypasses the model's context for file sync operations, reducing a 665,000-token sync to a single command. The project revealed that the API returns a map keyed by path instead of a list, returns hard HTTP 403 for access-denied errors, and inspects bytes rather than file extensions for binary detection. The resulting tool uses atomic writes and byte-level conflict resolution to ensure data integrity.", "body_md": "# Claude Design Sync: A Deep Dive into Protocol Archaeology\n\n[Claude](/en/tags/claude/)Design to a local disk is essentially using a supercomputer as a glorified\n\n`cp`\n\ncommand. I tracked a single project sync that burned through 665,000 tokens just to move bytes from point A to point B. Since moving files isn't a reasoning task, paying that \"token tax\" is absurd.To fix this, I decided to build a CLI that handles `clone`\n\n, `pull`\n\n, and `push`\n\noperations directly via the API, bypassing the model's context entirely. The catch? The Design API is undocumented.\n\n## Reverse-Engineering the Protocol\n\nSince the endpoint is an [MCP](/en/tags/mcp/) server, the transport layer (JSON-RPC) is predictable, but the tool definitions are a black box. I had to treat this like archaeology: call the endpoint, observe the response, and document the behavior.\n\nThe biggest trap in this process is relying on mocks. If you build a mock based on a guess, your tests will pass, but you're just verifying your own assumptions. I hit three specific walls where my assumptions failed:\n\n**Return Types:** I assumed`write_files`\n\nreturned a list. It actually returns a map keyed by path.**Error Handling:** I expected \"access denied\" to be a tool-level error inside a 200 response. It's actually a hard HTTP 403.**Binary Detection:** I thought the server checked file extensions. It actually inspects the bytes; a`.txt`\n\nfile full of NULs is treated as binary.\n\nTo prevent this, I implemented a \"live test\" suite. While mocks handle logic, the actual protocol facts are verified against the real server. If the API changes, the tests go red immediately.\n\n## Ensuring Data Integrity\n\nOnce you remove the LLM from the loop, you're building a sync engine, and sync engines are notorious for data loss. I focused on two main safeguards for this AI workflow:\n\n1. **Atomic Writes:** Every file is written to a temporary location and then renamed. This prevents half-written files if the process crashes, which would otherwise look like a local edit and lead to accidental overwrites.\n\n2. **Byte-Level Conflict Resolution:** I ignored timestamps and etags entirely. If the bytes differ on both ends, it's a conflict. Period.\n\nFor those looking to implement similar logic or explore the underlying structure, here is the conceptual prompt logic I used to map out the initial tool capabilities:\n\n```\nAct as a protocol analyst. I will provide you with a series of JSON-RPC requests and responses from an undocumented MCP server. \nYour goal is to:\n1. Identify the exact schema of the tool arguments.\n2. Map the possible return types (List vs Map).\n3. Distinguish between transport-level errors (HTTP codes) and application-level errors.\n4. Flag any discrepancies between the filename extension and the server's content-type detection.\n\nCurrent observation: [Insert JSON trace here]\n```\n\nBy treating the API as a living organism rather than a static document, I turned a 665k token expense into a simple one-line summary: `pulled 103, unchanged 0, binary 6`\n\n.\n\n[Next Solana AI Agent: My Deployment Workflow →](/en/threads/3777/)", "url": "https://wpnews.pro/news/claude-design-sync-a-deep-dive-into-protocol-archaeology", "canonical_source": "https://promptcube3.com/en/threads/3778/", "published_at": "2026-07-26 17:25:34+00:00", "updated_at": "2026-07-26 17:39:43.266872+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "artificial-intelligence"], "entities": ["Claude Design API", "Anthropic", "MCP"], "alternates": {"html": "https://wpnews.pro/news/claude-design-sync-a-deep-dive-into-protocol-archaeology", "markdown": "https://wpnews.pro/news/claude-design-sync-a-deep-dive-into-protocol-archaeology.md", "text": "https://wpnews.pro/news/claude-design-sync-a-deep-dive-into-protocol-archaeology.txt", "jsonld": "https://wpnews.pro/news/claude-design-sync-a-deep-dive-into-protocol-archaeology.jsonld"}}