Skip to content
Skills Library
Programming · Planning

authoritative-server

/authoritative-server

Use this skill when the user says 'authoritative server', 'server tick loop', 'server reconciliation', 'lag compensation', 'dedicated server', 'input authority'. Designs authoritative game servers: tick loop, world state and snapshots, input authority, reconciliation/rollback, lag compensation and session handling. Do NOT use for: client-side prediction details (use multiplayer-netcode), fleet scaling (use scaling-architecture).

Licence
MIT
Last repository change
10.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
7
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 10.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use this skill when the user says 'authoritative server', 'server tick loop', 'server reconciliation', 'lag compensation', 'dedicated server', 'input authority'. Designs authoritative game servers: tick loop, world state and snapshots, input authority, reconciliation/rollback, lag compensation and session handling. Do NOT use for: client-side prediction details (use multiplayer-netcode), fleet scaling (use scaling-architecture).

Triggers from the description

authoritative serverserver tick loopserver reconciliationlag compensationdedicated serverinput authority
Original author description

Use this skill when the user says 'authoritative server', 'server tick loop', 'server reconciliation', 'lag compensation', 'dedicated server', 'input authority'. Designs authoritative game servers: tick loop, world state and snapshots, input authority, reconciliation/rollback, lag compensation and session handling. Do NOT use for: client-side prediction details (use multiplayer-netcode), fleet scaling (use scaling-architecture).

How it works

  1. Purpose
  2. Agent Protocol
  3. 1. Why Authoritative
  4. 2. Server-Side Simulation Can't Afford a Game-Loop Problem
  5. 3. Input Authority & The Input Pipeline
  6. 4. World-State Snapshot Serialization
  7. 5. Reconciliation, Rollback & Lag Compensation
  8. 6. Connection & Session Handling
  9. 7. Exploit & Cheat Resistance (Server Facts)
  10. 8. Scalability & Cost (Server-Side Budgets)
Original SKILL.md headings · 196 lines, 1,283 words
SKILL.md preview
---
name: authoritative-server
description: >
  Use this skill when the user says 'authoritative server', 'server tick loop', 'server reconciliation', 'lag compensation', 'dedicated server', 'input authority'. Designs authoritative game servers: tick loop, world state and snapshots, input authority, reconciliation/rollback, lag compensation and session handling. Do NOT use for: client-side prediction details (use multiplayer-netcode), fleet scaling (use scaling-architecture).
version: "2.0.0"
author: "j4flmao"
license: "MIT"
tags: [game, server, authoritative, netcode]
---

# Authoritative Server — Deep Engineering Guide

## Purpose
The server is the single source of truth. Clients only *intend*; the server *decides*. This skill covers the server tick loop, world-state serialization, input authority, reconciliation/rollback, lag compensation and session/connection management that make online games correct, cheat-resistant and smooth under real network loss.

## Agent Protocol

### Trigger
"authoritative server", "server tick loop", "server reconciliation", "lag compensation", "dedicated server", "input authority".

### Input Context
- Genre, player count, tick rate target
- Engine/language of server
- Hosting model

### Output Artifact
Server loop design and code. No file unless requested.

### Response Format
```
Tick: {Hz}
Loop: {receive -> simulate -> snapshot -> send}
Authority: {what server validates}
Code: {snippet}
```

## 1. Why Authoritative

- Clients are untrusted: a modified client shouldn't teleport, duplicate items, or confirm kills it didn't earn.
- Server-authority = the only place where state can be validated + validated state is shared.

```
client sends INPUT (intent)        → net
server runs sim (authoritative)    → sim decides
server sends SNAPSHOT (state)      → net
client renders (interpolated)      → visual
```

### 1.1 The Trust Boundary

| Decided by | Where |
|------------|-------|
| Compile-time rules, rules engine (damage, physics) | server |
| Cosmetic-only (VFX transform, emote) | client |
| **Compromise (authoritative with client prediction)** | server + prediction |

Pick: **full authoritative** (server runs everything; client is dumb viewer) vs **client-predicted** (client predicts its own move; server reconciles) vs **client-side prediction + server rollback** (fast action games). All start from "server is truth".

## 2. Server-Side Simulation Can't Afford a Game-Loop Problem

### 2.1 Fixed Timestep

