blog.dopana

Back

Code Storage is managed Git infrastructure for AI agents, built by Pierre Computer Company. It enables creating repositories, writing commits, merging branches, and getting Git remote URLs through SDK, HTTP API, or Git over HTTPS.

Problem#

When building AI-powered systems, especially AI agents, traditional storage solutions face significant limitations:

  • Makeshift S3/R2 solutions: Slow and brittle, not designed for collaborative workloads
  • Traditional storage APIs: Not built for collaborative work
  • Git primitives complexity: Teams duplicate Git primitives across Postgres and other datastores while trying to manage diverging snapshots in S3
  • Poor performance: Current solutions can’t handle millions of new repositories per day
  • Rate limits and complex authentication: Public APIs have rate limits and complex authentication flows

For AI agents, Git offers deterministic, reproducible state with content-addressed snapshots you can pin in prompts, evals, and rollbacks, as well as familiar multi-player strategies (like branching) for human-agent collaboration.

Solution#

Code Storage is a high-scale, distributed storage system built on Git for storing and collaborating on repos, with API ergonomics optimized for machines.

Core Architecture#

Code Storage leverages Git’s three-phase commit protocol and a “spoke-like” quorum-based architecture to guarantee the durability and consistency of all reads and writes at scale.

graph TD
    A[AI Agent/Application] --> B[Code Storage SDK]
    B --> C[HTTP API]
    C --> D[Quorum-based Storage Layer]
    D --> E[Git Repository Storage]
    D --> F[Git LFS Storage]
    D --> G[Metadata Storage]
    
    H[JWT Authentication] --> C
    I[Ref Policies] --> C
    J[Commit Signing] --> C
    
    K[Webhooks] --> L[Build Systems]
    K --> M[Bots]
    K --> N[AI Agents]
    
    C --> K

Key Features#

Git Operations#

  • Clone, fetch, push, and pull over HTTPS with JWT-authenticated remotes
  • No rate limits, complex auth-flows, or other limitations

Git LFS#

  • Track large files over the same remote, with no separate LFS server

Git Notes#

  • Attach metadata to commits and keep note streams isolated by ref

Ref Policies#

  • Limit the refs that a JWT can update and reject force pushes

Commit Signing#

  • Register keys and require signed commits on selected refs

Import Namespace#

  • Bulk push large repositories, which Code Storage moves to cold storage

Ephemeral Namespace#

  • Create isolated refs for previews and experiments, then promote them

Repository Forks#

  • Copy a repository for a template, a snapshot, or isolated work

GitHub Sync#

  • Mirror a GitHub repository to and from Code Storage

Generic Sync#

  • Mirror a GitLab, Bitbucket, or other HTTPS Git repository

Webhooks#

  • Receive push and sync events, verified with HMAC signatures

AI Agent Workflows#

Code Storage provides specialized workflows for agents:

Connect a Sandbox#

Clone into Modal, E2B, Daytona, and other sandboxes with authenticated URLs.

sequenceDiagram
    participant Agent as AI Agent
    participant CodeStorage as Code Storage
    participant Sandbox as Modal/E2B/Daytona
    
    Agent->>CodeStorage: Request authenticated URL
    CodeStorage-->>Agent: JWT-authenticated Git URL
    Agent->>Sandbox: Clone with authenticated URL
    Sandbox->>CodeStorage: Git clone via HTTPS
    CodeStorage-->>Sandbox: Repository data
    Sandbox-->>Agent: Clone complete

Store Session State#

Store agent session state as ephemeral commits, with the normal branches unchanged.

Resume Sandbox Work#

Restore the last session state in a new sandbox.

Run Parallel Attempts#

Start several attempts from one commit and promote the best result.

graph TD
    A[Base Commit] --> B[Attempt 1]
    A --> C[Attempt 2]
    A --> D[Attempt 3]
    
    B --> E{Result Quality?}
    C --> F{Result Quality?}
    D --> G{Result Quality?}
    
    E -->|Best| H[Promote to Main]
    F -->|Best| H
    G -->|Best| H
    
    H --> I[Final Result]

Show Live Diffs#

Render an agent branch as a live diff that refreshes on each new state.

Quick Start#

Installation#

# TypeScript
pnpm i @pierre/storage

# Python (using uv - recommended)
uv add pierre-storage

# Or using pip
pip install pierre-storage

