agentleFS
evgenyvinnikevgenyvinnik/llm-driven-system-design/google-sheets/CLAUDE.md

llm-driven-system-design / google-sheets

CLAUDE.md60 starsChanged 10 months agoMITView on GitHub

A collaborative spreadsheet application focusing on real-time multi-user editing, similar to Google Sheets.

We split this CLAUDE.md into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Decision: Use @tanstack/react-virtual for row and column virtualization

    line 10
  2. Distinctive:

    No need for complex middleware

    line 46
  3. Distinctive:

    Update on resize events

    line 97

≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Google Sheets - Development with Claude

Project Context

A collaborative spreadsheet application focusing on real-time multi-user editing, similar to Google Sheets.

Key Design Decisions

Virtualization with TanStack Virtual

Decision: Use @tanstack/react-virtual for row and column virtualization Rationale:

  • Modern, well-maintained library
  • Supports both horizontal and vertical virtualization
  • Efficient for large grids (1000+ rows/columns)
  • Framework-agnostic core with React bindings

WebSocket for Real-Time Sync

Decision: Native WebSocket with custom protocol instead of Socket.io Rationale:

  • Lower overhead than Socket.io
  • More control over message format
  • Simpler for this use case (no fallback needed)
  • Built-in browser support

Sparse Cell Storage

Decision: Store only non-empty cells in database and state Rationale:

  • Massive storage efficiency (most cells are empty)
  • Faster queries and state updates
  • Natural fit for spreadsheet data model

Last-Write-Wins Conflict Resolution

Decision: Simple per-cell last-write-wins instead of OT/CRDT Rationale:

  • Much simpler to implement
  • Good enough for learning purposes
  • Each cell is independent unit
  • Real conflicts are rare in practice

State Management with Zustand

Decision: Zustand instead of Redux or Context Rationale:

  • Minimal boilerplate
  • Excellent TypeScript support
  • Built-in selector optimization
  • No need for complex middleware

Implementation Phases

Phase 1: Core Grid (Completed)

  • Virtualized grid with TanStack Virtual
  • Cell component with editing
  • Selection (single cell)
  • Keyboard navigation
  • Column/row headers

Phase 2: Collaboration (Completed)

  • WebSocket server setup
  • Connection management
  • Cell edit broadcasting
  • Cursor position sharing
  • User presence indicators
  • Collaborator cursor overlays

Phase 3: Data Persistence (Completed)

  • PostgreSQL schema
  • Cell CRUD operations
  • Spreadsheet/sheet management
  • REST API

Phase 4: Polish (Planned)

  • HyperFormula for formulas
  • Column/row resize handles
  • Range selection
  • Copy/paste
  • Undo/redo
  • Cell formatting

Technical Challenges

Cell Memoization

React re-renders can be expensive with thousands of cells. Solution:

  • Memoized Cell component with custom comparison
  • Selector-based state access to minimize re-renders
  • Virtualization limits DOM nodes

WebSocket Reconnection

Need to handle disconnects gracefully:

  • Heartbeat (ping/pong) every 30 seconds
  • Full state sync on reconnect
  • Optimistic updates with server confirmation

Cursor Position Calculation

Converting cell coordinates to pixel positions:

  • Sum row heights/column widths up to target
  • Cache calculations where possible
  • Update on resize events

Resources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.