game-netcode

game-netcode is a skill for Claude Code, Codex from Wade-DevCode/awesome-coding-skills-cn. It costs 23 tokens per session (2,519 once invoked), scanned A, original, MIT.

A guide to multiplayer game networking, including how game state is shared between players and servers. It explains synchronization models, latency handling, disconnections, and anti-cheat checks.

In plain words
What is it for?
Use it when designing or changing matchmaking, combat synchronization, chat broadcasts, replays, frame synchronization, state synchronization, or relay-server integrations.
Why use it?
It helps prevent mismatched game states, poor responsiveness, excessive network traffic, and cheats caused by trusting the client.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when designing or changing matchmaking, combat synchronization, chat broadcasts, replays, frame synchronization, state synchronization, or relay-server integrations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/game-netcode
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill game-netcode
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for game-netcode

README.md
[![agentmods](https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/game-netcode/github.svg)](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/game-netcode)
Your own site
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/game-netcode"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/game-netcode/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for game-netcode

Your own site · 80×15
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/game-netcode"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/game-netcode.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 23 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,519 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00023 $0.02519
Opus 5.5 $0.00009 $0.01008
Sonnet 5.5 $0.00005 $0.00504
Haiku 4.5 $0.00002 $0.00252

Measured 1mo ago against content hash 749462bb3ea6, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

game-netcode scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/game-netcode/SKILL.md · 169 lines

How it starts

The opening of the file, as written. The whole thing — 169 lines — stays where its author put it; the contents beside it link to each section on GitHub.

游戏联网同步

何时用

  • 新增或修改任何多人联机逻辑(房间匹配、战斗同步、聊天广播)之前。
  • 发现帧同步与状态同步混用、或不清楚权威端在哪里时。
  • 遇到"客户端打了但服务端没算到"、"回放对不上"等同步类 bug 时。
  • 准备接入帧同步 SDK 或自研 Relay 服务前做方案评审时。

核心规则

1. 选对同步模型

规则: 按游戏类型明确选择状态同步或帧同步,并在立项初期确定好权威端,后期切换代价极高。

为什么: 常见错误是用帧同步做 MMORPG——每帧广播全量输入,稍有延迟就全员卡顿;或者在格斗/RTS 里用状态同步,服务端每帧推送全局状态,带宽爆炸且客户端表现割裂。更隐蔽的错误是"临时先客户端权威,后面再改",结果权威端逻辑散落到客户端每个角落,迁移时要全局重写。

怎么做:

  • 格斗/RTS/竞技类:优先帧同步,输入上行、服务端转发、各端本地计算——前提是逻辑完全确定性(浮点要用定点或 libfixmath)。
  • MMORPG/射击/休闲多人:优先状态同步,服务端跑权威逻辑,下发关键实体状态。
  • 确定模型后立刻在设计文档写明「权威端:服务端」或「权威端:服务端转发,各客户端本地执行」,并在代码中用注释标注哪些函数只能在权威端调用。

2. 服务器权威:关键逻辑服务端校验

规则: 伤害计算、金币增减、技能命中判定等影响游戏公平性的逻辑必须在服务端执行并校验,客户端只负责表现与预测,不能只靠客户端上报结果。

为什么: 最常犯的错是"客户端算出伤害 150,发消息给服务端说'我打了 150 伤害',服务端直接扣血"。这是最经典的游戏外挂入口——改一行本地代码就能无限秒杀。即使是"只是 Demo"也会留下习惯,真正上线时来不及改。

怎么做:

  • 服务端持有所有玩家的 HP、金币、buff 列表等权威状态;客户端不能直接写这些值。
  • 客户端发送的是意图(MsgAttack{target_id, skill_id, client_tick}),服务端收到后自己算伤害、自己扣血、再广播结果。
  • 对高频操作做服务端速率限制(Rate Limit),防止通过高频请求刷出超额收益。
  • 校验失败时服务端下发权威状态强制纠正客户端,而非静默忽略。

3. 延迟处理:预测 + 校正 + 插值三件套

规则: 客户端必须做本地预测(降低操作延迟感),服务端必须做状态校正(保证一致性),远端实体必须做插值(消除抖动),三者缺一不可。

为什么: 只做预测不做校正,高延迟玩家的角色会在服务端和客户端持续撕裂,最终位置对不上;只做插值不做预测,玩家按下跳跃键需要一个 RTT 才能看到角色起跳,手感极差;什么都不做,100ms 延迟就已经让动作游戏完全不可玩。

怎么做:

// 客户端预测:立刻在本地执行输入
void OnPlayerInput(InputCmd cmd) {
    ApplyInputLocally(cmd);          // 立刻移动本地角色
    pendingInputs.push_back(cmd);    // 暂存等服务端确认
    SendToServer(cmd);
}

// 服务端 ACK 后做 Reconciliation
void OnServerState(ServerSnapshot snap) {
    // 回滚到 snap.tick 时刻,重放 snap.tick 之后的本地输入
    RollbackTo(snap);
    for (auto& cmd : pendingInputs) {
        if (cmd.tick > snap.tick) ApplyInputLocally(cmd);
    }
}

// 远端实体插值(不是本地玩家)
void UpdateRemoteEntity(float deltaTime) {
    renderPos = Vector3.Lerp(renderPos, authorativePos, deltaTime * lerpSpeed);
}
  • 插值缓冲区保持 2-3 帧的历史快照,避免网络抖动直接暴露到画面上。

4. 断线重连:状态可恢复、消息幂等、重连补帧

规则: 网络游戏必须将断线重连作为一等功能设计,而不是事后补丁。服务端状态快照可随时还原,消息处理天然幂等,重连后能补全缺失的帧/事件。

为什么: 最常见的事故:断线重连成功,但服务端已经销毁了该玩家的战斗实体,客户端收到空数据崩溃;或者消息重发时,金币被加了两次——因为消息处理没有去重逻辑。另一个坑:帧同步游戏断线后无法快速追帧,重连要从第 0 帧开始 replay,追帧期间玩家干等几分钟。

Read the full file on GitHub · 169 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 169 lines · 23 tokens per session scan A 749462bb3ea6

Subscribe to this mod's changes

game-netcode is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (7 stars, last pushed 4mo ago), licensed MIT. It adds 23 tokens to every session and 2,519 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.