Skip to main content
Learn how to use the Pierre SDK to create a repo, create a commit, read files, and apply diffs. These operations are some of the building blocks for agent workflows.

1. Sign up and create a private key

  • Create an account at code.storage.
  • Create a new Organization if needed (e.g., your-org)
  • Create a key on the organization’s Keys page.
  • Store the private key and set these environment variables. Replace your-org with your organization name:
See Authentication for more details.

2. Install the SDK

Install the SDK for your language: @pierre/sdk for TypeScript, pierre-sdk for Python, or the Go module github.com/pierrecomputer/sdk/go.

3. Initialize the client

new Pierre() in TypeScript, Pierre() in Python, and pierre.NewClient() in Go read the same environment variables:
  • PIERRE_ORG: your organization name.
  • PIERRE_PRIVATE_KEY: your private key in PEM form. You can set PIERRE_PRIVATE_KEY_FILE to the path of the key file instead.
  • PIERRE_TOKEN: a fixed token. When it is set, the client sends it in place of a token that it signs with your key.
  • PIERRE_API_BASE_URL and PIERRE_GIT_HOST: other hosts in place of https://api.{org}.code.storage and {org}.code.storage.
With your private key, the client signs a 5-minute token for each request. Leave PIERRE_TOKEN unset for this guide, because step 4 signs a token for a Git remote URL, and a fixed token cannot do that. The Python examples use Pierre, the blocking client. AsyncPierre has the same methods for asyncio code. The code of steps 3 to 7 runs as one program, in page order. In TypeScript, put it in one ES module file: set "type": "module" in your package.json, or use a .mts file. See the SDK page for the client options.

4. Create a repository

Each repository belongs to your organization and has a unique name. Code Storage can generate a UUID, or you can supply a name such as team/project-alpha. A new repository uses main as its default branch, but it has no branch until its first commit. Step 5 creates main. A synced repository takes the default branch of its upstream.
The remote URL holds a token, so do not write it to a log that other people can read. The token expires after 1 hour, the longest lifetime that the SDK allows. For Git work that lasts longer, use the credential helper of the CLI. A public GitHub repository needs no GitHub App. To sync a private GitHub repository, or a repository on GitLab, Bitbucket, or another HTTPS host, pass a different upstream. See GitHub Sync and Generic Sync.

5. Create a commit

Write files and commit them to repo without a local clone.

6. Read repository data

Read files, list commits, and stream file content from repo.

7. Apply a diff

Commit a unified diff to repo without a local clone.