# Go
go get github.com/pierrecomputer/sdk/packages/code-storage-go@latest
bash

Initialize Client#

TypeScript#

import { GitStorage } from '@pierre/storage';

const storage = new GitStorage({
  name: 'your-org',
  key: process.env.PIERRE_PRIVATE_KEY!,
});
typescript

Python#

from pierre_storage import GitStorage

storage = GitStorage({
    "name": "your-org",
    "key": os.environ["PIERRE_PRIVATE_KEY"],
})
python

Go#

client, err := storage.NewClient(storage.Options{
	Name: "your-org",
	Key:  os.Getenv("PIERRE_PRIVATE_KEY"),
})
go

Create Repository and First Commit#

TypeScript#

const repo = await storage.createRepo({ id: 'new-workspace' });

const result = await repo
  .createCommit({
    targetBranch: 'main',
    commitMessage: 'Get started with Code Storage',
    author: { name: 'Pierre', email: 'pierre@pierre.co' },
  })
  .addFileFromString('README.md', '# Getting started\n')
  .addFileFromString('main.ts', 'console.log("Hello from Code Storage");')
  .send();

console.log(result.commitSha);
typescript

Python#

repo = await storage.create_repo(id="new-workspace")

result = await (
    repo.create_commit(
        target_branch="main",
        commit_message="Get started with Code Storage",
        author={"name": "Pierre", "email": "pierre@pierre.co"},
    )
    .add_file_from_string("README.md", "# Getting started\n")
    .add_file_from_string("main.py", "print('Hello from Code Storage')")
    .send()
)

print(result["commit_sha"])
python

Go#

ctx := context.Background()
repo, err := client.CreateRepo(ctx, storage.CreateRepoOptions{ID: "new-workspace"})

builder, err := repo.CreateCommit(storage.CommitOptions{
	TargetBranch:  "main",
	CommitMessage: "Get started with Code Storage",
	Author:        storage.CommitSignature{Name: "Pierre", Email: "pierre@pierre.co"},
})

result, err := builder.
	AddFileFromString("README.md", "# Getting started\n", nil).
	AddFileFromString("main.go", "package main\n\nfunc main() {}\n", nil).
	Send(ctx)

fmt.Println(result.CommitSHA)
go

Authentication & Security#

Code Storage uses JSON Web Tokens (JWT) for authentication. Each Code Storage request uses a JWT that your organization signs. You control the repository access, scopes, expiration, and ref policy in each JWT, so every client, agent, or task gets exactly the access it needs.

flowchart TD
    A[Organization] --> B[Sign JWT]
    B --> C[JWT with Scopes]
    C --> D[Ref Policies]
    C --> E[Expiration]
    C --> F[Repository Access]
    
    D --> G[Limit Ref Updates]
    E --> H[Token Expiry]
    F --> I[Repository Permissions]
    
    G --> J[Agent Request]
    H --> J
    I --> J
    
    J --> K[Code Storage API]
    K --> L[Validate JWT]
    L --> M[Apply Policies]
    M --> N[Execute Operation]

Performance and Scale#

Code Storage is designed to handle workloads at massive scale:

  • Millions of repos per day: Can handle millions of new repositories per day
  • 60x faster: Read/write operations are ~60x faster than similar S3/R2-based solutions
  • 99.99% uptime: High availability for critical repository infrastructure
  • 90,000+ operations at peak: Can sustain 90,000+ operations at peak times

Case Study: Lovable#

Lovable, an AI-powered software development platform, chose Code Storage to handle 8M+ new repos per week with unprecedented speed, scale, and reliability requirements.

Results Achieved#

  • 99.99% uptime for critical repository infrastructure
  • 90,000+ operations at peak times
  • 230% improvement in p50 fetch latency
  • 160% improvement in push latency

“Pierre has become foundational infrastructure for how we operate AI-native software generation at scale. Their team deeply understands the operational realities of agent-driven development workloads.”

— Will Rudenmalm, Member of Technical Staff, Lovable

Best Practices#

  1. Use ephemeral branches for experiments and previews
  2. Implement ref policies to limit force pushes and protect important branches
  3. Leverage webhooks to integrate with build systems and bots
  4. Use session state workflow for agent state management
  5. Implement parallel attempts for exploration and optimization

Important Notes#

[!NOTE] Code Storage does not provide pull requests, issues, or code review. It focuses on Git infrastructure and storage, not GitHub’s collaboration features.

References#