
Getting started — launching Claude in a repo
Launch Claude from a terminal inside the repository. When it starts, Claude will list the permissions it requires (reading files, executing commands). For repositories you control, granting those permissions enables deeper analysis and automated edits. Typical actions Claude can help with:- File analysis and navigation
- Applying edits across many files
- Running builds and tests
- Executing bash commands and git operations
- Integrating with editors like VS Code
Terminal setup (VS Code integration)
Run/terminal-setup to configure terminal keybindings and IDE integration; for example, Claude can install a Shift+Enter terminal snippet shortcut in VS Code:
Tip: Only allow trusted code execution for repositories you control. Claude may propose running build or test commands; grant them when you expect the tool to read or modify source files.
High-level overview — Retro Racer at a glance
Ask Claude for a high-level summary to quickly map the project structure and tech stack. Below is a consolidated example output Claude might produce. Table: Project structure and tech stack
Technology summary
- Frontend: JavaScript ES6+, Three.js
- Backend: Go 1.23.2 with Gorilla WebSocket
- Communication: WebSocket real-time messages (JSON-based)
- Concurrency: goroutines + channels, mutex for critical sections
Exploring the Go backend architecture
Ask Claude to “Explain the main architecture of the Go backend app” and it will analyze key files (for example:backend/main.go, server/server.go, hub.go, game logic files) and produce a focused summary. Key architecture points from the Retro Racer example:
- Event-driven hub model: a central hub manages client registration, inputs, and broadcasts.
- Concurrency model relies on goroutines and channels for inter-goroutine messaging.
- Fixed game tick (60 Hz) for deterministic physics and state updates.
- Separate channels for registration, input, and broadcasting.
- Mutex-protected shared state for critical sections.
- Per-client goroutines for read/write operations over WebSocket.
- JSON-based message protocol mapped to Go structs.
- Designed for small lobbies (current config: up to 8 players per hub).
Finding database usage
When prompted to locate DB access, Claude can scango.mod and the codebase. In this Retro Racer iteration Claude found:
- No database dependencies in
go.mod - No SQL or DB imports in Go files
- Game state stored in-memory (e.g.,
game/state.go) - Logs written to
retroracer_server.log(file-based logging)
Log analysis — diagnosing runtime issues
Claude can scan logs to surface errors and suspicious patterns. Example issues detected inretroracer_server.log:
- Player-client map synchronization problem
- Example:
[DEBUG] Removing player 1748150421520079300-2524 from players map - no client found - Symptom: players removed immediately after joining → indicates race between registration and sync.
- Example:
- Client count discrepancy
- Example:
[DEBUG] Broadcasted updated player list to 0 clientswhile players exist.
- Example:
- Phantom heartbeat messages
- Heartbeats arrive from connections that appear removed in internal state.
- WebSocket connection events
- Normal disconnects (
close 1001), but timing suggests premature cleanup.
- Normal disconnects (
- The server used two separate maps:
clients(connections) andplayers(registered player state). A synchronization routine compared them and could remove a player before registration finished, causing a race across goroutines handling WebSocket reads/writes and hub synchronization.
Suggested fixes — make registration atomic and use a single source of truth
Claude recommended the following high-level changes to resolve the race condition:- Move to a single canonical map (e.g.,
clients) representing active connections. - Introduce a registration flag on each
Client(e.g.,registrationComplete bool) protected by a mutex. - Route registrations through the hub’s main event loop using an atomic registration message so the hub owns state transitions.
- Ensure helper methods (e.g., those that build player lists) ignore clients with
registrationComplete == false. - Mark registration complete only after the client sends the join message and the hub processes it.
Implementing and validating fixes
Claude can apply edits across files, then run builds/tests to validate compilation. Typical iterative flow:- Apply code changes (add flag, remove redundant map, add registration channel).
- Run
go buildand fix compilation errors caused by removed symbols. - Update all call sites to use helper methods that respect
registrationComplete. - Re-run
go buildorgo testuntil successful.
- After initial edits, Claude reported compile errors where code still referenced the removed
playersmap:
- Fix: update those call sites to use the single
clientsmap plus helper functions that only includeregistrationComplete == trueclients when producing player lists.
- Once references were updated, Claude re-ran the build:
Result and reasoning
Before:- Dual maps (
clientsvsplayers) and separate synchronization logic left a window where a connection existed inclientsbut the correspondingplayerentry had not been created — sync logic sometimes removed the (not-yet-registered) player, causing inconsistent behavior.
- Single source of truth (
clients) plusregistrationCompletesemantics ensures:- Client connects → added to
clientswithregistrationComplete = false. - Helper methods and broadcasts ignore incomplete registrations.
- Client sends the join message → hub marks
registrationComplete = true. - Client appears in game state and broadcasts.
- Reduced race surface and more predictable multiplayer behavior.
- Client connects → added to
Summary — what Claude Code adds to your workflow
Claude Code can:- Inspect large repositories and produce architecture summaries.
- Locate files and code paths relevant to a bug (e.g., WebSocket flow).
- Scan logs and surface likely root causes for runtime anomalies.
- Propose concrete code edits (concurrency fixes, event loop updates, struct fields).
- Apply edits and run builds/tests to validate fixes iteratively.
Next steps — choose how you want to proceed
- Show the concrete diffs Claude produced (file-by-file).
- Walk through a safe minimal patch you can manually apply.
- Run unit/integration tests to validate behavior under simulated multiplayer clients.