- **Server tick**: fixed 30–64 Hz (30 for strategy, 60 for aimful shooters; 128 for esports aimers).
- Derive the tick count from an accumulator over a monotonic clock (see `game-loop-and-timestep`), then sleep until the next tick deadline instead of spinning; never scale gameplay by the measured frame time.

```cpp
// server main loop:
tick = 0;
while (running) {
    dtFromWallClock = now - last;
    accumulator += dtFromWallClock;
    while (accumulator >= TICK_MS) {
        SimulateTick(tick);         // deterministic, fixed dt
        accumulator -= TICK_MS;
        tick++;
    }
    netOutputs[ticksToSend].Flush();
}
```

### 2.2 Deterministic Sim

The server sim must be **deterministic given a seed**: lockstep (see `game-engine/multiplayer-netcode` determinism refs) so replay, spec or tests reproduce identically. No `fast-math`, no wall-clock, no `rand()` global.

- RNG: per-entity/instance seeded, tick-advanced — reproducible.
- Physics stepping: fixed dt = stable.

## 3. Input Authority & The Input Pipeline

```
client: sample input → serialized command {tick, seq, buttons, aim} → UDP
server: collect per-tick input, run queued commands, apply at tick boundary, optionally re-sim (rollback)
```

Key properties:
- **Tick-stamped commands**: each command carries the client tick it was generated for; the server buffers a small amount (a jitter buffer of 1-3 ticks) and applies it at that tick, dropping commands that arrive too late.
- **Input history buffer** on server: replay recent inputs if a rolled-back tick needs them.
- **Client command throttling**: cap commands/second; server drops excess (anti-abuse).

### 3.1 Client Prediction ↔ Server Reconciliation

- Client predicts its own motion (renders its projection).
- Server reconciles the actual authoritative value each tick; client corrects only if the mismatch exceeds a tolerance (e.g. a few cm of position error), and smooths small corrections over several frames.
- Tolerance + extrapolation clipping prevent wild rubber-banding (see `rollback-and-reconciliation.md`).

## 4. World-State Snapshot Serialization

Server serializes **deltas**, not full state:

| Approach | Cost | Use |
|----------|------|-----|
| Full state | large | lobbies, tiny games, keyframes |
| Delta (since last ack) | efficient | standard |
| Interest-gated masks | minimal | open world (see interest-management skill) |

Snapshot minimal components:
- `matchId`, `tick`, `seq`, per-entity: `{entityId, flags, bits...}`.
- Compressed position: quantized to a fixed grid (e.g. int16/int32 at 1 cm), sent as deltas against the acked baseline.
- Entities unchanged since last snapshot: omitted (per-entity dirty flags).

See `game-engine-multiplayer-netcode` for engine-level replication formats.

## 5. Reconciliation, Rollback & Lag Compensation

### 5.1 Rollback (Fighters, Fast Games)

Client predicts; server re-sims when input ran in the wrong order (delayed arrival). Server stores the last N-tick state frames; on late arrival re-runs tick with the corrected input:

```
server keeps history[40 ticks]
incoming input says "my tick 1000 shot"
if history[1000] exists → re-run 1000..now with that input
→ send diff to client (rollback) ≤ threshold
```

### 5.2 Lag Compensation (Hit Scan)

Server can't "aim at where client renders" — it rewinds to the client's requested timestamp to check the shot hit:

- Store per-tick hitbox poses for the maximum rewind window (commonly 200-300 ms, capped and configurable).
- The shot command names the tick (plus interpolation fraction) the shooter was rendering; the server rewinds other players to that time — clamped to the window — and raycasts against the stored poses.
- Crosshair hits what the shooter saw = fair for the shooter, deterministic to server.

### 5.3 The "Client is Right?" Test

The criterion: a valid shot = the server re-sim with client's inputs *would* have produced a hit. This is authoritative but *player-fair*. Cheat-resistant because "position" is server-side truth, not client-reported.

## 6. Connection & Session Handling

### 6.1 The Connection State Machine

```
UNRESPONSIVE → HANDSHAKE (challenge/response) → ESTABLISHED
   → RESYNC (after rejoin) → (periodic heartbeat) → TIMEDOUT (kicked)
```

- Handshake: server->client challenge (`nonce`) — client signs → avoids spoofed connects.
- Heartbeats: client `ping` every ~1 s; server drops idle > 5–10 s (configurable).
- Backfill: server assigns `sessionToken`; a client reconnecting with an old token resumes state (or is denied on match close).

