Documentation Index
Fetch the complete documentation index at: https://code.storage/docs/llms.txt
Use this file to discover all available pages before exploring further.
The fastest way to get up and running is with the Code Storage SDK, available for TypeScript, Python, and Go. Before getting
started head to the dashboard to generate a private key and make note of your organization’s
name identifier.
-
Install the SDK:
-
Initialize the client:
import { GitStorage } from '@pierre/storage';
const store = new GitStorage({
name: 'your-org', // Your organization identifier
key: env.privateKey, // Your API key
});
-
Create and use a repository:
// Create a new repository
const repo = await store.createRepo();
// Get a secure Git URL with authentication
const url = await repo.getRemoteURL();
// Configure Git to use the repository
console.log(`git remote add origin ${url}`);
// Output: git remote add origin https://t:JWT@[org].code.storage/repo-id.git
See Integrations for provider-specific setup, including GitHub App sync,
public GitHub mode, and generic HTTPS Git providers.
-
Make your first commit:
import { GitStorage } from '@pierre/storage';
async function main() {
const store = new GitStorage({
name: 'your-name',
key: env.privateKey,
});
const repo = await store.createRepo();
console.log(`Created repository: ${repo.id}`);
const url = await repo.getRemoteURL();
console.log(`Git URL: ${url}`);
const result = await repo
.createCommit({
targetBranch: 'main',
commitMessage: 'Initial commit',
author: { name: 'Your Name', email: 'you@example.com' },
})
.addFileFromString('README.md', '# My Project\n\nWelcome!')
.send();
console.log(`Commit SHA: ${result.commitSha}`);
}
-
Read repository data:
async function readData() {
const store = new GitStorage({ name: 'your-name', key: env.privateKey });
const repo = await store.findOne({ id: 'repo-id' });
if (!repo) return;
// List files
const files = await repo.listFiles();
console.log('Files:', files.paths);
// List commits
const commits = await repo.listCommits({ limit: 10 });
commits.commits.forEach((commit) => {
console.log(`${commit.sha.slice(0, 7)} - ${commit.message}`);
});
// Get file content
const response = await repo.getFileStream({ path: 'README.md' });
const content = await response.text();
console.log(content);
}
-
Apply an existing diff:
async function applyDiff() {
const store = new GitStorage({ name: 'your-name', key: env.privateKey });
const repo = await store.findOne({ id: 'repo-id' });
if (!repo) return;
const diffText = `--- a/README.md
+++ b/README.md
@@
-Old line
+New line
`;
const result = await repo.createCommitFromDiff({
targetBranch: 'main',
commitMessage: 'Apply upstream changes',
diff: diffText,
author: { name: 'Automation', email: 'bot@example.com' },
baseBranch: 'main', // optional, matches createCommit options
});
console.log(`Updated commit: ${result.commitSha}`);
}