erkoknoll/helbreath-base-game/introducing-network-messages
Claude Code and agent skill by erkoknoll/helbreath-base-game
- community
Checking that the SKILL.md file is still in the repository.
Add or update client/server protobuf network messages for this repo. Use when introducing new packets, changing websocket message flow, editing `multiplayer/proto/network.proto`, wiring new messages through `multiplayer/mp-client/src/utils/NetworkManager.ts`, `multiplayer/server/Server.cs`, `multiplayer/server/World/Game/GameWorld.cs`, or related server/player packet handlers.
Install
npx vskill@latest install erkoknoll/helbreath-base-game/introducing-network-messagesSKILL.md
Introducing Network Messages
Use this skill when adding a new message that travels between the client and server.
Follow These Rules First
Before editing networking code, follow:
multiplayer/.cursor/rules/common-guidlines.mdcmultiplayer/.cursor/rules/server-csharp-guidelines.mdcmultiplayer/.cursor/rules/client-typescript-guidelines.mdc
If the server-side packet flow is relevant, also follow:
multiplayer/.cursor/rules/server-threading-and-packet-flow.mdcmultiplayer/docs/SERVER_THREADING_AND_PACKET_FLOW.md
Files To Inspect
Start from these files:
multiplayer/proto/network.protomultiplayer/mp-client/src/utils/NetworkManager.tsmultiplayer/server/Server.csmultiplayer/server/World/Game/GameWorld.cs
Often also inspect:
multiplayer/server/World/Game/GameWorldPlayer.csmultiplayer/mp-client/src/proto/generated/network.ts- whichever client scene, store, or manager should react to the new packet
Core Principles
- Do not add legacy or backward-compat fallbacks for packet fields (sentinel values, coalescing to local state, etc.); server and client stay in sync via
proto/and joint deploys. See Server/client network sync inmultiplayer/.cursor/rules/common-guidlines.mdc. multiplayer/proto/network.protois the source of truth for shared packet definitions.- When a scalar field is semantically "present only in some cases", prefer
optionalin proto3 instead of sentinel values such as0or empty string. - Do not hand-edit
multiplayer/mp-client/src/proto/generated/network.ts. - Never manually generate or substitute protobuf code. If
proto:generatefails, fix the tooling (see below) instead of writing encode/decode logic by hand. multiplayer/server/Server.csis the network edge: socket lifetime, frame reads, protobuf parse, and routing.- Put gameplay packet handling in
multiplayer/server/World/Game/GameWorld.cs,multiplayer/server/World/Game/GameWorldPlayer.cs, or another dedicated server class, not inServer.cs. - Keep
NetworkManager.tsthin. It should encode, send, decode, and hand off, not own broad gameplay logic. - When packets represent long-lived client world state such as remote players, prefer keeping the latest authoritative snapshot in
NetworkManager.tsand let scenes hydrate from that state when they become ready, instead of relying on transient pending-event queues.
Workflow
1. Define the protobuf message
Edit multiplayer/proto/network.proto.
- Add the new leaf message type such as
MoveRequestorPlayerMoved. - Add it to
ClientMessageorServerMessageunder the correctoneof payload. - Use a new field number. Do not renumber or reuse existing field numbers.
- Keep packet names explicit about direction and intent.
Default pattern:
- client -> server:
SomethingRequest - server -> client:
SomethingResponse,SomethingUpdate, or another explicit event name
2. Regenerate protobuf code
For the client:
Run that in multiplayer/mp-client/.
For the server:
- C# protobuf code is generated by the server build from
multiplayer/server/Server.csproj. - Run
dotnet buildinmultiplayer/server/after editingmultiplayer/proto/network.proto.
3. Wire client-to-server sending
If the client needs to send the new message:
- Encode it through
ClientMessage.encode({ payload: { $case: '...' } })inNetworkManager.tsor a thin helper it calls. - Keep the actual payload shape aligned with the generated TypeScript types.
- If a scene, store, or manager triggers the packet, keep the trigger in that domain and let
NetworkManagerhandle transport.
4. Wire server-side receiving
The current server flow is:
Server.csreads websocket framesServer.csparsesClientMessageServer.csroutesClientPacketMessageinto the player's currentGameWorldGameWorldswitches onmessage.Message.PayloadCaseGameWorlddelegates toGameWorldPlayeror other world-owned logic as needed
When adding a new client packet:
- Do not add gameplay branching to
Server.cs. - Extend the switch in
GameWorld.HandleClientPacket(...). - If the behavior is player-specific, prefer a method on
GameWorldPlayer. - If the behavior mutates shared world state, keep that logic in
GameWorldor a world-owned server type.
5. Wire server-to-client sending
If the server needs to send a new message back:
- Construct a
ServerMessagein world-owned code such asGameWorldorGameWorldPlayer. - Send it through the existing per-connection callback/path instead of writing directly to the websocket.
- Let
Server.cskeep ownership of socket writes through the outbound queue and send loop.
6. Wire client-side receiving
When the client receives a new server packet in NetworkManager.ts:
- Decode
ServerMessageonce inhandleMessage. - Switch on
message.payload?.$case. - Keep
NetworkManagerresponsible for transport-level handling and dispatch. - Forward gameplay/UI consequences to the right place, often via EventBus, a store, or a domain manager.
Do not let NetworkManager become a large gameplay controller.
Validation
After changes:
- Run
npm run proto:generateinmultiplayer/mp-client/. - Run
dotnet buildinmultiplayer/server/. - If client TypeScript changed beyond generated code, run the relevant client build or checks.
- Verify both sides agree on the same oneof case name and payload fields.
- Test the full packet path end to end.
Common Pitfalls
- Editing generated TypeScript instead of
multiplayer/proto/network.proto - Manually writing protobuf encode/decode code when
proto:generatefails instead of fixing the grpc-tools binary install - Forgetting to regenerate client protobufs
- Putting gameplay handling in
multiplayer/server/Server.cs - Adding a new server packet but not decoding it in
NetworkManager.ts - Reusing protobuf field numbers
- Renaming a oneof case on one side without regenerating and updating the other side
- Letting transport code directly mutate gameplay state across boundaries
Minimal Example Pattern
For a new client packet:
- Add
MoveRequesttomultiplayer/proto/network.protounderClientMessage.payload - Run
npm run proto:generateinmultiplayer/mp-client/ - Run
dotnet buildinmultiplayer/server/ - Encode and send
MoveRequestfrom the client throughNetworkManager - Handle
ClientMessage.PayloadOneofCase.MoveRequestinGameWorld - Delegate to
GameWorldPlayeror world logic
For a new server packet:
- Add
PlayerMovedtomultiplayer/proto/network.protounderServerMessage.payload - Regenerate/build
- Create the
ServerMessagein server world-owned logic - Decode
message.payload?.$case === 'playerMoved'inNetworkManager.ts - Forward the result to the correct client system
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingmultiplayer/.cursor/skills/introducing-network-messages/SKILL.md
Popularity
- Repository stars
- 49
- Repository forks
- 10
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/erkoknoll/helbreath-base-game/introducing-network-messages)