### 6.2 The "Replay Value" Problem

If a client drops in a rank/match, on return server either:
1. **Fast-recovery**: client reconnects with its session token and receives a full keyframe snapshot, then deltas (simple, standard).
2. **Late-join backfill**: watch a spectator cam until slot opens (complex; for dedicated shows).

Pick 1 for most titles; 2 only when the design requires drop-in spectators.

## 7. Exploit & Cheat Resistance (Server Facts)

| Attack | Server counter |
|--------|----------------|
| Modded client teleport | server sim ignores client positions |
| Speed hack ("0 ping looks") | speed-check: max Δpos / tick |
| Input flood | cap commands/s + rate limit |
| Item duplication | every item change server-confirmed |
| Hit-scan "aim assist" | server ran the shot against stored poses |

Combined with validation hooks in `anti-cheat-server`.

## 8. Scalability & Cost (Server-Side Budgets)

| Per-player server budget | Target |
|--------------------------|--------|
| Bandwidth out | ≤ ~60 kB/s (deltas) |
| Memory | ≤ 2 MB (state) |
| Tick compute | ~50–200 us/player typical |

When a single process cannot hold the tick budget, split the world (zones) or reduce per-player cost (interest management) — never split one match's simulation across processes. If a tick > budget, drop non-crucial systems (network simulation throttle — not gameplay).

## 9. Testing the Server

- **Determinism replay**: run a match twice with the same input stream → byte-identical state hash.
- **Network fault injection**: drop%, reorder, duplicate, delay 50–500 ms → assert no desync, no crash, bounded resync.
- **Load test**: N bots with synthetic input; assert tick under budget + no queue backlog.
- **Chaos**: kill a tick mid-sim, restart, restore last ack.

## 10. References

- `references/tick-loop.md` — fixed timestep, accumulator, tick queue, determinism under load
- `references/world-state-snapshot.md` — entity serialization, deltas, dirty flags, quantization, ack/gap detection
- `references/input-authority.md` — input command flow, server queues, anti-abuse caps
- `references/rollback-and-reconciliation.md` — client prediction, server reconcile, rubber-banding, rollback replay
- `references/lag-compensation.md` — hit-scan rewinding, stored poses, fair-shot verification
- `references/connection-and-session.md` — handshake, heartbeat, timeouts, resume, backfill
Files in this package (7)
  • SKILL.md 9 KB
  • references/connection-and-session.md 4 KB
  • references/input-authority.md 4 KB
  • references/lag-compensation.md 4 KB
  • references/rollback-and-reconciliation.md 5 KB
  • references/tick-loop.md 3 KB
  • references/world-state-snapshot.md 4 KB

Versions

The database has no other skills named authoritative-server.

Database snapshot: 13.11.2026 · package version 1919f341d1d8 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100multiplayer-netcode
    Use this skill when the user says 'multiplayer', 'netcode', 'client prediction', 'server reconciliation', 'entity interpolation', 'rollback netcode', 'lag compensation', 'GGPO'. Gameplay-level netcode: transports, client prediction and reconciliation, interpolation, lag…
  • 95engineering-game-backend-architecture
    Use when building game servers, WebSocket connections, room management, game tick loops, or server-authoritative architecture with Elysia. Triggers: game server, WebSocket, rooms, tick loop, server architecture, multiplayer backend.
  • 95game-engine-multiplayer-netcode
    Use this skill when the user says 'engine netcode architecture', 'replication system design', 'netcode in custom engine', 'snapshot interpolation engine', 'rollback engine integration'. Engine-level netcode architecture: transport, replication model, prediction/interpolation,…
  • 90multiplayer-netcode
    Build multiplayer with an authoritative server, client prediction, reconciliation, and lag compensation. Use when adding networking to a game or fixing rubber-banding and desync.
  • 100gamedev-multiplayer
    Use when adding multiplayer or netcode to a game — client-server vs P2P, server authority and anti-cheat, state replication vs RPCs, prediction and reconciliation, lag compensation, plus Godot 4 / Unity NGO / Unreal wiring. NOT single-player gameplay (that is `godot`, `unity`,…
  • 95multiplayer-game-architecture
    Design and review the networking contract for multiplayer games before engine or backend implementation. Use when a team must choose dedicated-authoritative, listen-server, relay-assisted peer, lockstep, snapshot, or asynchronous models; assign authority for movement, combat,…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.