[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M730R17T4M71XV68QK8T4TME":3,"skill-same:01M730R17T4M71XV68QK8T4TME":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M730R17T4M71XV68QK8T4TME","bittorrent-client-from-scratch",null,"Use when building a BitTorrent client or any peer-to-peer file-sharing protocol from first principles — not when integrating an existing torrent library. Triggers on: 'build a torrent client', 'implement bittorrent protocol', 'peer wire protocol', 'bencode parser', 'write a torrent tracker client', 'piece selection algorithm'. Covers bencode encoding, tracker HTTP\u002FUDP protocol, the peer wire protocol, and piece-selection strategy.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fbittorrent-client-from-scratch\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: bittorrent-client-from-scratch\ndescription: \"Use when building a BitTorrent client or any peer-to-peer file-sharing protocol from first principles — not when integrating an existing torrent library. Triggers on: 'build a torrent client', 'implement bittorrent protocol', 'peer wire protocol', 'bencode parser', 'write a torrent tracker client', 'piece selection algorithm'. Covers bencode encoding, tracker HTTP\u002FUDP protocol, the peer wire protocol, and piece-selection strategy.\"\norigin: yana-ai — synthesized from public BitTorrent protocol specification (BEP 3, BEP 15, BEP 5) and community from-scratch tutorials indexed in codecrafters-io\u002Fbuild-your-own-x\nlicense: Apache-2.0\nversion: 1.0.0\ncompatibility: yana-ai >= 0.43.2\n---\n\n# \u002Fbittorrent-client-from-scratch\n\n## When to Use\n\n- Building a minimal BitTorrent client (download-only or full peer) to understand the protocol, not to ship a production downloader.\n- Implementing bencode (BitTorrent's serialization format) for a `.torrent` file parser.\n- Writing tracker communication (HTTP\u002FUDP announce) or a bare peer-wire-protocol handshake.\n- Teaching or learning piece-selection strategy (rarest-first), choke\u002Funchoke algorithms.\n\n## Do NOT use for\n\n- Production file transfer — use an existing library (libtorrent, aria2, WebTorrent) instead of hand-rolling protocol code for a real product.\n- General P2P networking unrelated to BitTorrent's specific wire format (see `wamp-pubsub-patterns` or `raft-consensus-patterns` for other distributed patterns).\n- DHT-only (trackerless) discovery as a first implementation — build the tracker-based path first (see Step 4), DHT is a documented extension, not the starting point.\n\n---\n\n## Protocol Layers (build in this order)\n\n```\n1. Bencode        — the serialization format everything else is written in\n2. .torrent file  — bencoded dict describing the download (info hash, piece hashes, tracker URL)\n3. Tracker         — HTTP\u002FUDP request that returns a peer list\n4. Peer wire       — TCP protocol between two peers: handshake, message framing, piece exchange\n5. Piece manager    — tracks which pieces you have\u002Fneed, drives requests\n6. (Optional) DHT  — trackerless peer discovery, BEP 5 — add only after 1-5 work\n```\n\n## Step 1: Bencode\n\nFour types only — no schema needed, all self-describing:\n\n```\nInteger:      i\u003Cnumber>e              → i42e = 42\nByte string:  \u003Clength>:\u003Cbytes>        → 4:spam = \"spam\"\nList:         l\u003Citems>e               → l4:spami42ee = [\"spam\", 42]\nDictionary:   d\u003Ckey>\u003Cvalue>...e       → d3:cow3:mooe = {\"cow\": \"moo\"}, keys sorted by raw byte order\n```\n\nWrite both `decode(bytes) -> value` and `encode(value) -> bytes` — you need `encode` to re-derive the info hash (see Step 2) and to build tracker announce requests.\n\n## Step 2: Parse the .torrent File\n\nA `.torrent` file is a bencoded dict with keys: `announce` (tracker URL), `info` (dict containing `name`, `piece length`, `pieces` — a concatenated string of 20-byte SHA-1 hashes, one per piece, `length` for single-file or `files` for multi-file torrents).\n\nThe **info hash** — the torrent's unique identifier everywhere in the protocol — is `SHA1(bencode(info_dict))`, computed over the *raw bencoded bytes* of just the `info` value, not a re-serialization from a parsed struct (re-encoding can silently reorder or reformat and produce the wrong hash — keep the raw byte range from the original decode).\n\n## Step 3: Talk to the Tracker\n\nHTTP GET to the `announce` URL with query params: `info_hash` (20 raw bytes, URL-encoded), `peer_id` (your 20-byte client ID), `port`, `uploaded`, `downloaded`, `left`, `compact=1`. Response is a bencoded dict with `interval` (seconds until re-announce) and `peers` — with `compact=1`, a byte string where every 6 bytes is one peer (4 bytes IP + 2 bytes port, big-endian).\n\nUDP tracker protocol (BEP 15) exists for trackers that don't support HTTP — it's a separate connect\u002Fannounce handshake, implement it only if a tracker in practice requires it.\n\n## Step 4: Peer Wire Protocol\n\nHandshake (fixed 68 bytes): `\\x13BitTorrent protocol` + 8 reserved bytes + 20-byte info hash + 20-byte peer ID. Both sides send this first; a peer that returns a different info hash is not serving your torrent — drop the connection.\n\nAfter the handshake, all messages are length-prefixed (4-byte big-endian length, then 1-byte message ID, then payload). Core message IDs:\n\n```\n0  choke            5  bitfield   (which pieces this peer has)\n1  unchoke          6  request    (index, begin, length)\n2  interested       7  piece      (index, begin, block data)\n3  not interested    8  cancel\n4  have (piece idx)\n```\n\nState machine per connection: you start `choked` + `not interested`. Send `interested`. Wait for the peer to `unchoke` you — only then can you `request` blocks. A zero-length message (just the 4-byte length field, no ID) is a keep-alive.\n\n## Step 5: Piece Manager\n\n- Track piece state as a bitfield (have \u002F don't have \u002F in-flight).\n- Split each piece into blocks (commonly 16KB) — `request` messages are per-block, not per-piece.\n- **Rarest-first**: track which peers have which pieces; request pieces that fewest peers have first — this keeps piece availability balanced across the swarm and avoids everyone racing for the same common piece.\n- On receiving a full piece, verify its SHA-1 against the hash from the `.torrent` file's `pieces` field before writing to disk or announcing `have` — a mismatched hash means a corrupt\u002Fmalicious peer, discard and re-request from someone else.\n\n## What NOT to Do\n\n- Don't reorder or reformat the `info` dict before hashing it — you'll compute the wrong info hash and every tracker\u002Fpeer will reject you.\n- Don't request whole pieces in one message — the wire protocol requests blocks (~16KB); requesting a multi-MB piece in one `request` message is invalid per spec and most peers will drop you.\n- Don't skip piece-hash verification \"to save time\" — an unverified piece can poison the rest of the download since later pieces may depend on file layout assumptions from earlier ones.\n- Don't build DHT before the tracker path works end-to-end — DHT is a strictly harder distributed-hash-table problem layered on top of a protocol you should already understand.\n","# \u002Fbittorrent-client-from-scratch\n\n## When to Use\n\n- Building a minimal BitTorrent client (download-only or full peer) to understand the protocol, not to ship a production downloader.\n- Implementing bencode (BitTorrent's serialization format) for a `.torrent` file parser.\n- Writing tracker communication (HTTP\u002FUDP announce) or a bare peer-wire-protocol handshake.\n- Teaching or learning piece-selection strategy (rarest-first), choke\u002Funchoke algorithms.\n\n## Do NOT use for\n\n- Production file transfer — use an existing library (libtorrent, aria2, WebTorrent) instead of hand-rolling protocol code for a real product.\n- General P2P networking unrelated to BitTorrent's specific wire format (see `wamp-pubsub-patterns` or `raft-consensus-patterns` for other distributed patterns).\n- DHT-only (trackerless) discovery as a first implementation — build the tracker-based path first (see Step 4), DHT is a documented extension, not the starting point.\n\n---\n\n## Protocol Layers (build in this order)\n\n```\n1. Bencode        — the serialization format everything else is written in\n2. .torrent file  — bencoded dict describing the download (info hash, piece hashes, tracker URL)\n3. Tracker         — HTTP\u002FUDP request that returns a peer list\n4. Peer wire       — TCP protocol between two peers: handshake, message framing, piece exchange\n5. Piece manager    — tracks which pieces you have\u002Fneed, drives requests\n6. (Optional) DHT  — trackerless peer discovery, BEP 5 — add only after 1-5 work\n```\n\n## Step 1: Bencode\n\nFour types only — no schema needed, all self-describing:\n\n```\nInteger:      i\u003Cnumber>e              → i42e = 42\nByte string:  \u003Clength>:\u003Cbytes>        → 4:spam = \"spam\"\nList:         l\u003Citems>e               → l4:spami42ee = [\"spam\", 42]\nDictionary:   d\u003Ckey>\u003Cvalue>...e       → d3:cow3:mooe = {\"cow\": \"moo\"}, keys sorted by raw byte order\n```\n\nWrite both `decode(bytes) -> value` and `encode(value) -> bytes` — you need `encode` to re-derive the info hash (see Step 2) and to build tracker announce requests.\n\n## Step 2: Parse the .torrent File\n\nA `.torrent` file is a bencoded dict with keys: `announce` (tracker URL), `info` (dict containing `name`, `piece length`, `pieces` — a concatenated string of 20-byte SHA-1 hashes, one per piece, `length` for single-file or `files` for multi-file torrents).\n\nThe **info hash** — the torrent's unique identifier everywhere in the protocol — is `SHA1(bencode(info_dict))`, computed over the *raw bencoded bytes* of just the `info` value, not a re-serialization from a parsed struct (re-encoding can silently reorder or reformat and produce the wrong hash — keep the raw byte range from the original decode).\n\n## Step 3: Talk to the Tracker\n\nHTTP GET to the `announce` URL with query params: `info_hash` (20 raw bytes, URL-encoded), `peer_id` (your 20-byte client ID), `port`, `uploaded`, `downloaded`, `left`, `compact=1`. Response is a bencoded dict with `interval` (seconds until re-announce) and `peers` — with `compact=1`, a byte string where every 6 bytes is one peer (4 bytes IP + 2 bytes port, big-endian).\n\nUDP tracker protocol (BEP 15) exists for trackers that don't support HTTP — it's a separate connect\u002Fannounce handshake, implement it only if a tracker in practice requires it.\n\n## Step 4: Peer Wire Protocol\n\nHandshake (fixed 68 bytes): `\\x13BitTorrent protocol` + 8 reserved bytes + 20-byte info hash + 20-byte peer ID. Both sides send this first; a peer that returns a different info hash is not serving your torrent — drop the connection.\n\nAfter the handshake, all messages are length-prefixed (4-byte big-endian length, then 1-byte message ID, then payload). Core message IDs:\n\n```\n0  choke            5  bitfield   (which pieces this peer has)\n1  unchoke          6  request    (index, begin, length)\n2  interested       7  piece      (index, begin, block data)\n3  not interested    8  cancel\n4  have (piece idx)\n```\n\nState machine per connection: you start `choked` + `not interested`. Send `interested`. Wait for the peer to `unchoke` you — only then can you `request` blocks. A zero-length message (just the 4-byte length field, no ID) is a keep-alive.\n\n## Step 5: Piece Manager\n\n- Track piece state as a bitfield (have \u002F don't have \u002F in-flight).\n- Split each piece into blocks (commonly 16KB) — `request` messages are per-block, not per-piece.\n- **Rarest-first**: track which peers have which pieces; request pieces that fewest peers have first — this keeps piece availability balanced across the swarm and avoids everyone racing for the same common piece.\n- On receiving a full piece, verify its SHA-1 against the hash from the `.torrent` file's `pieces` field before writing to disk or announcing `have` — a mismatched hash means a corrupt\u002Fmalicious peer, discard and re-request from someone else.\n\n## What NOT to Do\n\n- Don't reorder or reformat the `info` dict before hashing it — you'll compute the wrong info hash and every tracker\u002Fpeer will reject you.\n- Don't request whole pieces in one message — the wire protocol requests blocks (~16KB); requesting a multi-MB piece in one `request` message is invalid per spec and most peers will drop you.\n- Don't skip piece-hash verification \"to save time\" — an unverified piece can poison the rest of the download since later pieces may depend on file layout assumptions from earlier ones.\n- Don't build DHT before the tracker path works end-to-end — DHT is a strictly harder distributed-hash-table problem layered on top of a protocol you should already understand.\n",{"name":5,"origin":24,"license":15,"version":25,"description":7,"compatibility":26},"yana-ai — synthesized from public BitTorrent protocol specification (BEP 3, BEP 15, BEP 5) and community from-scratch tutorials indexed in codecrafters-io\u002Fbuild-your-own-x","1.0.0","yana-ai >= 0.43.2","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa",".claude\u002Fskills\u002Fbittorrent-client-from-scratch",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill bittorrent-client-from-scratch",{"tool":43,"command":44},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill bittorrent-client-from-scratch",{"tool":46,"command":47},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill bittorrent-client-from-scratch","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fbittorrent-client-from-scratch\u002FSKILL.md",true,[],[52,60,67,75,83,91],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":56,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":71,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":79,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]